documentation.d.ts 3.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573
  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 _color;
  25461. private _computeParticleColor;
  25462. private _computeParticleTexture;
  25463. private _computeParticleRotation;
  25464. private _computeParticleVertex;
  25465. private _computeBoundingBox;
  25466. private _depthSortParticles;
  25467. private _camera;
  25468. private _mustUnrotateFixedNormals;
  25469. private _particlesIntersect;
  25470. private _needs32Bits;
  25471. private _isNotBuilt;
  25472. private _lastParticleId;
  25473. private _idxOfId;
  25474. /**
  25475. * Creates a SPS (Solid Particle System) object.
  25476. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25477. * @param scene (Scene) is the scene in which the SPS is added.
  25478. * @param options defines the options of the sps e.g.
  25479. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25480. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25481. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25482. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25483. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25484. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25485. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25486. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25487. */
  25488. constructor(name: string, scene: Scene, options?: {
  25489. updatable?: boolean;
  25490. isPickable?: boolean;
  25491. enableDepthSort?: boolean;
  25492. particleIntersection?: boolean;
  25493. boundingSphereOnly?: boolean;
  25494. bSphereRadiusFactor?: number;
  25495. expandable?: boolean;
  25496. });
  25497. /**
  25498. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25499. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25500. * @returns the created mesh
  25501. */
  25502. buildMesh(): Mesh;
  25503. /**
  25504. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25505. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25506. * Thus the particles generated from `digest()` have their property `position` set yet.
  25507. * @param mesh ( Mesh ) is the mesh to be digested
  25508. * @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
  25509. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25510. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25511. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  25512. * @returns the current SPS
  25513. */
  25514. digest(mesh: Mesh, options?: {
  25515. facetNb?: number;
  25516. number?: number;
  25517. delta?: number;
  25518. storage?: [];
  25519. }): SolidParticleSystem;
  25520. /**
  25521. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  25522. * @hidden
  25523. */
  25524. private _unrotateFixedNormals;
  25525. /**
  25526. * Resets the temporary working copy particle
  25527. * @hidden
  25528. */
  25529. private _resetCopy;
  25530. /**
  25531. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  25532. * @param p the current index in the positions array to be updated
  25533. * @param shape a Vector3 array, the shape geometry
  25534. * @param positions the positions array to be updated
  25535. * @param meshInd the shape indices array
  25536. * @param indices the indices array to be updated
  25537. * @param meshUV the shape uv array
  25538. * @param uvs the uv array to be updated
  25539. * @param meshCol the shape color array
  25540. * @param colors the color array to be updated
  25541. * @param meshNor the shape normals array
  25542. * @param normals the normals array to be updated
  25543. * @param idx the particle index
  25544. * @param idxInShape the particle index in its shape
  25545. * @param options the addShape() method passed options
  25546. * @hidden
  25547. */
  25548. private _meshBuilder;
  25549. /**
  25550. * Returns a shape Vector3 array from positions float array
  25551. * @param positions float array
  25552. * @returns a vector3 array
  25553. * @hidden
  25554. */
  25555. private _posToShape;
  25556. /**
  25557. * Returns a shapeUV array from a float uvs (array deep copy)
  25558. * @param uvs as a float array
  25559. * @returns a shapeUV array
  25560. * @hidden
  25561. */
  25562. private _uvsToShapeUV;
  25563. /**
  25564. * Adds a new particle object in the particles array
  25565. * @param idx particle index in particles array
  25566. * @param id particle id
  25567. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  25568. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  25569. * @param model particle ModelShape object
  25570. * @param shapeId model shape identifier
  25571. * @param idxInShape index of the particle in the current model
  25572. * @param bInfo model bounding info object
  25573. * @param storage target storage array, if any
  25574. * @hidden
  25575. */
  25576. private _addParticle;
  25577. /**
  25578. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25579. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25580. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25581. * @param nb (positive integer) the number of particles to be created from this model
  25582. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25583. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25584. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  25585. * @returns the number of shapes in the system
  25586. */
  25587. addShape(mesh: Mesh, nb: number, options?: {
  25588. positionFunction?: any;
  25589. vertexFunction?: any;
  25590. storage?: [];
  25591. }): number;
  25592. /**
  25593. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  25594. * @hidden
  25595. */
  25596. private _rebuildParticle;
  25597. /**
  25598. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25599. * @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.
  25600. * @returns the SPS.
  25601. */
  25602. rebuildMesh(reset?: boolean): SolidParticleSystem;
  25603. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  25604. * Returns an array with the removed particles.
  25605. * 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.
  25606. * The SPS can't be empty so at least one particle needs to remain in place.
  25607. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  25608. * @param start index of the first particle to remove
  25609. * @param end index of the last particle to remove (included)
  25610. * @returns an array populated with the removed particles
  25611. */
  25612. removeParticles(start: number, end: number): SolidParticle[];
  25613. /**
  25614. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  25615. * @param solidParticleArray an array populated with Solid Particles objects
  25616. * @returns the SPS
  25617. */
  25618. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  25619. /**
  25620. * Creates a new particle and modifies the SPS mesh geometry :
  25621. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  25622. * - calls _addParticle() to populate the particle array
  25623. * factorized code from addShape() and insertParticlesFromArray()
  25624. * @param idx particle index in the particles array
  25625. * @param i particle index in its shape
  25626. * @param modelShape particle ModelShape object
  25627. * @param shape shape vertex array
  25628. * @param meshInd shape indices array
  25629. * @param meshUV shape uv array
  25630. * @param meshCol shape color array
  25631. * @param meshNor shape normals array
  25632. * @param bbInfo shape bounding info
  25633. * @param storage target particle storage
  25634. * @options addShape() passed options
  25635. * @hidden
  25636. */
  25637. private _insertNewParticle;
  25638. /**
  25639. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25640. * This method calls `updateParticle()` for each particle of the SPS.
  25641. * For an animated SPS, it is usually called within the render loop.
  25642. * 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.
  25643. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25644. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25645. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25646. * @returns the SPS.
  25647. */
  25648. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25649. /**
  25650. * Disposes the SPS.
  25651. */
  25652. dispose(): void;
  25653. /**
  25654. * Returns a SolidParticle object from its identifier : particle.id
  25655. * @param id (integer) the particle Id
  25656. * @returns the searched particle or null if not found in the SPS.
  25657. */
  25658. getParticleById(id: number): Nullable<SolidParticle>;
  25659. /**
  25660. * Returns a new array populated with the particles having the passed shapeId.
  25661. * @param shapeId (integer) the shape identifier
  25662. * @returns a new solid particle array
  25663. */
  25664. getParticlesByShapeId(shapeId: number): SolidParticle[];
  25665. /**
  25666. * Populates the passed array "ref" with the particles having the passed shapeId.
  25667. * @param shapeId the shape identifier
  25668. * @returns the SPS
  25669. * @param ref
  25670. */
  25671. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  25672. /**
  25673. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25674. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25675. * @returns the SPS.
  25676. */
  25677. refreshVisibleSize(): SolidParticleSystem;
  25678. /**
  25679. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25680. * @param size the size (float) of the visibility box
  25681. * note : this doesn't lock the SPS mesh bounding box.
  25682. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25683. */
  25684. setVisibilityBox(size: number): void;
  25685. /**
  25686. * Gets whether the SPS as always visible or not
  25687. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25688. */
  25689. /**
  25690. * Sets the SPS as always visible or not
  25691. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25692. */
  25693. isAlwaysVisible: boolean;
  25694. /**
  25695. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25696. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25697. */
  25698. /**
  25699. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25700. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25701. */
  25702. isVisibilityBoxLocked: boolean;
  25703. /**
  25704. * Tells to `setParticles()` to compute the particle rotations or not.
  25705. * Default value : true. The SPS is faster when it's set to false.
  25706. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25707. */
  25708. /**
  25709. * Gets if `setParticles()` computes the particle rotations or not.
  25710. * Default value : true. The SPS is faster when it's set to false.
  25711. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25712. */
  25713. computeParticleRotation: boolean;
  25714. /**
  25715. * Tells to `setParticles()` to compute the particle colors or not.
  25716. * Default value : true. The SPS is faster when it's set to false.
  25717. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25718. */
  25719. /**
  25720. * Gets if `setParticles()` computes the particle colors or not.
  25721. * Default value : true. The SPS is faster when it's set to false.
  25722. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25723. */
  25724. computeParticleColor: boolean;
  25725. /**
  25726. * Gets if `setParticles()` computes the particle textures or not.
  25727. * Default value : true. The SPS is faster when it's set to false.
  25728. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25729. */
  25730. computeParticleTexture: boolean;
  25731. /**
  25732. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25733. * Default value : false. The SPS is faster when it's set to false.
  25734. * Note : the particle custom vertex positions aren't stored values.
  25735. */
  25736. /**
  25737. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25738. * Default value : false. The SPS is faster when it's set to false.
  25739. * Note : the particle custom vertex positions aren't stored values.
  25740. */
  25741. computeParticleVertex: boolean;
  25742. /**
  25743. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25744. */
  25745. /**
  25746. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25747. */
  25748. computeBoundingBox: boolean;
  25749. /**
  25750. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25751. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25752. * Default : `true`
  25753. */
  25754. /**
  25755. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25756. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25757. * Default : `true`
  25758. */
  25759. depthSortParticles: boolean;
  25760. /**
  25761. * Gets if the SPS is created as expandable at construction time.
  25762. * Default : `false`
  25763. */
  25764. readonly expandable: boolean;
  25765. /**
  25766. * This function does nothing. It may be overwritten to set all the particle first values.
  25767. * The SPS doesn't call this function, you may have to call it by your own.
  25768. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25769. */
  25770. initParticles(): void;
  25771. /**
  25772. * This function does nothing. It may be overwritten to recycle a particle.
  25773. * The SPS doesn't call this function, you may have to call it by your own.
  25774. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25775. * @param particle The particle to recycle
  25776. * @returns the recycled particle
  25777. */
  25778. recycleParticle(particle: SolidParticle): SolidParticle;
  25779. /**
  25780. * Updates a particle : this function should be overwritten by the user.
  25781. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25782. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25783. * @example : just set a particle position or velocity and recycle conditions
  25784. * @param particle The particle to update
  25785. * @returns the updated particle
  25786. */
  25787. updateParticle(particle: SolidParticle): SolidParticle;
  25788. /**
  25789. * Updates a vertex of a particle : it can be overwritten by the user.
  25790. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25791. * @param particle the current particle
  25792. * @param vertex the current index of the current particle
  25793. * @param pt the index of the current vertex in the particle shape
  25794. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25795. * @example : just set a vertex particle position
  25796. * @returns the updated vertex
  25797. */
  25798. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25799. /**
  25800. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25801. * This does nothing and may be overwritten by the user.
  25802. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25803. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25804. * @param update the boolean update value actually passed to setParticles()
  25805. */
  25806. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25807. /**
  25808. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25809. * This will be passed three parameters.
  25810. * This does nothing and may be overwritten by the user.
  25811. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25812. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25813. * @param update the boolean update value actually passed to setParticles()
  25814. */
  25815. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25816. }
  25817. }
  25818. declare module BABYLON {
  25819. /**
  25820. * Represents one particle of a solid particle system.
  25821. */
  25822. export class SolidParticle {
  25823. /**
  25824. * particle global index
  25825. */
  25826. idx: number;
  25827. /**
  25828. * particle identifier
  25829. */
  25830. id: number;
  25831. /**
  25832. * The color of the particle
  25833. */
  25834. color: Nullable<Color4>;
  25835. /**
  25836. * The world space position of the particle.
  25837. */
  25838. position: Vector3;
  25839. /**
  25840. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25841. */
  25842. rotation: Vector3;
  25843. /**
  25844. * The world space rotation quaternion of the particle.
  25845. */
  25846. rotationQuaternion: Nullable<Quaternion>;
  25847. /**
  25848. * The scaling of the particle.
  25849. */
  25850. scaling: Vector3;
  25851. /**
  25852. * The uvs of the particle.
  25853. */
  25854. uvs: Vector4;
  25855. /**
  25856. * The current speed of the particle.
  25857. */
  25858. velocity: Vector3;
  25859. /**
  25860. * The pivot point in the particle local space.
  25861. */
  25862. pivot: Vector3;
  25863. /**
  25864. * Must the particle be translated from its pivot point in its local space ?
  25865. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25866. * Default : false
  25867. */
  25868. translateFromPivot: boolean;
  25869. /**
  25870. * Is the particle active or not ?
  25871. */
  25872. alive: boolean;
  25873. /**
  25874. * Is the particle visible or not ?
  25875. */
  25876. isVisible: boolean;
  25877. /**
  25878. * Index of this particle in the global "positions" array (Internal use)
  25879. * @hidden
  25880. */
  25881. _pos: number;
  25882. /**
  25883. * @hidden Index of this particle in the global "indices" array (Internal use)
  25884. */
  25885. _ind: number;
  25886. /**
  25887. * @hidden ModelShape of this particle (Internal use)
  25888. */
  25889. _model: ModelShape;
  25890. /**
  25891. * ModelShape id of this particle
  25892. */
  25893. shapeId: number;
  25894. /**
  25895. * Index of the particle in its shape id
  25896. */
  25897. idxInShape: number;
  25898. /**
  25899. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25900. */
  25901. _modelBoundingInfo: BoundingInfo;
  25902. /**
  25903. * @hidden Particle BoundingInfo object (Internal use)
  25904. */
  25905. _boundingInfo: BoundingInfo;
  25906. /**
  25907. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25908. */
  25909. _sps: SolidParticleSystem;
  25910. /**
  25911. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25912. */
  25913. _stillInvisible: boolean;
  25914. /**
  25915. * @hidden Last computed particle rotation matrix
  25916. */
  25917. _rotationMatrix: number[];
  25918. /**
  25919. * Parent particle Id, if any.
  25920. * Default null.
  25921. */
  25922. parentId: Nullable<number>;
  25923. /**
  25924. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25925. * The possible values are :
  25926. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25927. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25928. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25929. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25930. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25931. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25932. * */
  25933. cullingStrategy: number;
  25934. /**
  25935. * @hidden Internal global position in the SPS.
  25936. */
  25937. _globalPosition: Vector3;
  25938. /**
  25939. * Creates a Solid Particle object.
  25940. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25941. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  25942. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  25943. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25944. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25945. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25946. * @param shapeId (integer) is the model shape identifier in the SPS.
  25947. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25948. * @param sps defines the sps it is associated to
  25949. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25950. */
  25951. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25952. /**
  25953. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  25954. * @param target the particle target
  25955. * @returns the current particle
  25956. */
  25957. copyToRef(target: SolidParticle): SolidParticle;
  25958. /**
  25959. * Legacy support, changed scale to scaling
  25960. */
  25961. /**
  25962. * Legacy support, changed scale to scaling
  25963. */
  25964. scale: Vector3;
  25965. /**
  25966. * Legacy support, changed quaternion to rotationQuaternion
  25967. */
  25968. /**
  25969. * Legacy support, changed quaternion to rotationQuaternion
  25970. */
  25971. quaternion: Nullable<Quaternion>;
  25972. /**
  25973. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25974. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25975. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25976. * @returns true if it intersects
  25977. */
  25978. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25979. /**
  25980. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25981. * A particle is in the frustum if its bounding box intersects the frustum
  25982. * @param frustumPlanes defines the frustum to test
  25983. * @returns true if the particle is in the frustum planes
  25984. */
  25985. isInFrustum(frustumPlanes: Plane[]): boolean;
  25986. /**
  25987. * get the rotation matrix of the particle
  25988. * @hidden
  25989. */
  25990. getRotationMatrix(m: Matrix): void;
  25991. }
  25992. /**
  25993. * Represents the shape of the model used by one particle of a solid particle system.
  25994. * SPS internal tool, don't use it manually.
  25995. */
  25996. export class ModelShape {
  25997. /**
  25998. * The shape id
  25999. * @hidden
  26000. */
  26001. shapeID: number;
  26002. /**
  26003. * flat array of model positions (internal use)
  26004. * @hidden
  26005. */
  26006. _shape: Vector3[];
  26007. /**
  26008. * flat array of model UVs (internal use)
  26009. * @hidden
  26010. */
  26011. _shapeUV: number[];
  26012. /**
  26013. * color array of the model
  26014. * @hidden
  26015. */
  26016. _shapeColors: number[];
  26017. /**
  26018. * indices array of the model
  26019. * @hidden
  26020. */
  26021. _indices: number[];
  26022. /**
  26023. * normals array of the model
  26024. * @hidden
  26025. */
  26026. _normals: number[];
  26027. /**
  26028. * length of the shape in the model indices array (internal use)
  26029. * @hidden
  26030. */
  26031. _indicesLength: number;
  26032. /**
  26033. * Custom position function (internal use)
  26034. * @hidden
  26035. */
  26036. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26037. /**
  26038. * Custom vertex function (internal use)
  26039. * @hidden
  26040. */
  26041. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26042. /**
  26043. * 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.
  26044. * SPS internal tool, don't use it manually.
  26045. * @hidden
  26046. */
  26047. 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>);
  26048. }
  26049. /**
  26050. * Represents a Depth Sorted Particle in the solid particle system.
  26051. */
  26052. export class DepthSortedParticle {
  26053. /**
  26054. * Index of the particle in the "indices" array
  26055. */
  26056. ind: number;
  26057. /**
  26058. * Length of the particle shape in the "indices" array
  26059. */
  26060. indicesLength: number;
  26061. /**
  26062. * Squared distance from the particle to the camera
  26063. */
  26064. sqDistance: number;
  26065. }
  26066. }
  26067. declare module BABYLON {
  26068. /**
  26069. * @hidden
  26070. */
  26071. export class _MeshCollisionData {
  26072. _checkCollisions: boolean;
  26073. _collisionMask: number;
  26074. _collisionGroup: number;
  26075. _collider: Nullable<Collider>;
  26076. _oldPositionForCollisions: Vector3;
  26077. _diffPositionForCollisions: Vector3;
  26078. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26079. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26080. }
  26081. }
  26082. declare module BABYLON {
  26083. /** @hidden */
  26084. class _FacetDataStorage {
  26085. facetPositions: Vector3[];
  26086. facetNormals: Vector3[];
  26087. facetPartitioning: number[][];
  26088. facetNb: number;
  26089. partitioningSubdivisions: number;
  26090. partitioningBBoxRatio: number;
  26091. facetDataEnabled: boolean;
  26092. facetParameters: any;
  26093. bbSize: Vector3;
  26094. subDiv: {
  26095. max: number;
  26096. X: number;
  26097. Y: number;
  26098. Z: number;
  26099. };
  26100. facetDepthSort: boolean;
  26101. facetDepthSortEnabled: boolean;
  26102. depthSortedIndices: IndicesArray;
  26103. depthSortedFacets: {
  26104. ind: number;
  26105. sqDistance: number;
  26106. }[];
  26107. facetDepthSortFunction: (f1: {
  26108. ind: number;
  26109. sqDistance: number;
  26110. }, f2: {
  26111. ind: number;
  26112. sqDistance: number;
  26113. }) => number;
  26114. facetDepthSortFrom: Vector3;
  26115. facetDepthSortOrigin: Vector3;
  26116. invertedMatrix: Matrix;
  26117. }
  26118. /**
  26119. * @hidden
  26120. **/
  26121. class _InternalAbstractMeshDataInfo {
  26122. _hasVertexAlpha: boolean;
  26123. _useVertexColors: boolean;
  26124. _numBoneInfluencers: number;
  26125. _applyFog: boolean;
  26126. _receiveShadows: boolean;
  26127. _facetData: _FacetDataStorage;
  26128. _visibility: number;
  26129. _skeleton: Nullable<Skeleton>;
  26130. _layerMask: number;
  26131. _computeBonesUsingShaders: boolean;
  26132. _isActive: boolean;
  26133. _onlyForInstances: boolean;
  26134. _isActiveIntermediate: boolean;
  26135. _onlyForInstancesIntermediate: boolean;
  26136. _actAsRegularMesh: boolean;
  26137. }
  26138. /**
  26139. * Class used to store all common mesh properties
  26140. */
  26141. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26142. /** No occlusion */
  26143. static OCCLUSION_TYPE_NONE: number;
  26144. /** Occlusion set to optimisitic */
  26145. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26146. /** Occlusion set to strict */
  26147. static OCCLUSION_TYPE_STRICT: number;
  26148. /** Use an accurante occlusion algorithm */
  26149. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26150. /** Use a conservative occlusion algorithm */
  26151. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26152. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26153. * Test order :
  26154. * Is the bounding sphere outside the frustum ?
  26155. * If not, are the bounding box vertices outside the frustum ?
  26156. * It not, then the cullable object is in the frustum.
  26157. */
  26158. static readonly CULLINGSTRATEGY_STANDARD: number;
  26159. /** Culling strategy : Bounding Sphere Only.
  26160. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26161. * It's also less accurate than the standard because some not visible objects can still be selected.
  26162. * Test : is the bounding sphere outside the frustum ?
  26163. * If not, then the cullable object is in the frustum.
  26164. */
  26165. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26166. /** Culling strategy : Optimistic Inclusion.
  26167. * This in an inclusion test first, then the standard exclusion test.
  26168. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26169. * 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.
  26170. * Anyway, it's as accurate as the standard strategy.
  26171. * Test :
  26172. * Is the cullable object bounding sphere center in the frustum ?
  26173. * If not, apply the default culling strategy.
  26174. */
  26175. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26176. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26177. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26178. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26179. * 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.
  26180. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26181. * Test :
  26182. * Is the cullable object bounding sphere center in the frustum ?
  26183. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26184. */
  26185. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26186. /**
  26187. * No billboard
  26188. */
  26189. static readonly BILLBOARDMODE_NONE: number;
  26190. /** Billboard on X axis */
  26191. static readonly BILLBOARDMODE_X: number;
  26192. /** Billboard on Y axis */
  26193. static readonly BILLBOARDMODE_Y: number;
  26194. /** Billboard on Z axis */
  26195. static readonly BILLBOARDMODE_Z: number;
  26196. /** Billboard on all axes */
  26197. static readonly BILLBOARDMODE_ALL: number;
  26198. /** Billboard on using position instead of orientation */
  26199. static readonly BILLBOARDMODE_USE_POSITION: number;
  26200. /** @hidden */
  26201. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26202. /**
  26203. * The culling strategy to use to check whether the mesh must be rendered or not.
  26204. * This value can be changed at any time and will be used on the next render mesh selection.
  26205. * The possible values are :
  26206. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26207. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26208. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26209. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26210. * Please read each static variable documentation to get details about the culling process.
  26211. * */
  26212. cullingStrategy: number;
  26213. /**
  26214. * Gets the number of facets in the mesh
  26215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26216. */
  26217. readonly facetNb: number;
  26218. /**
  26219. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26220. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26221. */
  26222. partitioningSubdivisions: number;
  26223. /**
  26224. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26225. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26226. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26227. */
  26228. partitioningBBoxRatio: number;
  26229. /**
  26230. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26231. * Works only for updatable meshes.
  26232. * Doesn't work with multi-materials
  26233. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26234. */
  26235. mustDepthSortFacets: boolean;
  26236. /**
  26237. * The location (Vector3) where the facet depth sort must be computed from.
  26238. * By default, the active camera position.
  26239. * Used only when facet depth sort is enabled
  26240. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26241. */
  26242. facetDepthSortFrom: Vector3;
  26243. /**
  26244. * gets a boolean indicating if facetData is enabled
  26245. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26246. */
  26247. readonly isFacetDataEnabled: boolean;
  26248. /** @hidden */
  26249. _updateNonUniformScalingState(value: boolean): boolean;
  26250. /**
  26251. * An event triggered when this mesh collides with another one
  26252. */
  26253. onCollideObservable: Observable<AbstractMesh>;
  26254. /** Set a function to call when this mesh collides with another one */
  26255. onCollide: () => void;
  26256. /**
  26257. * An event triggered when the collision's position changes
  26258. */
  26259. onCollisionPositionChangeObservable: Observable<Vector3>;
  26260. /** Set a function to call when the collision's position changes */
  26261. onCollisionPositionChange: () => void;
  26262. /**
  26263. * An event triggered when material is changed
  26264. */
  26265. onMaterialChangedObservable: Observable<AbstractMesh>;
  26266. /**
  26267. * Gets or sets the orientation for POV movement & rotation
  26268. */
  26269. definedFacingForward: boolean;
  26270. /** @hidden */
  26271. _occlusionQuery: Nullable<WebGLQuery>;
  26272. /** @hidden */
  26273. _renderingGroup: Nullable<RenderingGroup>;
  26274. /**
  26275. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26276. */
  26277. /**
  26278. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26279. */
  26280. visibility: number;
  26281. /** Gets or sets the alpha index used to sort transparent meshes
  26282. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26283. */
  26284. alphaIndex: number;
  26285. /**
  26286. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26287. */
  26288. isVisible: boolean;
  26289. /**
  26290. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26291. */
  26292. isPickable: boolean;
  26293. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26294. showSubMeshesBoundingBox: boolean;
  26295. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26296. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26297. */
  26298. isBlocker: boolean;
  26299. /**
  26300. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26301. */
  26302. enablePointerMoveEvents: boolean;
  26303. /**
  26304. * Specifies the rendering group id for this mesh (0 by default)
  26305. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26306. */
  26307. renderingGroupId: number;
  26308. private _material;
  26309. /** Gets or sets current material */
  26310. material: Nullable<Material>;
  26311. /**
  26312. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26313. * @see http://doc.babylonjs.com/babylon101/shadows
  26314. */
  26315. receiveShadows: boolean;
  26316. /** Defines color to use when rendering outline */
  26317. outlineColor: Color3;
  26318. /** Define width to use when rendering outline */
  26319. outlineWidth: number;
  26320. /** Defines color to use when rendering overlay */
  26321. overlayColor: Color3;
  26322. /** Defines alpha to use when rendering overlay */
  26323. overlayAlpha: number;
  26324. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26325. hasVertexAlpha: boolean;
  26326. /** 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) */
  26327. useVertexColors: boolean;
  26328. /**
  26329. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26330. */
  26331. computeBonesUsingShaders: boolean;
  26332. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26333. numBoneInfluencers: number;
  26334. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26335. applyFog: boolean;
  26336. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26337. useOctreeForRenderingSelection: boolean;
  26338. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26339. useOctreeForPicking: boolean;
  26340. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26341. useOctreeForCollisions: boolean;
  26342. /**
  26343. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26344. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26345. */
  26346. layerMask: number;
  26347. /**
  26348. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26349. */
  26350. alwaysSelectAsActiveMesh: boolean;
  26351. /**
  26352. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26353. */
  26354. doNotSyncBoundingInfo: boolean;
  26355. /**
  26356. * Gets or sets the current action manager
  26357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26358. */
  26359. actionManager: Nullable<AbstractActionManager>;
  26360. private _meshCollisionData;
  26361. /**
  26362. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26364. */
  26365. ellipsoid: Vector3;
  26366. /**
  26367. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26368. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26369. */
  26370. ellipsoidOffset: Vector3;
  26371. /**
  26372. * Gets or sets a collision mask used to mask collisions (default is -1).
  26373. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26374. */
  26375. collisionMask: number;
  26376. /**
  26377. * Gets or sets the current collision group mask (-1 by default).
  26378. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26379. */
  26380. collisionGroup: number;
  26381. /**
  26382. * Defines edge width used when edgesRenderer is enabled
  26383. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26384. */
  26385. edgesWidth: number;
  26386. /**
  26387. * Defines edge color used when edgesRenderer is enabled
  26388. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26389. */
  26390. edgesColor: Color4;
  26391. /** @hidden */
  26392. _edgesRenderer: Nullable<IEdgesRenderer>;
  26393. /** @hidden */
  26394. _masterMesh: Nullable<AbstractMesh>;
  26395. /** @hidden */
  26396. _boundingInfo: Nullable<BoundingInfo>;
  26397. /** @hidden */
  26398. _renderId: number;
  26399. /**
  26400. * Gets or sets the list of subMeshes
  26401. * @see http://doc.babylonjs.com/how_to/multi_materials
  26402. */
  26403. subMeshes: SubMesh[];
  26404. /** @hidden */
  26405. _intersectionsInProgress: AbstractMesh[];
  26406. /** @hidden */
  26407. _unIndexed: boolean;
  26408. /** @hidden */
  26409. _lightSources: Light[];
  26410. /** Gets the list of lights affecting that mesh */
  26411. readonly lightSources: Light[];
  26412. /** @hidden */
  26413. readonly _positions: Nullable<Vector3[]>;
  26414. /** @hidden */
  26415. _waitingData: {
  26416. lods: Nullable<any>;
  26417. actions: Nullable<any>;
  26418. freezeWorldMatrix: Nullable<boolean>;
  26419. };
  26420. /** @hidden */
  26421. _bonesTransformMatrices: Nullable<Float32Array>;
  26422. /** @hidden */
  26423. _transformMatrixTexture: Nullable<RawTexture>;
  26424. /**
  26425. * Gets or sets a skeleton to apply skining transformations
  26426. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26427. */
  26428. skeleton: Nullable<Skeleton>;
  26429. /**
  26430. * An event triggered when the mesh is rebuilt.
  26431. */
  26432. onRebuildObservable: Observable<AbstractMesh>;
  26433. /**
  26434. * Creates a new AbstractMesh
  26435. * @param name defines the name of the mesh
  26436. * @param scene defines the hosting scene
  26437. */
  26438. constructor(name: string, scene?: Nullable<Scene>);
  26439. /**
  26440. * Returns the string "AbstractMesh"
  26441. * @returns "AbstractMesh"
  26442. */
  26443. getClassName(): string;
  26444. /**
  26445. * Gets a string representation of the current mesh
  26446. * @param fullDetails defines a boolean indicating if full details must be included
  26447. * @returns a string representation of the current mesh
  26448. */
  26449. toString(fullDetails?: boolean): string;
  26450. /**
  26451. * @hidden
  26452. */
  26453. protected _getEffectiveParent(): Nullable<Node>;
  26454. /** @hidden */
  26455. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26456. /** @hidden */
  26457. _rebuild(): void;
  26458. /** @hidden */
  26459. _resyncLightSources(): void;
  26460. /** @hidden */
  26461. _resyncLighSource(light: Light): void;
  26462. /** @hidden */
  26463. _unBindEffect(): void;
  26464. /** @hidden */
  26465. _removeLightSource(light: Light, dispose: boolean): void;
  26466. private _markSubMeshesAsDirty;
  26467. /** @hidden */
  26468. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26469. /** @hidden */
  26470. _markSubMeshesAsAttributesDirty(): void;
  26471. /** @hidden */
  26472. _markSubMeshesAsMiscDirty(): void;
  26473. /**
  26474. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26475. */
  26476. scaling: Vector3;
  26477. /**
  26478. * Returns true if the mesh is blocked. Implemented by child classes
  26479. */
  26480. readonly isBlocked: boolean;
  26481. /**
  26482. * Returns the mesh itself by default. Implemented by child classes
  26483. * @param camera defines the camera to use to pick the right LOD level
  26484. * @returns the currentAbstractMesh
  26485. */
  26486. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26487. /**
  26488. * Returns 0 by default. Implemented by child classes
  26489. * @returns an integer
  26490. */
  26491. getTotalVertices(): number;
  26492. /**
  26493. * Returns a positive integer : the total number of indices in this mesh geometry.
  26494. * @returns the numner of indices or zero if the mesh has no geometry.
  26495. */
  26496. getTotalIndices(): number;
  26497. /**
  26498. * Returns null by default. Implemented by child classes
  26499. * @returns null
  26500. */
  26501. getIndices(): Nullable<IndicesArray>;
  26502. /**
  26503. * Returns the array of the requested vertex data kind. Implemented by child classes
  26504. * @param kind defines the vertex data kind to use
  26505. * @returns null
  26506. */
  26507. getVerticesData(kind: string): Nullable<FloatArray>;
  26508. /**
  26509. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26510. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26511. * Note that a new underlying VertexBuffer object is created each call.
  26512. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26513. * @param kind defines vertex data kind:
  26514. * * VertexBuffer.PositionKind
  26515. * * VertexBuffer.UVKind
  26516. * * VertexBuffer.UV2Kind
  26517. * * VertexBuffer.UV3Kind
  26518. * * VertexBuffer.UV4Kind
  26519. * * VertexBuffer.UV5Kind
  26520. * * VertexBuffer.UV6Kind
  26521. * * VertexBuffer.ColorKind
  26522. * * VertexBuffer.MatricesIndicesKind
  26523. * * VertexBuffer.MatricesIndicesExtraKind
  26524. * * VertexBuffer.MatricesWeightsKind
  26525. * * VertexBuffer.MatricesWeightsExtraKind
  26526. * @param data defines the data source
  26527. * @param updatable defines if the data must be flagged as updatable (or static)
  26528. * @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
  26529. * @returns the current mesh
  26530. */
  26531. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26532. /**
  26533. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26534. * If the mesh has no geometry, it is simply returned as it is.
  26535. * @param kind defines vertex data kind:
  26536. * * VertexBuffer.PositionKind
  26537. * * VertexBuffer.UVKind
  26538. * * VertexBuffer.UV2Kind
  26539. * * VertexBuffer.UV3Kind
  26540. * * VertexBuffer.UV4Kind
  26541. * * VertexBuffer.UV5Kind
  26542. * * VertexBuffer.UV6Kind
  26543. * * VertexBuffer.ColorKind
  26544. * * VertexBuffer.MatricesIndicesKind
  26545. * * VertexBuffer.MatricesIndicesExtraKind
  26546. * * VertexBuffer.MatricesWeightsKind
  26547. * * VertexBuffer.MatricesWeightsExtraKind
  26548. * @param data defines the data source
  26549. * @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
  26550. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26551. * @returns the current mesh
  26552. */
  26553. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26554. /**
  26555. * Sets the mesh indices,
  26556. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26557. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26558. * @param totalVertices Defines the total number of vertices
  26559. * @returns the current mesh
  26560. */
  26561. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26562. /**
  26563. * Gets a boolean indicating if specific vertex data is present
  26564. * @param kind defines the vertex data kind to use
  26565. * @returns true is data kind is present
  26566. */
  26567. isVerticesDataPresent(kind: string): boolean;
  26568. /**
  26569. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26570. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26571. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26572. * @returns a BoundingInfo
  26573. */
  26574. getBoundingInfo(): BoundingInfo;
  26575. /**
  26576. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26577. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26578. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26579. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26580. * @returns the current mesh
  26581. */
  26582. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26583. /**
  26584. * Overwrite the current bounding info
  26585. * @param boundingInfo defines the new bounding info
  26586. * @returns the current mesh
  26587. */
  26588. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26589. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26590. readonly useBones: boolean;
  26591. /** @hidden */
  26592. _preActivate(): void;
  26593. /** @hidden */
  26594. _preActivateForIntermediateRendering(renderId: number): void;
  26595. /** @hidden */
  26596. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26597. /** @hidden */
  26598. _postActivate(): void;
  26599. /** @hidden */
  26600. _freeze(): void;
  26601. /** @hidden */
  26602. _unFreeze(): void;
  26603. /**
  26604. * Gets the current world matrix
  26605. * @returns a Matrix
  26606. */
  26607. getWorldMatrix(): Matrix;
  26608. /** @hidden */
  26609. _getWorldMatrixDeterminant(): number;
  26610. /**
  26611. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26612. */
  26613. readonly isAnInstance: boolean;
  26614. /**
  26615. * Gets a boolean indicating if this mesh has instances
  26616. */
  26617. readonly hasInstances: boolean;
  26618. /**
  26619. * Perform relative position change from the point of view of behind the front of the mesh.
  26620. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26621. * Supports definition of mesh facing forward or backward
  26622. * @param amountRight defines the distance on the right axis
  26623. * @param amountUp defines the distance on the up axis
  26624. * @param amountForward defines the distance on the forward axis
  26625. * @returns the current mesh
  26626. */
  26627. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26628. /**
  26629. * Calculate relative position change from the point of view of behind the front of the mesh.
  26630. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26631. * Supports definition of mesh facing forward or backward
  26632. * @param amountRight defines the distance on the right axis
  26633. * @param amountUp defines the distance on the up axis
  26634. * @param amountForward defines the distance on the forward axis
  26635. * @returns the new displacement vector
  26636. */
  26637. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26638. /**
  26639. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26640. * Supports definition of mesh facing forward or backward
  26641. * @param flipBack defines the flip
  26642. * @param twirlClockwise defines the twirl
  26643. * @param tiltRight defines the tilt
  26644. * @returns the current mesh
  26645. */
  26646. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26647. /**
  26648. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26649. * Supports definition of mesh facing forward or backward.
  26650. * @param flipBack defines the flip
  26651. * @param twirlClockwise defines the twirl
  26652. * @param tiltRight defines the tilt
  26653. * @returns the new rotation vector
  26654. */
  26655. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26656. /**
  26657. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26658. * This means the mesh underlying bounding box and sphere are recomputed.
  26659. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26660. * @returns the current mesh
  26661. */
  26662. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26663. /** @hidden */
  26664. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26665. /** @hidden */
  26666. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26667. /** @hidden */
  26668. _updateBoundingInfo(): AbstractMesh;
  26669. /** @hidden */
  26670. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26671. /** @hidden */
  26672. protected _afterComputeWorldMatrix(): void;
  26673. /** @hidden */
  26674. readonly _effectiveMesh: AbstractMesh;
  26675. /**
  26676. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26677. * A mesh is in the frustum if its bounding box intersects the frustum
  26678. * @param frustumPlanes defines the frustum to test
  26679. * @returns true if the mesh is in the frustum planes
  26680. */
  26681. isInFrustum(frustumPlanes: Plane[]): boolean;
  26682. /**
  26683. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26684. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26685. * @param frustumPlanes defines the frustum to test
  26686. * @returns true if the mesh is completely in the frustum planes
  26687. */
  26688. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26689. /**
  26690. * True if the mesh intersects another mesh or a SolidParticle object
  26691. * @param mesh defines a target mesh or SolidParticle to test
  26692. * @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)
  26693. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26694. * @returns true if there is an intersection
  26695. */
  26696. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26697. /**
  26698. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26699. * @param point defines the point to test
  26700. * @returns true if there is an intersection
  26701. */
  26702. intersectsPoint(point: Vector3): boolean;
  26703. /**
  26704. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26705. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26706. */
  26707. checkCollisions: boolean;
  26708. /**
  26709. * Gets Collider object used to compute collisions (not physics)
  26710. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26711. */
  26712. readonly collider: Nullable<Collider>;
  26713. /**
  26714. * Move the mesh using collision engine
  26715. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26716. * @param displacement defines the requested displacement vector
  26717. * @returns the current mesh
  26718. */
  26719. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26720. private _onCollisionPositionChange;
  26721. /** @hidden */
  26722. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26723. /** @hidden */
  26724. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26725. /** @hidden */
  26726. _checkCollision(collider: Collider): AbstractMesh;
  26727. /** @hidden */
  26728. _generatePointsArray(): boolean;
  26729. /**
  26730. * Checks if the passed Ray intersects with the mesh
  26731. * @param ray defines the ray to use
  26732. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26733. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26734. * @returns the picking info
  26735. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26736. */
  26737. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26738. /**
  26739. * Clones the current mesh
  26740. * @param name defines the mesh name
  26741. * @param newParent defines the new mesh parent
  26742. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26743. * @returns the new mesh
  26744. */
  26745. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26746. /**
  26747. * Disposes all the submeshes of the current meshnp
  26748. * @returns the current mesh
  26749. */
  26750. releaseSubMeshes(): AbstractMesh;
  26751. /**
  26752. * Releases resources associated with this abstract mesh.
  26753. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26754. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26755. */
  26756. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26757. /**
  26758. * Adds the passed mesh as a child to the current mesh
  26759. * @param mesh defines the child mesh
  26760. * @returns the current mesh
  26761. */
  26762. addChild(mesh: AbstractMesh): AbstractMesh;
  26763. /**
  26764. * Removes the passed mesh from the current mesh children list
  26765. * @param mesh defines the child mesh
  26766. * @returns the current mesh
  26767. */
  26768. removeChild(mesh: AbstractMesh): AbstractMesh;
  26769. /** @hidden */
  26770. private _initFacetData;
  26771. /**
  26772. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26773. * This method can be called within the render loop.
  26774. * 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
  26775. * @returns the current mesh
  26776. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26777. */
  26778. updateFacetData(): AbstractMesh;
  26779. /**
  26780. * Returns the facetLocalNormals array.
  26781. * The normals are expressed in the mesh local spac
  26782. * @returns an array of Vector3
  26783. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26784. */
  26785. getFacetLocalNormals(): Vector3[];
  26786. /**
  26787. * Returns the facetLocalPositions array.
  26788. * The facet positions are expressed in the mesh local space
  26789. * @returns an array of Vector3
  26790. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26791. */
  26792. getFacetLocalPositions(): Vector3[];
  26793. /**
  26794. * Returns the facetLocalPartioning array
  26795. * @returns an array of array of numbers
  26796. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26797. */
  26798. getFacetLocalPartitioning(): number[][];
  26799. /**
  26800. * Returns the i-th facet position in the world system.
  26801. * This method allocates a new Vector3 per call
  26802. * @param i defines the facet index
  26803. * @returns a new Vector3
  26804. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26805. */
  26806. getFacetPosition(i: number): Vector3;
  26807. /**
  26808. * Sets the reference Vector3 with the i-th facet position in the world system
  26809. * @param i defines the facet index
  26810. * @param ref defines the target vector
  26811. * @returns the current mesh
  26812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26813. */
  26814. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26815. /**
  26816. * Returns the i-th facet normal in the world system.
  26817. * This method allocates a new Vector3 per call
  26818. * @param i defines the facet index
  26819. * @returns a new Vector3
  26820. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26821. */
  26822. getFacetNormal(i: number): Vector3;
  26823. /**
  26824. * Sets the reference Vector3 with the i-th facet normal in the world system
  26825. * @param i defines the facet index
  26826. * @param ref defines the target vector
  26827. * @returns the current mesh
  26828. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26829. */
  26830. getFacetNormalToRef(i: number, ref: Vector3): this;
  26831. /**
  26832. * 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)
  26833. * @param x defines x coordinate
  26834. * @param y defines y coordinate
  26835. * @param z defines z coordinate
  26836. * @returns the array of facet indexes
  26837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26838. */
  26839. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26840. /**
  26841. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26842. * @param projected sets as the (x,y,z) world projection on the facet
  26843. * @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
  26844. * @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
  26845. * @param x defines x coordinate
  26846. * @param y defines y coordinate
  26847. * @param z defines z coordinate
  26848. * @returns the face index if found (or null instead)
  26849. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26850. */
  26851. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26852. /**
  26853. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26854. * @param projected sets as the (x,y,z) local projection on the facet
  26855. * @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
  26856. * @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
  26857. * @param x defines x coordinate
  26858. * @param y defines y coordinate
  26859. * @param z defines z coordinate
  26860. * @returns the face index if found (or null instead)
  26861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26862. */
  26863. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26864. /**
  26865. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26866. * @returns the parameters
  26867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26868. */
  26869. getFacetDataParameters(): any;
  26870. /**
  26871. * Disables the feature FacetData and frees the related memory
  26872. * @returns the current mesh
  26873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26874. */
  26875. disableFacetData(): AbstractMesh;
  26876. /**
  26877. * Updates the AbstractMesh indices array
  26878. * @param indices defines the data source
  26879. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26880. * @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)
  26881. * @returns the current mesh
  26882. */
  26883. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26884. /**
  26885. * Creates new normals data for the mesh
  26886. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26887. * @returns the current mesh
  26888. */
  26889. createNormals(updatable: boolean): AbstractMesh;
  26890. /**
  26891. * Align the mesh with a normal
  26892. * @param normal defines the normal to use
  26893. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26894. * @returns the current mesh
  26895. */
  26896. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26897. /** @hidden */
  26898. _checkOcclusionQuery(): boolean;
  26899. /**
  26900. * Disables the mesh edge rendering mode
  26901. * @returns the currentAbstractMesh
  26902. */
  26903. disableEdgesRendering(): AbstractMesh;
  26904. /**
  26905. * Enables the edge rendering mode on the mesh.
  26906. * This mode makes the mesh edges visible
  26907. * @param epsilon defines the maximal distance between two angles to detect a face
  26908. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26909. * @returns the currentAbstractMesh
  26910. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26911. */
  26912. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26913. }
  26914. }
  26915. declare module BABYLON {
  26916. /**
  26917. * Interface used to define ActionEvent
  26918. */
  26919. export interface IActionEvent {
  26920. /** The mesh or sprite that triggered the action */
  26921. source: any;
  26922. /** The X mouse cursor position at the time of the event */
  26923. pointerX: number;
  26924. /** The Y mouse cursor position at the time of the event */
  26925. pointerY: number;
  26926. /** The mesh that is currently pointed at (can be null) */
  26927. meshUnderPointer: Nullable<AbstractMesh>;
  26928. /** the original (browser) event that triggered the ActionEvent */
  26929. sourceEvent?: any;
  26930. /** additional data for the event */
  26931. additionalData?: any;
  26932. }
  26933. /**
  26934. * ActionEvent is the event being sent when an action is triggered.
  26935. */
  26936. export class ActionEvent implements IActionEvent {
  26937. /** The mesh or sprite that triggered the action */
  26938. source: any;
  26939. /** The X mouse cursor position at the time of the event */
  26940. pointerX: number;
  26941. /** The Y mouse cursor position at the time of the event */
  26942. pointerY: number;
  26943. /** The mesh that is currently pointed at (can be null) */
  26944. meshUnderPointer: Nullable<AbstractMesh>;
  26945. /** the original (browser) event that triggered the ActionEvent */
  26946. sourceEvent?: any;
  26947. /** additional data for the event */
  26948. additionalData?: any;
  26949. /**
  26950. * Creates a new ActionEvent
  26951. * @param source The mesh or sprite that triggered the action
  26952. * @param pointerX The X mouse cursor position at the time of the event
  26953. * @param pointerY The Y mouse cursor position at the time of the event
  26954. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26955. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26956. * @param additionalData additional data for the event
  26957. */
  26958. constructor(
  26959. /** The mesh or sprite that triggered the action */
  26960. source: any,
  26961. /** The X mouse cursor position at the time of the event */
  26962. pointerX: number,
  26963. /** The Y mouse cursor position at the time of the event */
  26964. pointerY: number,
  26965. /** The mesh that is currently pointed at (can be null) */
  26966. meshUnderPointer: Nullable<AbstractMesh>,
  26967. /** the original (browser) event that triggered the ActionEvent */
  26968. sourceEvent?: any,
  26969. /** additional data for the event */
  26970. additionalData?: any);
  26971. /**
  26972. * Helper function to auto-create an ActionEvent from a source mesh.
  26973. * @param source The source mesh that triggered the event
  26974. * @param evt The original (browser) event
  26975. * @param additionalData additional data for the event
  26976. * @returns the new ActionEvent
  26977. */
  26978. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26979. /**
  26980. * Helper function to auto-create an ActionEvent from a source sprite
  26981. * @param source The source sprite that triggered the event
  26982. * @param scene Scene associated with the sprite
  26983. * @param evt The original (browser) event
  26984. * @param additionalData additional data for the event
  26985. * @returns the new ActionEvent
  26986. */
  26987. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26988. /**
  26989. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26990. * @param scene the scene where the event occurred
  26991. * @param evt The original (browser) event
  26992. * @returns the new ActionEvent
  26993. */
  26994. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26995. /**
  26996. * Helper function to auto-create an ActionEvent from a primitive
  26997. * @param prim defines the target primitive
  26998. * @param pointerPos defines the pointer position
  26999. * @param evt The original (browser) event
  27000. * @param additionalData additional data for the event
  27001. * @returns the new ActionEvent
  27002. */
  27003. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27004. }
  27005. }
  27006. declare module BABYLON {
  27007. /**
  27008. * Abstract class used to decouple action Manager from scene and meshes.
  27009. * Do not instantiate.
  27010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27011. */
  27012. export abstract class AbstractActionManager implements IDisposable {
  27013. /** Gets the list of active triggers */
  27014. static Triggers: {
  27015. [key: string]: number;
  27016. };
  27017. /** Gets the cursor to use when hovering items */
  27018. hoverCursor: string;
  27019. /** Gets the list of actions */
  27020. actions: IAction[];
  27021. /**
  27022. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27023. */
  27024. isRecursive: boolean;
  27025. /**
  27026. * Releases all associated resources
  27027. */
  27028. abstract dispose(): void;
  27029. /**
  27030. * Does this action manager has pointer triggers
  27031. */
  27032. abstract readonly hasPointerTriggers: boolean;
  27033. /**
  27034. * Does this action manager has pick triggers
  27035. */
  27036. abstract readonly hasPickTriggers: boolean;
  27037. /**
  27038. * Process a specific trigger
  27039. * @param trigger defines the trigger to process
  27040. * @param evt defines the event details to be processed
  27041. */
  27042. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27043. /**
  27044. * Does this action manager handles actions of any of the given triggers
  27045. * @param triggers defines the triggers to be tested
  27046. * @return a boolean indicating whether one (or more) of the triggers is handled
  27047. */
  27048. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27049. /**
  27050. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27051. * speed.
  27052. * @param triggerA defines the trigger to be tested
  27053. * @param triggerB defines the trigger to be tested
  27054. * @return a boolean indicating whether one (or more) of the triggers is handled
  27055. */
  27056. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27057. /**
  27058. * Does this action manager handles actions of a given trigger
  27059. * @param trigger defines the trigger to be tested
  27060. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27061. * @return whether the trigger is handled
  27062. */
  27063. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27064. /**
  27065. * Serialize this manager to a JSON object
  27066. * @param name defines the property name to store this manager
  27067. * @returns a JSON representation of this manager
  27068. */
  27069. abstract serialize(name: string): any;
  27070. /**
  27071. * Registers an action to this action manager
  27072. * @param action defines the action to be registered
  27073. * @return the action amended (prepared) after registration
  27074. */
  27075. abstract registerAction(action: IAction): Nullable<IAction>;
  27076. /**
  27077. * Unregisters an action to this action manager
  27078. * @param action defines the action to be unregistered
  27079. * @return a boolean indicating whether the action has been unregistered
  27080. */
  27081. abstract unregisterAction(action: IAction): Boolean;
  27082. /**
  27083. * Does exist one action manager with at least one trigger
  27084. **/
  27085. static readonly HasTriggers: boolean;
  27086. /**
  27087. * Does exist one action manager with at least one pick trigger
  27088. **/
  27089. static readonly HasPickTriggers: boolean;
  27090. /**
  27091. * Does exist one action manager that handles actions of a given trigger
  27092. * @param trigger defines the trigger to be tested
  27093. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27094. **/
  27095. static HasSpecificTrigger(trigger: number): boolean;
  27096. }
  27097. }
  27098. declare module BABYLON {
  27099. /**
  27100. * Defines how a node can be built from a string name.
  27101. */
  27102. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27103. /**
  27104. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27105. */
  27106. export class Node implements IBehaviorAware<Node> {
  27107. /** @hidden */
  27108. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  27109. private static _NodeConstructors;
  27110. /**
  27111. * Add a new node constructor
  27112. * @param type defines the type name of the node to construct
  27113. * @param constructorFunc defines the constructor function
  27114. */
  27115. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27116. /**
  27117. * Returns a node constructor based on type name
  27118. * @param type defines the type name
  27119. * @param name defines the new node name
  27120. * @param scene defines the hosting scene
  27121. * @param options defines optional options to transmit to constructors
  27122. * @returns the new constructor or null
  27123. */
  27124. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27125. /**
  27126. * Gets or sets the name of the node
  27127. */
  27128. name: string;
  27129. /**
  27130. * Gets or sets the id of the node
  27131. */
  27132. id: string;
  27133. /**
  27134. * Gets or sets the unique id of the node
  27135. */
  27136. uniqueId: number;
  27137. /**
  27138. * Gets or sets a string used to store user defined state for the node
  27139. */
  27140. state: string;
  27141. /**
  27142. * Gets or sets an object used to store user defined information for the node
  27143. */
  27144. metadata: any;
  27145. /**
  27146. * For internal use only. Please do not use.
  27147. */
  27148. reservedDataStore: any;
  27149. /**
  27150. * List of inspectable custom properties (used by the Inspector)
  27151. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27152. */
  27153. inspectableCustomProperties: IInspectable[];
  27154. private _doNotSerialize;
  27155. /**
  27156. * Gets or sets a boolean used to define if the node must be serialized
  27157. */
  27158. doNotSerialize: boolean;
  27159. /** @hidden */
  27160. _isDisposed: boolean;
  27161. /**
  27162. * Gets a list of Animations associated with the node
  27163. */
  27164. animations: Animation[];
  27165. protected _ranges: {
  27166. [name: string]: Nullable<AnimationRange>;
  27167. };
  27168. /**
  27169. * Callback raised when the node is ready to be used
  27170. */
  27171. onReady: Nullable<(node: Node) => void>;
  27172. private _isEnabled;
  27173. private _isParentEnabled;
  27174. private _isReady;
  27175. /** @hidden */
  27176. _currentRenderId: number;
  27177. private _parentUpdateId;
  27178. /** @hidden */
  27179. _childUpdateId: number;
  27180. /** @hidden */
  27181. _waitingParentId: Nullable<string>;
  27182. /** @hidden */
  27183. _scene: Scene;
  27184. /** @hidden */
  27185. _cache: any;
  27186. private _parentNode;
  27187. private _children;
  27188. /** @hidden */
  27189. _worldMatrix: Matrix;
  27190. /** @hidden */
  27191. _worldMatrixDeterminant: number;
  27192. /** @hidden */
  27193. _worldMatrixDeterminantIsDirty: boolean;
  27194. /** @hidden */
  27195. private _sceneRootNodesIndex;
  27196. /**
  27197. * Gets a boolean indicating if the node has been disposed
  27198. * @returns true if the node was disposed
  27199. */
  27200. isDisposed(): boolean;
  27201. /**
  27202. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27203. * @see https://doc.babylonjs.com/how_to/parenting
  27204. */
  27205. parent: Nullable<Node>;
  27206. /** @hidden */
  27207. _addToSceneRootNodes(): void;
  27208. /** @hidden */
  27209. _removeFromSceneRootNodes(): void;
  27210. private _animationPropertiesOverride;
  27211. /**
  27212. * Gets or sets the animation properties override
  27213. */
  27214. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27215. /**
  27216. * Gets a string idenfifying the name of the class
  27217. * @returns "Node" string
  27218. */
  27219. getClassName(): string;
  27220. /** @hidden */
  27221. readonly _isNode: boolean;
  27222. /**
  27223. * An event triggered when the mesh is disposed
  27224. */
  27225. onDisposeObservable: Observable<Node>;
  27226. private _onDisposeObserver;
  27227. /**
  27228. * Sets a callback that will be raised when the node will be disposed
  27229. */
  27230. onDispose: () => void;
  27231. /**
  27232. * Creates a new Node
  27233. * @param name the name and id to be given to this node
  27234. * @param scene the scene this node will be added to
  27235. */
  27236. constructor(name: string, scene?: Nullable<Scene>);
  27237. /**
  27238. * Gets the scene of the node
  27239. * @returns a scene
  27240. */
  27241. getScene(): Scene;
  27242. /**
  27243. * Gets the engine of the node
  27244. * @returns a Engine
  27245. */
  27246. getEngine(): Engine;
  27247. private _behaviors;
  27248. /**
  27249. * Attach a behavior to the node
  27250. * @see http://doc.babylonjs.com/features/behaviour
  27251. * @param behavior defines the behavior to attach
  27252. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27253. * @returns the current Node
  27254. */
  27255. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27256. /**
  27257. * Remove an attached behavior
  27258. * @see http://doc.babylonjs.com/features/behaviour
  27259. * @param behavior defines the behavior to attach
  27260. * @returns the current Node
  27261. */
  27262. removeBehavior(behavior: Behavior<Node>): Node;
  27263. /**
  27264. * Gets the list of attached behaviors
  27265. * @see http://doc.babylonjs.com/features/behaviour
  27266. */
  27267. readonly behaviors: Behavior<Node>[];
  27268. /**
  27269. * Gets an attached behavior by name
  27270. * @param name defines the name of the behavior to look for
  27271. * @see http://doc.babylonjs.com/features/behaviour
  27272. * @returns null if behavior was not found else the requested behavior
  27273. */
  27274. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27275. /**
  27276. * Returns the latest update of the World matrix
  27277. * @returns a Matrix
  27278. */
  27279. getWorldMatrix(): Matrix;
  27280. /** @hidden */
  27281. _getWorldMatrixDeterminant(): number;
  27282. /**
  27283. * Returns directly the latest state of the mesh World matrix.
  27284. * A Matrix is returned.
  27285. */
  27286. readonly worldMatrixFromCache: Matrix;
  27287. /** @hidden */
  27288. _initCache(): void;
  27289. /** @hidden */
  27290. updateCache(force?: boolean): void;
  27291. /** @hidden */
  27292. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27293. /** @hidden */
  27294. _updateCache(ignoreParentClass?: boolean): void;
  27295. /** @hidden */
  27296. _isSynchronized(): boolean;
  27297. /** @hidden */
  27298. _markSyncedWithParent(): void;
  27299. /** @hidden */
  27300. isSynchronizedWithParent(): boolean;
  27301. /** @hidden */
  27302. isSynchronized(): boolean;
  27303. /**
  27304. * Is this node ready to be used/rendered
  27305. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27306. * @return true if the node is ready
  27307. */
  27308. isReady(completeCheck?: boolean): boolean;
  27309. /**
  27310. * Is this node enabled?
  27311. * 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
  27312. * @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
  27313. * @return whether this node (and its parent) is enabled
  27314. */
  27315. isEnabled(checkAncestors?: boolean): boolean;
  27316. /** @hidden */
  27317. protected _syncParentEnabledState(): void;
  27318. /**
  27319. * Set the enabled state of this node
  27320. * @param value defines the new enabled state
  27321. */
  27322. setEnabled(value: boolean): void;
  27323. /**
  27324. * Is this node a descendant of the given node?
  27325. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27326. * @param ancestor defines the parent node to inspect
  27327. * @returns a boolean indicating if this node is a descendant of the given node
  27328. */
  27329. isDescendantOf(ancestor: Node): boolean;
  27330. /** @hidden */
  27331. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27332. /**
  27333. * Will return all nodes that have this node as ascendant
  27334. * @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
  27335. * @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
  27336. * @return all children nodes of all types
  27337. */
  27338. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27339. /**
  27340. * Get all child-meshes of this node
  27341. * @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)
  27342. * @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
  27343. * @returns an array of AbstractMesh
  27344. */
  27345. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27346. /**
  27347. * Get all direct children of this node
  27348. * @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
  27349. * @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)
  27350. * @returns an array of Node
  27351. */
  27352. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27353. /** @hidden */
  27354. _setReady(state: boolean): void;
  27355. /**
  27356. * Get an animation by name
  27357. * @param name defines the name of the animation to look for
  27358. * @returns null if not found else the requested animation
  27359. */
  27360. getAnimationByName(name: string): Nullable<Animation>;
  27361. /**
  27362. * Creates an animation range for this node
  27363. * @param name defines the name of the range
  27364. * @param from defines the starting key
  27365. * @param to defines the end key
  27366. */
  27367. createAnimationRange(name: string, from: number, to: number): void;
  27368. /**
  27369. * Delete a specific animation range
  27370. * @param name defines the name of the range to delete
  27371. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27372. */
  27373. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27374. /**
  27375. * Get an animation range by name
  27376. * @param name defines the name of the animation range to look for
  27377. * @returns null if not found else the requested animation range
  27378. */
  27379. getAnimationRange(name: string): Nullable<AnimationRange>;
  27380. /**
  27381. * Gets the list of all animation ranges defined on this node
  27382. * @returns an array
  27383. */
  27384. getAnimationRanges(): Nullable<AnimationRange>[];
  27385. /**
  27386. * Will start the animation sequence
  27387. * @param name defines the range frames for animation sequence
  27388. * @param loop defines if the animation should loop (false by default)
  27389. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27390. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27391. * @returns the object created for this animation. If range does not exist, it will return null
  27392. */
  27393. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27394. /**
  27395. * Serialize animation ranges into a JSON compatible object
  27396. * @returns serialization object
  27397. */
  27398. serializeAnimationRanges(): any;
  27399. /**
  27400. * Computes the world matrix of the node
  27401. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27402. * @returns the world matrix
  27403. */
  27404. computeWorldMatrix(force?: boolean): Matrix;
  27405. /**
  27406. * Releases resources associated with this node.
  27407. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27408. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27409. */
  27410. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27411. /**
  27412. * Parse animation range data from a serialization object and store them into a given node
  27413. * @param node defines where to store the animation ranges
  27414. * @param parsedNode defines the serialization object to read data from
  27415. * @param scene defines the hosting scene
  27416. */
  27417. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27418. /**
  27419. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27420. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27421. * @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
  27422. * @returns the new bounding vectors
  27423. */
  27424. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27425. min: Vector3;
  27426. max: Vector3;
  27427. };
  27428. }
  27429. }
  27430. declare module BABYLON {
  27431. /**
  27432. * @hidden
  27433. */
  27434. export class _IAnimationState {
  27435. key: number;
  27436. repeatCount: number;
  27437. workValue?: any;
  27438. loopMode?: number;
  27439. offsetValue?: any;
  27440. highLimitValue?: any;
  27441. }
  27442. /**
  27443. * Class used to store any kind of animation
  27444. */
  27445. export class Animation {
  27446. /**Name of the animation */
  27447. name: string;
  27448. /**Property to animate */
  27449. targetProperty: string;
  27450. /**The frames per second of the animation */
  27451. framePerSecond: number;
  27452. /**The data type of the animation */
  27453. dataType: number;
  27454. /**The loop mode of the animation */
  27455. loopMode?: number | undefined;
  27456. /**Specifies if blending should be enabled */
  27457. enableBlending?: boolean | undefined;
  27458. /**
  27459. * Use matrix interpolation instead of using direct key value when animating matrices
  27460. */
  27461. static AllowMatricesInterpolation: boolean;
  27462. /**
  27463. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27464. */
  27465. static AllowMatrixDecomposeForInterpolation: boolean;
  27466. /**
  27467. * Stores the key frames of the animation
  27468. */
  27469. private _keys;
  27470. /**
  27471. * Stores the easing function of the animation
  27472. */
  27473. private _easingFunction;
  27474. /**
  27475. * @hidden Internal use only
  27476. */
  27477. _runtimeAnimations: RuntimeAnimation[];
  27478. /**
  27479. * The set of event that will be linked to this animation
  27480. */
  27481. private _events;
  27482. /**
  27483. * Stores an array of target property paths
  27484. */
  27485. targetPropertyPath: string[];
  27486. /**
  27487. * Stores the blending speed of the animation
  27488. */
  27489. blendingSpeed: number;
  27490. /**
  27491. * Stores the animation ranges for the animation
  27492. */
  27493. private _ranges;
  27494. /**
  27495. * @hidden Internal use
  27496. */
  27497. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27498. /**
  27499. * Sets up an animation
  27500. * @param property The property to animate
  27501. * @param animationType The animation type to apply
  27502. * @param framePerSecond The frames per second of the animation
  27503. * @param easingFunction The easing function used in the animation
  27504. * @returns The created animation
  27505. */
  27506. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27507. /**
  27508. * Create and start an animation on a node
  27509. * @param name defines the name of the global animation that will be run on all nodes
  27510. * @param node defines the root node where the animation will take place
  27511. * @param targetProperty defines property to animate
  27512. * @param framePerSecond defines the number of frame per second yo use
  27513. * @param totalFrame defines the number of frames in total
  27514. * @param from defines the initial value
  27515. * @param to defines the final value
  27516. * @param loopMode defines which loop mode you want to use (off by default)
  27517. * @param easingFunction defines the easing function to use (linear by default)
  27518. * @param onAnimationEnd defines the callback to call when animation end
  27519. * @returns the animatable created for this animation
  27520. */
  27521. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27522. /**
  27523. * Create and start an animation on a node and its descendants
  27524. * @param name defines the name of the global animation that will be run on all nodes
  27525. * @param node defines the root node where the animation will take place
  27526. * @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
  27527. * @param targetProperty defines property to animate
  27528. * @param framePerSecond defines the number of frame per second to use
  27529. * @param totalFrame defines the number of frames in total
  27530. * @param from defines the initial value
  27531. * @param to defines the final value
  27532. * @param loopMode defines which loop mode you want to use (off by default)
  27533. * @param easingFunction defines the easing function to use (linear by default)
  27534. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27535. * @returns the list of animatables created for all nodes
  27536. * @example https://www.babylonjs-playground.com/#MH0VLI
  27537. */
  27538. 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[]>;
  27539. /**
  27540. * Creates a new animation, merges it with the existing animations and starts it
  27541. * @param name Name of the animation
  27542. * @param node Node which contains the scene that begins the animations
  27543. * @param targetProperty Specifies which property to animate
  27544. * @param framePerSecond The frames per second of the animation
  27545. * @param totalFrame The total number of frames
  27546. * @param from The frame at the beginning of the animation
  27547. * @param to The frame at the end of the animation
  27548. * @param loopMode Specifies the loop mode of the animation
  27549. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27550. * @param onAnimationEnd Callback to run once the animation is complete
  27551. * @returns Nullable animation
  27552. */
  27553. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27554. /**
  27555. * Transition property of an host to the target Value
  27556. * @param property The property to transition
  27557. * @param targetValue The target Value of the property
  27558. * @param host The object where the property to animate belongs
  27559. * @param scene Scene used to run the animation
  27560. * @param frameRate Framerate (in frame/s) to use
  27561. * @param transition The transition type we want to use
  27562. * @param duration The duration of the animation, in milliseconds
  27563. * @param onAnimationEnd Callback trigger at the end of the animation
  27564. * @returns Nullable animation
  27565. */
  27566. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27567. /**
  27568. * Return the array of runtime animations currently using this animation
  27569. */
  27570. readonly runtimeAnimations: RuntimeAnimation[];
  27571. /**
  27572. * Specifies if any of the runtime animations are currently running
  27573. */
  27574. readonly hasRunningRuntimeAnimations: boolean;
  27575. /**
  27576. * Initializes the animation
  27577. * @param name Name of the animation
  27578. * @param targetProperty Property to animate
  27579. * @param framePerSecond The frames per second of the animation
  27580. * @param dataType The data type of the animation
  27581. * @param loopMode The loop mode of the animation
  27582. * @param enableBlending Specifies if blending should be enabled
  27583. */
  27584. constructor(
  27585. /**Name of the animation */
  27586. name: string,
  27587. /**Property to animate */
  27588. targetProperty: string,
  27589. /**The frames per second of the animation */
  27590. framePerSecond: number,
  27591. /**The data type of the animation */
  27592. dataType: number,
  27593. /**The loop mode of the animation */
  27594. loopMode?: number | undefined,
  27595. /**Specifies if blending should be enabled */
  27596. enableBlending?: boolean | undefined);
  27597. /**
  27598. * Converts the animation to a string
  27599. * @param fullDetails support for multiple levels of logging within scene loading
  27600. * @returns String form of the animation
  27601. */
  27602. toString(fullDetails?: boolean): string;
  27603. /**
  27604. * Add an event to this animation
  27605. * @param event Event to add
  27606. */
  27607. addEvent(event: AnimationEvent): void;
  27608. /**
  27609. * Remove all events found at the given frame
  27610. * @param frame The frame to remove events from
  27611. */
  27612. removeEvents(frame: number): void;
  27613. /**
  27614. * Retrieves all the events from the animation
  27615. * @returns Events from the animation
  27616. */
  27617. getEvents(): AnimationEvent[];
  27618. /**
  27619. * Creates an animation range
  27620. * @param name Name of the animation range
  27621. * @param from Starting frame of the animation range
  27622. * @param to Ending frame of the animation
  27623. */
  27624. createRange(name: string, from: number, to: number): void;
  27625. /**
  27626. * Deletes an animation range by name
  27627. * @param name Name of the animation range to delete
  27628. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27629. */
  27630. deleteRange(name: string, deleteFrames?: boolean): void;
  27631. /**
  27632. * Gets the animation range by name, or null if not defined
  27633. * @param name Name of the animation range
  27634. * @returns Nullable animation range
  27635. */
  27636. getRange(name: string): Nullable<AnimationRange>;
  27637. /**
  27638. * Gets the key frames from the animation
  27639. * @returns The key frames of the animation
  27640. */
  27641. getKeys(): Array<IAnimationKey>;
  27642. /**
  27643. * Gets the highest frame rate of the animation
  27644. * @returns Highest frame rate of the animation
  27645. */
  27646. getHighestFrame(): number;
  27647. /**
  27648. * Gets the easing function of the animation
  27649. * @returns Easing function of the animation
  27650. */
  27651. getEasingFunction(): IEasingFunction;
  27652. /**
  27653. * Sets the easing function of the animation
  27654. * @param easingFunction A custom mathematical formula for animation
  27655. */
  27656. setEasingFunction(easingFunction: EasingFunction): void;
  27657. /**
  27658. * Interpolates a scalar linearly
  27659. * @param startValue Start value of the animation curve
  27660. * @param endValue End value of the animation curve
  27661. * @param gradient Scalar amount to interpolate
  27662. * @returns Interpolated scalar value
  27663. */
  27664. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27665. /**
  27666. * Interpolates a scalar cubically
  27667. * @param startValue Start value of the animation curve
  27668. * @param outTangent End tangent of the animation
  27669. * @param endValue End value of the animation curve
  27670. * @param inTangent Start tangent of the animation curve
  27671. * @param gradient Scalar amount to interpolate
  27672. * @returns Interpolated scalar value
  27673. */
  27674. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27675. /**
  27676. * Interpolates a quaternion using a spherical linear interpolation
  27677. * @param startValue Start value of the animation curve
  27678. * @param endValue End value of the animation curve
  27679. * @param gradient Scalar amount to interpolate
  27680. * @returns Interpolated quaternion value
  27681. */
  27682. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27683. /**
  27684. * Interpolates a quaternion cubically
  27685. * @param startValue Start value of the animation curve
  27686. * @param outTangent End tangent of the animation curve
  27687. * @param endValue End value of the animation curve
  27688. * @param inTangent Start tangent of the animation curve
  27689. * @param gradient Scalar amount to interpolate
  27690. * @returns Interpolated quaternion value
  27691. */
  27692. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27693. /**
  27694. * Interpolates a Vector3 linearl
  27695. * @param startValue Start value of the animation curve
  27696. * @param endValue End value of the animation curve
  27697. * @param gradient Scalar amount to interpolate
  27698. * @returns Interpolated scalar value
  27699. */
  27700. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27701. /**
  27702. * Interpolates a Vector3 cubically
  27703. * @param startValue Start value of the animation curve
  27704. * @param outTangent End tangent of the animation
  27705. * @param endValue End value of the animation curve
  27706. * @param inTangent Start tangent of the animation curve
  27707. * @param gradient Scalar amount to interpolate
  27708. * @returns InterpolatedVector3 value
  27709. */
  27710. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27711. /**
  27712. * Interpolates a Vector2 linearly
  27713. * @param startValue Start value of the animation curve
  27714. * @param endValue End value of the animation curve
  27715. * @param gradient Scalar amount to interpolate
  27716. * @returns Interpolated Vector2 value
  27717. */
  27718. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27719. /**
  27720. * Interpolates a Vector2 cubically
  27721. * @param startValue Start value of the animation curve
  27722. * @param outTangent End tangent of the animation
  27723. * @param endValue End value of the animation curve
  27724. * @param inTangent Start tangent of the animation curve
  27725. * @param gradient Scalar amount to interpolate
  27726. * @returns Interpolated Vector2 value
  27727. */
  27728. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27729. /**
  27730. * Interpolates a size linearly
  27731. * @param startValue Start value of the animation curve
  27732. * @param endValue End value of the animation curve
  27733. * @param gradient Scalar amount to interpolate
  27734. * @returns Interpolated Size value
  27735. */
  27736. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27737. /**
  27738. * Interpolates a Color3 linearly
  27739. * @param startValue Start value of the animation curve
  27740. * @param endValue End value of the animation curve
  27741. * @param gradient Scalar amount to interpolate
  27742. * @returns Interpolated Color3 value
  27743. */
  27744. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27745. /**
  27746. * Interpolates a Color4 linearly
  27747. * @param startValue Start value of the animation curve
  27748. * @param endValue End value of the animation curve
  27749. * @param gradient Scalar amount to interpolate
  27750. * @returns Interpolated Color3 value
  27751. */
  27752. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  27753. /**
  27754. * @hidden Internal use only
  27755. */
  27756. _getKeyValue(value: any): any;
  27757. /**
  27758. * @hidden Internal use only
  27759. */
  27760. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27761. /**
  27762. * Defines the function to use to interpolate matrices
  27763. * @param startValue defines the start matrix
  27764. * @param endValue defines the end matrix
  27765. * @param gradient defines the gradient between both matrices
  27766. * @param result defines an optional target matrix where to store the interpolation
  27767. * @returns the interpolated matrix
  27768. */
  27769. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27770. /**
  27771. * Makes a copy of the animation
  27772. * @returns Cloned animation
  27773. */
  27774. clone(): Animation;
  27775. /**
  27776. * Sets the key frames of the animation
  27777. * @param values The animation key frames to set
  27778. */
  27779. setKeys(values: Array<IAnimationKey>): void;
  27780. /**
  27781. * Serializes the animation to an object
  27782. * @returns Serialized object
  27783. */
  27784. serialize(): any;
  27785. /**
  27786. * Float animation type
  27787. */
  27788. static readonly ANIMATIONTYPE_FLOAT: number;
  27789. /**
  27790. * Vector3 animation type
  27791. */
  27792. static readonly ANIMATIONTYPE_VECTOR3: number;
  27793. /**
  27794. * Quaternion animation type
  27795. */
  27796. static readonly ANIMATIONTYPE_QUATERNION: number;
  27797. /**
  27798. * Matrix animation type
  27799. */
  27800. static readonly ANIMATIONTYPE_MATRIX: number;
  27801. /**
  27802. * Color3 animation type
  27803. */
  27804. static readonly ANIMATIONTYPE_COLOR3: number;
  27805. /**
  27806. * Color3 animation type
  27807. */
  27808. static readonly ANIMATIONTYPE_COLOR4: number;
  27809. /**
  27810. * Vector2 animation type
  27811. */
  27812. static readonly ANIMATIONTYPE_VECTOR2: number;
  27813. /**
  27814. * Size animation type
  27815. */
  27816. static readonly ANIMATIONTYPE_SIZE: number;
  27817. /**
  27818. * Relative Loop Mode
  27819. */
  27820. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27821. /**
  27822. * Cycle Loop Mode
  27823. */
  27824. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27825. /**
  27826. * Constant Loop Mode
  27827. */
  27828. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27829. /** @hidden */
  27830. static _UniversalLerp(left: any, right: any, amount: number): any;
  27831. /**
  27832. * Parses an animation object and creates an animation
  27833. * @param parsedAnimation Parsed animation object
  27834. * @returns Animation object
  27835. */
  27836. static Parse(parsedAnimation: any): Animation;
  27837. /**
  27838. * Appends the serialized animations from the source animations
  27839. * @param source Source containing the animations
  27840. * @param destination Target to store the animations
  27841. */
  27842. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27843. }
  27844. }
  27845. declare module BABYLON {
  27846. /**
  27847. * Interface containing an array of animations
  27848. */
  27849. export interface IAnimatable {
  27850. /**
  27851. * Array of animations
  27852. */
  27853. animations: Nullable<Array<Animation>>;
  27854. }
  27855. }
  27856. declare module BABYLON {
  27857. /**
  27858. * This represents all the required information to add a fresnel effect on a material:
  27859. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27860. */
  27861. export class FresnelParameters {
  27862. private _isEnabled;
  27863. /**
  27864. * Define if the fresnel effect is enable or not.
  27865. */
  27866. isEnabled: boolean;
  27867. /**
  27868. * Define the color used on edges (grazing angle)
  27869. */
  27870. leftColor: Color3;
  27871. /**
  27872. * Define the color used on center
  27873. */
  27874. rightColor: Color3;
  27875. /**
  27876. * Define bias applied to computed fresnel term
  27877. */
  27878. bias: number;
  27879. /**
  27880. * Defined the power exponent applied to fresnel term
  27881. */
  27882. power: number;
  27883. /**
  27884. * Clones the current fresnel and its valuues
  27885. * @returns a clone fresnel configuration
  27886. */
  27887. clone(): FresnelParameters;
  27888. /**
  27889. * Serializes the current fresnel parameters to a JSON representation.
  27890. * @return the JSON serialization
  27891. */
  27892. serialize(): any;
  27893. /**
  27894. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27895. * @param parsedFresnelParameters Define the JSON representation
  27896. * @returns the parsed parameters
  27897. */
  27898. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27899. }
  27900. }
  27901. declare module BABYLON {
  27902. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27903. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27904. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27905. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27906. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27907. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27908. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27909. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27910. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27911. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27912. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27913. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27914. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27915. /**
  27916. * Decorator used to define property that can be serialized as reference to a camera
  27917. * @param sourceName defines the name of the property to decorate
  27918. */
  27919. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27920. /**
  27921. * Class used to help serialization objects
  27922. */
  27923. export class SerializationHelper {
  27924. /** @hidden */
  27925. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27926. /** @hidden */
  27927. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27928. /** @hidden */
  27929. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27930. /** @hidden */
  27931. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27932. /**
  27933. * Appends the serialized animations from the source animations
  27934. * @param source Source containing the animations
  27935. * @param destination Target to store the animations
  27936. */
  27937. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27938. /**
  27939. * Static function used to serialized a specific entity
  27940. * @param entity defines the entity to serialize
  27941. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27942. * @returns a JSON compatible object representing the serialization of the entity
  27943. */
  27944. static Serialize<T>(entity: T, serializationObject?: any): any;
  27945. /**
  27946. * Creates a new entity from a serialization data object
  27947. * @param creationFunction defines a function used to instanciated the new entity
  27948. * @param source defines the source serialization data
  27949. * @param scene defines the hosting scene
  27950. * @param rootUrl defines the root url for resources
  27951. * @returns a new entity
  27952. */
  27953. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27954. /**
  27955. * Clones an object
  27956. * @param creationFunction defines the function used to instanciate the new object
  27957. * @param source defines the source object
  27958. * @returns the cloned object
  27959. */
  27960. static Clone<T>(creationFunction: () => T, source: T): T;
  27961. /**
  27962. * Instanciates a new object based on a source one (some data will be shared between both object)
  27963. * @param creationFunction defines the function used to instanciate the new object
  27964. * @param source defines the source object
  27965. * @returns the new object
  27966. */
  27967. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27968. }
  27969. }
  27970. declare module BABYLON {
  27971. /**
  27972. * Class used to manipulate GUIDs
  27973. */
  27974. export class GUID {
  27975. /**
  27976. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27977. * Be aware Math.random() could cause collisions, but:
  27978. * "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"
  27979. * @returns a pseudo random id
  27980. */
  27981. static RandomId(): string;
  27982. }
  27983. }
  27984. declare module BABYLON {
  27985. /**
  27986. * Base class of all the textures in babylon.
  27987. * It groups all the common properties the materials, post process, lights... might need
  27988. * in order to make a correct use of the texture.
  27989. */
  27990. export class BaseTexture implements IAnimatable {
  27991. /**
  27992. * Default anisotropic filtering level for the application.
  27993. * It is set to 4 as a good tradeoff between perf and quality.
  27994. */
  27995. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27996. /**
  27997. * Gets or sets the unique id of the texture
  27998. */
  27999. uniqueId: number;
  28000. /**
  28001. * Define the name of the texture.
  28002. */
  28003. name: string;
  28004. /**
  28005. * Gets or sets an object used to store user defined information.
  28006. */
  28007. metadata: any;
  28008. /**
  28009. * For internal use only. Please do not use.
  28010. */
  28011. reservedDataStore: any;
  28012. private _hasAlpha;
  28013. /**
  28014. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28015. */
  28016. hasAlpha: boolean;
  28017. /**
  28018. * Defines if the alpha value should be determined via the rgb values.
  28019. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28020. */
  28021. getAlphaFromRGB: boolean;
  28022. /**
  28023. * Intensity or strength of the texture.
  28024. * It is commonly used by materials to fine tune the intensity of the texture
  28025. */
  28026. level: number;
  28027. /**
  28028. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28029. * This is part of the texture as textures usually maps to one uv set.
  28030. */
  28031. coordinatesIndex: number;
  28032. private _coordinatesMode;
  28033. /**
  28034. * How a texture is mapped.
  28035. *
  28036. * | Value | Type | Description |
  28037. * | ----- | ----------------------------------- | ----------- |
  28038. * | 0 | EXPLICIT_MODE | |
  28039. * | 1 | SPHERICAL_MODE | |
  28040. * | 2 | PLANAR_MODE | |
  28041. * | 3 | CUBIC_MODE | |
  28042. * | 4 | PROJECTION_MODE | |
  28043. * | 5 | SKYBOX_MODE | |
  28044. * | 6 | INVCUBIC_MODE | |
  28045. * | 7 | EQUIRECTANGULAR_MODE | |
  28046. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28047. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28048. */
  28049. coordinatesMode: number;
  28050. /**
  28051. * | Value | Type | Description |
  28052. * | ----- | ------------------ | ----------- |
  28053. * | 0 | CLAMP_ADDRESSMODE | |
  28054. * | 1 | WRAP_ADDRESSMODE | |
  28055. * | 2 | MIRROR_ADDRESSMODE | |
  28056. */
  28057. wrapU: number;
  28058. /**
  28059. * | Value | Type | Description |
  28060. * | ----- | ------------------ | ----------- |
  28061. * | 0 | CLAMP_ADDRESSMODE | |
  28062. * | 1 | WRAP_ADDRESSMODE | |
  28063. * | 2 | MIRROR_ADDRESSMODE | |
  28064. */
  28065. wrapV: number;
  28066. /**
  28067. * | Value | Type | Description |
  28068. * | ----- | ------------------ | ----------- |
  28069. * | 0 | CLAMP_ADDRESSMODE | |
  28070. * | 1 | WRAP_ADDRESSMODE | |
  28071. * | 2 | MIRROR_ADDRESSMODE | |
  28072. */
  28073. wrapR: number;
  28074. /**
  28075. * With compliant hardware and browser (supporting anisotropic filtering)
  28076. * this defines the level of anisotropic filtering in the texture.
  28077. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28078. */
  28079. anisotropicFilteringLevel: number;
  28080. /**
  28081. * Define if the texture is a cube texture or if false a 2d texture.
  28082. */
  28083. isCube: boolean;
  28084. /**
  28085. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28086. */
  28087. is3D: boolean;
  28088. /**
  28089. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  28090. */
  28091. is2DArray: boolean;
  28092. /**
  28093. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28094. * HDR texture are usually stored in linear space.
  28095. * This only impacts the PBR and Background materials
  28096. */
  28097. gammaSpace: boolean;
  28098. /**
  28099. * Gets or sets whether or not the texture contains RGBD data.
  28100. */
  28101. isRGBD: boolean;
  28102. /**
  28103. * Is Z inverted in the texture (useful in a cube texture).
  28104. */
  28105. invertZ: boolean;
  28106. /**
  28107. * Are mip maps generated for this texture or not.
  28108. */
  28109. readonly noMipmap: boolean;
  28110. /**
  28111. * @hidden
  28112. */
  28113. lodLevelInAlpha: boolean;
  28114. /**
  28115. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28116. */
  28117. lodGenerationOffset: number;
  28118. /**
  28119. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28120. */
  28121. lodGenerationScale: number;
  28122. /**
  28123. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28124. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28125. * average roughness values.
  28126. */
  28127. linearSpecularLOD: boolean;
  28128. /**
  28129. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28130. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28131. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28132. */
  28133. irradianceTexture: Nullable<BaseTexture>;
  28134. /**
  28135. * Define if the texture is a render target.
  28136. */
  28137. isRenderTarget: boolean;
  28138. /**
  28139. * Define the unique id of the texture in the scene.
  28140. */
  28141. readonly uid: string;
  28142. /**
  28143. * Return a string representation of the texture.
  28144. * @returns the texture as a string
  28145. */
  28146. toString(): string;
  28147. /**
  28148. * Get the class name of the texture.
  28149. * @returns "BaseTexture"
  28150. */
  28151. getClassName(): string;
  28152. /**
  28153. * Define the list of animation attached to the texture.
  28154. */
  28155. animations: Animation[];
  28156. /**
  28157. * An event triggered when the texture is disposed.
  28158. */
  28159. onDisposeObservable: Observable<BaseTexture>;
  28160. private _onDisposeObserver;
  28161. /**
  28162. * Callback triggered when the texture has been disposed.
  28163. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28164. */
  28165. onDispose: () => void;
  28166. /**
  28167. * Define the current state of the loading sequence when in delayed load mode.
  28168. */
  28169. delayLoadState: number;
  28170. private _scene;
  28171. /** @hidden */
  28172. _texture: Nullable<InternalTexture>;
  28173. private _uid;
  28174. /**
  28175. * Define if the texture is preventinga material to render or not.
  28176. * If not and the texture is not ready, the engine will use a default black texture instead.
  28177. */
  28178. readonly isBlocking: boolean;
  28179. /**
  28180. * Instantiates a new BaseTexture.
  28181. * Base class of all the textures in babylon.
  28182. * It groups all the common properties the materials, post process, lights... might need
  28183. * in order to make a correct use of the texture.
  28184. * @param scene Define the scene the texture blongs to
  28185. */
  28186. constructor(scene: Nullable<Scene>);
  28187. /**
  28188. * Get the scene the texture belongs to.
  28189. * @returns the scene or null if undefined
  28190. */
  28191. getScene(): Nullable<Scene>;
  28192. /**
  28193. * Get the texture transform matrix used to offset tile the texture for istance.
  28194. * @returns the transformation matrix
  28195. */
  28196. getTextureMatrix(): Matrix;
  28197. /**
  28198. * Get the texture reflection matrix used to rotate/transform the reflection.
  28199. * @returns the reflection matrix
  28200. */
  28201. getReflectionTextureMatrix(): Matrix;
  28202. /**
  28203. * Get the underlying lower level texture from Babylon.
  28204. * @returns the insternal texture
  28205. */
  28206. getInternalTexture(): Nullable<InternalTexture>;
  28207. /**
  28208. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28209. * @returns true if ready or not blocking
  28210. */
  28211. isReadyOrNotBlocking(): boolean;
  28212. /**
  28213. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28214. * @returns true if fully ready
  28215. */
  28216. isReady(): boolean;
  28217. private _cachedSize;
  28218. /**
  28219. * Get the size of the texture.
  28220. * @returns the texture size.
  28221. */
  28222. getSize(): ISize;
  28223. /**
  28224. * Get the base size of the texture.
  28225. * It can be different from the size if the texture has been resized for POT for instance
  28226. * @returns the base size
  28227. */
  28228. getBaseSize(): ISize;
  28229. /**
  28230. * Update the sampling mode of the texture.
  28231. * Default is Trilinear mode.
  28232. *
  28233. * | Value | Type | Description |
  28234. * | ----- | ------------------ | ----------- |
  28235. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28236. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28237. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28238. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28239. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28240. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28241. * | 7 | NEAREST_LINEAR | |
  28242. * | 8 | NEAREST_NEAREST | |
  28243. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28244. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28245. * | 11 | LINEAR_LINEAR | |
  28246. * | 12 | LINEAR_NEAREST | |
  28247. *
  28248. * > _mag_: magnification filter (close to the viewer)
  28249. * > _min_: minification filter (far from the viewer)
  28250. * > _mip_: filter used between mip map levels
  28251. *@param samplingMode Define the new sampling mode of the texture
  28252. */
  28253. updateSamplingMode(samplingMode: number): void;
  28254. /**
  28255. * Scales the texture if is `canRescale()`
  28256. * @param ratio the resize factor we want to use to rescale
  28257. */
  28258. scale(ratio: number): void;
  28259. /**
  28260. * Get if the texture can rescale.
  28261. */
  28262. readonly canRescale: boolean;
  28263. /** @hidden */
  28264. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28265. /** @hidden */
  28266. _rebuild(): void;
  28267. /**
  28268. * Triggers the load sequence in delayed load mode.
  28269. */
  28270. delayLoad(): void;
  28271. /**
  28272. * Clones the texture.
  28273. * @returns the cloned texture
  28274. */
  28275. clone(): Nullable<BaseTexture>;
  28276. /**
  28277. * Get the texture underlying type (INT, FLOAT...)
  28278. */
  28279. readonly textureType: number;
  28280. /**
  28281. * Get the texture underlying format (RGB, RGBA...)
  28282. */
  28283. readonly textureFormat: number;
  28284. /**
  28285. * Indicates that textures need to be re-calculated for all materials
  28286. */
  28287. protected _markAllSubMeshesAsTexturesDirty(): void;
  28288. /**
  28289. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28290. * This will returns an RGBA array buffer containing either in values (0-255) or
  28291. * float values (0-1) depending of the underlying buffer type.
  28292. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28293. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28294. * @param buffer defines a user defined buffer to fill with data (can be null)
  28295. * @returns The Array buffer containing the pixels data.
  28296. */
  28297. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28298. /**
  28299. * Release and destroy the underlying lower level texture aka internalTexture.
  28300. */
  28301. releaseInternalTexture(): void;
  28302. /** @hidden */
  28303. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28304. /** @hidden */
  28305. readonly _lodTextureMid: Nullable<BaseTexture>;
  28306. /** @hidden */
  28307. readonly _lodTextureLow: Nullable<BaseTexture>;
  28308. /**
  28309. * Dispose the texture and release its associated resources.
  28310. */
  28311. dispose(): void;
  28312. /**
  28313. * Serialize the texture into a JSON representation that can be parsed later on.
  28314. * @returns the JSON representation of the texture
  28315. */
  28316. serialize(): any;
  28317. /**
  28318. * Helper function to be called back once a list of texture contains only ready textures.
  28319. * @param textures Define the list of textures to wait for
  28320. * @param callback Define the callback triggered once the entire list will be ready
  28321. */
  28322. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28323. }
  28324. }
  28325. declare module BABYLON {
  28326. /**
  28327. * Options to be used when creating an effect.
  28328. */
  28329. export interface IEffectCreationOptions {
  28330. /**
  28331. * Atrributes that will be used in the shader.
  28332. */
  28333. attributes: string[];
  28334. /**
  28335. * Uniform varible names that will be set in the shader.
  28336. */
  28337. uniformsNames: string[];
  28338. /**
  28339. * Uniform buffer varible names that will be set in the shader.
  28340. */
  28341. uniformBuffersNames: string[];
  28342. /**
  28343. * Sampler texture variable names that will be set in the shader.
  28344. */
  28345. samplers: string[];
  28346. /**
  28347. * Define statements that will be set in the shader.
  28348. */
  28349. defines: any;
  28350. /**
  28351. * Possible fallbacks for this effect to improve performance when needed.
  28352. */
  28353. fallbacks: Nullable<IEffectFallbacks>;
  28354. /**
  28355. * Callback that will be called when the shader is compiled.
  28356. */
  28357. onCompiled: Nullable<(effect: Effect) => void>;
  28358. /**
  28359. * Callback that will be called if an error occurs during shader compilation.
  28360. */
  28361. onError: Nullable<(effect: Effect, errors: string) => void>;
  28362. /**
  28363. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28364. */
  28365. indexParameters?: any;
  28366. /**
  28367. * Max number of lights that can be used in the shader.
  28368. */
  28369. maxSimultaneousLights?: number;
  28370. /**
  28371. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28372. */
  28373. transformFeedbackVaryings?: Nullable<string[]>;
  28374. }
  28375. /**
  28376. * Effect containing vertex and fragment shader that can be executed on an object.
  28377. */
  28378. export class Effect implements IDisposable {
  28379. /**
  28380. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28381. */
  28382. static ShadersRepository: string;
  28383. /**
  28384. * Name of the effect.
  28385. */
  28386. name: any;
  28387. /**
  28388. * String container all the define statements that should be set on the shader.
  28389. */
  28390. defines: string;
  28391. /**
  28392. * Callback that will be called when the shader is compiled.
  28393. */
  28394. onCompiled: Nullable<(effect: Effect) => void>;
  28395. /**
  28396. * Callback that will be called if an error occurs during shader compilation.
  28397. */
  28398. onError: Nullable<(effect: Effect, errors: string) => void>;
  28399. /**
  28400. * Callback that will be called when effect is bound.
  28401. */
  28402. onBind: Nullable<(effect: Effect) => void>;
  28403. /**
  28404. * Unique ID of the effect.
  28405. */
  28406. uniqueId: number;
  28407. /**
  28408. * Observable that will be called when the shader is compiled.
  28409. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28410. */
  28411. onCompileObservable: Observable<Effect>;
  28412. /**
  28413. * Observable that will be called if an error occurs during shader compilation.
  28414. */
  28415. onErrorObservable: Observable<Effect>;
  28416. /** @hidden */
  28417. _onBindObservable: Nullable<Observable<Effect>>;
  28418. /**
  28419. * Observable that will be called when effect is bound.
  28420. */
  28421. readonly onBindObservable: Observable<Effect>;
  28422. /** @hidden */
  28423. _bonesComputationForcedToCPU: boolean;
  28424. private static _uniqueIdSeed;
  28425. private _engine;
  28426. private _uniformBuffersNames;
  28427. private _uniformsNames;
  28428. private _samplerList;
  28429. private _samplers;
  28430. private _isReady;
  28431. private _compilationError;
  28432. private _allFallbacksProcessed;
  28433. private _attributesNames;
  28434. private _attributes;
  28435. private _uniforms;
  28436. /**
  28437. * Key for the effect.
  28438. * @hidden
  28439. */
  28440. _key: string;
  28441. private _indexParameters;
  28442. private _fallbacks;
  28443. private _vertexSourceCode;
  28444. private _fragmentSourceCode;
  28445. private _vertexSourceCodeOverride;
  28446. private _fragmentSourceCodeOverride;
  28447. private _transformFeedbackVaryings;
  28448. /**
  28449. * Compiled shader to webGL program.
  28450. * @hidden
  28451. */
  28452. _pipelineContext: Nullable<IPipelineContext>;
  28453. private _valueCache;
  28454. private static _baseCache;
  28455. /**
  28456. * Instantiates an effect.
  28457. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28458. * @param baseName Name of the effect.
  28459. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28460. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28461. * @param samplers List of sampler variables that will be passed to the shader.
  28462. * @param engine Engine to be used to render the effect
  28463. * @param defines Define statements to be added to the shader.
  28464. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28465. * @param onCompiled Callback that will be called when the shader is compiled.
  28466. * @param onError Callback that will be called if an error occurs during shader compilation.
  28467. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28468. */
  28469. 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);
  28470. private _useFinalCode;
  28471. /**
  28472. * Unique key for this effect
  28473. */
  28474. readonly key: string;
  28475. /**
  28476. * If the effect has been compiled and prepared.
  28477. * @returns if the effect is compiled and prepared.
  28478. */
  28479. isReady(): boolean;
  28480. private _isReadyInternal;
  28481. /**
  28482. * The engine the effect was initialized with.
  28483. * @returns the engine.
  28484. */
  28485. getEngine(): Engine;
  28486. /**
  28487. * The pipeline context for this effect
  28488. * @returns the associated pipeline context
  28489. */
  28490. getPipelineContext(): Nullable<IPipelineContext>;
  28491. /**
  28492. * The set of names of attribute variables for the shader.
  28493. * @returns An array of attribute names.
  28494. */
  28495. getAttributesNames(): string[];
  28496. /**
  28497. * Returns the attribute at the given index.
  28498. * @param index The index of the attribute.
  28499. * @returns The location of the attribute.
  28500. */
  28501. getAttributeLocation(index: number): number;
  28502. /**
  28503. * Returns the attribute based on the name of the variable.
  28504. * @param name of the attribute to look up.
  28505. * @returns the attribute location.
  28506. */
  28507. getAttributeLocationByName(name: string): number;
  28508. /**
  28509. * The number of attributes.
  28510. * @returns the numnber of attributes.
  28511. */
  28512. getAttributesCount(): number;
  28513. /**
  28514. * Gets the index of a uniform variable.
  28515. * @param uniformName of the uniform to look up.
  28516. * @returns the index.
  28517. */
  28518. getUniformIndex(uniformName: string): number;
  28519. /**
  28520. * Returns the attribute based on the name of the variable.
  28521. * @param uniformName of the uniform to look up.
  28522. * @returns the location of the uniform.
  28523. */
  28524. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28525. /**
  28526. * Returns an array of sampler variable names
  28527. * @returns The array of sampler variable neames.
  28528. */
  28529. getSamplers(): string[];
  28530. /**
  28531. * The error from the last compilation.
  28532. * @returns the error string.
  28533. */
  28534. getCompilationError(): string;
  28535. /**
  28536. * Gets a boolean indicating that all fallbacks were used during compilation
  28537. * @returns true if all fallbacks were used
  28538. */
  28539. allFallbacksProcessed(): boolean;
  28540. /**
  28541. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28542. * @param func The callback to be used.
  28543. */
  28544. executeWhenCompiled(func: (effect: Effect) => void): void;
  28545. private _checkIsReady;
  28546. private _loadShader;
  28547. /**
  28548. * Recompiles the webGL program
  28549. * @param vertexSourceCode The source code for the vertex shader.
  28550. * @param fragmentSourceCode The source code for the fragment shader.
  28551. * @param onCompiled Callback called when completed.
  28552. * @param onError Callback called on error.
  28553. * @hidden
  28554. */
  28555. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28556. /**
  28557. * Prepares the effect
  28558. * @hidden
  28559. */
  28560. _prepareEffect(): void;
  28561. private _processCompilationErrors;
  28562. /**
  28563. * Checks if the effect is supported. (Must be called after compilation)
  28564. */
  28565. readonly isSupported: boolean;
  28566. /**
  28567. * Binds a texture to the engine to be used as output of the shader.
  28568. * @param channel Name of the output variable.
  28569. * @param texture Texture to bind.
  28570. * @hidden
  28571. */
  28572. _bindTexture(channel: string, texture: InternalTexture): void;
  28573. /**
  28574. * Sets a texture on the engine to be used in the shader.
  28575. * @param channel Name of the sampler variable.
  28576. * @param texture Texture to set.
  28577. */
  28578. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28579. /**
  28580. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28581. * @param channel Name of the sampler variable.
  28582. * @param texture Texture to set.
  28583. */
  28584. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28585. /**
  28586. * Sets an array of textures on the engine to be used in the shader.
  28587. * @param channel Name of the variable.
  28588. * @param textures Textures to set.
  28589. */
  28590. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28591. /**
  28592. * 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)
  28593. * @param channel Name of the sampler variable.
  28594. * @param postProcess Post process to get the input texture from.
  28595. */
  28596. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28597. /**
  28598. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28599. * 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)
  28600. * @param channel Name of the sampler variable.
  28601. * @param postProcess Post process to get the output texture from.
  28602. */
  28603. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28604. /** @hidden */
  28605. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28606. /** @hidden */
  28607. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28608. /** @hidden */
  28609. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28610. /** @hidden */
  28611. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28612. /**
  28613. * Binds a buffer to a uniform.
  28614. * @param buffer Buffer to bind.
  28615. * @param name Name of the uniform variable to bind to.
  28616. */
  28617. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28618. /**
  28619. * Binds block to a uniform.
  28620. * @param blockName Name of the block to bind.
  28621. * @param index Index to bind.
  28622. */
  28623. bindUniformBlock(blockName: string, index: number): void;
  28624. /**
  28625. * Sets an interger value on a uniform variable.
  28626. * @param uniformName Name of the variable.
  28627. * @param value Value to be set.
  28628. * @returns this effect.
  28629. */
  28630. setInt(uniformName: string, value: number): Effect;
  28631. /**
  28632. * Sets an int array on a uniform variable.
  28633. * @param uniformName Name of the variable.
  28634. * @param array array to be set.
  28635. * @returns this effect.
  28636. */
  28637. setIntArray(uniformName: string, array: Int32Array): Effect;
  28638. /**
  28639. * 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)
  28640. * @param uniformName Name of the variable.
  28641. * @param array array to be set.
  28642. * @returns this effect.
  28643. */
  28644. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28645. /**
  28646. * 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)
  28647. * @param uniformName Name of the variable.
  28648. * @param array array to be set.
  28649. * @returns this effect.
  28650. */
  28651. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28652. /**
  28653. * 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)
  28654. * @param uniformName Name of the variable.
  28655. * @param array array to be set.
  28656. * @returns this effect.
  28657. */
  28658. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28659. /**
  28660. * Sets an float array on a uniform variable.
  28661. * @param uniformName Name of the variable.
  28662. * @param array array to be set.
  28663. * @returns this effect.
  28664. */
  28665. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28666. /**
  28667. * 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)
  28668. * @param uniformName Name of the variable.
  28669. * @param array array to be set.
  28670. * @returns this effect.
  28671. */
  28672. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28673. /**
  28674. * 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)
  28675. * @param uniformName Name of the variable.
  28676. * @param array array to be set.
  28677. * @returns this effect.
  28678. */
  28679. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28680. /**
  28681. * 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)
  28682. * @param uniformName Name of the variable.
  28683. * @param array array to be set.
  28684. * @returns this effect.
  28685. */
  28686. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28687. /**
  28688. * Sets an array on a uniform variable.
  28689. * @param uniformName Name of the variable.
  28690. * @param array array to be set.
  28691. * @returns this effect.
  28692. */
  28693. setArray(uniformName: string, array: number[]): Effect;
  28694. /**
  28695. * 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)
  28696. * @param uniformName Name of the variable.
  28697. * @param array array to be set.
  28698. * @returns this effect.
  28699. */
  28700. setArray2(uniformName: string, array: number[]): Effect;
  28701. /**
  28702. * 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)
  28703. * @param uniformName Name of the variable.
  28704. * @param array array to be set.
  28705. * @returns this effect.
  28706. */
  28707. setArray3(uniformName: string, array: number[]): Effect;
  28708. /**
  28709. * 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)
  28710. * @param uniformName Name of the variable.
  28711. * @param array array to be set.
  28712. * @returns this effect.
  28713. */
  28714. setArray4(uniformName: string, array: number[]): Effect;
  28715. /**
  28716. * Sets matrices on a uniform variable.
  28717. * @param uniformName Name of the variable.
  28718. * @param matrices matrices to be set.
  28719. * @returns this effect.
  28720. */
  28721. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28722. /**
  28723. * Sets matrix on a uniform variable.
  28724. * @param uniformName Name of the variable.
  28725. * @param matrix matrix to be set.
  28726. * @returns this effect.
  28727. */
  28728. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28729. /**
  28730. * 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)
  28731. * @param uniformName Name of the variable.
  28732. * @param matrix matrix to be set.
  28733. * @returns this effect.
  28734. */
  28735. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28736. /**
  28737. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28738. * @param uniformName Name of the variable.
  28739. * @param matrix matrix to be set.
  28740. * @returns this effect.
  28741. */
  28742. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28743. /**
  28744. * Sets a float on a uniform variable.
  28745. * @param uniformName Name of the variable.
  28746. * @param value value to be set.
  28747. * @returns this effect.
  28748. */
  28749. setFloat(uniformName: string, value: number): Effect;
  28750. /**
  28751. * Sets a boolean on a uniform variable.
  28752. * @param uniformName Name of the variable.
  28753. * @param bool value to be set.
  28754. * @returns this effect.
  28755. */
  28756. setBool(uniformName: string, bool: boolean): Effect;
  28757. /**
  28758. * Sets a Vector2 on a uniform variable.
  28759. * @param uniformName Name of the variable.
  28760. * @param vector2 vector2 to be set.
  28761. * @returns this effect.
  28762. */
  28763. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28764. /**
  28765. * Sets a float2 on a uniform variable.
  28766. * @param uniformName Name of the variable.
  28767. * @param x First float in float2.
  28768. * @param y Second float in float2.
  28769. * @returns this effect.
  28770. */
  28771. setFloat2(uniformName: string, x: number, y: number): Effect;
  28772. /**
  28773. * Sets a Vector3 on a uniform variable.
  28774. * @param uniformName Name of the variable.
  28775. * @param vector3 Value to be set.
  28776. * @returns this effect.
  28777. */
  28778. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28779. /**
  28780. * Sets a float3 on a uniform variable.
  28781. * @param uniformName Name of the variable.
  28782. * @param x First float in float3.
  28783. * @param y Second float in float3.
  28784. * @param z Third float in float3.
  28785. * @returns this effect.
  28786. */
  28787. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28788. /**
  28789. * Sets a Vector4 on a uniform variable.
  28790. * @param uniformName Name of the variable.
  28791. * @param vector4 Value to be set.
  28792. * @returns this effect.
  28793. */
  28794. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28795. /**
  28796. * Sets a float4 on a uniform variable.
  28797. * @param uniformName Name of the variable.
  28798. * @param x First float in float4.
  28799. * @param y Second float in float4.
  28800. * @param z Third float in float4.
  28801. * @param w Fourth float in float4.
  28802. * @returns this effect.
  28803. */
  28804. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28805. /**
  28806. * Sets a Color3 on a uniform variable.
  28807. * @param uniformName Name of the variable.
  28808. * @param color3 Value to be set.
  28809. * @returns this effect.
  28810. */
  28811. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28812. /**
  28813. * Sets a Color4 on a uniform variable.
  28814. * @param uniformName Name of the variable.
  28815. * @param color3 Value to be set.
  28816. * @param alpha Alpha value to be set.
  28817. * @returns this effect.
  28818. */
  28819. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28820. /**
  28821. * Sets a Color4 on a uniform variable
  28822. * @param uniformName defines the name of the variable
  28823. * @param color4 defines the value to be set
  28824. * @returns this effect.
  28825. */
  28826. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28827. /** Release all associated resources */
  28828. dispose(): void;
  28829. /**
  28830. * This function will add a new shader to the shader store
  28831. * @param name the name of the shader
  28832. * @param pixelShader optional pixel shader content
  28833. * @param vertexShader optional vertex shader content
  28834. */
  28835. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28836. /**
  28837. * Store of each shader (The can be looked up using effect.key)
  28838. */
  28839. static ShadersStore: {
  28840. [key: string]: string;
  28841. };
  28842. /**
  28843. * Store of each included file for a shader (The can be looked up using effect.key)
  28844. */
  28845. static IncludesShadersStore: {
  28846. [key: string]: string;
  28847. };
  28848. /**
  28849. * Resets the cache of effects.
  28850. */
  28851. static ResetCache(): void;
  28852. }
  28853. }
  28854. declare module BABYLON {
  28855. /**
  28856. * Interface used to describe the capabilities of the engine relatively to the current browser
  28857. */
  28858. export interface EngineCapabilities {
  28859. /** Maximum textures units per fragment shader */
  28860. maxTexturesImageUnits: number;
  28861. /** Maximum texture units per vertex shader */
  28862. maxVertexTextureImageUnits: number;
  28863. /** Maximum textures units in the entire pipeline */
  28864. maxCombinedTexturesImageUnits: number;
  28865. /** Maximum texture size */
  28866. maxTextureSize: number;
  28867. /** Maximum cube texture size */
  28868. maxCubemapTextureSize: number;
  28869. /** Maximum render texture size */
  28870. maxRenderTextureSize: number;
  28871. /** Maximum number of vertex attributes */
  28872. maxVertexAttribs: number;
  28873. /** Maximum number of varyings */
  28874. maxVaryingVectors: number;
  28875. /** Maximum number of uniforms per vertex shader */
  28876. maxVertexUniformVectors: number;
  28877. /** Maximum number of uniforms per fragment shader */
  28878. maxFragmentUniformVectors: number;
  28879. /** Defines if standard derivates (dx/dy) are supported */
  28880. standardDerivatives: boolean;
  28881. /** Defines if s3tc texture compression is supported */
  28882. s3tc?: WEBGL_compressed_texture_s3tc;
  28883. /** Defines if pvrtc texture compression is supported */
  28884. pvrtc: any;
  28885. /** Defines if etc1 texture compression is supported */
  28886. etc1: any;
  28887. /** Defines if etc2 texture compression is supported */
  28888. etc2: any;
  28889. /** Defines if astc texture compression is supported */
  28890. astc: any;
  28891. /** Defines if float textures are supported */
  28892. textureFloat: boolean;
  28893. /** Defines if vertex array objects are supported */
  28894. vertexArrayObject: boolean;
  28895. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28896. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  28897. /** Gets the maximum level of anisotropy supported */
  28898. maxAnisotropy: number;
  28899. /** Defines if instancing is supported */
  28900. instancedArrays: boolean;
  28901. /** Defines if 32 bits indices are supported */
  28902. uintIndices: boolean;
  28903. /** Defines if high precision shaders are supported */
  28904. highPrecisionShaderSupported: boolean;
  28905. /** Defines if depth reading in the fragment shader is supported */
  28906. fragmentDepthSupported: boolean;
  28907. /** Defines if float texture linear filtering is supported*/
  28908. textureFloatLinearFiltering: boolean;
  28909. /** Defines if rendering to float textures is supported */
  28910. textureFloatRender: boolean;
  28911. /** Defines if half float textures are supported*/
  28912. textureHalfFloat: boolean;
  28913. /** Defines if half float texture linear filtering is supported*/
  28914. textureHalfFloatLinearFiltering: boolean;
  28915. /** Defines if rendering to half float textures is supported */
  28916. textureHalfFloatRender: boolean;
  28917. /** Defines if textureLOD shader command is supported */
  28918. textureLOD: boolean;
  28919. /** Defines if draw buffers extension is supported */
  28920. drawBuffersExtension: boolean;
  28921. /** Defines if depth textures are supported */
  28922. depthTextureExtension: boolean;
  28923. /** Defines if float color buffer are supported */
  28924. colorBufferFloat: boolean;
  28925. /** Gets disjoint timer query extension (null if not supported) */
  28926. timerQuery?: EXT_disjoint_timer_query;
  28927. /** Defines if timestamp can be used with timer query */
  28928. canUseTimestampForTimerQuery: boolean;
  28929. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28930. multiview?: any;
  28931. /** Function used to let the system compiles shaders in background */
  28932. parallelShaderCompile?: {
  28933. COMPLETION_STATUS_KHR: number;
  28934. };
  28935. /** Max number of texture samples for MSAA */
  28936. maxMSAASamples: number;
  28937. /** Defines if the blend min max extension is supported */
  28938. blendMinMax: boolean;
  28939. }
  28940. }
  28941. declare module BABYLON {
  28942. /**
  28943. * @hidden
  28944. **/
  28945. export class DepthCullingState {
  28946. private _isDepthTestDirty;
  28947. private _isDepthMaskDirty;
  28948. private _isDepthFuncDirty;
  28949. private _isCullFaceDirty;
  28950. private _isCullDirty;
  28951. private _isZOffsetDirty;
  28952. private _isFrontFaceDirty;
  28953. private _depthTest;
  28954. private _depthMask;
  28955. private _depthFunc;
  28956. private _cull;
  28957. private _cullFace;
  28958. private _zOffset;
  28959. private _frontFace;
  28960. /**
  28961. * Initializes the state.
  28962. */
  28963. constructor();
  28964. readonly isDirty: boolean;
  28965. zOffset: number;
  28966. cullFace: Nullable<number>;
  28967. cull: Nullable<boolean>;
  28968. depthFunc: Nullable<number>;
  28969. depthMask: boolean;
  28970. depthTest: boolean;
  28971. frontFace: Nullable<number>;
  28972. reset(): void;
  28973. apply(gl: WebGLRenderingContext): void;
  28974. }
  28975. }
  28976. declare module BABYLON {
  28977. /**
  28978. * @hidden
  28979. **/
  28980. export class StencilState {
  28981. /** 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 */
  28982. static readonly ALWAYS: number;
  28983. /** Passed to stencilOperation to specify that stencil value must be kept */
  28984. static readonly KEEP: number;
  28985. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28986. static readonly REPLACE: number;
  28987. private _isStencilTestDirty;
  28988. private _isStencilMaskDirty;
  28989. private _isStencilFuncDirty;
  28990. private _isStencilOpDirty;
  28991. private _stencilTest;
  28992. private _stencilMask;
  28993. private _stencilFunc;
  28994. private _stencilFuncRef;
  28995. private _stencilFuncMask;
  28996. private _stencilOpStencilFail;
  28997. private _stencilOpDepthFail;
  28998. private _stencilOpStencilDepthPass;
  28999. readonly isDirty: boolean;
  29000. stencilFunc: number;
  29001. stencilFuncRef: number;
  29002. stencilFuncMask: number;
  29003. stencilOpStencilFail: number;
  29004. stencilOpDepthFail: number;
  29005. stencilOpStencilDepthPass: number;
  29006. stencilMask: number;
  29007. stencilTest: boolean;
  29008. constructor();
  29009. reset(): void;
  29010. apply(gl: WebGLRenderingContext): void;
  29011. }
  29012. }
  29013. declare module BABYLON {
  29014. /**
  29015. * @hidden
  29016. **/
  29017. export class AlphaState {
  29018. private _isAlphaBlendDirty;
  29019. private _isBlendFunctionParametersDirty;
  29020. private _isBlendEquationParametersDirty;
  29021. private _isBlendConstantsDirty;
  29022. private _alphaBlend;
  29023. private _blendFunctionParameters;
  29024. private _blendEquationParameters;
  29025. private _blendConstants;
  29026. /**
  29027. * Initializes the state.
  29028. */
  29029. constructor();
  29030. readonly isDirty: boolean;
  29031. alphaBlend: boolean;
  29032. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29033. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29034. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29035. reset(): void;
  29036. apply(gl: WebGLRenderingContext): void;
  29037. }
  29038. }
  29039. declare module BABYLON {
  29040. /** @hidden */
  29041. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29042. attributeProcessor(attribute: string): string;
  29043. varyingProcessor(varying: string, isFragment: boolean): string;
  29044. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29045. }
  29046. }
  29047. declare module BABYLON {
  29048. /**
  29049. * Interface for attribute information associated with buffer instanciation
  29050. */
  29051. export interface InstancingAttributeInfo {
  29052. /**
  29053. * Index/offset of the attribute in the vertex shader
  29054. */
  29055. index: number;
  29056. /**
  29057. * size of the attribute, 1, 2, 3 or 4
  29058. */
  29059. attributeSize: number;
  29060. /**
  29061. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29062. * default is FLOAT
  29063. */
  29064. attributeType: number;
  29065. /**
  29066. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29067. */
  29068. normalized: boolean;
  29069. /**
  29070. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29071. */
  29072. offset: number;
  29073. /**
  29074. * Name of the GLSL attribute, for debugging purpose only
  29075. */
  29076. attributeName: string;
  29077. }
  29078. }
  29079. declare module BABYLON {
  29080. interface ThinEngine {
  29081. /**
  29082. * Update a video texture
  29083. * @param texture defines the texture to update
  29084. * @param video defines the video element to use
  29085. * @param invertY defines if data must be stored with Y axis inverted
  29086. */
  29087. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29088. }
  29089. }
  29090. declare module BABYLON {
  29091. /**
  29092. * Settings for finer control over video usage
  29093. */
  29094. export interface VideoTextureSettings {
  29095. /**
  29096. * Applies `autoplay` to video, if specified
  29097. */
  29098. autoPlay?: boolean;
  29099. /**
  29100. * Applies `loop` to video, if specified
  29101. */
  29102. loop?: boolean;
  29103. /**
  29104. * Automatically updates internal texture from video at every frame in the render loop
  29105. */
  29106. autoUpdateTexture: boolean;
  29107. /**
  29108. * Image src displayed during the video loading or until the user interacts with the video.
  29109. */
  29110. poster?: string;
  29111. }
  29112. /**
  29113. * If you want to display a video in your scene, this is the special texture for that.
  29114. * This special texture works similar to other textures, with the exception of a few parameters.
  29115. * @see https://doc.babylonjs.com/how_to/video_texture
  29116. */
  29117. export class VideoTexture extends Texture {
  29118. /**
  29119. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29120. */
  29121. readonly autoUpdateTexture: boolean;
  29122. /**
  29123. * The video instance used by the texture internally
  29124. */
  29125. readonly video: HTMLVideoElement;
  29126. private _onUserActionRequestedObservable;
  29127. /**
  29128. * Event triggerd when a dom action is required by the user to play the video.
  29129. * This happens due to recent changes in browser policies preventing video to auto start.
  29130. */
  29131. readonly onUserActionRequestedObservable: Observable<Texture>;
  29132. private _generateMipMaps;
  29133. private _engine;
  29134. private _stillImageCaptured;
  29135. private _displayingPosterTexture;
  29136. private _settings;
  29137. private _createInternalTextureOnEvent;
  29138. private _frameId;
  29139. /**
  29140. * Creates a video texture.
  29141. * If you want to display a video in your scene, this is the special texture for that.
  29142. * This special texture works similar to other textures, with the exception of a few parameters.
  29143. * @see https://doc.babylonjs.com/how_to/video_texture
  29144. * @param name optional name, will detect from video source, if not defined
  29145. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29146. * @param scene is obviously the current scene.
  29147. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29148. * @param invertY is false by default but can be used to invert video on Y axis
  29149. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29150. * @param settings allows finer control over video usage
  29151. */
  29152. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29153. private _getName;
  29154. private _getVideo;
  29155. private _createInternalTexture;
  29156. private reset;
  29157. /**
  29158. * @hidden Internal method to initiate `update`.
  29159. */
  29160. _rebuild(): void;
  29161. /**
  29162. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29163. */
  29164. update(): void;
  29165. /**
  29166. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29167. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29168. */
  29169. updateTexture(isVisible: boolean): void;
  29170. protected _updateInternalTexture: () => void;
  29171. /**
  29172. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29173. * @param url New url.
  29174. */
  29175. updateURL(url: string): void;
  29176. /**
  29177. * Dispose the texture and release its associated resources.
  29178. */
  29179. dispose(): void;
  29180. /**
  29181. * Creates a video texture straight from a stream.
  29182. * @param scene Define the scene the texture should be created in
  29183. * @param stream Define the stream the texture should be created from
  29184. * @returns The created video texture as a promise
  29185. */
  29186. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29187. /**
  29188. * Creates a video texture straight from your WebCam video feed.
  29189. * @param scene Define the scene the texture should be created in
  29190. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29191. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29192. * @returns The created video texture as a promise
  29193. */
  29194. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29195. minWidth: number;
  29196. maxWidth: number;
  29197. minHeight: number;
  29198. maxHeight: number;
  29199. deviceId: string;
  29200. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29201. /**
  29202. * Creates a video texture straight from your WebCam video feed.
  29203. * @param scene Define the scene the texture should be created in
  29204. * @param onReady Define a callback to triggered once the texture will be ready
  29205. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29206. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29207. */
  29208. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29209. minWidth: number;
  29210. maxWidth: number;
  29211. minHeight: number;
  29212. maxHeight: number;
  29213. deviceId: string;
  29214. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29215. }
  29216. }
  29217. declare module BABYLON {
  29218. /**
  29219. * Defines the interface used by objects working like Scene
  29220. * @hidden
  29221. */
  29222. interface ISceneLike {
  29223. _addPendingData(data: any): void;
  29224. _removePendingData(data: any): void;
  29225. offlineProvider: IOfflineProvider;
  29226. }
  29227. /** Interface defining initialization parameters for Engine class */
  29228. export interface EngineOptions extends WebGLContextAttributes {
  29229. /**
  29230. * Defines if the engine should no exceed a specified device ratio
  29231. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29232. */
  29233. limitDeviceRatio?: number;
  29234. /**
  29235. * Defines if webvr should be enabled automatically
  29236. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29237. */
  29238. autoEnableWebVR?: boolean;
  29239. /**
  29240. * Defines if webgl2 should be turned off even if supported
  29241. * @see http://doc.babylonjs.com/features/webgl2
  29242. */
  29243. disableWebGL2Support?: boolean;
  29244. /**
  29245. * Defines if webaudio should be initialized as well
  29246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29247. */
  29248. audioEngine?: boolean;
  29249. /**
  29250. * Defines if animations should run using a deterministic lock step
  29251. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29252. */
  29253. deterministicLockstep?: boolean;
  29254. /** Defines the maximum steps to use with deterministic lock step mode */
  29255. lockstepMaxSteps?: number;
  29256. /**
  29257. * Defines that engine should ignore context lost events
  29258. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29259. */
  29260. doNotHandleContextLost?: boolean;
  29261. /**
  29262. * Defines that engine should ignore modifying touch action attribute and style
  29263. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29264. */
  29265. doNotHandleTouchAction?: boolean;
  29266. /**
  29267. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29268. */
  29269. useHighPrecisionFloats?: boolean;
  29270. }
  29271. /**
  29272. * The base engine class (root of all engines)
  29273. */
  29274. export class ThinEngine {
  29275. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29276. static ExceptionList: ({
  29277. key: string;
  29278. capture: string;
  29279. captureConstraint: number;
  29280. targets: string[];
  29281. } | {
  29282. key: string;
  29283. capture: null;
  29284. captureConstraint: null;
  29285. targets: string[];
  29286. })[];
  29287. /** @hidden */
  29288. static _TextureLoaders: IInternalTextureLoader[];
  29289. /**
  29290. * Returns the current npm package of the sdk
  29291. */
  29292. static readonly NpmPackage: string;
  29293. /**
  29294. * Returns the current version of the framework
  29295. */
  29296. static readonly Version: string;
  29297. /**
  29298. * Returns a string describing the current engine
  29299. */
  29300. readonly description: string;
  29301. /**
  29302. * Gets or sets the epsilon value used by collision engine
  29303. */
  29304. static CollisionsEpsilon: number;
  29305. /**
  29306. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29307. */
  29308. static ShadersRepository: string;
  29309. /** @hidden */
  29310. _shaderProcessor: IShaderProcessor;
  29311. /**
  29312. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29313. */
  29314. forcePOTTextures: boolean;
  29315. /**
  29316. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29317. */
  29318. isFullscreen: boolean;
  29319. /**
  29320. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29321. */
  29322. cullBackFaces: boolean;
  29323. /**
  29324. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29325. */
  29326. renderEvenInBackground: boolean;
  29327. /**
  29328. * Gets or sets a boolean indicating that cache can be kept between frames
  29329. */
  29330. preventCacheWipeBetweenFrames: boolean;
  29331. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29332. validateShaderPrograms: boolean;
  29333. /**
  29334. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29335. */
  29336. disableUniformBuffers: boolean;
  29337. /** @hidden */
  29338. _uniformBuffers: UniformBuffer[];
  29339. /**
  29340. * Gets a boolean indicating that the engine supports uniform buffers
  29341. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29342. */
  29343. readonly supportsUniformBuffers: boolean;
  29344. /** @hidden */
  29345. _gl: WebGLRenderingContext;
  29346. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29347. protected _windowIsBackground: boolean;
  29348. protected _webGLVersion: number;
  29349. protected _creationOptions: EngineOptions;
  29350. protected _highPrecisionShadersAllowed: boolean;
  29351. /** @hidden */
  29352. readonly _shouldUseHighPrecisionShader: boolean;
  29353. /**
  29354. * Gets a boolean indicating that only power of 2 textures are supported
  29355. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29356. */
  29357. readonly needPOTTextures: boolean;
  29358. /** @hidden */
  29359. _badOS: boolean;
  29360. /** @hidden */
  29361. _badDesktopOS: boolean;
  29362. private _hardwareScalingLevel;
  29363. /** @hidden */
  29364. _caps: EngineCapabilities;
  29365. private _isStencilEnable;
  29366. protected _colorWrite: boolean;
  29367. private _glVersion;
  29368. private _glRenderer;
  29369. private _glVendor;
  29370. /** @hidden */
  29371. _videoTextureSupported: boolean;
  29372. protected _renderingQueueLaunched: boolean;
  29373. protected _activeRenderLoops: (() => void)[];
  29374. /**
  29375. * Observable signaled when a context lost event is raised
  29376. */
  29377. onContextLostObservable: Observable<ThinEngine>;
  29378. /**
  29379. * Observable signaled when a context restored event is raised
  29380. */
  29381. onContextRestoredObservable: Observable<ThinEngine>;
  29382. private _onContextLost;
  29383. private _onContextRestored;
  29384. protected _contextWasLost: boolean;
  29385. /** @hidden */
  29386. _doNotHandleContextLost: boolean;
  29387. /**
  29388. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29389. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29390. */
  29391. doNotHandleContextLost: boolean;
  29392. /**
  29393. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29394. */
  29395. disableVertexArrayObjects: boolean;
  29396. /** @hidden */
  29397. protected _depthCullingState: DepthCullingState;
  29398. /** @hidden */
  29399. protected _stencilState: StencilState;
  29400. /** @hidden */
  29401. protected _alphaState: AlphaState;
  29402. /** @hidden */
  29403. _internalTexturesCache: InternalTexture[];
  29404. /** @hidden */
  29405. protected _activeChannel: number;
  29406. private _currentTextureChannel;
  29407. /** @hidden */
  29408. protected _boundTexturesCache: {
  29409. [key: string]: Nullable<InternalTexture>;
  29410. };
  29411. /** @hidden */
  29412. protected _currentEffect: Nullable<Effect>;
  29413. /** @hidden */
  29414. protected _currentProgram: Nullable<WebGLProgram>;
  29415. private _compiledEffects;
  29416. private _vertexAttribArraysEnabled;
  29417. /** @hidden */
  29418. protected _cachedViewport: Nullable<IViewportLike>;
  29419. private _cachedVertexArrayObject;
  29420. /** @hidden */
  29421. protected _cachedVertexBuffers: any;
  29422. /** @hidden */
  29423. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29424. /** @hidden */
  29425. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29426. /** @hidden */
  29427. _currentRenderTarget: Nullable<InternalTexture>;
  29428. private _uintIndicesCurrentlySet;
  29429. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29430. /** @hidden */
  29431. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29432. private _currentBufferPointers;
  29433. private _currentInstanceLocations;
  29434. private _currentInstanceBuffers;
  29435. private _textureUnits;
  29436. /** @hidden */
  29437. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  29438. /** @hidden */
  29439. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  29440. /** @hidden */
  29441. _boundRenderFunction: any;
  29442. private _vaoRecordInProgress;
  29443. private _mustWipeVertexAttributes;
  29444. private _emptyTexture;
  29445. private _emptyCubeTexture;
  29446. private _emptyTexture3D;
  29447. private _emptyTexture2DArray;
  29448. /** @hidden */
  29449. _frameHandler: number;
  29450. private _nextFreeTextureSlots;
  29451. private _maxSimultaneousTextures;
  29452. private _activeRequests;
  29453. protected _texturesSupported: string[];
  29454. /** @hidden */
  29455. _textureFormatInUse: Nullable<string>;
  29456. protected readonly _supportsHardwareTextureRescaling: boolean;
  29457. /**
  29458. * Gets the list of texture formats supported
  29459. */
  29460. readonly texturesSupported: Array<string>;
  29461. /**
  29462. * Gets the list of texture formats in use
  29463. */
  29464. readonly textureFormatInUse: Nullable<string>;
  29465. /**
  29466. * Gets the current viewport
  29467. */
  29468. readonly currentViewport: Nullable<IViewportLike>;
  29469. /**
  29470. * Gets the default empty texture
  29471. */
  29472. readonly emptyTexture: InternalTexture;
  29473. /**
  29474. * Gets the default empty 3D texture
  29475. */
  29476. readonly emptyTexture3D: InternalTexture;
  29477. /**
  29478. * Gets the default empty 2D array texture
  29479. */
  29480. readonly emptyTexture2DArray: InternalTexture;
  29481. /**
  29482. * Gets the default empty cube texture
  29483. */
  29484. readonly emptyCubeTexture: InternalTexture;
  29485. /**
  29486. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29487. */
  29488. readonly premultipliedAlpha: boolean;
  29489. /**
  29490. * Observable event triggered before each texture is initialized
  29491. */
  29492. onBeforeTextureInitObservable: Observable<Texture>;
  29493. /**
  29494. * Creates a new engine
  29495. * @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
  29496. * @param antialias defines enable antialiasing (default: false)
  29497. * @param options defines further options to be sent to the getContext() function
  29498. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29499. */
  29500. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29501. private _rebuildInternalTextures;
  29502. private _rebuildEffects;
  29503. /**
  29504. * Gets a boolean indicating if all created effects are ready
  29505. * @returns true if all effects are ready
  29506. */
  29507. areAllEffectsReady(): boolean;
  29508. protected _rebuildBuffers(): void;
  29509. private _initGLContext;
  29510. /**
  29511. * Gets version of the current webGL context
  29512. */
  29513. readonly webGLVersion: number;
  29514. /**
  29515. * Gets a string idenfifying the name of the class
  29516. * @returns "Engine" string
  29517. */
  29518. getClassName(): string;
  29519. /**
  29520. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29521. */
  29522. readonly isStencilEnable: boolean;
  29523. /** @hidden */
  29524. _prepareWorkingCanvas(): void;
  29525. /**
  29526. * Reset the texture cache to empty state
  29527. */
  29528. resetTextureCache(): void;
  29529. /**
  29530. * Gets an object containing information about the current webGL context
  29531. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29532. */
  29533. getGlInfo(): {
  29534. vendor: string;
  29535. renderer: string;
  29536. version: string;
  29537. };
  29538. /**
  29539. * Defines the hardware scaling level.
  29540. * By default the hardware scaling level is computed from the window device ratio.
  29541. * 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.
  29542. * @param level defines the level to use
  29543. */
  29544. setHardwareScalingLevel(level: number): void;
  29545. /**
  29546. * Gets the current hardware scaling level.
  29547. * By default the hardware scaling level is computed from the window device ratio.
  29548. * 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.
  29549. * @returns a number indicating the current hardware scaling level
  29550. */
  29551. getHardwareScalingLevel(): number;
  29552. /**
  29553. * Gets the list of loaded textures
  29554. * @returns an array containing all loaded textures
  29555. */
  29556. getLoadedTexturesCache(): InternalTexture[];
  29557. /**
  29558. * Gets the object containing all engine capabilities
  29559. * @returns the EngineCapabilities object
  29560. */
  29561. getCaps(): EngineCapabilities;
  29562. /**
  29563. * stop executing a render loop function and remove it from the execution array
  29564. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29565. */
  29566. stopRenderLoop(renderFunction?: () => void): void;
  29567. /** @hidden */
  29568. _renderLoop(): void;
  29569. /**
  29570. * Gets the HTML canvas attached with the current webGL context
  29571. * @returns a HTML canvas
  29572. */
  29573. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29574. /**
  29575. * Gets host window
  29576. * @returns the host window object
  29577. */
  29578. getHostWindow(): Nullable<Window>;
  29579. /**
  29580. * Gets the current render width
  29581. * @param useScreen defines if screen size must be used (or the current render target if any)
  29582. * @returns a number defining the current render width
  29583. */
  29584. getRenderWidth(useScreen?: boolean): number;
  29585. /**
  29586. * Gets the current render height
  29587. * @param useScreen defines if screen size must be used (or the current render target if any)
  29588. * @returns a number defining the current render height
  29589. */
  29590. getRenderHeight(useScreen?: boolean): number;
  29591. /**
  29592. * Can be used to override the current requestAnimationFrame requester.
  29593. * @hidden
  29594. */
  29595. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29596. /**
  29597. * Register and execute a render loop. The engine can have more than one render function
  29598. * @param renderFunction defines the function to continuously execute
  29599. */
  29600. runRenderLoop(renderFunction: () => void): void;
  29601. /**
  29602. * Clear the current render buffer or the current render target (if any is set up)
  29603. * @param color defines the color to use
  29604. * @param backBuffer defines if the back buffer must be cleared
  29605. * @param depth defines if the depth buffer must be cleared
  29606. * @param stencil defines if the stencil buffer must be cleared
  29607. */
  29608. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29609. private _viewportCached;
  29610. /** @hidden */
  29611. _viewport(x: number, y: number, width: number, height: number): void;
  29612. /**
  29613. * Set the WebGL's viewport
  29614. * @param viewport defines the viewport element to be used
  29615. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29616. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29617. */
  29618. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29619. /**
  29620. * Begin a new frame
  29621. */
  29622. beginFrame(): void;
  29623. /**
  29624. * Enf the current frame
  29625. */
  29626. endFrame(): void;
  29627. /**
  29628. * Resize the view according to the canvas' size
  29629. */
  29630. resize(): void;
  29631. /**
  29632. * Force a specific size of the canvas
  29633. * @param width defines the new canvas' width
  29634. * @param height defines the new canvas' height
  29635. */
  29636. setSize(width: number, height: number): void;
  29637. /**
  29638. * Binds the frame buffer to the specified texture.
  29639. * @param texture The texture to render to or null for the default canvas
  29640. * @param faceIndex The face of the texture to render to in case of cube texture
  29641. * @param requiredWidth The width of the target to render to
  29642. * @param requiredHeight The height of the target to render to
  29643. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29644. * @param depthStencilTexture The depth stencil texture to use to render
  29645. * @param lodLevel defines le lod level to bind to the frame buffer
  29646. */
  29647. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29648. /** @hidden */
  29649. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29650. /**
  29651. * Unbind the current render target texture from the webGL context
  29652. * @param texture defines the render target texture to unbind
  29653. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29654. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29655. */
  29656. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29657. /**
  29658. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29659. */
  29660. flushFramebuffer(): void;
  29661. /**
  29662. * Unbind the current render target and bind the default framebuffer
  29663. */
  29664. restoreDefaultFramebuffer(): void;
  29665. /** @hidden */
  29666. protected _resetVertexBufferBinding(): void;
  29667. /**
  29668. * Creates a vertex buffer
  29669. * @param data the data for the vertex buffer
  29670. * @returns the new WebGL static buffer
  29671. */
  29672. createVertexBuffer(data: DataArray): DataBuffer;
  29673. private _createVertexBuffer;
  29674. /**
  29675. * Creates a dynamic vertex buffer
  29676. * @param data the data for the dynamic vertex buffer
  29677. * @returns the new WebGL dynamic buffer
  29678. */
  29679. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29680. protected _resetIndexBufferBinding(): void;
  29681. /**
  29682. * Creates a new index buffer
  29683. * @param indices defines the content of the index buffer
  29684. * @param updatable defines if the index buffer must be updatable
  29685. * @returns a new webGL buffer
  29686. */
  29687. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29688. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29689. /**
  29690. * Bind a webGL buffer to the webGL context
  29691. * @param buffer defines the buffer to bind
  29692. */
  29693. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29694. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  29695. private bindBuffer;
  29696. /**
  29697. * update the bound buffer with the given data
  29698. * @param data defines the data to update
  29699. */
  29700. updateArrayBuffer(data: Float32Array): void;
  29701. private _vertexAttribPointer;
  29702. private _bindIndexBufferWithCache;
  29703. private _bindVertexBuffersAttributes;
  29704. /**
  29705. * Records a vertex array object
  29706. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29707. * @param vertexBuffers defines the list of vertex buffers to store
  29708. * @param indexBuffer defines the index buffer to store
  29709. * @param effect defines the effect to store
  29710. * @returns the new vertex array object
  29711. */
  29712. recordVertexArrayObject(vertexBuffers: {
  29713. [key: string]: VertexBuffer;
  29714. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29715. /**
  29716. * Bind a specific vertex array object
  29717. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29718. * @param vertexArrayObject defines the vertex array object to bind
  29719. * @param indexBuffer defines the index buffer to bind
  29720. */
  29721. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29722. /**
  29723. * Bind webGl buffers directly to the webGL context
  29724. * @param vertexBuffer defines the vertex buffer to bind
  29725. * @param indexBuffer defines the index buffer to bind
  29726. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29727. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29728. * @param effect defines the effect associated with the vertex buffer
  29729. */
  29730. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29731. private _unbindVertexArrayObject;
  29732. /**
  29733. * Bind a list of vertex buffers to the webGL context
  29734. * @param vertexBuffers defines the list of vertex buffers to bind
  29735. * @param indexBuffer defines the index buffer to bind
  29736. * @param effect defines the effect associated with the vertex buffers
  29737. */
  29738. bindBuffers(vertexBuffers: {
  29739. [key: string]: Nullable<VertexBuffer>;
  29740. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29741. /**
  29742. * Unbind all instance attributes
  29743. */
  29744. unbindInstanceAttributes(): void;
  29745. /**
  29746. * Release and free the memory of a vertex array object
  29747. * @param vao defines the vertex array object to delete
  29748. */
  29749. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29750. /** @hidden */
  29751. _releaseBuffer(buffer: DataBuffer): boolean;
  29752. protected _deleteBuffer(buffer: DataBuffer): void;
  29753. /**
  29754. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29755. * @param instancesBuffer defines the webGL buffer to update and bind
  29756. * @param data defines the data to store in the buffer
  29757. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29758. */
  29759. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29760. /**
  29761. * Apply all cached states (depth, culling, stencil and alpha)
  29762. */
  29763. applyStates(): void;
  29764. /**
  29765. * Send a draw order
  29766. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29767. * @param indexStart defines the starting index
  29768. * @param indexCount defines the number of index to draw
  29769. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29770. */
  29771. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29772. /**
  29773. * Draw a list of points
  29774. * @param verticesStart defines the index of first vertex to draw
  29775. * @param verticesCount defines the count of vertices to draw
  29776. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29777. */
  29778. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29779. /**
  29780. * Draw a list of unindexed primitives
  29781. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29782. * @param verticesStart defines the index of first vertex to draw
  29783. * @param verticesCount defines the count of vertices to draw
  29784. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29785. */
  29786. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29787. /**
  29788. * Draw a list of indexed primitives
  29789. * @param fillMode defines the primitive to use
  29790. * @param indexStart defines the starting index
  29791. * @param indexCount defines the number of index to draw
  29792. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29793. */
  29794. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29795. /**
  29796. * Draw a list of unindexed primitives
  29797. * @param fillMode defines the primitive to use
  29798. * @param verticesStart defines the index of first vertex to draw
  29799. * @param verticesCount defines the count of vertices to draw
  29800. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29801. */
  29802. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29803. private _drawMode;
  29804. /** @hidden */
  29805. protected _reportDrawCall(): void;
  29806. /** @hidden */
  29807. _releaseEffect(effect: Effect): void;
  29808. /** @hidden */
  29809. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29810. /**
  29811. * Create a new effect (used to store vertex/fragment shaders)
  29812. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29813. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  29814. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29815. * @param samplers defines an array of string used to represent textures
  29816. * @param defines defines the string containing the defines to use to compile the shaders
  29817. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29818. * @param onCompiled defines a function to call when the effect creation is successful
  29819. * @param onError defines a function to call when the effect creation has failed
  29820. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29821. * @returns the new Effect
  29822. */
  29823. 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;
  29824. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29825. private _compileShader;
  29826. private _compileRawShader;
  29827. /**
  29828. * Directly creates a webGL program
  29829. * @param pipelineContext defines the pipeline context to attach to
  29830. * @param vertexCode defines the vertex shader code to use
  29831. * @param fragmentCode defines the fragment shader code to use
  29832. * @param context defines the webGL context to use (if not set, the current one will be used)
  29833. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29834. * @returns the new webGL program
  29835. */
  29836. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29837. /**
  29838. * Creates a webGL program
  29839. * @param pipelineContext defines the pipeline context to attach to
  29840. * @param vertexCode defines the vertex shader code to use
  29841. * @param fragmentCode defines the fragment shader code to use
  29842. * @param defines defines the string containing the defines to use to compile the shaders
  29843. * @param context defines the webGL context to use (if not set, the current one will be used)
  29844. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29845. * @returns the new webGL program
  29846. */
  29847. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29848. /**
  29849. * Creates a new pipeline context
  29850. * @returns the new pipeline
  29851. */
  29852. createPipelineContext(): IPipelineContext;
  29853. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29854. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29855. /** @hidden */
  29856. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29857. /** @hidden */
  29858. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29859. /** @hidden */
  29860. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29861. /**
  29862. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29863. * @param pipelineContext defines the pipeline context to use
  29864. * @param uniformsNames defines the list of uniform names
  29865. * @returns an array of webGL uniform locations
  29866. */
  29867. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29868. /**
  29869. * Gets the lsit of active attributes for a given webGL program
  29870. * @param pipelineContext defines the pipeline context to use
  29871. * @param attributesNames defines the list of attribute names to get
  29872. * @returns an array of indices indicating the offset of each attribute
  29873. */
  29874. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29875. /**
  29876. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29877. * @param effect defines the effect to activate
  29878. */
  29879. enableEffect(effect: Nullable<Effect>): void;
  29880. /**
  29881. * Set the value of an uniform to a number (int)
  29882. * @param uniform defines the webGL uniform location where to store the value
  29883. * @param value defines the int number to store
  29884. */
  29885. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29886. /**
  29887. * Set the value of an uniform to an array of int32
  29888. * @param uniform defines the webGL uniform location where to store the value
  29889. * @param array defines the array of int32 to store
  29890. */
  29891. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29892. /**
  29893. * Set the value of an uniform to an array of int32 (stored as vec2)
  29894. * @param uniform defines the webGL uniform location where to store the value
  29895. * @param array defines the array of int32 to store
  29896. */
  29897. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29898. /**
  29899. * Set the value of an uniform to an array of int32 (stored as vec3)
  29900. * @param uniform defines the webGL uniform location where to store the value
  29901. * @param array defines the array of int32 to store
  29902. */
  29903. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29904. /**
  29905. * Set the value of an uniform to an array of int32 (stored as vec4)
  29906. * @param uniform defines the webGL uniform location where to store the value
  29907. * @param array defines the array of int32 to store
  29908. */
  29909. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29910. /**
  29911. * Set the value of an uniform to an array of number
  29912. * @param uniform defines the webGL uniform location where to store the value
  29913. * @param array defines the array of number to store
  29914. */
  29915. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29916. /**
  29917. * Set the value of an uniform to an array of number (stored as vec2)
  29918. * @param uniform defines the webGL uniform location where to store the value
  29919. * @param array defines the array of number to store
  29920. */
  29921. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29922. /**
  29923. * Set the value of an uniform to an array of number (stored as vec3)
  29924. * @param uniform defines the webGL uniform location where to store the value
  29925. * @param array defines the array of number to store
  29926. */
  29927. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29928. /**
  29929. * Set the value of an uniform to an array of number (stored as vec4)
  29930. * @param uniform defines the webGL uniform location where to store the value
  29931. * @param array defines the array of number to store
  29932. */
  29933. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29934. /**
  29935. * Set the value of an uniform to an array of float32 (stored as matrices)
  29936. * @param uniform defines the webGL uniform location where to store the value
  29937. * @param matrices defines the array of float32 to store
  29938. */
  29939. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29940. /**
  29941. * Set the value of an uniform to a matrix (3x3)
  29942. * @param uniform defines the webGL uniform location where to store the value
  29943. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29944. */
  29945. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29946. /**
  29947. * Set the value of an uniform to a matrix (2x2)
  29948. * @param uniform defines the webGL uniform location where to store the value
  29949. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29950. */
  29951. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29952. /**
  29953. * Set the value of an uniform to a number (float)
  29954. * @param uniform defines the webGL uniform location where to store the value
  29955. * @param value defines the float number to store
  29956. */
  29957. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29958. /**
  29959. * Set the value of an uniform to a vec2
  29960. * @param uniform defines the webGL uniform location where to store the value
  29961. * @param x defines the 1st component of the value
  29962. * @param y defines the 2nd component of the value
  29963. */
  29964. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29965. /**
  29966. * Set the value of an uniform to a vec3
  29967. * @param uniform defines the webGL uniform location where to store the value
  29968. * @param x defines the 1st component of the value
  29969. * @param y defines the 2nd component of the value
  29970. * @param z defines the 3rd component of the value
  29971. */
  29972. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29973. /**
  29974. * Set the value of an uniform to a vec4
  29975. * @param uniform defines the webGL uniform location where to store the value
  29976. * @param x defines the 1st component of the value
  29977. * @param y defines the 2nd component of the value
  29978. * @param z defines the 3rd component of the value
  29979. * @param w defines the 4th component of the value
  29980. */
  29981. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29982. /**
  29983. * Gets the depth culling state manager
  29984. */
  29985. readonly depthCullingState: DepthCullingState;
  29986. /**
  29987. * Gets the alpha state manager
  29988. */
  29989. readonly alphaState: AlphaState;
  29990. /**
  29991. * Gets the stencil state manager
  29992. */
  29993. readonly stencilState: StencilState;
  29994. /**
  29995. * Clears the list of texture accessible through engine.
  29996. * This can help preventing texture load conflict due to name collision.
  29997. */
  29998. clearInternalTexturesCache(): void;
  29999. /**
  30000. * Force the entire cache to be cleared
  30001. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30002. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30003. */
  30004. wipeCaches(bruteForce?: boolean): void;
  30005. /** @hidden */
  30006. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30007. min: number;
  30008. mag: number;
  30009. };
  30010. /** @hidden */
  30011. _createTexture(): WebGLTexture;
  30012. /**
  30013. * Usually called from Texture.ts.
  30014. * Passed information to create a WebGLTexture
  30015. * @param urlArg defines a value which contains one of the following:
  30016. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30017. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30018. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30019. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30020. * @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)
  30021. * @param scene needed for loading to the correct scene
  30022. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30023. * @param onLoad optional callback to be called upon successful completion
  30024. * @param onError optional callback to be called upon failure
  30025. * @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
  30026. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30027. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30028. * @param forcedExtension defines the extension to use to pick the right loader
  30029. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30030. * @param mimeType defines an optional mime type
  30031. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30032. */
  30033. 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;
  30034. /**
  30035. * @hidden
  30036. */
  30037. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30038. /**
  30039. * Creates a raw texture
  30040. * @param data defines the data to store in the texture
  30041. * @param width defines the width of the texture
  30042. * @param height defines the height of the texture
  30043. * @param format defines the format of the data
  30044. * @param generateMipMaps defines if the engine should generate the mip levels
  30045. * @param invertY defines if data must be stored with Y axis inverted
  30046. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30047. * @param compression defines the compression used (null by default)
  30048. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30049. * @returns the raw texture inside an InternalTexture
  30050. */
  30051. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30052. /**
  30053. * Creates a new raw cube texture
  30054. * @param data defines the array of data to use to create each face
  30055. * @param size defines the size of the textures
  30056. * @param format defines the format of the data
  30057. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30058. * @param generateMipMaps defines if the engine should generate the mip levels
  30059. * @param invertY defines if data must be stored with Y axis inverted
  30060. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30061. * @param compression defines the compression used (null by default)
  30062. * @returns the cube texture as an InternalTexture
  30063. */
  30064. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30065. /**
  30066. * Creates a new raw 3D texture
  30067. * @param data defines the data used to create the texture
  30068. * @param width defines the width of the texture
  30069. * @param height defines the height of the texture
  30070. * @param depth defines the depth of the texture
  30071. * @param format defines the format of the texture
  30072. * @param generateMipMaps defines if the engine must generate mip levels
  30073. * @param invertY defines if data must be stored with Y axis inverted
  30074. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30075. * @param compression defines the compressed used (can be null)
  30076. * @param textureType defines the compressed used (can be null)
  30077. * @returns a new raw 3D texture (stored in an InternalTexture)
  30078. */
  30079. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30080. /**
  30081. * Creates a new raw 2D array texture
  30082. * @param data defines the data used to create the texture
  30083. * @param width defines the width of the texture
  30084. * @param height defines the height of the texture
  30085. * @param depth defines the number of layers of the texture
  30086. * @param format defines the format of the texture
  30087. * @param generateMipMaps defines if the engine must generate mip levels
  30088. * @param invertY defines if data must be stored with Y axis inverted
  30089. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30090. * @param compression defines the compressed used (can be null)
  30091. * @param textureType defines the compressed used (can be null)
  30092. * @returns a new raw 2D array texture (stored in an InternalTexture)
  30093. */
  30094. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30095. private _unpackFlipYCached;
  30096. /**
  30097. * In case you are sharing the context with other applications, it might
  30098. * be interested to not cache the unpack flip y state to ensure a consistent
  30099. * value would be set.
  30100. */
  30101. enableUnpackFlipYCached: boolean;
  30102. /** @hidden */
  30103. _unpackFlipY(value: boolean): void;
  30104. /** @hidden */
  30105. _getUnpackAlignement(): number;
  30106. /**
  30107. * Update the sampling mode of a given texture
  30108. * @param samplingMode defines the required sampling mode
  30109. * @param texture defines the texture to update
  30110. */
  30111. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30112. /** @hidden */
  30113. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30114. width: number;
  30115. height: number;
  30116. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30117. /** @hidden */
  30118. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30119. /** @hidden */
  30120. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30121. /** @hidden */
  30122. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30123. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30124. private _prepareWebGLTexture;
  30125. /** @hidden */
  30126. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30127. /** @hidden */
  30128. _releaseFramebufferObjects(texture: InternalTexture): void;
  30129. /** @hidden */
  30130. _releaseTexture(texture: InternalTexture): void;
  30131. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30132. protected _setProgram(program: WebGLProgram): void;
  30133. protected _boundUniforms: {
  30134. [key: number]: WebGLUniformLocation;
  30135. };
  30136. /**
  30137. * Binds an effect to the webGL context
  30138. * @param effect defines the effect to bind
  30139. */
  30140. bindSamplers(effect: Effect): void;
  30141. private _activateCurrentTexture;
  30142. /** @hidden */
  30143. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30144. /** @hidden */
  30145. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30146. /**
  30147. * Unbind all textures from the webGL context
  30148. */
  30149. unbindAllTextures(): void;
  30150. /**
  30151. * Sets a texture to the according uniform.
  30152. * @param channel The texture channel
  30153. * @param uniform The uniform to set
  30154. * @param texture The texture to apply
  30155. */
  30156. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30157. private _bindSamplerUniformToChannel;
  30158. private _getTextureWrapMode;
  30159. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30160. /**
  30161. * Sets an array of texture to the webGL context
  30162. * @param channel defines the channel where the texture array must be set
  30163. * @param uniform defines the associated uniform location
  30164. * @param textures defines the array of textures to bind
  30165. */
  30166. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30167. /** @hidden */
  30168. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30169. private _setTextureParameterFloat;
  30170. private _setTextureParameterInteger;
  30171. /**
  30172. * Unbind all vertex attributes from the webGL context
  30173. */
  30174. unbindAllAttributes(): void;
  30175. /**
  30176. * 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
  30177. */
  30178. releaseEffects(): void;
  30179. /**
  30180. * Dispose and release all associated resources
  30181. */
  30182. dispose(): void;
  30183. /**
  30184. * Attach a new callback raised when context lost event is fired
  30185. * @param callback defines the callback to call
  30186. */
  30187. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30188. /**
  30189. * Attach a new callback raised when context restored event is fired
  30190. * @param callback defines the callback to call
  30191. */
  30192. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30193. /**
  30194. * Get the current error code of the webGL context
  30195. * @returns the error code
  30196. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30197. */
  30198. getError(): number;
  30199. private _canRenderToFloatFramebuffer;
  30200. private _canRenderToHalfFloatFramebuffer;
  30201. private _canRenderToFramebuffer;
  30202. /** @hidden */
  30203. _getWebGLTextureType(type: number): number;
  30204. /** @hidden */
  30205. _getInternalFormat(format: number): number;
  30206. /** @hidden */
  30207. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30208. /** @hidden */
  30209. _getRGBAMultiSampleBufferFormat(type: number): number;
  30210. /** @hidden */
  30211. _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;
  30212. /**
  30213. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30214. * @returns true if the engine can be created
  30215. * @ignorenaming
  30216. */
  30217. static isSupported(): boolean;
  30218. /**
  30219. * Find the next highest power of two.
  30220. * @param x Number to start search from.
  30221. * @return Next highest power of two.
  30222. */
  30223. static CeilingPOT(x: number): number;
  30224. /**
  30225. * Find the next lowest power of two.
  30226. * @param x Number to start search from.
  30227. * @return Next lowest power of two.
  30228. */
  30229. static FloorPOT(x: number): number;
  30230. /**
  30231. * Find the nearest power of two.
  30232. * @param x Number to start search from.
  30233. * @return Next nearest power of two.
  30234. */
  30235. static NearestPOT(x: number): number;
  30236. /**
  30237. * Get the closest exponent of two
  30238. * @param value defines the value to approximate
  30239. * @param max defines the maximum value to return
  30240. * @param mode defines how to define the closest value
  30241. * @returns closest exponent of two of the given value
  30242. */
  30243. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30244. /**
  30245. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30246. * @param func - the function to be called
  30247. * @param requester - the object that will request the next frame. Falls back to window.
  30248. * @returns frame number
  30249. */
  30250. static QueueNewFrame(func: () => void, requester?: any): number;
  30251. }
  30252. }
  30253. declare module BABYLON {
  30254. /**
  30255. * Class representing spherical harmonics coefficients to the 3rd degree
  30256. */
  30257. export class SphericalHarmonics {
  30258. /**
  30259. * Defines whether or not the harmonics have been prescaled for rendering.
  30260. */
  30261. preScaled: boolean;
  30262. /**
  30263. * The l0,0 coefficients of the spherical harmonics
  30264. */
  30265. l00: Vector3;
  30266. /**
  30267. * The l1,-1 coefficients of the spherical harmonics
  30268. */
  30269. l1_1: Vector3;
  30270. /**
  30271. * The l1,0 coefficients of the spherical harmonics
  30272. */
  30273. l10: Vector3;
  30274. /**
  30275. * The l1,1 coefficients of the spherical harmonics
  30276. */
  30277. l11: Vector3;
  30278. /**
  30279. * The l2,-2 coefficients of the spherical harmonics
  30280. */
  30281. l2_2: Vector3;
  30282. /**
  30283. * The l2,-1 coefficients of the spherical harmonics
  30284. */
  30285. l2_1: Vector3;
  30286. /**
  30287. * The l2,0 coefficients of the spherical harmonics
  30288. */
  30289. l20: Vector3;
  30290. /**
  30291. * The l2,1 coefficients of the spherical harmonics
  30292. */
  30293. l21: Vector3;
  30294. /**
  30295. * The l2,2 coefficients of the spherical harmonics
  30296. */
  30297. l22: Vector3;
  30298. /**
  30299. * Adds a light to the spherical harmonics
  30300. * @param direction the direction of the light
  30301. * @param color the color of the light
  30302. * @param deltaSolidAngle the delta solid angle of the light
  30303. */
  30304. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30305. /**
  30306. * Scales the spherical harmonics by the given amount
  30307. * @param scale the amount to scale
  30308. */
  30309. scaleInPlace(scale: number): void;
  30310. /**
  30311. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30312. *
  30313. * ```
  30314. * E_lm = A_l * L_lm
  30315. * ```
  30316. *
  30317. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30318. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30319. * the scaling factors are given in equation 9.
  30320. */
  30321. convertIncidentRadianceToIrradiance(): void;
  30322. /**
  30323. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30324. *
  30325. * ```
  30326. * L = (1/pi) * E * rho
  30327. * ```
  30328. *
  30329. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30330. */
  30331. convertIrradianceToLambertianRadiance(): void;
  30332. /**
  30333. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30334. * required operations at run time.
  30335. *
  30336. * This is simply done by scaling back the SH with Ylm constants parameter.
  30337. * The trigonometric part being applied by the shader at run time.
  30338. */
  30339. preScaleForRendering(): void;
  30340. /**
  30341. * Constructs a spherical harmonics from an array.
  30342. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30343. * @returns the spherical harmonics
  30344. */
  30345. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30346. /**
  30347. * Gets the spherical harmonics from polynomial
  30348. * @param polynomial the spherical polynomial
  30349. * @returns the spherical harmonics
  30350. */
  30351. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30352. }
  30353. /**
  30354. * Class representing spherical polynomial coefficients to the 3rd degree
  30355. */
  30356. export class SphericalPolynomial {
  30357. private _harmonics;
  30358. /**
  30359. * The spherical harmonics used to create the polynomials.
  30360. */
  30361. readonly preScaledHarmonics: SphericalHarmonics;
  30362. /**
  30363. * The x coefficients of the spherical polynomial
  30364. */
  30365. x: Vector3;
  30366. /**
  30367. * The y coefficients of the spherical polynomial
  30368. */
  30369. y: Vector3;
  30370. /**
  30371. * The z coefficients of the spherical polynomial
  30372. */
  30373. z: Vector3;
  30374. /**
  30375. * The xx coefficients of the spherical polynomial
  30376. */
  30377. xx: Vector3;
  30378. /**
  30379. * The yy coefficients of the spherical polynomial
  30380. */
  30381. yy: Vector3;
  30382. /**
  30383. * The zz coefficients of the spherical polynomial
  30384. */
  30385. zz: Vector3;
  30386. /**
  30387. * The xy coefficients of the spherical polynomial
  30388. */
  30389. xy: Vector3;
  30390. /**
  30391. * The yz coefficients of the spherical polynomial
  30392. */
  30393. yz: Vector3;
  30394. /**
  30395. * The zx coefficients of the spherical polynomial
  30396. */
  30397. zx: Vector3;
  30398. /**
  30399. * Adds an ambient color to the spherical polynomial
  30400. * @param color the color to add
  30401. */
  30402. addAmbient(color: Color3): void;
  30403. /**
  30404. * Scales the spherical polynomial by the given amount
  30405. * @param scale the amount to scale
  30406. */
  30407. scaleInPlace(scale: number): void;
  30408. /**
  30409. * Gets the spherical polynomial from harmonics
  30410. * @param harmonics the spherical harmonics
  30411. * @returns the spherical polynomial
  30412. */
  30413. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30414. /**
  30415. * Constructs a spherical polynomial from an array.
  30416. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30417. * @returns the spherical polynomial
  30418. */
  30419. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30420. }
  30421. }
  30422. declare module BABYLON {
  30423. /**
  30424. * Defines the source of the internal texture
  30425. */
  30426. export enum InternalTextureSource {
  30427. /**
  30428. * The source of the texture data is unknown
  30429. */
  30430. Unknown = 0,
  30431. /**
  30432. * Texture data comes from an URL
  30433. */
  30434. Url = 1,
  30435. /**
  30436. * Texture data is only used for temporary storage
  30437. */
  30438. Temp = 2,
  30439. /**
  30440. * Texture data comes from raw data (ArrayBuffer)
  30441. */
  30442. Raw = 3,
  30443. /**
  30444. * Texture content is dynamic (video or dynamic texture)
  30445. */
  30446. Dynamic = 4,
  30447. /**
  30448. * Texture content is generated by rendering to it
  30449. */
  30450. RenderTarget = 5,
  30451. /**
  30452. * Texture content is part of a multi render target process
  30453. */
  30454. MultiRenderTarget = 6,
  30455. /**
  30456. * Texture data comes from a cube data file
  30457. */
  30458. Cube = 7,
  30459. /**
  30460. * Texture data comes from a raw cube data
  30461. */
  30462. CubeRaw = 8,
  30463. /**
  30464. * Texture data come from a prefiltered cube data file
  30465. */
  30466. CubePrefiltered = 9,
  30467. /**
  30468. * Texture content is raw 3D data
  30469. */
  30470. Raw3D = 10,
  30471. /**
  30472. * Texture content is raw 2D array data
  30473. */
  30474. Raw2DArray = 11,
  30475. /**
  30476. * Texture content is a depth texture
  30477. */
  30478. Depth = 12,
  30479. /**
  30480. * Texture data comes from a raw cube data encoded with RGBD
  30481. */
  30482. CubeRawRGBD = 13
  30483. }
  30484. /**
  30485. * Class used to store data associated with WebGL texture data for the engine
  30486. * This class should not be used directly
  30487. */
  30488. export class InternalTexture {
  30489. /** @hidden */
  30490. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30491. /**
  30492. * Defines if the texture is ready
  30493. */
  30494. isReady: boolean;
  30495. /**
  30496. * Defines if the texture is a cube texture
  30497. */
  30498. isCube: boolean;
  30499. /**
  30500. * Defines if the texture contains 3D data
  30501. */
  30502. is3D: boolean;
  30503. /**
  30504. * Defines if the texture contains 2D array data
  30505. */
  30506. is2DArray: boolean;
  30507. /**
  30508. * Defines if the texture contains multiview data
  30509. */
  30510. isMultiview: boolean;
  30511. /**
  30512. * Gets the URL used to load this texture
  30513. */
  30514. url: string;
  30515. /**
  30516. * Gets the sampling mode of the texture
  30517. */
  30518. samplingMode: number;
  30519. /**
  30520. * Gets a boolean indicating if the texture needs mipmaps generation
  30521. */
  30522. generateMipMaps: boolean;
  30523. /**
  30524. * Gets the number of samples used by the texture (WebGL2+ only)
  30525. */
  30526. samples: number;
  30527. /**
  30528. * Gets the type of the texture (int, float...)
  30529. */
  30530. type: number;
  30531. /**
  30532. * Gets the format of the texture (RGB, RGBA...)
  30533. */
  30534. format: number;
  30535. /**
  30536. * Observable called when the texture is loaded
  30537. */
  30538. onLoadedObservable: Observable<InternalTexture>;
  30539. /**
  30540. * Gets the width of the texture
  30541. */
  30542. width: number;
  30543. /**
  30544. * Gets the height of the texture
  30545. */
  30546. height: number;
  30547. /**
  30548. * Gets the depth of the texture
  30549. */
  30550. depth: number;
  30551. /**
  30552. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30553. */
  30554. baseWidth: number;
  30555. /**
  30556. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30557. */
  30558. baseHeight: number;
  30559. /**
  30560. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30561. */
  30562. baseDepth: number;
  30563. /**
  30564. * Gets a boolean indicating if the texture is inverted on Y axis
  30565. */
  30566. invertY: boolean;
  30567. /** @hidden */
  30568. _invertVScale: boolean;
  30569. /** @hidden */
  30570. _associatedChannel: number;
  30571. /** @hidden */
  30572. _source: InternalTextureSource;
  30573. /** @hidden */
  30574. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  30575. /** @hidden */
  30576. _bufferView: Nullable<ArrayBufferView>;
  30577. /** @hidden */
  30578. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30579. /** @hidden */
  30580. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30581. /** @hidden */
  30582. _size: number;
  30583. /** @hidden */
  30584. _extension: string;
  30585. /** @hidden */
  30586. _files: Nullable<string[]>;
  30587. /** @hidden */
  30588. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30589. /** @hidden */
  30590. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30591. /** @hidden */
  30592. _framebuffer: Nullable<WebGLFramebuffer>;
  30593. /** @hidden */
  30594. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30595. /** @hidden */
  30596. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30597. /** @hidden */
  30598. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30599. /** @hidden */
  30600. _attachments: Nullable<number[]>;
  30601. /** @hidden */
  30602. _cachedCoordinatesMode: Nullable<number>;
  30603. /** @hidden */
  30604. _cachedWrapU: Nullable<number>;
  30605. /** @hidden */
  30606. _cachedWrapV: Nullable<number>;
  30607. /** @hidden */
  30608. _cachedWrapR: Nullable<number>;
  30609. /** @hidden */
  30610. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30611. /** @hidden */
  30612. _isDisabled: boolean;
  30613. /** @hidden */
  30614. _compression: Nullable<string>;
  30615. /** @hidden */
  30616. _generateStencilBuffer: boolean;
  30617. /** @hidden */
  30618. _generateDepthBuffer: boolean;
  30619. /** @hidden */
  30620. _comparisonFunction: number;
  30621. /** @hidden */
  30622. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30623. /** @hidden */
  30624. _lodGenerationScale: number;
  30625. /** @hidden */
  30626. _lodGenerationOffset: number;
  30627. /** @hidden */
  30628. _colorTextureArray: Nullable<WebGLTexture>;
  30629. /** @hidden */
  30630. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30631. /** @hidden */
  30632. _lodTextureHigh: Nullable<BaseTexture>;
  30633. /** @hidden */
  30634. _lodTextureMid: Nullable<BaseTexture>;
  30635. /** @hidden */
  30636. _lodTextureLow: Nullable<BaseTexture>;
  30637. /** @hidden */
  30638. _isRGBD: boolean;
  30639. /** @hidden */
  30640. _linearSpecularLOD: boolean;
  30641. /** @hidden */
  30642. _irradianceTexture: Nullable<BaseTexture>;
  30643. /** @hidden */
  30644. _webGLTexture: Nullable<WebGLTexture>;
  30645. /** @hidden */
  30646. _references: number;
  30647. private _engine;
  30648. /**
  30649. * Gets the Engine the texture belongs to.
  30650. * @returns The babylon engine
  30651. */
  30652. getEngine(): ThinEngine;
  30653. /**
  30654. * Gets the data source type of the texture
  30655. */
  30656. readonly source: InternalTextureSource;
  30657. /**
  30658. * Creates a new InternalTexture
  30659. * @param engine defines the engine to use
  30660. * @param source defines the type of data that will be used
  30661. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30662. */
  30663. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  30664. /**
  30665. * Increments the number of references (ie. the number of Texture that point to it)
  30666. */
  30667. incrementReferences(): void;
  30668. /**
  30669. * Change the size of the texture (not the size of the content)
  30670. * @param width defines the new width
  30671. * @param height defines the new height
  30672. * @param depth defines the new depth (1 by default)
  30673. */
  30674. updateSize(width: int, height: int, depth?: int): void;
  30675. /** @hidden */
  30676. _rebuild(): void;
  30677. /** @hidden */
  30678. _swapAndDie(target: InternalTexture): void;
  30679. /**
  30680. * Dispose the current allocated resources
  30681. */
  30682. dispose(): void;
  30683. }
  30684. }
  30685. declare module BABYLON {
  30686. /**
  30687. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30689. */
  30690. export class Analyser {
  30691. /**
  30692. * Gets or sets the smoothing
  30693. * @ignorenaming
  30694. */
  30695. SMOOTHING: number;
  30696. /**
  30697. * Gets or sets the FFT table size
  30698. * @ignorenaming
  30699. */
  30700. FFT_SIZE: number;
  30701. /**
  30702. * Gets or sets the bar graph amplitude
  30703. * @ignorenaming
  30704. */
  30705. BARGRAPHAMPLITUDE: number;
  30706. /**
  30707. * Gets or sets the position of the debug canvas
  30708. * @ignorenaming
  30709. */
  30710. DEBUGCANVASPOS: {
  30711. x: number;
  30712. y: number;
  30713. };
  30714. /**
  30715. * Gets or sets the debug canvas size
  30716. * @ignorenaming
  30717. */
  30718. DEBUGCANVASSIZE: {
  30719. width: number;
  30720. height: number;
  30721. };
  30722. private _byteFreqs;
  30723. private _byteTime;
  30724. private _floatFreqs;
  30725. private _webAudioAnalyser;
  30726. private _debugCanvas;
  30727. private _debugCanvasContext;
  30728. private _scene;
  30729. private _registerFunc;
  30730. private _audioEngine;
  30731. /**
  30732. * Creates a new analyser
  30733. * @param scene defines hosting scene
  30734. */
  30735. constructor(scene: Scene);
  30736. /**
  30737. * Get the number of data values you will have to play with for the visualization
  30738. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30739. * @returns a number
  30740. */
  30741. getFrequencyBinCount(): number;
  30742. /**
  30743. * Gets the current frequency data as a byte array
  30744. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30745. * @returns a Uint8Array
  30746. */
  30747. getByteFrequencyData(): Uint8Array;
  30748. /**
  30749. * Gets the current waveform as a byte array
  30750. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30751. * @returns a Uint8Array
  30752. */
  30753. getByteTimeDomainData(): Uint8Array;
  30754. /**
  30755. * Gets the current frequency data as a float array
  30756. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30757. * @returns a Float32Array
  30758. */
  30759. getFloatFrequencyData(): Float32Array;
  30760. /**
  30761. * Renders the debug canvas
  30762. */
  30763. drawDebugCanvas(): void;
  30764. /**
  30765. * Stops rendering the debug canvas and removes it
  30766. */
  30767. stopDebugCanvas(): void;
  30768. /**
  30769. * Connects two audio nodes
  30770. * @param inputAudioNode defines first node to connect
  30771. * @param outputAudioNode defines second node to connect
  30772. */
  30773. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30774. /**
  30775. * Releases all associated resources
  30776. */
  30777. dispose(): void;
  30778. }
  30779. }
  30780. declare module BABYLON {
  30781. /**
  30782. * This represents an audio engine and it is responsible
  30783. * to play, synchronize and analyse sounds throughout the application.
  30784. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30785. */
  30786. export interface IAudioEngine extends IDisposable {
  30787. /**
  30788. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30789. */
  30790. readonly canUseWebAudio: boolean;
  30791. /**
  30792. * Gets the current AudioContext if available.
  30793. */
  30794. readonly audioContext: Nullable<AudioContext>;
  30795. /**
  30796. * The master gain node defines the global audio volume of your audio engine.
  30797. */
  30798. readonly masterGain: GainNode;
  30799. /**
  30800. * Gets whether or not mp3 are supported by your browser.
  30801. */
  30802. readonly isMP3supported: boolean;
  30803. /**
  30804. * Gets whether or not ogg are supported by your browser.
  30805. */
  30806. readonly isOGGsupported: boolean;
  30807. /**
  30808. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30809. * @ignoreNaming
  30810. */
  30811. WarnedWebAudioUnsupported: boolean;
  30812. /**
  30813. * Defines if the audio engine relies on a custom unlocked button.
  30814. * In this case, the embedded button will not be displayed.
  30815. */
  30816. useCustomUnlockedButton: boolean;
  30817. /**
  30818. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30819. */
  30820. readonly unlocked: boolean;
  30821. /**
  30822. * Event raised when audio has been unlocked on the browser.
  30823. */
  30824. onAudioUnlockedObservable: Observable<AudioEngine>;
  30825. /**
  30826. * Event raised when audio has been locked on the browser.
  30827. */
  30828. onAudioLockedObservable: Observable<AudioEngine>;
  30829. /**
  30830. * Flags the audio engine in Locked state.
  30831. * This happens due to new browser policies preventing audio to autoplay.
  30832. */
  30833. lock(): void;
  30834. /**
  30835. * Unlocks the audio engine once a user action has been done on the dom.
  30836. * This is helpful to resume play once browser policies have been satisfied.
  30837. */
  30838. unlock(): void;
  30839. }
  30840. /**
  30841. * This represents the default audio engine used in babylon.
  30842. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30843. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30844. */
  30845. export class AudioEngine implements IAudioEngine {
  30846. private _audioContext;
  30847. private _audioContextInitialized;
  30848. private _muteButton;
  30849. private _hostElement;
  30850. /**
  30851. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30852. */
  30853. canUseWebAudio: boolean;
  30854. /**
  30855. * The master gain node defines the global audio volume of your audio engine.
  30856. */
  30857. masterGain: GainNode;
  30858. /**
  30859. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30860. * @ignoreNaming
  30861. */
  30862. WarnedWebAudioUnsupported: boolean;
  30863. /**
  30864. * Gets whether or not mp3 are supported by your browser.
  30865. */
  30866. isMP3supported: boolean;
  30867. /**
  30868. * Gets whether or not ogg are supported by your browser.
  30869. */
  30870. isOGGsupported: boolean;
  30871. /**
  30872. * Gets whether audio has been unlocked on the device.
  30873. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30874. * a user interaction has happened.
  30875. */
  30876. unlocked: boolean;
  30877. /**
  30878. * Defines if the audio engine relies on a custom unlocked button.
  30879. * In this case, the embedded button will not be displayed.
  30880. */
  30881. useCustomUnlockedButton: boolean;
  30882. /**
  30883. * Event raised when audio has been unlocked on the browser.
  30884. */
  30885. onAudioUnlockedObservable: Observable<AudioEngine>;
  30886. /**
  30887. * Event raised when audio has been locked on the browser.
  30888. */
  30889. onAudioLockedObservable: Observable<AudioEngine>;
  30890. /**
  30891. * Gets the current AudioContext if available.
  30892. */
  30893. readonly audioContext: Nullable<AudioContext>;
  30894. private _connectedAnalyser;
  30895. /**
  30896. * Instantiates a new audio engine.
  30897. *
  30898. * There should be only one per page as some browsers restrict the number
  30899. * of audio contexts you can create.
  30900. * @param hostElement defines the host element where to display the mute icon if necessary
  30901. */
  30902. constructor(hostElement?: Nullable<HTMLElement>);
  30903. /**
  30904. * Flags the audio engine in Locked state.
  30905. * This happens due to new browser policies preventing audio to autoplay.
  30906. */
  30907. lock(): void;
  30908. /**
  30909. * Unlocks the audio engine once a user action has been done on the dom.
  30910. * This is helpful to resume play once browser policies have been satisfied.
  30911. */
  30912. unlock(): void;
  30913. private _resumeAudioContext;
  30914. private _initializeAudioContext;
  30915. private _tryToRun;
  30916. private _triggerRunningState;
  30917. private _triggerSuspendedState;
  30918. private _displayMuteButton;
  30919. private _moveButtonToTopLeft;
  30920. private _onResize;
  30921. private _hideMuteButton;
  30922. /**
  30923. * Destroy and release the resources associated with the audio ccontext.
  30924. */
  30925. dispose(): void;
  30926. /**
  30927. * Gets the global volume sets on the master gain.
  30928. * @returns the global volume if set or -1 otherwise
  30929. */
  30930. getGlobalVolume(): number;
  30931. /**
  30932. * Sets the global volume of your experience (sets on the master gain).
  30933. * @param newVolume Defines the new global volume of the application
  30934. */
  30935. setGlobalVolume(newVolume: number): void;
  30936. /**
  30937. * Connect the audio engine to an audio analyser allowing some amazing
  30938. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30939. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30940. * @param analyser The analyser to connect to the engine
  30941. */
  30942. connectToAnalyser(analyser: Analyser): void;
  30943. }
  30944. }
  30945. declare module BABYLON {
  30946. /**
  30947. * Interface used to present a loading screen while loading a scene
  30948. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30949. */
  30950. export interface ILoadingScreen {
  30951. /**
  30952. * Function called to display the loading screen
  30953. */
  30954. displayLoadingUI: () => void;
  30955. /**
  30956. * Function called to hide the loading screen
  30957. */
  30958. hideLoadingUI: () => void;
  30959. /**
  30960. * Gets or sets the color to use for the background
  30961. */
  30962. loadingUIBackgroundColor: string;
  30963. /**
  30964. * Gets or sets the text to display while loading
  30965. */
  30966. loadingUIText: string;
  30967. }
  30968. /**
  30969. * Class used for the default loading screen
  30970. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30971. */
  30972. export class DefaultLoadingScreen implements ILoadingScreen {
  30973. private _renderingCanvas;
  30974. private _loadingText;
  30975. private _loadingDivBackgroundColor;
  30976. private _loadingDiv;
  30977. private _loadingTextDiv;
  30978. /** Gets or sets the logo url to use for the default loading screen */
  30979. static DefaultLogoUrl: string;
  30980. /** Gets or sets the spinner url to use for the default loading screen */
  30981. static DefaultSpinnerUrl: string;
  30982. /**
  30983. * Creates a new default loading screen
  30984. * @param _renderingCanvas defines the canvas used to render the scene
  30985. * @param _loadingText defines the default text to display
  30986. * @param _loadingDivBackgroundColor defines the default background color
  30987. */
  30988. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30989. /**
  30990. * Function called to display the loading screen
  30991. */
  30992. displayLoadingUI(): void;
  30993. /**
  30994. * Function called to hide the loading screen
  30995. */
  30996. hideLoadingUI(): void;
  30997. /**
  30998. * Gets or sets the text to display while loading
  30999. */
  31000. loadingUIText: string;
  31001. /**
  31002. * Gets or sets the color to use for the background
  31003. */
  31004. loadingUIBackgroundColor: string;
  31005. private _resizeLoadingUI;
  31006. }
  31007. }
  31008. declare module BABYLON {
  31009. /**
  31010. * Interface for any object that can request an animation frame
  31011. */
  31012. export interface ICustomAnimationFrameRequester {
  31013. /**
  31014. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31015. */
  31016. renderFunction?: Function;
  31017. /**
  31018. * Called to request the next frame to render to
  31019. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31020. */
  31021. requestAnimationFrame: Function;
  31022. /**
  31023. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31024. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31025. */
  31026. requestID?: number;
  31027. }
  31028. }
  31029. declare module BABYLON {
  31030. /**
  31031. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31032. */
  31033. export class PerformanceMonitor {
  31034. private _enabled;
  31035. private _rollingFrameTime;
  31036. private _lastFrameTimeMs;
  31037. /**
  31038. * constructor
  31039. * @param frameSampleSize The number of samples required to saturate the sliding window
  31040. */
  31041. constructor(frameSampleSize?: number);
  31042. /**
  31043. * Samples current frame
  31044. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31045. */
  31046. sampleFrame(timeMs?: number): void;
  31047. /**
  31048. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31049. */
  31050. readonly averageFrameTime: number;
  31051. /**
  31052. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31053. */
  31054. readonly averageFrameTimeVariance: number;
  31055. /**
  31056. * Returns the frame time of the most recent frame
  31057. */
  31058. readonly instantaneousFrameTime: number;
  31059. /**
  31060. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31061. */
  31062. readonly averageFPS: number;
  31063. /**
  31064. * Returns the average framerate in frames per second using the most recent frame time
  31065. */
  31066. readonly instantaneousFPS: number;
  31067. /**
  31068. * Returns true if enough samples have been taken to completely fill the sliding window
  31069. */
  31070. readonly isSaturated: boolean;
  31071. /**
  31072. * Enables contributions to the sliding window sample set
  31073. */
  31074. enable(): void;
  31075. /**
  31076. * Disables contributions to the sliding window sample set
  31077. * Samples will not be interpolated over the disabled period
  31078. */
  31079. disable(): void;
  31080. /**
  31081. * Returns true if sampling is enabled
  31082. */
  31083. readonly isEnabled: boolean;
  31084. /**
  31085. * Resets performance monitor
  31086. */
  31087. reset(): void;
  31088. }
  31089. /**
  31090. * RollingAverage
  31091. *
  31092. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31093. */
  31094. export class RollingAverage {
  31095. /**
  31096. * Current average
  31097. */
  31098. average: number;
  31099. /**
  31100. * Current variance
  31101. */
  31102. variance: number;
  31103. protected _samples: Array<number>;
  31104. protected _sampleCount: number;
  31105. protected _pos: number;
  31106. protected _m2: number;
  31107. /**
  31108. * constructor
  31109. * @param length The number of samples required to saturate the sliding window
  31110. */
  31111. constructor(length: number);
  31112. /**
  31113. * Adds a sample to the sample set
  31114. * @param v The sample value
  31115. */
  31116. add(v: number): void;
  31117. /**
  31118. * Returns previously added values or null if outside of history or outside the sliding window domain
  31119. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31120. * @return Value previously recorded with add() or null if outside of range
  31121. */
  31122. history(i: number): number;
  31123. /**
  31124. * Returns true if enough samples have been taken to completely fill the sliding window
  31125. * @return true if sample-set saturated
  31126. */
  31127. isSaturated(): boolean;
  31128. /**
  31129. * Resets the rolling average (equivalent to 0 samples taken so far)
  31130. */
  31131. reset(): void;
  31132. /**
  31133. * Wraps a value around the sample range boundaries
  31134. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31135. * @return Wrapped position in sample range
  31136. */
  31137. protected _wrapPosition(i: number): number;
  31138. }
  31139. }
  31140. declare module BABYLON {
  31141. /**
  31142. * This class is used to track a performance counter which is number based.
  31143. * The user has access to many properties which give statistics of different nature.
  31144. *
  31145. * The implementer can track two kinds of Performance Counter: time and count.
  31146. * 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.
  31147. * 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.
  31148. */
  31149. export class PerfCounter {
  31150. /**
  31151. * Gets or sets a global boolean to turn on and off all the counters
  31152. */
  31153. static Enabled: boolean;
  31154. /**
  31155. * Returns the smallest value ever
  31156. */
  31157. readonly min: number;
  31158. /**
  31159. * Returns the biggest value ever
  31160. */
  31161. readonly max: number;
  31162. /**
  31163. * Returns the average value since the performance counter is running
  31164. */
  31165. readonly average: number;
  31166. /**
  31167. * Returns the average value of the last second the counter was monitored
  31168. */
  31169. readonly lastSecAverage: number;
  31170. /**
  31171. * Returns the current value
  31172. */
  31173. readonly current: number;
  31174. /**
  31175. * Gets the accumulated total
  31176. */
  31177. readonly total: number;
  31178. /**
  31179. * Gets the total value count
  31180. */
  31181. readonly count: number;
  31182. /**
  31183. * Creates a new counter
  31184. */
  31185. constructor();
  31186. /**
  31187. * Call this method to start monitoring a new frame.
  31188. * 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.
  31189. */
  31190. fetchNewFrame(): void;
  31191. /**
  31192. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31193. * @param newCount the count value to add to the monitored count
  31194. * @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.
  31195. */
  31196. addCount(newCount: number, fetchResult: boolean): void;
  31197. /**
  31198. * Start monitoring this performance counter
  31199. */
  31200. beginMonitoring(): void;
  31201. /**
  31202. * Compute the time lapsed since the previous beginMonitoring() call.
  31203. * @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
  31204. */
  31205. endMonitoring(newFrame?: boolean): void;
  31206. private _fetchResult;
  31207. private _startMonitoringTime;
  31208. private _min;
  31209. private _max;
  31210. private _average;
  31211. private _current;
  31212. private _totalValueCount;
  31213. private _totalAccumulated;
  31214. private _lastSecAverage;
  31215. private _lastSecAccumulated;
  31216. private _lastSecTime;
  31217. private _lastSecValueCount;
  31218. }
  31219. }
  31220. declare module BABYLON {
  31221. /**
  31222. * Defines the interface used by display changed events
  31223. */
  31224. export interface IDisplayChangedEventArgs {
  31225. /** Gets the vrDisplay object (if any) */
  31226. vrDisplay: Nullable<any>;
  31227. /** Gets a boolean indicating if webVR is supported */
  31228. vrSupported: boolean;
  31229. }
  31230. /**
  31231. * Defines the interface used by objects containing a viewport (like a camera)
  31232. */
  31233. interface IViewportOwnerLike {
  31234. /**
  31235. * Gets or sets the viewport
  31236. */
  31237. viewport: IViewportLike;
  31238. }
  31239. /**
  31240. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31241. */
  31242. export class Engine extends ThinEngine {
  31243. /** Defines that alpha blending is disabled */
  31244. static readonly ALPHA_DISABLE: number;
  31245. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31246. static readonly ALPHA_ADD: number;
  31247. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31248. static readonly ALPHA_COMBINE: number;
  31249. /** Defines that alpha blending to DEST - SRC * DEST */
  31250. static readonly ALPHA_SUBTRACT: number;
  31251. /** Defines that alpha blending to SRC * DEST */
  31252. static readonly ALPHA_MULTIPLY: number;
  31253. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31254. static readonly ALPHA_MAXIMIZED: number;
  31255. /** Defines that alpha blending to SRC + DEST */
  31256. static readonly ALPHA_ONEONE: number;
  31257. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31258. static readonly ALPHA_PREMULTIPLIED: number;
  31259. /**
  31260. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31261. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31262. */
  31263. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31264. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31265. static readonly ALPHA_INTERPOLATE: number;
  31266. /**
  31267. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31268. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31269. */
  31270. static readonly ALPHA_SCREENMODE: number;
  31271. /** Defines that the ressource is not delayed*/
  31272. static readonly DELAYLOADSTATE_NONE: number;
  31273. /** Defines that the ressource was successfully delay loaded */
  31274. static readonly DELAYLOADSTATE_LOADED: number;
  31275. /** Defines that the ressource is currently delay loading */
  31276. static readonly DELAYLOADSTATE_LOADING: number;
  31277. /** Defines that the ressource is delayed and has not started loading */
  31278. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31279. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31280. static readonly NEVER: number;
  31281. /** 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 */
  31282. static readonly ALWAYS: number;
  31283. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31284. static readonly LESS: number;
  31285. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31286. static readonly EQUAL: number;
  31287. /** 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 */
  31288. static readonly LEQUAL: number;
  31289. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31290. static readonly GREATER: number;
  31291. /** 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 */
  31292. static readonly GEQUAL: number;
  31293. /** 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 */
  31294. static readonly NOTEQUAL: number;
  31295. /** Passed to stencilOperation to specify that stencil value must be kept */
  31296. static readonly KEEP: number;
  31297. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31298. static readonly REPLACE: number;
  31299. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31300. static readonly INCR: number;
  31301. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31302. static readonly DECR: number;
  31303. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31304. static readonly INVERT: number;
  31305. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31306. static readonly INCR_WRAP: number;
  31307. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31308. static readonly DECR_WRAP: number;
  31309. /** Texture is not repeating outside of 0..1 UVs */
  31310. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31311. /** Texture is repeating outside of 0..1 UVs */
  31312. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31313. /** Texture is repeating and mirrored */
  31314. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31315. /** ALPHA */
  31316. static readonly TEXTUREFORMAT_ALPHA: number;
  31317. /** LUMINANCE */
  31318. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31319. /** LUMINANCE_ALPHA */
  31320. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31321. /** RGB */
  31322. static readonly TEXTUREFORMAT_RGB: number;
  31323. /** RGBA */
  31324. static readonly TEXTUREFORMAT_RGBA: number;
  31325. /** RED */
  31326. static readonly TEXTUREFORMAT_RED: number;
  31327. /** RED (2nd reference) */
  31328. static readonly TEXTUREFORMAT_R: number;
  31329. /** RG */
  31330. static readonly TEXTUREFORMAT_RG: number;
  31331. /** RED_INTEGER */
  31332. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31333. /** RED_INTEGER (2nd reference) */
  31334. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31335. /** RG_INTEGER */
  31336. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31337. /** RGB_INTEGER */
  31338. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31339. /** RGBA_INTEGER */
  31340. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31341. /** UNSIGNED_BYTE */
  31342. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31343. /** UNSIGNED_BYTE (2nd reference) */
  31344. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31345. /** FLOAT */
  31346. static readonly TEXTURETYPE_FLOAT: number;
  31347. /** HALF_FLOAT */
  31348. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31349. /** BYTE */
  31350. static readonly TEXTURETYPE_BYTE: number;
  31351. /** SHORT */
  31352. static readonly TEXTURETYPE_SHORT: number;
  31353. /** UNSIGNED_SHORT */
  31354. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31355. /** INT */
  31356. static readonly TEXTURETYPE_INT: number;
  31357. /** UNSIGNED_INT */
  31358. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31359. /** UNSIGNED_SHORT_4_4_4_4 */
  31360. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31361. /** UNSIGNED_SHORT_5_5_5_1 */
  31362. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31363. /** UNSIGNED_SHORT_5_6_5 */
  31364. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31365. /** UNSIGNED_INT_2_10_10_10_REV */
  31366. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31367. /** UNSIGNED_INT_24_8 */
  31368. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31369. /** UNSIGNED_INT_10F_11F_11F_REV */
  31370. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31371. /** UNSIGNED_INT_5_9_9_9_REV */
  31372. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31373. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31374. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31375. /** nearest is mag = nearest and min = nearest and mip = linear */
  31376. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31377. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31378. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31379. /** Trilinear is mag = linear and min = linear and mip = linear */
  31380. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31381. /** nearest is mag = nearest and min = nearest and mip = linear */
  31382. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31383. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31384. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31385. /** Trilinear is mag = linear and min = linear and mip = linear */
  31386. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31387. /** mag = nearest and min = nearest and mip = nearest */
  31388. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31389. /** mag = nearest and min = linear and mip = nearest */
  31390. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31391. /** mag = nearest and min = linear and mip = linear */
  31392. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31393. /** mag = nearest and min = linear and mip = none */
  31394. static readonly TEXTURE_NEAREST_LINEAR: number;
  31395. /** mag = nearest and min = nearest and mip = none */
  31396. static readonly TEXTURE_NEAREST_NEAREST: number;
  31397. /** mag = linear and min = nearest and mip = nearest */
  31398. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31399. /** mag = linear and min = nearest and mip = linear */
  31400. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31401. /** mag = linear and min = linear and mip = none */
  31402. static readonly TEXTURE_LINEAR_LINEAR: number;
  31403. /** mag = linear and min = nearest and mip = none */
  31404. static readonly TEXTURE_LINEAR_NEAREST: number;
  31405. /** Explicit coordinates mode */
  31406. static readonly TEXTURE_EXPLICIT_MODE: number;
  31407. /** Spherical coordinates mode */
  31408. static readonly TEXTURE_SPHERICAL_MODE: number;
  31409. /** Planar coordinates mode */
  31410. static readonly TEXTURE_PLANAR_MODE: number;
  31411. /** Cubic coordinates mode */
  31412. static readonly TEXTURE_CUBIC_MODE: number;
  31413. /** Projection coordinates mode */
  31414. static readonly TEXTURE_PROJECTION_MODE: number;
  31415. /** Skybox coordinates mode */
  31416. static readonly TEXTURE_SKYBOX_MODE: number;
  31417. /** Inverse Cubic coordinates mode */
  31418. static readonly TEXTURE_INVCUBIC_MODE: number;
  31419. /** Equirectangular coordinates mode */
  31420. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31421. /** Equirectangular Fixed coordinates mode */
  31422. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31423. /** Equirectangular Fixed Mirrored coordinates mode */
  31424. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31425. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31426. static readonly SCALEMODE_FLOOR: number;
  31427. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31428. static readonly SCALEMODE_NEAREST: number;
  31429. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31430. static readonly SCALEMODE_CEILING: number;
  31431. /**
  31432. * Returns the current npm package of the sdk
  31433. */
  31434. static readonly NpmPackage: string;
  31435. /**
  31436. * Returns the current version of the framework
  31437. */
  31438. static readonly Version: string;
  31439. /** Gets the list of created engines */
  31440. static readonly Instances: Engine[];
  31441. /**
  31442. * Gets the latest created engine
  31443. */
  31444. static readonly LastCreatedEngine: Nullable<Engine>;
  31445. /**
  31446. * Gets the latest created scene
  31447. */
  31448. static readonly LastCreatedScene: Nullable<Scene>;
  31449. /**
  31450. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31451. * @param flag defines which part of the materials must be marked as dirty
  31452. * @param predicate defines a predicate used to filter which materials should be affected
  31453. */
  31454. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31455. /**
  31456. * Method called to create the default loading screen.
  31457. * This can be overriden in your own app.
  31458. * @param canvas The rendering canvas element
  31459. * @returns The loading screen
  31460. */
  31461. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31462. /**
  31463. * Method called to create the default rescale post process on each engine.
  31464. */
  31465. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31466. /**
  31467. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31468. **/
  31469. enableOfflineSupport: boolean;
  31470. /**
  31471. * 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)
  31472. **/
  31473. disableManifestCheck: boolean;
  31474. /**
  31475. * Gets the list of created scenes
  31476. */
  31477. scenes: Scene[];
  31478. /**
  31479. * Event raised when a new scene is created
  31480. */
  31481. onNewSceneAddedObservable: Observable<Scene>;
  31482. /**
  31483. * Gets the list of created postprocesses
  31484. */
  31485. postProcesses: PostProcess[];
  31486. /**
  31487. * Gets a boolean indicating if the pointer is currently locked
  31488. */
  31489. isPointerLock: boolean;
  31490. /**
  31491. * Observable event triggered each time the rendering canvas is resized
  31492. */
  31493. onResizeObservable: Observable<Engine>;
  31494. /**
  31495. * Observable event triggered each time the canvas loses focus
  31496. */
  31497. onCanvasBlurObservable: Observable<Engine>;
  31498. /**
  31499. * Observable event triggered each time the canvas gains focus
  31500. */
  31501. onCanvasFocusObservable: Observable<Engine>;
  31502. /**
  31503. * Observable event triggered each time the canvas receives pointerout event
  31504. */
  31505. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31506. /**
  31507. * Observable raised when the engine begins a new frame
  31508. */
  31509. onBeginFrameObservable: Observable<Engine>;
  31510. /**
  31511. * If set, will be used to request the next animation frame for the render loop
  31512. */
  31513. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31514. /**
  31515. * Observable raised when the engine ends the current frame
  31516. */
  31517. onEndFrameObservable: Observable<Engine>;
  31518. /**
  31519. * Observable raised when the engine is about to compile a shader
  31520. */
  31521. onBeforeShaderCompilationObservable: Observable<Engine>;
  31522. /**
  31523. * Observable raised when the engine has jsut compiled a shader
  31524. */
  31525. onAfterShaderCompilationObservable: Observable<Engine>;
  31526. /**
  31527. * Gets the audio engine
  31528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31529. * @ignorenaming
  31530. */
  31531. static audioEngine: IAudioEngine;
  31532. /**
  31533. * Default AudioEngine factory responsible of creating the Audio Engine.
  31534. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31535. */
  31536. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31537. /**
  31538. * Default offline support factory responsible of creating a tool used to store data locally.
  31539. * By default, this will create a Database object if the workload has been embedded.
  31540. */
  31541. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31542. private _loadingScreen;
  31543. private _pointerLockRequested;
  31544. private _dummyFramebuffer;
  31545. private _rescalePostProcess;
  31546. /** @hidden */
  31547. protected _alphaMode: number;
  31548. /** @hidden */
  31549. protected _alphaEquation: number;
  31550. private _deterministicLockstep;
  31551. private _lockstepMaxSteps;
  31552. protected readonly _supportsHardwareTextureRescaling: boolean;
  31553. private _fps;
  31554. private _deltaTime;
  31555. /** @hidden */
  31556. _drawCalls: PerfCounter;
  31557. /**
  31558. * Turn this value on if you want to pause FPS computation when in background
  31559. */
  31560. disablePerformanceMonitorInBackground: boolean;
  31561. private _performanceMonitor;
  31562. /**
  31563. * Gets the performance monitor attached to this engine
  31564. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31565. */
  31566. readonly performanceMonitor: PerformanceMonitor;
  31567. private _onFocus;
  31568. private _onBlur;
  31569. private _onCanvasPointerOut;
  31570. private _onCanvasBlur;
  31571. private _onCanvasFocus;
  31572. private _onFullscreenChange;
  31573. private _onPointerLockChange;
  31574. /**
  31575. * Gets the HTML element used to attach event listeners
  31576. * @returns a HTML element
  31577. */
  31578. getInputElement(): Nullable<HTMLElement>;
  31579. /**
  31580. * Creates a new engine
  31581. * @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
  31582. * @param antialias defines enable antialiasing (default: false)
  31583. * @param options defines further options to be sent to the getContext() function
  31584. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31585. */
  31586. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31587. /**
  31588. * Gets current aspect ratio
  31589. * @param viewportOwner defines the camera to use to get the aspect ratio
  31590. * @param useScreen defines if screen size must be used (or the current render target if any)
  31591. * @returns a number defining the aspect ratio
  31592. */
  31593. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31594. /**
  31595. * Gets current screen aspect ratio
  31596. * @returns a number defining the aspect ratio
  31597. */
  31598. getScreenAspectRatio(): number;
  31599. /**
  31600. * Gets host document
  31601. * @returns the host document object
  31602. */
  31603. getHostDocument(): Document;
  31604. /**
  31605. * Gets the client rect of the HTML canvas attached with the current webGL context
  31606. * @returns a client rectanglee
  31607. */
  31608. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31609. /**
  31610. * Gets the client rect of the HTML element used for events
  31611. * @returns a client rectanglee
  31612. */
  31613. getInputElementClientRect(): Nullable<ClientRect>;
  31614. /**
  31615. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31616. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31617. * @returns true if engine is in deterministic lock step mode
  31618. */
  31619. isDeterministicLockStep(): boolean;
  31620. /**
  31621. * Gets the max steps when engine is running in deterministic lock step
  31622. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31623. * @returns the max steps
  31624. */
  31625. getLockstepMaxSteps(): number;
  31626. /**
  31627. * Force the mipmap generation for the given render target texture
  31628. * @param texture defines the render target texture to use
  31629. */
  31630. generateMipMapsForCubemap(texture: InternalTexture): void;
  31631. /** States */
  31632. /**
  31633. * Set various states to the webGL context
  31634. * @param culling defines backface culling state
  31635. * @param zOffset defines the value to apply to zOffset (0 by default)
  31636. * @param force defines if states must be applied even if cache is up to date
  31637. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31638. */
  31639. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31640. /**
  31641. * Set the z offset to apply to current rendering
  31642. * @param value defines the offset to apply
  31643. */
  31644. setZOffset(value: number): void;
  31645. /**
  31646. * Gets the current value of the zOffset
  31647. * @returns the current zOffset state
  31648. */
  31649. getZOffset(): number;
  31650. /**
  31651. * Enable or disable depth buffering
  31652. * @param enable defines the state to set
  31653. */
  31654. setDepthBuffer(enable: boolean): void;
  31655. /**
  31656. * Gets a boolean indicating if depth writing is enabled
  31657. * @returns the current depth writing state
  31658. */
  31659. getDepthWrite(): boolean;
  31660. /**
  31661. * Enable or disable depth writing
  31662. * @param enable defines the state to set
  31663. */
  31664. setDepthWrite(enable: boolean): void;
  31665. /**
  31666. * Enable or disable color writing
  31667. * @param enable defines the state to set
  31668. */
  31669. setColorWrite(enable: boolean): void;
  31670. /**
  31671. * Gets a boolean indicating if color writing is enabled
  31672. * @returns the current color writing state
  31673. */
  31674. getColorWrite(): boolean;
  31675. /**
  31676. * Sets alpha constants used by some alpha blending modes
  31677. * @param r defines the red component
  31678. * @param g defines the green component
  31679. * @param b defines the blue component
  31680. * @param a defines the alpha component
  31681. */
  31682. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31683. /**
  31684. * Sets the current alpha mode
  31685. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31686. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31687. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31688. */
  31689. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31690. /**
  31691. * Gets the current alpha mode
  31692. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31693. * @returns the current alpha mode
  31694. */
  31695. getAlphaMode(): number;
  31696. /**
  31697. * Sets the current alpha equation
  31698. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31699. */
  31700. setAlphaEquation(equation: number): void;
  31701. /**
  31702. * Gets the current alpha equation.
  31703. * @returns the current alpha equation
  31704. */
  31705. getAlphaEquation(): number;
  31706. /**
  31707. * Gets a boolean indicating if stencil buffer is enabled
  31708. * @returns the current stencil buffer state
  31709. */
  31710. getStencilBuffer(): boolean;
  31711. /**
  31712. * Enable or disable the stencil buffer
  31713. * @param enable defines if the stencil buffer must be enabled or disabled
  31714. */
  31715. setStencilBuffer(enable: boolean): void;
  31716. /**
  31717. * Gets the current stencil mask
  31718. * @returns a number defining the new stencil mask to use
  31719. */
  31720. getStencilMask(): number;
  31721. /**
  31722. * Sets the current stencil mask
  31723. * @param mask defines the new stencil mask to use
  31724. */
  31725. setStencilMask(mask: number): void;
  31726. /**
  31727. * Gets the current stencil function
  31728. * @returns a number defining the stencil function to use
  31729. */
  31730. getStencilFunction(): number;
  31731. /**
  31732. * Gets the current stencil reference value
  31733. * @returns a number defining the stencil reference value to use
  31734. */
  31735. getStencilFunctionReference(): number;
  31736. /**
  31737. * Gets the current stencil mask
  31738. * @returns a number defining the stencil mask to use
  31739. */
  31740. getStencilFunctionMask(): number;
  31741. /**
  31742. * Sets the current stencil function
  31743. * @param stencilFunc defines the new stencil function to use
  31744. */
  31745. setStencilFunction(stencilFunc: number): void;
  31746. /**
  31747. * Sets the current stencil reference
  31748. * @param reference defines the new stencil reference to use
  31749. */
  31750. setStencilFunctionReference(reference: number): void;
  31751. /**
  31752. * Sets the current stencil mask
  31753. * @param mask defines the new stencil mask to use
  31754. */
  31755. setStencilFunctionMask(mask: number): void;
  31756. /**
  31757. * Gets the current stencil operation when stencil fails
  31758. * @returns a number defining stencil operation to use when stencil fails
  31759. */
  31760. getStencilOperationFail(): number;
  31761. /**
  31762. * Gets the current stencil operation when depth fails
  31763. * @returns a number defining stencil operation to use when depth fails
  31764. */
  31765. getStencilOperationDepthFail(): number;
  31766. /**
  31767. * Gets the current stencil operation when stencil passes
  31768. * @returns a number defining stencil operation to use when stencil passes
  31769. */
  31770. getStencilOperationPass(): number;
  31771. /**
  31772. * Sets the stencil operation to use when stencil fails
  31773. * @param operation defines the stencil operation to use when stencil fails
  31774. */
  31775. setStencilOperationFail(operation: number): void;
  31776. /**
  31777. * Sets the stencil operation to use when depth fails
  31778. * @param operation defines the stencil operation to use when depth fails
  31779. */
  31780. setStencilOperationDepthFail(operation: number): void;
  31781. /**
  31782. * Sets the stencil operation to use when stencil passes
  31783. * @param operation defines the stencil operation to use when stencil passes
  31784. */
  31785. setStencilOperationPass(operation: number): void;
  31786. /**
  31787. * Sets a boolean indicating if the dithering state is enabled or disabled
  31788. * @param value defines the dithering state
  31789. */
  31790. setDitheringState(value: boolean): void;
  31791. /**
  31792. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31793. * @param value defines the rasterizer state
  31794. */
  31795. setRasterizerState(value: boolean): void;
  31796. /**
  31797. * Gets the current depth function
  31798. * @returns a number defining the depth function
  31799. */
  31800. getDepthFunction(): Nullable<number>;
  31801. /**
  31802. * Sets the current depth function
  31803. * @param depthFunc defines the function to use
  31804. */
  31805. setDepthFunction(depthFunc: number): void;
  31806. /**
  31807. * Sets the current depth function to GREATER
  31808. */
  31809. setDepthFunctionToGreater(): void;
  31810. /**
  31811. * Sets the current depth function to GEQUAL
  31812. */
  31813. setDepthFunctionToGreaterOrEqual(): void;
  31814. /**
  31815. * Sets the current depth function to LESS
  31816. */
  31817. setDepthFunctionToLess(): void;
  31818. /**
  31819. * Sets the current depth function to LEQUAL
  31820. */
  31821. setDepthFunctionToLessOrEqual(): void;
  31822. private _cachedStencilBuffer;
  31823. private _cachedStencilFunction;
  31824. private _cachedStencilMask;
  31825. private _cachedStencilOperationPass;
  31826. private _cachedStencilOperationFail;
  31827. private _cachedStencilOperationDepthFail;
  31828. private _cachedStencilReference;
  31829. /**
  31830. * Caches the the state of the stencil buffer
  31831. */
  31832. cacheStencilState(): void;
  31833. /**
  31834. * Restores the state of the stencil buffer
  31835. */
  31836. restoreStencilState(): void;
  31837. /**
  31838. * Directly set the WebGL Viewport
  31839. * @param x defines the x coordinate of the viewport (in screen space)
  31840. * @param y defines the y coordinate of the viewport (in screen space)
  31841. * @param width defines the width of the viewport (in screen space)
  31842. * @param height defines the height of the viewport (in screen space)
  31843. * @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
  31844. */
  31845. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31846. /**
  31847. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31848. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31849. * @param y defines the y-coordinate of the corner of the clear rectangle
  31850. * @param width defines the width of the clear rectangle
  31851. * @param height defines the height of the clear rectangle
  31852. * @param clearColor defines the clear color
  31853. */
  31854. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31855. /**
  31856. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31857. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31858. * @param y defines the y-coordinate of the corner of the clear rectangle
  31859. * @param width defines the width of the clear rectangle
  31860. * @param height defines the height of the clear rectangle
  31861. */
  31862. enableScissor(x: number, y: number, width: number, height: number): void;
  31863. /**
  31864. * Disable previously set scissor test rectangle
  31865. */
  31866. disableScissor(): void;
  31867. protected _reportDrawCall(): void;
  31868. /**
  31869. * Initializes a webVR display and starts listening to display change events
  31870. * The onVRDisplayChangedObservable will be notified upon these changes
  31871. * @returns The onVRDisplayChangedObservable
  31872. */
  31873. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31874. /** @hidden */
  31875. _prepareVRComponent(): void;
  31876. /** @hidden */
  31877. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31878. /** @hidden */
  31879. _submitVRFrame(): void;
  31880. /**
  31881. * Call this function to leave webVR mode
  31882. * Will do nothing if webVR is not supported or if there is no webVR device
  31883. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31884. */
  31885. disableVR(): void;
  31886. /**
  31887. * Gets a boolean indicating that the system is in VR mode and is presenting
  31888. * @returns true if VR mode is engaged
  31889. */
  31890. isVRPresenting(): boolean;
  31891. /** @hidden */
  31892. _requestVRFrame(): void;
  31893. /** @hidden */
  31894. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31895. /**
  31896. * Gets the source code of the vertex shader associated with a specific webGL program
  31897. * @param program defines the program to use
  31898. * @returns a string containing the source code of the vertex shader associated with the program
  31899. */
  31900. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31901. /**
  31902. * Gets the source code of the fragment shader associated with a specific webGL program
  31903. * @param program defines the program to use
  31904. * @returns a string containing the source code of the fragment shader associated with the program
  31905. */
  31906. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31907. /**
  31908. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31909. * @param x defines the x coordinate of the rectangle where pixels must be read
  31910. * @param y defines the y coordinate of the rectangle where pixels must be read
  31911. * @param width defines the width of the rectangle where pixels must be read
  31912. * @param height defines the height of the rectangle where pixels must be read
  31913. * @returns a Uint8Array containing RGBA colors
  31914. */
  31915. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31916. /**
  31917. * Sets a depth stencil texture from a render target to the according uniform.
  31918. * @param channel The texture channel
  31919. * @param uniform The uniform to set
  31920. * @param texture The render target texture containing the depth stencil texture to apply
  31921. */
  31922. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31923. /**
  31924. * Sets a texture to the webGL context from a postprocess
  31925. * @param channel defines the channel to use
  31926. * @param postProcess defines the source postprocess
  31927. */
  31928. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31929. /**
  31930. * Binds the output of the passed in post process to the texture channel specified
  31931. * @param channel The channel the texture should be bound to
  31932. * @param postProcess The post process which's output should be bound
  31933. */
  31934. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31935. /** @hidden */
  31936. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31937. protected _rebuildBuffers(): void;
  31938. /** @hidden */
  31939. _renderFrame(): void;
  31940. _renderLoop(): void;
  31941. /** @hidden */
  31942. _renderViews(): boolean;
  31943. /**
  31944. * Toggle full screen mode
  31945. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31946. */
  31947. switchFullscreen(requestPointerLock: boolean): void;
  31948. /**
  31949. * Enters full screen mode
  31950. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31951. */
  31952. enterFullscreen(requestPointerLock: boolean): void;
  31953. /**
  31954. * Exits full screen mode
  31955. */
  31956. exitFullscreen(): void;
  31957. /**
  31958. * Enters Pointerlock mode
  31959. */
  31960. enterPointerlock(): void;
  31961. /**
  31962. * Exits Pointerlock mode
  31963. */
  31964. exitPointerlock(): void;
  31965. /**
  31966. * Begin a new frame
  31967. */
  31968. beginFrame(): void;
  31969. /**
  31970. * Enf the current frame
  31971. */
  31972. endFrame(): void;
  31973. resize(): void;
  31974. /**
  31975. * Set the compressed texture format to use, based on the formats you have, and the formats
  31976. * supported by the hardware / browser.
  31977. *
  31978. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31979. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31980. * to API arguments needed to compressed textures. This puts the burden on the container
  31981. * generator to house the arcane code for determining these for current & future formats.
  31982. *
  31983. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31984. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31985. *
  31986. * Note: The result of this call is not taken into account when a texture is base64.
  31987. *
  31988. * @param formatsAvailable defines the list of those format families you have created
  31989. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31990. *
  31991. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31992. * @returns The extension selected.
  31993. */
  31994. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31995. /**
  31996. * Force a specific size of the canvas
  31997. * @param width defines the new canvas' width
  31998. * @param height defines the new canvas' height
  31999. */
  32000. setSize(width: number, height: number): void;
  32001. /**
  32002. * Updates a dynamic vertex buffer.
  32003. * @param vertexBuffer the vertex buffer to update
  32004. * @param data the data used to update the vertex buffer
  32005. * @param byteOffset the byte offset of the data
  32006. * @param byteLength the byte length of the data
  32007. */
  32008. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  32009. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32010. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32011. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32012. _releaseTexture(texture: InternalTexture): void;
  32013. /**
  32014. * @hidden
  32015. * Rescales a texture
  32016. * @param source input texutre
  32017. * @param destination destination texture
  32018. * @param scene scene to use to render the resize
  32019. * @param internalFormat format to use when resizing
  32020. * @param onComplete callback to be called when resize has completed
  32021. */
  32022. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32023. /**
  32024. * Gets the current framerate
  32025. * @returns a number representing the framerate
  32026. */
  32027. getFps(): number;
  32028. /**
  32029. * Gets the time spent between current and previous frame
  32030. * @returns a number representing the delta time in ms
  32031. */
  32032. getDeltaTime(): number;
  32033. private _measureFps;
  32034. /** @hidden */
  32035. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  32036. /**
  32037. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32038. * @param renderTarget The render target to set the frame buffer for
  32039. */
  32040. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32041. /**
  32042. * Update a dynamic index buffer
  32043. * @param indexBuffer defines the target index buffer
  32044. * @param indices defines the data to update
  32045. * @param offset defines the offset in the target index buffer where update should start
  32046. */
  32047. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32048. /**
  32049. * Updates the sample count of a render target texture
  32050. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32051. * @param texture defines the texture to update
  32052. * @param samples defines the sample count to set
  32053. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32054. */
  32055. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32056. /**
  32057. * Updates a depth texture Comparison Mode and Function.
  32058. * If the comparison Function is equal to 0, the mode will be set to none.
  32059. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32060. * @param texture The texture to set the comparison function for
  32061. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32062. */
  32063. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32064. /**
  32065. * Creates a webGL buffer to use with instanciation
  32066. * @param capacity defines the size of the buffer
  32067. * @returns the webGL buffer
  32068. */
  32069. createInstancesBuffer(capacity: number): DataBuffer;
  32070. /**
  32071. * Delete a webGL buffer used with instanciation
  32072. * @param buffer defines the webGL buffer to delete
  32073. */
  32074. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  32075. /** @hidden */
  32076. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32077. dispose(): void;
  32078. private _disableTouchAction;
  32079. /**
  32080. * Display the loading screen
  32081. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32082. */
  32083. displayLoadingUI(): void;
  32084. /**
  32085. * Hide the loading screen
  32086. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32087. */
  32088. hideLoadingUI(): void;
  32089. /**
  32090. * Gets the current loading screen object
  32091. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32092. */
  32093. /**
  32094. * Sets the current loading screen object
  32095. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32096. */
  32097. loadingScreen: ILoadingScreen;
  32098. /**
  32099. * Sets the current loading screen text
  32100. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32101. */
  32102. loadingUIText: string;
  32103. /**
  32104. * Sets the current loading screen background color
  32105. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32106. */
  32107. loadingUIBackgroundColor: string;
  32108. /** Pointerlock and fullscreen */
  32109. /**
  32110. * Ask the browser to promote the current element to pointerlock mode
  32111. * @param element defines the DOM element to promote
  32112. */
  32113. static _RequestPointerlock(element: HTMLElement): void;
  32114. /**
  32115. * Asks the browser to exit pointerlock mode
  32116. */
  32117. static _ExitPointerlock(): void;
  32118. /**
  32119. * Ask the browser to promote the current element to fullscreen rendering mode
  32120. * @param element defines the DOM element to promote
  32121. */
  32122. static _RequestFullscreen(element: HTMLElement): void;
  32123. /**
  32124. * Asks the browser to exit fullscreen mode
  32125. */
  32126. static _ExitFullscreen(): void;
  32127. }
  32128. }
  32129. declare module BABYLON {
  32130. /**
  32131. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32132. * during the life time of the application.
  32133. */
  32134. export class EngineStore {
  32135. /** Gets the list of created engines */
  32136. static Instances: Engine[];
  32137. /** @hidden */
  32138. static _LastCreatedScene: Nullable<Scene>;
  32139. /**
  32140. * Gets the latest created engine
  32141. */
  32142. static readonly LastCreatedEngine: Nullable<Engine>;
  32143. /**
  32144. * Gets the latest created scene
  32145. */
  32146. static readonly LastCreatedScene: Nullable<Scene>;
  32147. /**
  32148. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32149. * @ignorenaming
  32150. */
  32151. static UseFallbackTexture: boolean;
  32152. /**
  32153. * Texture content used if a texture cannot loaded
  32154. * @ignorenaming
  32155. */
  32156. static FallbackTexture: string;
  32157. }
  32158. }
  32159. declare module BABYLON {
  32160. /**
  32161. * Helper class that provides a small promise polyfill
  32162. */
  32163. export class PromisePolyfill {
  32164. /**
  32165. * Static function used to check if the polyfill is required
  32166. * If this is the case then the function will inject the polyfill to window.Promise
  32167. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32168. */
  32169. static Apply(force?: boolean): void;
  32170. }
  32171. }
  32172. declare module BABYLON {
  32173. /**
  32174. * Interface for screenshot methods with describe argument called `size` as object with options
  32175. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32176. */
  32177. export interface IScreenshotSize {
  32178. /**
  32179. * number in pixels for canvas height
  32180. */
  32181. height?: number;
  32182. /**
  32183. * multiplier allowing render at a higher or lower resolution
  32184. * If value is defined then height and width will be ignored and taken from camera
  32185. */
  32186. precision?: number;
  32187. /**
  32188. * number in pixels for canvas width
  32189. */
  32190. width?: number;
  32191. }
  32192. }
  32193. declare module BABYLON {
  32194. interface IColor4Like {
  32195. r: float;
  32196. g: float;
  32197. b: float;
  32198. a: float;
  32199. }
  32200. /**
  32201. * Class containing a set of static utilities functions
  32202. */
  32203. export class Tools {
  32204. /**
  32205. * Gets or sets the base URL to use to load assets
  32206. */
  32207. static BaseUrl: string;
  32208. /**
  32209. * Enable/Disable Custom HTTP Request Headers globally.
  32210. * default = false
  32211. * @see CustomRequestHeaders
  32212. */
  32213. static UseCustomRequestHeaders: boolean;
  32214. /**
  32215. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32216. * i.e. when loading files, where the server/service expects an Authorization header
  32217. */
  32218. static CustomRequestHeaders: {
  32219. [key: string]: string;
  32220. };
  32221. /**
  32222. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32223. */
  32224. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32225. /**
  32226. * Default behaviour for cors in the application.
  32227. * It can be a string if the expected behavior is identical in the entire app.
  32228. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32229. */
  32230. static CorsBehavior: string | ((url: string | string[]) => string);
  32231. /**
  32232. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32233. * @ignorenaming
  32234. */
  32235. static UseFallbackTexture: boolean;
  32236. /**
  32237. * Use this object to register external classes like custom textures or material
  32238. * to allow the laoders to instantiate them
  32239. */
  32240. static RegisteredExternalClasses: {
  32241. [key: string]: Object;
  32242. };
  32243. /**
  32244. * Texture content used if a texture cannot loaded
  32245. * @ignorenaming
  32246. */
  32247. static fallbackTexture: string;
  32248. /**
  32249. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32250. * @param u defines the coordinate on X axis
  32251. * @param v defines the coordinate on Y axis
  32252. * @param width defines the width of the source data
  32253. * @param height defines the height of the source data
  32254. * @param pixels defines the source byte array
  32255. * @param color defines the output color
  32256. */
  32257. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32258. /**
  32259. * Interpolates between a and b via alpha
  32260. * @param a The lower value (returned when alpha = 0)
  32261. * @param b The upper value (returned when alpha = 1)
  32262. * @param alpha The interpolation-factor
  32263. * @return The mixed value
  32264. */
  32265. static Mix(a: number, b: number, alpha: number): number;
  32266. /**
  32267. * Tries to instantiate a new object from a given class name
  32268. * @param className defines the class name to instantiate
  32269. * @returns the new object or null if the system was not able to do the instantiation
  32270. */
  32271. static Instantiate(className: string): any;
  32272. /**
  32273. * Provides a slice function that will work even on IE
  32274. * @param data defines the array to slice
  32275. * @param start defines the start of the data (optional)
  32276. * @param end defines the end of the data (optional)
  32277. * @returns the new sliced array
  32278. */
  32279. static Slice<T>(data: T, start?: number, end?: number): T;
  32280. /**
  32281. * Polyfill for setImmediate
  32282. * @param action defines the action to execute after the current execution block
  32283. */
  32284. static SetImmediate(action: () => void): void;
  32285. /**
  32286. * Function indicating if a number is an exponent of 2
  32287. * @param value defines the value to test
  32288. * @returns true if the value is an exponent of 2
  32289. */
  32290. static IsExponentOfTwo(value: number): boolean;
  32291. private static _tmpFloatArray;
  32292. /**
  32293. * Returns the nearest 32-bit single precision float representation of a Number
  32294. * @param value A Number. If the parameter is of a different type, it will get converted
  32295. * to a number or to NaN if it cannot be converted
  32296. * @returns number
  32297. */
  32298. static FloatRound(value: number): number;
  32299. /**
  32300. * Extracts the filename from a path
  32301. * @param path defines the path to use
  32302. * @returns the filename
  32303. */
  32304. static GetFilename(path: string): string;
  32305. /**
  32306. * Extracts the "folder" part of a path (everything before the filename).
  32307. * @param uri The URI to extract the info from
  32308. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32309. * @returns The "folder" part of the path
  32310. */
  32311. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32312. /**
  32313. * Extracts text content from a DOM element hierarchy
  32314. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32315. */
  32316. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32317. /**
  32318. * Convert an angle in radians to degrees
  32319. * @param angle defines the angle to convert
  32320. * @returns the angle in degrees
  32321. */
  32322. static ToDegrees(angle: number): number;
  32323. /**
  32324. * Convert an angle in degrees to radians
  32325. * @param angle defines the angle to convert
  32326. * @returns the angle in radians
  32327. */
  32328. static ToRadians(angle: number): number;
  32329. /**
  32330. * Returns an array if obj is not an array
  32331. * @param obj defines the object to evaluate as an array
  32332. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32333. * @returns either obj directly if obj is an array or a new array containing obj
  32334. */
  32335. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32336. /**
  32337. * Gets the pointer prefix to use
  32338. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32339. */
  32340. static GetPointerPrefix(): string;
  32341. /**
  32342. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32343. * @param url define the url we are trying
  32344. * @param element define the dom element where to configure the cors policy
  32345. */
  32346. static SetCorsBehavior(url: string | string[], element: {
  32347. crossOrigin: string | null;
  32348. }): void;
  32349. /**
  32350. * Removes unwanted characters from an url
  32351. * @param url defines the url to clean
  32352. * @returns the cleaned url
  32353. */
  32354. static CleanUrl(url: string): string;
  32355. /**
  32356. * Gets or sets a function used to pre-process url before using them to load assets
  32357. */
  32358. static PreprocessUrl: (url: string) => string;
  32359. /**
  32360. * Loads an image as an HTMLImageElement.
  32361. * @param input url string, ArrayBuffer, or Blob to load
  32362. * @param onLoad callback called when the image successfully loads
  32363. * @param onError callback called when the image fails to load
  32364. * @param offlineProvider offline provider for caching
  32365. * @param mimeType optional mime type
  32366. * @returns the HTMLImageElement of the loaded image
  32367. */
  32368. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32369. /**
  32370. * Loads a file from a url
  32371. * @param url url string, ArrayBuffer, or Blob to load
  32372. * @param onSuccess callback called when the file successfully loads
  32373. * @param onProgress callback called while file is loading (if the server supports this mode)
  32374. * @param offlineProvider defines the offline provider for caching
  32375. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32376. * @param onError callback called when the file fails to load
  32377. * @returns a file request object
  32378. */
  32379. 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;
  32380. /**
  32381. * Loads a file from a url
  32382. * @param url the file url to load
  32383. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32384. */
  32385. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32386. /**
  32387. * Load a script (identified by an url). When the url returns, the
  32388. * content of this file is added into a new script element, attached to the DOM (body element)
  32389. * @param scriptUrl defines the url of the script to laod
  32390. * @param onSuccess defines the callback called when the script is loaded
  32391. * @param onError defines the callback to call if an error occurs
  32392. * @param scriptId defines the id of the script element
  32393. */
  32394. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32395. /**
  32396. * Load an asynchronous script (identified by an url). When the url returns, the
  32397. * content of this file is added into a new script element, attached to the DOM (body element)
  32398. * @param scriptUrl defines the url of the script to laod
  32399. * @param scriptId defines the id of the script element
  32400. * @returns a promise request object
  32401. */
  32402. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32403. /**
  32404. * Loads a file from a blob
  32405. * @param fileToLoad defines the blob to use
  32406. * @param callback defines the callback to call when data is loaded
  32407. * @param progressCallback defines the callback to call during loading process
  32408. * @returns a file request object
  32409. */
  32410. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32411. /**
  32412. * Reads a file from a File object
  32413. * @param file defines the file to load
  32414. * @param onSuccess defines the callback to call when data is loaded
  32415. * @param onProgress defines the callback to call during loading process
  32416. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32417. * @param onError defines the callback to call when an error occurs
  32418. * @returns a file request object
  32419. */
  32420. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  32421. /**
  32422. * Creates a data url from a given string content
  32423. * @param content defines the content to convert
  32424. * @returns the new data url link
  32425. */
  32426. static FileAsURL(content: string): string;
  32427. /**
  32428. * Format the given number to a specific decimal format
  32429. * @param value defines the number to format
  32430. * @param decimals defines the number of decimals to use
  32431. * @returns the formatted string
  32432. */
  32433. static Format(value: number, decimals?: number): string;
  32434. /**
  32435. * Tries to copy an object by duplicating every property
  32436. * @param source defines the source object
  32437. * @param destination defines the target object
  32438. * @param doNotCopyList defines a list of properties to avoid
  32439. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32440. */
  32441. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32442. /**
  32443. * Gets a boolean indicating if the given object has no own property
  32444. * @param obj defines the object to test
  32445. * @returns true if object has no own property
  32446. */
  32447. static IsEmpty(obj: any): boolean;
  32448. /**
  32449. * Function used to register events at window level
  32450. * @param windowElement defines the Window object to use
  32451. * @param events defines the events to register
  32452. */
  32453. static RegisterTopRootEvents(windowElement: Window, events: {
  32454. name: string;
  32455. handler: Nullable<(e: FocusEvent) => any>;
  32456. }[]): void;
  32457. /**
  32458. * Function used to unregister events from window level
  32459. * @param windowElement defines the Window object to use
  32460. * @param events defines the events to unregister
  32461. */
  32462. static UnregisterTopRootEvents(windowElement: Window, events: {
  32463. name: string;
  32464. handler: Nullable<(e: FocusEvent) => any>;
  32465. }[]): void;
  32466. /**
  32467. * @ignore
  32468. */
  32469. static _ScreenshotCanvas: HTMLCanvasElement;
  32470. /**
  32471. * Dumps the current bound framebuffer
  32472. * @param width defines the rendering width
  32473. * @param height defines the rendering height
  32474. * @param engine defines the hosting engine
  32475. * @param successCallback defines the callback triggered once the data are available
  32476. * @param mimeType defines the mime type of the result
  32477. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32478. */
  32479. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32480. /**
  32481. * Converts the canvas data to blob.
  32482. * This acts as a polyfill for browsers not supporting the to blob function.
  32483. * @param canvas Defines the canvas to extract the data from
  32484. * @param successCallback Defines the callback triggered once the data are available
  32485. * @param mimeType Defines the mime type of the result
  32486. */
  32487. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32488. /**
  32489. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32490. * @param successCallback defines the callback triggered once the data are available
  32491. * @param mimeType defines the mime type of the result
  32492. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32493. */
  32494. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32495. /**
  32496. * Downloads a blob in the browser
  32497. * @param blob defines the blob to download
  32498. * @param fileName defines the name of the downloaded file
  32499. */
  32500. static Download(blob: Blob, fileName: string): void;
  32501. /**
  32502. * Captures a screenshot of the current rendering
  32503. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32504. * @param engine defines the rendering engine
  32505. * @param camera defines the source camera
  32506. * @param size This parameter can be set to a single number or to an object with the
  32507. * following (optional) properties: precision, width, height. If a single number is passed,
  32508. * it will be used for both width and height. If an object is passed, the screenshot size
  32509. * will be derived from the parameters. The precision property is a multiplier allowing
  32510. * rendering at a higher or lower resolution
  32511. * @param successCallback defines the callback receives a single parameter which contains the
  32512. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32513. * src parameter of an <img> to display it
  32514. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32515. * Check your browser for supported MIME types
  32516. */
  32517. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32518. /**
  32519. * Captures a screenshot of the current rendering
  32520. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32521. * @param engine defines the rendering engine
  32522. * @param camera defines the source camera
  32523. * @param size This parameter can be set to a single number or to an object with the
  32524. * following (optional) properties: precision, width, height. If a single number is passed,
  32525. * it will be used for both width and height. If an object is passed, the screenshot size
  32526. * will be derived from the parameters. The precision property is a multiplier allowing
  32527. * rendering at a higher or lower resolution
  32528. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32529. * Check your browser for supported MIME types
  32530. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32531. * to the src parameter of an <img> to display it
  32532. */
  32533. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32534. /**
  32535. * Generates an image screenshot from the specified camera.
  32536. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32537. * @param engine The engine to use for rendering
  32538. * @param camera The camera to use for rendering
  32539. * @param size This parameter can be set to a single number or to an object with the
  32540. * following (optional) properties: precision, width, height. If a single number is passed,
  32541. * it will be used for both width and height. If an object is passed, the screenshot size
  32542. * will be derived from the parameters. The precision property is a multiplier allowing
  32543. * rendering at a higher or lower resolution
  32544. * @param successCallback The callback receives a single parameter which contains the
  32545. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32546. * src parameter of an <img> to display it
  32547. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32548. * Check your browser for supported MIME types
  32549. * @param samples Texture samples (default: 1)
  32550. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32551. * @param fileName A name for for the downloaded file.
  32552. */
  32553. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32554. /**
  32555. * Generates an image screenshot from the specified camera.
  32556. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32557. * @param engine The engine to use for rendering
  32558. * @param camera The camera to use for rendering
  32559. * @param size This parameter can be set to a single number or to an object with the
  32560. * following (optional) properties: precision, width, height. If a single number is passed,
  32561. * it will be used for both width and height. If an object is passed, the screenshot size
  32562. * will be derived from the parameters. The precision property is a multiplier allowing
  32563. * rendering at a higher or lower resolution
  32564. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32565. * Check your browser for supported MIME types
  32566. * @param samples Texture samples (default: 1)
  32567. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32568. * @param fileName A name for for the downloaded file.
  32569. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32570. * to the src parameter of an <img> to display it
  32571. */
  32572. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32573. /**
  32574. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32575. * Be aware Math.random() could cause collisions, but:
  32576. * "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"
  32577. * @returns a pseudo random id
  32578. */
  32579. static RandomId(): string;
  32580. /**
  32581. * Test if the given uri is a base64 string
  32582. * @param uri The uri to test
  32583. * @return True if the uri is a base64 string or false otherwise
  32584. */
  32585. static IsBase64(uri: string): boolean;
  32586. /**
  32587. * Decode the given base64 uri.
  32588. * @param uri The uri to decode
  32589. * @return The decoded base64 data.
  32590. */
  32591. static DecodeBase64(uri: string): ArrayBuffer;
  32592. /**
  32593. * Gets the absolute url.
  32594. * @param url the input url
  32595. * @return the absolute url
  32596. */
  32597. static GetAbsoluteUrl(url: string): string;
  32598. /**
  32599. * No log
  32600. */
  32601. static readonly NoneLogLevel: number;
  32602. /**
  32603. * Only message logs
  32604. */
  32605. static readonly MessageLogLevel: number;
  32606. /**
  32607. * Only warning logs
  32608. */
  32609. static readonly WarningLogLevel: number;
  32610. /**
  32611. * Only error logs
  32612. */
  32613. static readonly ErrorLogLevel: number;
  32614. /**
  32615. * All logs
  32616. */
  32617. static readonly AllLogLevel: number;
  32618. /**
  32619. * Gets a value indicating the number of loading errors
  32620. * @ignorenaming
  32621. */
  32622. static readonly errorsCount: number;
  32623. /**
  32624. * Callback called when a new log is added
  32625. */
  32626. static OnNewCacheEntry: (entry: string) => void;
  32627. /**
  32628. * Log a message to the console
  32629. * @param message defines the message to log
  32630. */
  32631. static Log(message: string): void;
  32632. /**
  32633. * Write a warning message to the console
  32634. * @param message defines the message to log
  32635. */
  32636. static Warn(message: string): void;
  32637. /**
  32638. * Write an error message to the console
  32639. * @param message defines the message to log
  32640. */
  32641. static Error(message: string): void;
  32642. /**
  32643. * Gets current log cache (list of logs)
  32644. */
  32645. static readonly LogCache: string;
  32646. /**
  32647. * Clears the log cache
  32648. */
  32649. static ClearLogCache(): void;
  32650. /**
  32651. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32652. */
  32653. static LogLevels: number;
  32654. /**
  32655. * Checks if the window object exists
  32656. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32657. */
  32658. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32659. /**
  32660. * No performance log
  32661. */
  32662. static readonly PerformanceNoneLogLevel: number;
  32663. /**
  32664. * Use user marks to log performance
  32665. */
  32666. static readonly PerformanceUserMarkLogLevel: number;
  32667. /**
  32668. * Log performance to the console
  32669. */
  32670. static readonly PerformanceConsoleLogLevel: number;
  32671. private static _performance;
  32672. /**
  32673. * Sets the current performance log level
  32674. */
  32675. static PerformanceLogLevel: number;
  32676. private static _StartPerformanceCounterDisabled;
  32677. private static _EndPerformanceCounterDisabled;
  32678. private static _StartUserMark;
  32679. private static _EndUserMark;
  32680. private static _StartPerformanceConsole;
  32681. private static _EndPerformanceConsole;
  32682. /**
  32683. * Starts a performance counter
  32684. */
  32685. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32686. /**
  32687. * Ends a specific performance coutner
  32688. */
  32689. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32690. /**
  32691. * Gets either window.performance.now() if supported or Date.now() else
  32692. */
  32693. static readonly Now: number;
  32694. /**
  32695. * This method will return the name of the class used to create the instance of the given object.
  32696. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32697. * @param object the object to get the class name from
  32698. * @param isType defines if the object is actually a type
  32699. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32700. */
  32701. static GetClassName(object: any, isType?: boolean): string;
  32702. /**
  32703. * Gets the first element of an array satisfying a given predicate
  32704. * @param array defines the array to browse
  32705. * @param predicate defines the predicate to use
  32706. * @returns null if not found or the element
  32707. */
  32708. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32709. /**
  32710. * This method will return the name of the full name of the class, including its owning module (if any).
  32711. * 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).
  32712. * @param object the object to get the class name from
  32713. * @param isType defines if the object is actually a type
  32714. * @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.
  32715. * @ignorenaming
  32716. */
  32717. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32718. /**
  32719. * Returns a promise that resolves after the given amount of time.
  32720. * @param delay Number of milliseconds to delay
  32721. * @returns Promise that resolves after the given amount of time
  32722. */
  32723. static DelayAsync(delay: number): Promise<void>;
  32724. }
  32725. /**
  32726. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32727. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32728. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32729. * @param name The name of the class, case should be preserved
  32730. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32731. */
  32732. export function className(name: string, module?: string): (target: Object) => void;
  32733. /**
  32734. * An implementation of a loop for asynchronous functions.
  32735. */
  32736. export class AsyncLoop {
  32737. /**
  32738. * Defines the number of iterations for the loop
  32739. */
  32740. iterations: number;
  32741. /**
  32742. * Defines the current index of the loop.
  32743. */
  32744. index: number;
  32745. private _done;
  32746. private _fn;
  32747. private _successCallback;
  32748. /**
  32749. * Constructor.
  32750. * @param iterations the number of iterations.
  32751. * @param func the function to run each iteration
  32752. * @param successCallback the callback that will be called upon succesful execution
  32753. * @param offset starting offset.
  32754. */
  32755. constructor(
  32756. /**
  32757. * Defines the number of iterations for the loop
  32758. */
  32759. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32760. /**
  32761. * Execute the next iteration. Must be called after the last iteration was finished.
  32762. */
  32763. executeNext(): void;
  32764. /**
  32765. * Break the loop and run the success callback.
  32766. */
  32767. breakLoop(): void;
  32768. /**
  32769. * Create and run an async loop.
  32770. * @param iterations the number of iterations.
  32771. * @param fn the function to run each iteration
  32772. * @param successCallback the callback that will be called upon succesful execution
  32773. * @param offset starting offset.
  32774. * @returns the created async loop object
  32775. */
  32776. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32777. /**
  32778. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32779. * @param iterations total number of iterations
  32780. * @param syncedIterations number of synchronous iterations in each async iteration.
  32781. * @param fn the function to call each iteration.
  32782. * @param callback a success call back that will be called when iterating stops.
  32783. * @param breakFunction a break condition (optional)
  32784. * @param timeout timeout settings for the setTimeout function. default - 0.
  32785. * @returns the created async loop object
  32786. */
  32787. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32788. }
  32789. }
  32790. declare module BABYLON {
  32791. /**
  32792. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32793. * The underlying implementation relies on an associative array to ensure the best performances.
  32794. * The value can be anything including 'null' but except 'undefined'
  32795. */
  32796. export class StringDictionary<T> {
  32797. /**
  32798. * This will clear this dictionary and copy the content from the 'source' one.
  32799. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32800. * @param source the dictionary to take the content from and copy to this dictionary
  32801. */
  32802. copyFrom(source: StringDictionary<T>): void;
  32803. /**
  32804. * Get a value based from its key
  32805. * @param key the given key to get the matching value from
  32806. * @return the value if found, otherwise undefined is returned
  32807. */
  32808. get(key: string): T | undefined;
  32809. /**
  32810. * Get a value from its key or add it if it doesn't exist.
  32811. * This method will ensure you that a given key/data will be present in the dictionary.
  32812. * @param key the given key to get the matching value from
  32813. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32814. * The factory will only be invoked if there's no data for the given key.
  32815. * @return the value corresponding to the key.
  32816. */
  32817. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32818. /**
  32819. * Get a value from its key if present in the dictionary otherwise add it
  32820. * @param key the key to get the value from
  32821. * @param val if there's no such key/value pair in the dictionary add it with this value
  32822. * @return the value corresponding to the key
  32823. */
  32824. getOrAdd(key: string, val: T): T;
  32825. /**
  32826. * Check if there's a given key in the dictionary
  32827. * @param key the key to check for
  32828. * @return true if the key is present, false otherwise
  32829. */
  32830. contains(key: string): boolean;
  32831. /**
  32832. * Add a new key and its corresponding value
  32833. * @param key the key to add
  32834. * @param value the value corresponding to the key
  32835. * @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
  32836. */
  32837. add(key: string, value: T): boolean;
  32838. /**
  32839. * Update a specific value associated to a key
  32840. * @param key defines the key to use
  32841. * @param value defines the value to store
  32842. * @returns true if the value was updated (or false if the key was not found)
  32843. */
  32844. set(key: string, value: T): boolean;
  32845. /**
  32846. * Get the element of the given key and remove it from the dictionary
  32847. * @param key defines the key to search
  32848. * @returns the value associated with the key or null if not found
  32849. */
  32850. getAndRemove(key: string): Nullable<T>;
  32851. /**
  32852. * Remove a key/value from the dictionary.
  32853. * @param key the key to remove
  32854. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32855. */
  32856. remove(key: string): boolean;
  32857. /**
  32858. * Clear the whole content of the dictionary
  32859. */
  32860. clear(): void;
  32861. /**
  32862. * Gets the current count
  32863. */
  32864. readonly count: number;
  32865. /**
  32866. * Execute a callback on each key/val of the dictionary.
  32867. * Note that you can remove any element in this dictionary in the callback implementation
  32868. * @param callback the callback to execute on a given key/value pair
  32869. */
  32870. forEach(callback: (key: string, val: T) => void): void;
  32871. /**
  32872. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32873. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32874. * Note that you can remove any element in this dictionary in the callback implementation
  32875. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32876. * @returns the first item
  32877. */
  32878. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32879. private _count;
  32880. private _data;
  32881. }
  32882. }
  32883. declare module BABYLON {
  32884. /** @hidden */
  32885. export interface ICollisionCoordinator {
  32886. createCollider(): Collider;
  32887. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32888. init(scene: Scene): void;
  32889. }
  32890. /** @hidden */
  32891. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32892. private _scene;
  32893. private _scaledPosition;
  32894. private _scaledVelocity;
  32895. private _finalPosition;
  32896. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32897. createCollider(): Collider;
  32898. init(scene: Scene): void;
  32899. private _collideWithWorld;
  32900. }
  32901. }
  32902. declare module BABYLON {
  32903. /**
  32904. * Class used to manage all inputs for the scene.
  32905. */
  32906. export class InputManager {
  32907. /** The distance in pixel that you have to move to prevent some events */
  32908. static DragMovementThreshold: number;
  32909. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32910. static LongPressDelay: number;
  32911. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32912. static DoubleClickDelay: number;
  32913. /** If you need to check double click without raising a single click at first click, enable this flag */
  32914. static ExclusiveDoubleClickMode: boolean;
  32915. private _wheelEventName;
  32916. private _onPointerMove;
  32917. private _onPointerDown;
  32918. private _onPointerUp;
  32919. private _initClickEvent;
  32920. private _initActionManager;
  32921. private _delayedSimpleClick;
  32922. private _delayedSimpleClickTimeout;
  32923. private _previousDelayedSimpleClickTimeout;
  32924. private _meshPickProceed;
  32925. private _previousButtonPressed;
  32926. private _currentPickResult;
  32927. private _previousPickResult;
  32928. private _totalPointersPressed;
  32929. private _doubleClickOccured;
  32930. private _pointerOverMesh;
  32931. private _pickedDownMesh;
  32932. private _pickedUpMesh;
  32933. private _pointerX;
  32934. private _pointerY;
  32935. private _unTranslatedPointerX;
  32936. private _unTranslatedPointerY;
  32937. private _startingPointerPosition;
  32938. private _previousStartingPointerPosition;
  32939. private _startingPointerTime;
  32940. private _previousStartingPointerTime;
  32941. private _pointerCaptures;
  32942. private _onKeyDown;
  32943. private _onKeyUp;
  32944. private _onCanvasFocusObserver;
  32945. private _onCanvasBlurObserver;
  32946. private _scene;
  32947. /**
  32948. * Creates a new InputManager
  32949. * @param scene defines the hosting scene
  32950. */
  32951. constructor(scene: Scene);
  32952. /**
  32953. * Gets the mesh that is currently under the pointer
  32954. */
  32955. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32956. /**
  32957. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32958. */
  32959. readonly unTranslatedPointer: Vector2;
  32960. /**
  32961. * Gets or sets the current on-screen X position of the pointer
  32962. */
  32963. pointerX: number;
  32964. /**
  32965. * Gets or sets the current on-screen Y position of the pointer
  32966. */
  32967. pointerY: number;
  32968. private _updatePointerPosition;
  32969. private _processPointerMove;
  32970. private _setRayOnPointerInfo;
  32971. private _checkPrePointerObservable;
  32972. /**
  32973. * Use this method to simulate a pointer move on a mesh
  32974. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32975. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32976. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32977. */
  32978. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32979. /**
  32980. * Use this method to simulate a pointer down on a mesh
  32981. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32982. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32983. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32984. */
  32985. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32986. private _processPointerDown;
  32987. /** @hidden */
  32988. _isPointerSwiping(): boolean;
  32989. /**
  32990. * Use this method to simulate a pointer up on a mesh
  32991. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32992. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32993. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32994. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32995. */
  32996. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32997. private _processPointerUp;
  32998. /**
  32999. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33000. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33001. * @returns true if the pointer was captured
  33002. */
  33003. isPointerCaptured(pointerId?: number): boolean;
  33004. /**
  33005. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33006. * @param attachUp defines if you want to attach events to pointerup
  33007. * @param attachDown defines if you want to attach events to pointerdown
  33008. * @param attachMove defines if you want to attach events to pointermove
  33009. */
  33010. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33011. /**
  33012. * Detaches all event handlers
  33013. */
  33014. detachControl(): void;
  33015. /**
  33016. * Force the value of meshUnderPointer
  33017. * @param mesh defines the mesh to use
  33018. */
  33019. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33020. /**
  33021. * Gets the mesh under the pointer
  33022. * @returns a Mesh or null if no mesh is under the pointer
  33023. */
  33024. getPointerOverMesh(): Nullable<AbstractMesh>;
  33025. }
  33026. }
  33027. declare module BABYLON {
  33028. /**
  33029. * Helper class used to generate session unique ID
  33030. */
  33031. export class UniqueIdGenerator {
  33032. private static _UniqueIdCounter;
  33033. /**
  33034. * Gets an unique (relatively to the current scene) Id
  33035. */
  33036. static readonly UniqueId: number;
  33037. }
  33038. }
  33039. declare module BABYLON {
  33040. /**
  33041. * This class defines the direct association between an animation and a target
  33042. */
  33043. export class TargetedAnimation {
  33044. /**
  33045. * Animation to perform
  33046. */
  33047. animation: Animation;
  33048. /**
  33049. * Target to animate
  33050. */
  33051. target: any;
  33052. /**
  33053. * Serialize the object
  33054. * @returns the JSON object representing the current entity
  33055. */
  33056. serialize(): any;
  33057. }
  33058. /**
  33059. * Use this class to create coordinated animations on multiple targets
  33060. */
  33061. export class AnimationGroup implements IDisposable {
  33062. /** The name of the animation group */
  33063. name: string;
  33064. private _scene;
  33065. private _targetedAnimations;
  33066. private _animatables;
  33067. private _from;
  33068. private _to;
  33069. private _isStarted;
  33070. private _isPaused;
  33071. private _speedRatio;
  33072. private _loopAnimation;
  33073. /**
  33074. * Gets or sets the unique id of the node
  33075. */
  33076. uniqueId: number;
  33077. /**
  33078. * This observable will notify when one animation have ended
  33079. */
  33080. onAnimationEndObservable: Observable<TargetedAnimation>;
  33081. /**
  33082. * Observer raised when one animation loops
  33083. */
  33084. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33085. /**
  33086. * Observer raised when all animations have looped
  33087. */
  33088. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  33089. /**
  33090. * This observable will notify when all animations have ended.
  33091. */
  33092. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33093. /**
  33094. * This observable will notify when all animations have paused.
  33095. */
  33096. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33097. /**
  33098. * This observable will notify when all animations are playing.
  33099. */
  33100. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33101. /**
  33102. * Gets the first frame
  33103. */
  33104. readonly from: number;
  33105. /**
  33106. * Gets the last frame
  33107. */
  33108. readonly to: number;
  33109. /**
  33110. * Define if the animations are started
  33111. */
  33112. readonly isStarted: boolean;
  33113. /**
  33114. * Gets a value indicating that the current group is playing
  33115. */
  33116. readonly isPlaying: boolean;
  33117. /**
  33118. * Gets or sets the speed ratio to use for all animations
  33119. */
  33120. /**
  33121. * Gets or sets the speed ratio to use for all animations
  33122. */
  33123. speedRatio: number;
  33124. /**
  33125. * Gets or sets if all animations should loop or not
  33126. */
  33127. loopAnimation: boolean;
  33128. /**
  33129. * Gets the targeted animations for this animation group
  33130. */
  33131. readonly targetedAnimations: Array<TargetedAnimation>;
  33132. /**
  33133. * returning the list of animatables controlled by this animation group.
  33134. */
  33135. readonly animatables: Array<Animatable>;
  33136. /**
  33137. * Instantiates a new Animation Group.
  33138. * This helps managing several animations at once.
  33139. * @see http://doc.babylonjs.com/how_to/group
  33140. * @param name Defines the name of the group
  33141. * @param scene Defines the scene the group belongs to
  33142. */
  33143. constructor(
  33144. /** The name of the animation group */
  33145. name: string, scene?: Nullable<Scene>);
  33146. /**
  33147. * Add an animation (with its target) in the group
  33148. * @param animation defines the animation we want to add
  33149. * @param target defines the target of the animation
  33150. * @returns the TargetedAnimation object
  33151. */
  33152. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33153. /**
  33154. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33155. * It can add constant keys at begin or end
  33156. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33157. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33158. * @returns the animation group
  33159. */
  33160. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33161. private _animationLoopCount;
  33162. private _animationLoopFlags;
  33163. private _processLoop;
  33164. /**
  33165. * Start all animations on given targets
  33166. * @param loop defines if animations must loop
  33167. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33168. * @param from defines the from key (optional)
  33169. * @param to defines the to key (optional)
  33170. * @returns the current animation group
  33171. */
  33172. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33173. /**
  33174. * Pause all animations
  33175. * @returns the animation group
  33176. */
  33177. pause(): AnimationGroup;
  33178. /**
  33179. * Play all animations to initial state
  33180. * This function will start() the animations if they were not started or will restart() them if they were paused
  33181. * @param loop defines if animations must loop
  33182. * @returns the animation group
  33183. */
  33184. play(loop?: boolean): AnimationGroup;
  33185. /**
  33186. * Reset all animations to initial state
  33187. * @returns the animation group
  33188. */
  33189. reset(): AnimationGroup;
  33190. /**
  33191. * Restart animations from key 0
  33192. * @returns the animation group
  33193. */
  33194. restart(): AnimationGroup;
  33195. /**
  33196. * Stop all animations
  33197. * @returns the animation group
  33198. */
  33199. stop(): AnimationGroup;
  33200. /**
  33201. * Set animation weight for all animatables
  33202. * @param weight defines the weight to use
  33203. * @return the animationGroup
  33204. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33205. */
  33206. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33207. /**
  33208. * Synchronize and normalize all animatables with a source animatable
  33209. * @param root defines the root animatable to synchronize with
  33210. * @return the animationGroup
  33211. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33212. */
  33213. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33214. /**
  33215. * Goes to a specific frame in this animation group
  33216. * @param frame the frame number to go to
  33217. * @return the animationGroup
  33218. */
  33219. goToFrame(frame: number): AnimationGroup;
  33220. /**
  33221. * Dispose all associated resources
  33222. */
  33223. dispose(): void;
  33224. private _checkAnimationGroupEnded;
  33225. /**
  33226. * Clone the current animation group and returns a copy
  33227. * @param newName defines the name of the new group
  33228. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33229. * @returns the new aniamtion group
  33230. */
  33231. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33232. /**
  33233. * Serializes the animationGroup to an object
  33234. * @returns Serialized object
  33235. */
  33236. serialize(): any;
  33237. /**
  33238. * Returns a new AnimationGroup object parsed from the source provided.
  33239. * @param parsedAnimationGroup defines the source
  33240. * @param scene defines the scene that will receive the animationGroup
  33241. * @returns a new AnimationGroup
  33242. */
  33243. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33244. /**
  33245. * Returns the string "AnimationGroup"
  33246. * @returns "AnimationGroup"
  33247. */
  33248. getClassName(): string;
  33249. /**
  33250. * Creates a detailled string about the object
  33251. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33252. * @returns a string representing the object
  33253. */
  33254. toString(fullDetails?: boolean): string;
  33255. }
  33256. }
  33257. declare module BABYLON {
  33258. /**
  33259. * Define an interface for all classes that will hold resources
  33260. */
  33261. export interface IDisposable {
  33262. /**
  33263. * Releases all held resources
  33264. */
  33265. dispose(): void;
  33266. }
  33267. /** Interface defining initialization parameters for Scene class */
  33268. export interface SceneOptions {
  33269. /**
  33270. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33271. * It will improve performance when the number of geometries becomes important.
  33272. */
  33273. useGeometryUniqueIdsMap?: boolean;
  33274. /**
  33275. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33276. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33277. */
  33278. useMaterialMeshMap?: boolean;
  33279. /**
  33280. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33281. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33282. */
  33283. useClonedMeshhMap?: boolean;
  33284. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33285. virtual?: boolean;
  33286. }
  33287. /**
  33288. * Represents a scene to be rendered by the engine.
  33289. * @see http://doc.babylonjs.com/features/scene
  33290. */
  33291. export class Scene extends AbstractScene implements IAnimatable {
  33292. /** The fog is deactivated */
  33293. static readonly FOGMODE_NONE: number;
  33294. /** The fog density is following an exponential function */
  33295. static readonly FOGMODE_EXP: number;
  33296. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33297. static readonly FOGMODE_EXP2: number;
  33298. /** The fog density is following a linear function. */
  33299. static readonly FOGMODE_LINEAR: number;
  33300. /**
  33301. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33302. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33303. */
  33304. static MinDeltaTime: number;
  33305. /**
  33306. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33307. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33308. */
  33309. static MaxDeltaTime: number;
  33310. /**
  33311. * Factory used to create the default material.
  33312. * @param name The name of the material to create
  33313. * @param scene The scene to create the material for
  33314. * @returns The default material
  33315. */
  33316. static DefaultMaterialFactory(scene: Scene): Material;
  33317. /**
  33318. * Factory used to create the a collision coordinator.
  33319. * @returns The collision coordinator
  33320. */
  33321. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33322. /** @hidden */
  33323. _inputManager: InputManager;
  33324. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33325. cameraToUseForPointers: Nullable<Camera>;
  33326. /** @hidden */
  33327. readonly _isScene: boolean;
  33328. /**
  33329. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33330. */
  33331. autoClear: boolean;
  33332. /**
  33333. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33334. */
  33335. autoClearDepthAndStencil: boolean;
  33336. /**
  33337. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33338. */
  33339. clearColor: Color4;
  33340. /**
  33341. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33342. */
  33343. ambientColor: Color3;
  33344. /**
  33345. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33346. * It should only be one of the following (if not the default embedded one):
  33347. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33348. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33349. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33350. * The material properties need to be setup according to the type of texture in use.
  33351. */
  33352. environmentBRDFTexture: BaseTexture;
  33353. /** @hidden */
  33354. protected _environmentTexture: Nullable<BaseTexture>;
  33355. /**
  33356. * Texture used in all pbr material as the reflection texture.
  33357. * As in the majority of the scene they are the same (exception for multi room and so on),
  33358. * this is easier to reference from here than from all the materials.
  33359. */
  33360. /**
  33361. * Texture used in all pbr material as the reflection texture.
  33362. * As in the majority of the scene they are the same (exception for multi room and so on),
  33363. * this is easier to set here than in all the materials.
  33364. */
  33365. environmentTexture: Nullable<BaseTexture>;
  33366. /** @hidden */
  33367. protected _environmentIntensity: number;
  33368. /**
  33369. * Intensity of the environment in all pbr material.
  33370. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33371. * As in the majority of the scene they are the same (exception for multi room and so on),
  33372. * this is easier to reference from here than from all the materials.
  33373. */
  33374. /**
  33375. * Intensity of the environment in all pbr material.
  33376. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33377. * As in the majority of the scene they are the same (exception for multi room and so on),
  33378. * this is easier to set here than in all the materials.
  33379. */
  33380. environmentIntensity: number;
  33381. /** @hidden */
  33382. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33383. /**
  33384. * Default image processing configuration used either in the rendering
  33385. * Forward main pass or through the imageProcessingPostProcess if present.
  33386. * As in the majority of the scene they are the same (exception for multi camera),
  33387. * this is easier to reference from here than from all the materials and post process.
  33388. *
  33389. * No setter as we it is a shared configuration, you can set the values instead.
  33390. */
  33391. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33392. private _forceWireframe;
  33393. /**
  33394. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33395. */
  33396. forceWireframe: boolean;
  33397. private _forcePointsCloud;
  33398. /**
  33399. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33400. */
  33401. forcePointsCloud: boolean;
  33402. /**
  33403. * Gets or sets the active clipplane 1
  33404. */
  33405. clipPlane: Nullable<Plane>;
  33406. /**
  33407. * Gets or sets the active clipplane 2
  33408. */
  33409. clipPlane2: Nullable<Plane>;
  33410. /**
  33411. * Gets or sets the active clipplane 3
  33412. */
  33413. clipPlane3: Nullable<Plane>;
  33414. /**
  33415. * Gets or sets the active clipplane 4
  33416. */
  33417. clipPlane4: Nullable<Plane>;
  33418. /**
  33419. * Gets or sets a boolean indicating if animations are enabled
  33420. */
  33421. animationsEnabled: boolean;
  33422. private _animationPropertiesOverride;
  33423. /**
  33424. * Gets or sets the animation properties override
  33425. */
  33426. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33427. /**
  33428. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33429. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33430. */
  33431. useConstantAnimationDeltaTime: boolean;
  33432. /**
  33433. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33434. * Please note that it requires to run a ray cast through the scene on every frame
  33435. */
  33436. constantlyUpdateMeshUnderPointer: boolean;
  33437. /**
  33438. * Defines the HTML cursor to use when hovering over interactive elements
  33439. */
  33440. hoverCursor: string;
  33441. /**
  33442. * Defines the HTML default cursor to use (empty by default)
  33443. */
  33444. defaultCursor: string;
  33445. /**
  33446. * Defines wether cursors are handled by the scene.
  33447. */
  33448. doNotHandleCursors: boolean;
  33449. /**
  33450. * This is used to call preventDefault() on pointer down
  33451. * in order to block unwanted artifacts like system double clicks
  33452. */
  33453. preventDefaultOnPointerDown: boolean;
  33454. /**
  33455. * This is used to call preventDefault() on pointer up
  33456. * in order to block unwanted artifacts like system double clicks
  33457. */
  33458. preventDefaultOnPointerUp: boolean;
  33459. /**
  33460. * Gets or sets user defined metadata
  33461. */
  33462. metadata: any;
  33463. /**
  33464. * For internal use only. Please do not use.
  33465. */
  33466. reservedDataStore: any;
  33467. /**
  33468. * Gets the name of the plugin used to load this scene (null by default)
  33469. */
  33470. loadingPluginName: string;
  33471. /**
  33472. * Use this array to add regular expressions used to disable offline support for specific urls
  33473. */
  33474. disableOfflineSupportExceptionRules: RegExp[];
  33475. /**
  33476. * An event triggered when the scene is disposed.
  33477. */
  33478. onDisposeObservable: Observable<Scene>;
  33479. private _onDisposeObserver;
  33480. /** Sets a function to be executed when this scene is disposed. */
  33481. onDispose: () => void;
  33482. /**
  33483. * An event triggered before rendering the scene (right after animations and physics)
  33484. */
  33485. onBeforeRenderObservable: Observable<Scene>;
  33486. private _onBeforeRenderObserver;
  33487. /** Sets a function to be executed before rendering this scene */
  33488. beforeRender: Nullable<() => void>;
  33489. /**
  33490. * An event triggered after rendering the scene
  33491. */
  33492. onAfterRenderObservable: Observable<Scene>;
  33493. /**
  33494. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33495. */
  33496. onAfterRenderCameraObservable: Observable<Camera>;
  33497. private _onAfterRenderObserver;
  33498. /** Sets a function to be executed after rendering this scene */
  33499. afterRender: Nullable<() => void>;
  33500. /**
  33501. * An event triggered before animating the scene
  33502. */
  33503. onBeforeAnimationsObservable: Observable<Scene>;
  33504. /**
  33505. * An event triggered after animations processing
  33506. */
  33507. onAfterAnimationsObservable: Observable<Scene>;
  33508. /**
  33509. * An event triggered before draw calls are ready to be sent
  33510. */
  33511. onBeforeDrawPhaseObservable: Observable<Scene>;
  33512. /**
  33513. * An event triggered after draw calls have been sent
  33514. */
  33515. onAfterDrawPhaseObservable: Observable<Scene>;
  33516. /**
  33517. * An event triggered when the scene is ready
  33518. */
  33519. onReadyObservable: Observable<Scene>;
  33520. /**
  33521. * An event triggered before rendering a camera
  33522. */
  33523. onBeforeCameraRenderObservable: Observable<Camera>;
  33524. private _onBeforeCameraRenderObserver;
  33525. /** Sets a function to be executed before rendering a camera*/
  33526. beforeCameraRender: () => void;
  33527. /**
  33528. * An event triggered after rendering a camera
  33529. */
  33530. onAfterCameraRenderObservable: Observable<Camera>;
  33531. private _onAfterCameraRenderObserver;
  33532. /** Sets a function to be executed after rendering a camera*/
  33533. afterCameraRender: () => void;
  33534. /**
  33535. * An event triggered when active meshes evaluation is about to start
  33536. */
  33537. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33538. /**
  33539. * An event triggered when active meshes evaluation is done
  33540. */
  33541. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33542. /**
  33543. * An event triggered when particles rendering is about to start
  33544. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33545. */
  33546. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33547. /**
  33548. * An event triggered when particles rendering is done
  33549. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33550. */
  33551. onAfterParticlesRenderingObservable: Observable<Scene>;
  33552. /**
  33553. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33554. */
  33555. onDataLoadedObservable: Observable<Scene>;
  33556. /**
  33557. * An event triggered when a camera is created
  33558. */
  33559. onNewCameraAddedObservable: Observable<Camera>;
  33560. /**
  33561. * An event triggered when a camera is removed
  33562. */
  33563. onCameraRemovedObservable: Observable<Camera>;
  33564. /**
  33565. * An event triggered when a light is created
  33566. */
  33567. onNewLightAddedObservable: Observable<Light>;
  33568. /**
  33569. * An event triggered when a light is removed
  33570. */
  33571. onLightRemovedObservable: Observable<Light>;
  33572. /**
  33573. * An event triggered when a geometry is created
  33574. */
  33575. onNewGeometryAddedObservable: Observable<Geometry>;
  33576. /**
  33577. * An event triggered when a geometry is removed
  33578. */
  33579. onGeometryRemovedObservable: Observable<Geometry>;
  33580. /**
  33581. * An event triggered when a transform node is created
  33582. */
  33583. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33584. /**
  33585. * An event triggered when a transform node is removed
  33586. */
  33587. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33588. /**
  33589. * An event triggered when a mesh is created
  33590. */
  33591. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33592. /**
  33593. * An event triggered when a mesh is removed
  33594. */
  33595. onMeshRemovedObservable: Observable<AbstractMesh>;
  33596. /**
  33597. * An event triggered when a skeleton is created
  33598. */
  33599. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33600. /**
  33601. * An event triggered when a skeleton is removed
  33602. */
  33603. onSkeletonRemovedObservable: Observable<Skeleton>;
  33604. /**
  33605. * An event triggered when a material is created
  33606. */
  33607. onNewMaterialAddedObservable: Observable<Material>;
  33608. /**
  33609. * An event triggered when a material is removed
  33610. */
  33611. onMaterialRemovedObservable: Observable<Material>;
  33612. /**
  33613. * An event triggered when a texture is created
  33614. */
  33615. onNewTextureAddedObservable: Observable<BaseTexture>;
  33616. /**
  33617. * An event triggered when a texture is removed
  33618. */
  33619. onTextureRemovedObservable: Observable<BaseTexture>;
  33620. /**
  33621. * An event triggered when render targets are about to be rendered
  33622. * Can happen multiple times per frame.
  33623. */
  33624. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33625. /**
  33626. * An event triggered when render targets were rendered.
  33627. * Can happen multiple times per frame.
  33628. */
  33629. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33630. /**
  33631. * An event triggered before calculating deterministic simulation step
  33632. */
  33633. onBeforeStepObservable: Observable<Scene>;
  33634. /**
  33635. * An event triggered after calculating deterministic simulation step
  33636. */
  33637. onAfterStepObservable: Observable<Scene>;
  33638. /**
  33639. * An event triggered when the activeCamera property is updated
  33640. */
  33641. onActiveCameraChanged: Observable<Scene>;
  33642. /**
  33643. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33644. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33645. * 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)
  33646. */
  33647. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33648. /**
  33649. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33650. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33651. * 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)
  33652. */
  33653. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33654. /**
  33655. * This Observable will when a mesh has been imported into the scene.
  33656. */
  33657. onMeshImportedObservable: Observable<AbstractMesh>;
  33658. /**
  33659. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33660. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33661. */
  33662. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33663. /** @hidden */
  33664. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33665. /**
  33666. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33667. */
  33668. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33669. /**
  33670. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33671. */
  33672. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33673. /**
  33674. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33675. */
  33676. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33677. /** Callback called when a pointer move is detected */
  33678. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33679. /** Callback called when a pointer down is detected */
  33680. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33681. /** Callback called when a pointer up is detected */
  33682. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33683. /** Callback called when a pointer pick is detected */
  33684. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33685. /**
  33686. * 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).
  33687. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33688. */
  33689. onPrePointerObservable: Observable<PointerInfoPre>;
  33690. /**
  33691. * Observable event triggered each time an input event is received from the rendering canvas
  33692. */
  33693. onPointerObservable: Observable<PointerInfo>;
  33694. /**
  33695. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33696. */
  33697. readonly unTranslatedPointer: Vector2;
  33698. /**
  33699. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33700. */
  33701. static DragMovementThreshold: number;
  33702. /**
  33703. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33704. */
  33705. static LongPressDelay: number;
  33706. /**
  33707. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33708. */
  33709. static DoubleClickDelay: number;
  33710. /** If you need to check double click without raising a single click at first click, enable this flag */
  33711. static ExclusiveDoubleClickMode: boolean;
  33712. /** @hidden */
  33713. _mirroredCameraPosition: Nullable<Vector3>;
  33714. /**
  33715. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33716. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33717. */
  33718. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33719. /**
  33720. * Observable event triggered each time an keyboard event is received from the hosting window
  33721. */
  33722. onKeyboardObservable: Observable<KeyboardInfo>;
  33723. private _useRightHandedSystem;
  33724. /**
  33725. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33726. */
  33727. useRightHandedSystem: boolean;
  33728. private _timeAccumulator;
  33729. private _currentStepId;
  33730. private _currentInternalStep;
  33731. /**
  33732. * Sets the step Id used by deterministic lock step
  33733. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33734. * @param newStepId defines the step Id
  33735. */
  33736. setStepId(newStepId: number): void;
  33737. /**
  33738. * Gets the step Id used by deterministic lock step
  33739. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33740. * @returns the step Id
  33741. */
  33742. getStepId(): number;
  33743. /**
  33744. * Gets the internal step used by deterministic lock step
  33745. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33746. * @returns the internal step
  33747. */
  33748. getInternalStep(): number;
  33749. private _fogEnabled;
  33750. /**
  33751. * Gets or sets a boolean indicating if fog is enabled on this scene
  33752. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33753. * (Default is true)
  33754. */
  33755. fogEnabled: boolean;
  33756. private _fogMode;
  33757. /**
  33758. * Gets or sets the fog mode to use
  33759. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33760. * | mode | value |
  33761. * | --- | --- |
  33762. * | FOGMODE_NONE | 0 |
  33763. * | FOGMODE_EXP | 1 |
  33764. * | FOGMODE_EXP2 | 2 |
  33765. * | FOGMODE_LINEAR | 3 |
  33766. */
  33767. fogMode: number;
  33768. /**
  33769. * Gets or sets the fog color to use
  33770. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33771. * (Default is Color3(0.2, 0.2, 0.3))
  33772. */
  33773. fogColor: Color3;
  33774. /**
  33775. * Gets or sets the fog density to use
  33776. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33777. * (Default is 0.1)
  33778. */
  33779. fogDensity: number;
  33780. /**
  33781. * Gets or sets the fog start distance to use
  33782. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33783. * (Default is 0)
  33784. */
  33785. fogStart: number;
  33786. /**
  33787. * Gets or sets the fog end distance to use
  33788. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33789. * (Default is 1000)
  33790. */
  33791. fogEnd: number;
  33792. private _shadowsEnabled;
  33793. /**
  33794. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33795. */
  33796. shadowsEnabled: boolean;
  33797. private _lightsEnabled;
  33798. /**
  33799. * Gets or sets a boolean indicating if lights are enabled on this scene
  33800. */
  33801. lightsEnabled: boolean;
  33802. /** All of the active cameras added to this scene. */
  33803. activeCameras: Camera[];
  33804. /** @hidden */
  33805. _activeCamera: Nullable<Camera>;
  33806. /** Gets or sets the current active camera */
  33807. activeCamera: Nullable<Camera>;
  33808. private _defaultMaterial;
  33809. /** The default material used on meshes when no material is affected */
  33810. /** The default material used on meshes when no material is affected */
  33811. defaultMaterial: Material;
  33812. private _texturesEnabled;
  33813. /**
  33814. * Gets or sets a boolean indicating if textures are enabled on this scene
  33815. */
  33816. texturesEnabled: boolean;
  33817. /**
  33818. * Gets or sets a boolean indicating if particles are enabled on this scene
  33819. */
  33820. particlesEnabled: boolean;
  33821. /**
  33822. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33823. */
  33824. spritesEnabled: boolean;
  33825. private _skeletonsEnabled;
  33826. /**
  33827. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33828. */
  33829. skeletonsEnabled: boolean;
  33830. /**
  33831. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33832. */
  33833. lensFlaresEnabled: boolean;
  33834. /**
  33835. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33836. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33837. */
  33838. collisionsEnabled: boolean;
  33839. private _collisionCoordinator;
  33840. /** @hidden */
  33841. readonly collisionCoordinator: ICollisionCoordinator;
  33842. /**
  33843. * Defines the gravity applied to this scene (used only for collisions)
  33844. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33845. */
  33846. gravity: Vector3;
  33847. /**
  33848. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33849. */
  33850. postProcessesEnabled: boolean;
  33851. /**
  33852. * The list of postprocesses added to the scene
  33853. */
  33854. postProcesses: PostProcess[];
  33855. /**
  33856. * Gets the current postprocess manager
  33857. */
  33858. postProcessManager: PostProcessManager;
  33859. /**
  33860. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33861. */
  33862. renderTargetsEnabled: boolean;
  33863. /**
  33864. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33865. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33866. */
  33867. dumpNextRenderTargets: boolean;
  33868. /**
  33869. * The list of user defined render targets added to the scene
  33870. */
  33871. customRenderTargets: RenderTargetTexture[];
  33872. /**
  33873. * Defines if texture loading must be delayed
  33874. * If true, textures will only be loaded when they need to be rendered
  33875. */
  33876. useDelayedTextureLoading: boolean;
  33877. /**
  33878. * Gets the list of meshes imported to the scene through SceneLoader
  33879. */
  33880. importedMeshesFiles: String[];
  33881. /**
  33882. * Gets or sets a boolean indicating if probes are enabled on this scene
  33883. */
  33884. probesEnabled: boolean;
  33885. /**
  33886. * Gets or sets the current offline provider to use to store scene data
  33887. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33888. */
  33889. offlineProvider: IOfflineProvider;
  33890. /**
  33891. * Gets or sets the action manager associated with the scene
  33892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33893. */
  33894. actionManager: AbstractActionManager;
  33895. private _meshesForIntersections;
  33896. /**
  33897. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33898. */
  33899. proceduralTexturesEnabled: boolean;
  33900. private _engine;
  33901. private _totalVertices;
  33902. /** @hidden */
  33903. _activeIndices: PerfCounter;
  33904. /** @hidden */
  33905. _activeParticles: PerfCounter;
  33906. /** @hidden */
  33907. _activeBones: PerfCounter;
  33908. private _animationRatio;
  33909. /** @hidden */
  33910. _animationTimeLast: number;
  33911. /** @hidden */
  33912. _animationTime: number;
  33913. /**
  33914. * Gets or sets a general scale for animation speed
  33915. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33916. */
  33917. animationTimeScale: number;
  33918. /** @hidden */
  33919. _cachedMaterial: Nullable<Material>;
  33920. /** @hidden */
  33921. _cachedEffect: Nullable<Effect>;
  33922. /** @hidden */
  33923. _cachedVisibility: Nullable<number>;
  33924. private _renderId;
  33925. private _frameId;
  33926. private _executeWhenReadyTimeoutId;
  33927. private _intermediateRendering;
  33928. private _viewUpdateFlag;
  33929. private _projectionUpdateFlag;
  33930. /** @hidden */
  33931. _toBeDisposed: Nullable<IDisposable>[];
  33932. private _activeRequests;
  33933. /** @hidden */
  33934. _pendingData: any[];
  33935. private _isDisposed;
  33936. /**
  33937. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33938. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33939. */
  33940. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33941. private _activeMeshes;
  33942. private _processedMaterials;
  33943. private _renderTargets;
  33944. /** @hidden */
  33945. _activeParticleSystems: SmartArray<IParticleSystem>;
  33946. private _activeSkeletons;
  33947. private _softwareSkinnedMeshes;
  33948. private _renderingManager;
  33949. /** @hidden */
  33950. _activeAnimatables: Animatable[];
  33951. private _transformMatrix;
  33952. private _sceneUbo;
  33953. /** @hidden */
  33954. _viewMatrix: Matrix;
  33955. private _projectionMatrix;
  33956. /** @hidden */
  33957. _forcedViewPosition: Nullable<Vector3>;
  33958. /** @hidden */
  33959. _frustumPlanes: Plane[];
  33960. /**
  33961. * Gets the list of frustum planes (built from the active camera)
  33962. */
  33963. readonly frustumPlanes: Plane[];
  33964. /**
  33965. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33966. * This is useful if there are more lights that the maximum simulteanous authorized
  33967. */
  33968. requireLightSorting: boolean;
  33969. /** @hidden */
  33970. readonly useMaterialMeshMap: boolean;
  33971. /** @hidden */
  33972. readonly useClonedMeshhMap: boolean;
  33973. private _externalData;
  33974. private _uid;
  33975. /**
  33976. * @hidden
  33977. * Backing store of defined scene components.
  33978. */
  33979. _components: ISceneComponent[];
  33980. /**
  33981. * @hidden
  33982. * Backing store of defined scene components.
  33983. */
  33984. _serializableComponents: ISceneSerializableComponent[];
  33985. /**
  33986. * List of components to register on the next registration step.
  33987. */
  33988. private _transientComponents;
  33989. /**
  33990. * Registers the transient components if needed.
  33991. */
  33992. private _registerTransientComponents;
  33993. /**
  33994. * @hidden
  33995. * Add a component to the scene.
  33996. * Note that the ccomponent could be registered on th next frame if this is called after
  33997. * the register component stage.
  33998. * @param component Defines the component to add to the scene
  33999. */
  34000. _addComponent(component: ISceneComponent): void;
  34001. /**
  34002. * @hidden
  34003. * Gets a component from the scene.
  34004. * @param name defines the name of the component to retrieve
  34005. * @returns the component or null if not present
  34006. */
  34007. _getComponent(name: string): Nullable<ISceneComponent>;
  34008. /**
  34009. * @hidden
  34010. * Defines the actions happening before camera updates.
  34011. */
  34012. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34013. /**
  34014. * @hidden
  34015. * Defines the actions happening before clear the canvas.
  34016. */
  34017. _beforeClearStage: Stage<SimpleStageAction>;
  34018. /**
  34019. * @hidden
  34020. * Defines the actions when collecting render targets for the frame.
  34021. */
  34022. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34023. /**
  34024. * @hidden
  34025. * Defines the actions happening for one camera in the frame.
  34026. */
  34027. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34028. /**
  34029. * @hidden
  34030. * Defines the actions happening during the per mesh ready checks.
  34031. */
  34032. _isReadyForMeshStage: Stage<MeshStageAction>;
  34033. /**
  34034. * @hidden
  34035. * Defines the actions happening before evaluate active mesh checks.
  34036. */
  34037. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34038. /**
  34039. * @hidden
  34040. * Defines the actions happening during the evaluate sub mesh checks.
  34041. */
  34042. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34043. /**
  34044. * @hidden
  34045. * Defines the actions happening during the active mesh stage.
  34046. */
  34047. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34048. /**
  34049. * @hidden
  34050. * Defines the actions happening during the per camera render target step.
  34051. */
  34052. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34053. /**
  34054. * @hidden
  34055. * Defines the actions happening just before the active camera is drawing.
  34056. */
  34057. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34058. /**
  34059. * @hidden
  34060. * Defines the actions happening just before a render target is drawing.
  34061. */
  34062. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34063. /**
  34064. * @hidden
  34065. * Defines the actions happening just before a rendering group is drawing.
  34066. */
  34067. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34068. /**
  34069. * @hidden
  34070. * Defines the actions happening just before a mesh is drawing.
  34071. */
  34072. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34073. /**
  34074. * @hidden
  34075. * Defines the actions happening just after a mesh has been drawn.
  34076. */
  34077. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34078. /**
  34079. * @hidden
  34080. * Defines the actions happening just after a rendering group has been drawn.
  34081. */
  34082. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34083. /**
  34084. * @hidden
  34085. * Defines the actions happening just after the active camera has been drawn.
  34086. */
  34087. _afterCameraDrawStage: Stage<CameraStageAction>;
  34088. /**
  34089. * @hidden
  34090. * Defines the actions happening just after a render target has been drawn.
  34091. */
  34092. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34093. /**
  34094. * @hidden
  34095. * Defines the actions happening just after rendering all cameras and computing intersections.
  34096. */
  34097. _afterRenderStage: Stage<SimpleStageAction>;
  34098. /**
  34099. * @hidden
  34100. * Defines the actions happening when a pointer move event happens.
  34101. */
  34102. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34103. /**
  34104. * @hidden
  34105. * Defines the actions happening when a pointer down event happens.
  34106. */
  34107. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34108. /**
  34109. * @hidden
  34110. * Defines the actions happening when a pointer up event happens.
  34111. */
  34112. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34113. /**
  34114. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34115. */
  34116. private geometriesByUniqueId;
  34117. /**
  34118. * Creates a new Scene
  34119. * @param engine defines the engine to use to render this scene
  34120. * @param options defines the scene options
  34121. */
  34122. constructor(engine: Engine, options?: SceneOptions);
  34123. /**
  34124. * Gets a string idenfifying the name of the class
  34125. * @returns "Scene" string
  34126. */
  34127. getClassName(): string;
  34128. private _defaultMeshCandidates;
  34129. /**
  34130. * @hidden
  34131. */
  34132. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34133. private _defaultSubMeshCandidates;
  34134. /**
  34135. * @hidden
  34136. */
  34137. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34138. /**
  34139. * Sets the default candidate providers for the scene.
  34140. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34141. * and getCollidingSubMeshCandidates to their default function
  34142. */
  34143. setDefaultCandidateProviders(): void;
  34144. /**
  34145. * Gets the mesh that is currently under the pointer
  34146. */
  34147. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34148. /**
  34149. * Gets or sets the current on-screen X position of the pointer
  34150. */
  34151. pointerX: number;
  34152. /**
  34153. * Gets or sets the current on-screen Y position of the pointer
  34154. */
  34155. pointerY: number;
  34156. /**
  34157. * Gets the cached material (ie. the latest rendered one)
  34158. * @returns the cached material
  34159. */
  34160. getCachedMaterial(): Nullable<Material>;
  34161. /**
  34162. * Gets the cached effect (ie. the latest rendered one)
  34163. * @returns the cached effect
  34164. */
  34165. getCachedEffect(): Nullable<Effect>;
  34166. /**
  34167. * Gets the cached visibility state (ie. the latest rendered one)
  34168. * @returns the cached visibility state
  34169. */
  34170. getCachedVisibility(): Nullable<number>;
  34171. /**
  34172. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34173. * @param material defines the current material
  34174. * @param effect defines the current effect
  34175. * @param visibility defines the current visibility state
  34176. * @returns true if one parameter is not cached
  34177. */
  34178. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34179. /**
  34180. * Gets the engine associated with the scene
  34181. * @returns an Engine
  34182. */
  34183. getEngine(): Engine;
  34184. /**
  34185. * Gets the total number of vertices rendered per frame
  34186. * @returns the total number of vertices rendered per frame
  34187. */
  34188. getTotalVertices(): number;
  34189. /**
  34190. * Gets the performance counter for total vertices
  34191. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34192. */
  34193. readonly totalVerticesPerfCounter: PerfCounter;
  34194. /**
  34195. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34196. * @returns the total number of active indices rendered per frame
  34197. */
  34198. getActiveIndices(): number;
  34199. /**
  34200. * Gets the performance counter for active indices
  34201. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34202. */
  34203. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34204. /**
  34205. * Gets the total number of active particles rendered per frame
  34206. * @returns the total number of active particles rendered per frame
  34207. */
  34208. getActiveParticles(): number;
  34209. /**
  34210. * Gets the performance counter for active particles
  34211. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34212. */
  34213. readonly activeParticlesPerfCounter: PerfCounter;
  34214. /**
  34215. * Gets the total number of active bones rendered per frame
  34216. * @returns the total number of active bones rendered per frame
  34217. */
  34218. getActiveBones(): number;
  34219. /**
  34220. * Gets the performance counter for active bones
  34221. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34222. */
  34223. readonly activeBonesPerfCounter: PerfCounter;
  34224. /**
  34225. * Gets the array of active meshes
  34226. * @returns an array of AbstractMesh
  34227. */
  34228. getActiveMeshes(): SmartArray<AbstractMesh>;
  34229. /**
  34230. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34231. * @returns a number
  34232. */
  34233. getAnimationRatio(): number;
  34234. /**
  34235. * Gets an unique Id for the current render phase
  34236. * @returns a number
  34237. */
  34238. getRenderId(): number;
  34239. /**
  34240. * Gets an unique Id for the current frame
  34241. * @returns a number
  34242. */
  34243. getFrameId(): number;
  34244. /** Call this function if you want to manually increment the render Id*/
  34245. incrementRenderId(): void;
  34246. private _createUbo;
  34247. /**
  34248. * Use this method to simulate a pointer move on a mesh
  34249. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34250. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34251. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34252. * @returns the current scene
  34253. */
  34254. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34255. /**
  34256. * Use this method to simulate a pointer down on a mesh
  34257. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34258. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34259. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34260. * @returns the current scene
  34261. */
  34262. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34263. /**
  34264. * Use this method to simulate a pointer up on a mesh
  34265. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34266. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34267. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34268. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34269. * @returns the current scene
  34270. */
  34271. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34272. /**
  34273. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34274. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34275. * @returns true if the pointer was captured
  34276. */
  34277. isPointerCaptured(pointerId?: number): boolean;
  34278. /**
  34279. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34280. * @param attachUp defines if you want to attach events to pointerup
  34281. * @param attachDown defines if you want to attach events to pointerdown
  34282. * @param attachMove defines if you want to attach events to pointermove
  34283. */
  34284. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34285. /** Detaches all event handlers*/
  34286. detachControl(): void;
  34287. /**
  34288. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34289. * Delay loaded resources are not taking in account
  34290. * @return true if all required resources are ready
  34291. */
  34292. isReady(): boolean;
  34293. /** Resets all cached information relative to material (including effect and visibility) */
  34294. resetCachedMaterial(): void;
  34295. /**
  34296. * Registers a function to be called before every frame render
  34297. * @param func defines the function to register
  34298. */
  34299. registerBeforeRender(func: () => void): void;
  34300. /**
  34301. * Unregisters a function called before every frame render
  34302. * @param func defines the function to unregister
  34303. */
  34304. unregisterBeforeRender(func: () => void): void;
  34305. /**
  34306. * Registers a function to be called after every frame render
  34307. * @param func defines the function to register
  34308. */
  34309. registerAfterRender(func: () => void): void;
  34310. /**
  34311. * Unregisters a function called after every frame render
  34312. * @param func defines the function to unregister
  34313. */
  34314. unregisterAfterRender(func: () => void): void;
  34315. private _executeOnceBeforeRender;
  34316. /**
  34317. * The provided function will run before render once and will be disposed afterwards.
  34318. * A timeout delay can be provided so that the function will be executed in N ms.
  34319. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34320. * @param func The function to be executed.
  34321. * @param timeout optional delay in ms
  34322. */
  34323. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34324. /** @hidden */
  34325. _addPendingData(data: any): void;
  34326. /** @hidden */
  34327. _removePendingData(data: any): void;
  34328. /**
  34329. * Returns the number of items waiting to be loaded
  34330. * @returns the number of items waiting to be loaded
  34331. */
  34332. getWaitingItemsCount(): number;
  34333. /**
  34334. * Returns a boolean indicating if the scene is still loading data
  34335. */
  34336. readonly isLoading: boolean;
  34337. /**
  34338. * Registers a function to be executed when the scene is ready
  34339. * @param {Function} func - the function to be executed
  34340. */
  34341. executeWhenReady(func: () => void): void;
  34342. /**
  34343. * Returns a promise that resolves when the scene is ready
  34344. * @returns A promise that resolves when the scene is ready
  34345. */
  34346. whenReadyAsync(): Promise<void>;
  34347. /** @hidden */
  34348. _checkIsReady(): void;
  34349. /**
  34350. * Gets all animatable attached to the scene
  34351. */
  34352. readonly animatables: Animatable[];
  34353. /**
  34354. * Resets the last animation time frame.
  34355. * Useful to override when animations start running when loading a scene for the first time.
  34356. */
  34357. resetLastAnimationTimeFrame(): void;
  34358. /**
  34359. * Gets the current view matrix
  34360. * @returns a Matrix
  34361. */
  34362. getViewMatrix(): Matrix;
  34363. /**
  34364. * Gets the current projection matrix
  34365. * @returns a Matrix
  34366. */
  34367. getProjectionMatrix(): Matrix;
  34368. /**
  34369. * Gets the current transform matrix
  34370. * @returns a Matrix made of View * Projection
  34371. */
  34372. getTransformMatrix(): Matrix;
  34373. /**
  34374. * Sets the current transform matrix
  34375. * @param viewL defines the View matrix to use
  34376. * @param projectionL defines the Projection matrix to use
  34377. * @param viewR defines the right View matrix to use (if provided)
  34378. * @param projectionR defines the right Projection matrix to use (if provided)
  34379. */
  34380. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34381. /**
  34382. * Gets the uniform buffer used to store scene data
  34383. * @returns a UniformBuffer
  34384. */
  34385. getSceneUniformBuffer(): UniformBuffer;
  34386. /**
  34387. * Gets an unique (relatively to the current scene) Id
  34388. * @returns an unique number for the scene
  34389. */
  34390. getUniqueId(): number;
  34391. /**
  34392. * Add a mesh to the list of scene's meshes
  34393. * @param newMesh defines the mesh to add
  34394. * @param recursive if all child meshes should also be added to the scene
  34395. */
  34396. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34397. /**
  34398. * Remove a mesh for the list of scene's meshes
  34399. * @param toRemove defines the mesh to remove
  34400. * @param recursive if all child meshes should also be removed from the scene
  34401. * @returns the index where the mesh was in the mesh list
  34402. */
  34403. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34404. /**
  34405. * Add a transform node to the list of scene's transform nodes
  34406. * @param newTransformNode defines the transform node to add
  34407. */
  34408. addTransformNode(newTransformNode: TransformNode): void;
  34409. /**
  34410. * Remove a transform node for the list of scene's transform nodes
  34411. * @param toRemove defines the transform node to remove
  34412. * @returns the index where the transform node was in the transform node list
  34413. */
  34414. removeTransformNode(toRemove: TransformNode): number;
  34415. /**
  34416. * Remove a skeleton for the list of scene's skeletons
  34417. * @param toRemove defines the skeleton to remove
  34418. * @returns the index where the skeleton was in the skeleton list
  34419. */
  34420. removeSkeleton(toRemove: Skeleton): number;
  34421. /**
  34422. * Remove a morph target for the list of scene's morph targets
  34423. * @param toRemove defines the morph target to remove
  34424. * @returns the index where the morph target was in the morph target list
  34425. */
  34426. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34427. /**
  34428. * Remove a light for the list of scene's lights
  34429. * @param toRemove defines the light to remove
  34430. * @returns the index where the light was in the light list
  34431. */
  34432. removeLight(toRemove: Light): number;
  34433. /**
  34434. * Remove a camera for the list of scene's cameras
  34435. * @param toRemove defines the camera to remove
  34436. * @returns the index where the camera was in the camera list
  34437. */
  34438. removeCamera(toRemove: Camera): number;
  34439. /**
  34440. * Remove a particle system for the list of scene's particle systems
  34441. * @param toRemove defines the particle system to remove
  34442. * @returns the index where the particle system was in the particle system list
  34443. */
  34444. removeParticleSystem(toRemove: IParticleSystem): number;
  34445. /**
  34446. * Remove a animation for the list of scene's animations
  34447. * @param toRemove defines the animation to remove
  34448. * @returns the index where the animation was in the animation list
  34449. */
  34450. removeAnimation(toRemove: Animation): number;
  34451. /**
  34452. * Will stop the animation of the given target
  34453. * @param target - the target
  34454. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34455. * @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)
  34456. */
  34457. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34458. /**
  34459. * Removes the given animation group from this scene.
  34460. * @param toRemove The animation group to remove
  34461. * @returns The index of the removed animation group
  34462. */
  34463. removeAnimationGroup(toRemove: AnimationGroup): number;
  34464. /**
  34465. * Removes the given multi-material from this scene.
  34466. * @param toRemove The multi-material to remove
  34467. * @returns The index of the removed multi-material
  34468. */
  34469. removeMultiMaterial(toRemove: MultiMaterial): number;
  34470. /**
  34471. * Removes the given material from this scene.
  34472. * @param toRemove The material to remove
  34473. * @returns The index of the removed material
  34474. */
  34475. removeMaterial(toRemove: Material): number;
  34476. /**
  34477. * Removes the given action manager from this scene.
  34478. * @param toRemove The action manager to remove
  34479. * @returns The index of the removed action manager
  34480. */
  34481. removeActionManager(toRemove: AbstractActionManager): number;
  34482. /**
  34483. * Removes the given texture from this scene.
  34484. * @param toRemove The texture to remove
  34485. * @returns The index of the removed texture
  34486. */
  34487. removeTexture(toRemove: BaseTexture): number;
  34488. /**
  34489. * Adds the given light to this scene
  34490. * @param newLight The light to add
  34491. */
  34492. addLight(newLight: Light): void;
  34493. /**
  34494. * Sorts the list list based on light priorities
  34495. */
  34496. sortLightsByPriority(): void;
  34497. /**
  34498. * Adds the given camera to this scene
  34499. * @param newCamera The camera to add
  34500. */
  34501. addCamera(newCamera: Camera): void;
  34502. /**
  34503. * Adds the given skeleton to this scene
  34504. * @param newSkeleton The skeleton to add
  34505. */
  34506. addSkeleton(newSkeleton: Skeleton): void;
  34507. /**
  34508. * Adds the given particle system to this scene
  34509. * @param newParticleSystem The particle system to add
  34510. */
  34511. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34512. /**
  34513. * Adds the given animation to this scene
  34514. * @param newAnimation The animation to add
  34515. */
  34516. addAnimation(newAnimation: Animation): void;
  34517. /**
  34518. * Adds the given animation group to this scene.
  34519. * @param newAnimationGroup The animation group to add
  34520. */
  34521. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34522. /**
  34523. * Adds the given multi-material to this scene
  34524. * @param newMultiMaterial The multi-material to add
  34525. */
  34526. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34527. /**
  34528. * Adds the given material to this scene
  34529. * @param newMaterial The material to add
  34530. */
  34531. addMaterial(newMaterial: Material): void;
  34532. /**
  34533. * Adds the given morph target to this scene
  34534. * @param newMorphTargetManager The morph target to add
  34535. */
  34536. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34537. /**
  34538. * Adds the given geometry to this scene
  34539. * @param newGeometry The geometry to add
  34540. */
  34541. addGeometry(newGeometry: Geometry): void;
  34542. /**
  34543. * Adds the given action manager to this scene
  34544. * @param newActionManager The action manager to add
  34545. */
  34546. addActionManager(newActionManager: AbstractActionManager): void;
  34547. /**
  34548. * Adds the given texture to this scene.
  34549. * @param newTexture The texture to add
  34550. */
  34551. addTexture(newTexture: BaseTexture): void;
  34552. /**
  34553. * Switch active camera
  34554. * @param newCamera defines the new active camera
  34555. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34556. */
  34557. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34558. /**
  34559. * sets the active camera of the scene using its ID
  34560. * @param id defines the camera's ID
  34561. * @return the new active camera or null if none found.
  34562. */
  34563. setActiveCameraByID(id: string): Nullable<Camera>;
  34564. /**
  34565. * sets the active camera of the scene using its name
  34566. * @param name defines the camera's name
  34567. * @returns the new active camera or null if none found.
  34568. */
  34569. setActiveCameraByName(name: string): Nullable<Camera>;
  34570. /**
  34571. * get an animation group using its name
  34572. * @param name defines the material's name
  34573. * @return the animation group or null if none found.
  34574. */
  34575. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34576. /**
  34577. * Get a material using its unique id
  34578. * @param uniqueId defines the material's unique id
  34579. * @return the material or null if none found.
  34580. */
  34581. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34582. /**
  34583. * get a material using its id
  34584. * @param id defines the material's ID
  34585. * @return the material or null if none found.
  34586. */
  34587. getMaterialByID(id: string): Nullable<Material>;
  34588. /**
  34589. * Gets a the last added material using a given id
  34590. * @param id defines the material's ID
  34591. * @return the last material with the given id or null if none found.
  34592. */
  34593. getLastMaterialByID(id: string): Nullable<Material>;
  34594. /**
  34595. * Gets a material using its name
  34596. * @param name defines the material's name
  34597. * @return the material or null if none found.
  34598. */
  34599. getMaterialByName(name: string): Nullable<Material>;
  34600. /**
  34601. * Get a texture using its unique id
  34602. * @param uniqueId defines the texture's unique id
  34603. * @return the texture or null if none found.
  34604. */
  34605. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34606. /**
  34607. * Gets a camera using its id
  34608. * @param id defines the id to look for
  34609. * @returns the camera or null if not found
  34610. */
  34611. getCameraByID(id: string): Nullable<Camera>;
  34612. /**
  34613. * Gets a camera using its unique id
  34614. * @param uniqueId defines the unique id to look for
  34615. * @returns the camera or null if not found
  34616. */
  34617. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34618. /**
  34619. * Gets a camera using its name
  34620. * @param name defines the camera's name
  34621. * @return the camera or null if none found.
  34622. */
  34623. getCameraByName(name: string): Nullable<Camera>;
  34624. /**
  34625. * Gets a bone using its id
  34626. * @param id defines the bone's id
  34627. * @return the bone or null if not found
  34628. */
  34629. getBoneByID(id: string): Nullable<Bone>;
  34630. /**
  34631. * Gets a bone using its id
  34632. * @param name defines the bone's name
  34633. * @return the bone or null if not found
  34634. */
  34635. getBoneByName(name: string): Nullable<Bone>;
  34636. /**
  34637. * Gets a light node using its name
  34638. * @param name defines the the light's name
  34639. * @return the light or null if none found.
  34640. */
  34641. getLightByName(name: string): Nullable<Light>;
  34642. /**
  34643. * Gets a light node using its id
  34644. * @param id defines the light's id
  34645. * @return the light or null if none found.
  34646. */
  34647. getLightByID(id: string): Nullable<Light>;
  34648. /**
  34649. * Gets a light node using its scene-generated unique ID
  34650. * @param uniqueId defines the light's unique id
  34651. * @return the light or null if none found.
  34652. */
  34653. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34654. /**
  34655. * Gets a particle system by id
  34656. * @param id defines the particle system id
  34657. * @return the corresponding system or null if none found
  34658. */
  34659. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34660. /**
  34661. * Gets a geometry using its ID
  34662. * @param id defines the geometry's id
  34663. * @return the geometry or null if none found.
  34664. */
  34665. getGeometryByID(id: string): Nullable<Geometry>;
  34666. private _getGeometryByUniqueID;
  34667. /**
  34668. * Add a new geometry to this scene
  34669. * @param geometry defines the geometry to be added to the scene.
  34670. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34671. * @return a boolean defining if the geometry was added or not
  34672. */
  34673. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34674. /**
  34675. * Removes an existing geometry
  34676. * @param geometry defines the geometry to be removed from the scene
  34677. * @return a boolean defining if the geometry was removed or not
  34678. */
  34679. removeGeometry(geometry: Geometry): boolean;
  34680. /**
  34681. * Gets the list of geometries attached to the scene
  34682. * @returns an array of Geometry
  34683. */
  34684. getGeometries(): Geometry[];
  34685. /**
  34686. * Gets the first added mesh found of a given ID
  34687. * @param id defines the id to search for
  34688. * @return the mesh found or null if not found at all
  34689. */
  34690. getMeshByID(id: string): Nullable<AbstractMesh>;
  34691. /**
  34692. * Gets a list of meshes using their id
  34693. * @param id defines the id to search for
  34694. * @returns a list of meshes
  34695. */
  34696. getMeshesByID(id: string): Array<AbstractMesh>;
  34697. /**
  34698. * Gets the first added transform node found of a given ID
  34699. * @param id defines the id to search for
  34700. * @return the found transform node or null if not found at all.
  34701. */
  34702. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34703. /**
  34704. * Gets a transform node with its auto-generated unique id
  34705. * @param uniqueId efines the unique id to search for
  34706. * @return the found transform node or null if not found at all.
  34707. */
  34708. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34709. /**
  34710. * Gets a list of transform nodes using their id
  34711. * @param id defines the id to search for
  34712. * @returns a list of transform nodes
  34713. */
  34714. getTransformNodesByID(id: string): Array<TransformNode>;
  34715. /**
  34716. * Gets a mesh with its auto-generated unique id
  34717. * @param uniqueId defines the unique id to search for
  34718. * @return the found mesh or null if not found at all.
  34719. */
  34720. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34721. /**
  34722. * Gets a the last added mesh using a given id
  34723. * @param id defines the id to search for
  34724. * @return the found mesh or null if not found at all.
  34725. */
  34726. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34727. /**
  34728. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34729. * @param id defines the id to search for
  34730. * @return the found node or null if not found at all
  34731. */
  34732. getLastEntryByID(id: string): Nullable<Node>;
  34733. /**
  34734. * Gets a node (Mesh, Camera, Light) using a given id
  34735. * @param id defines the id to search for
  34736. * @return the found node or null if not found at all
  34737. */
  34738. getNodeByID(id: string): Nullable<Node>;
  34739. /**
  34740. * Gets a node (Mesh, Camera, Light) using a given name
  34741. * @param name defines the name to search for
  34742. * @return the found node or null if not found at all.
  34743. */
  34744. getNodeByName(name: string): Nullable<Node>;
  34745. /**
  34746. * Gets a mesh using a given name
  34747. * @param name defines the name to search for
  34748. * @return the found mesh or null if not found at all.
  34749. */
  34750. getMeshByName(name: string): Nullable<AbstractMesh>;
  34751. /**
  34752. * Gets a transform node using a given name
  34753. * @param name defines the name to search for
  34754. * @return the found transform node or null if not found at all.
  34755. */
  34756. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34757. /**
  34758. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34759. * @param id defines the id to search for
  34760. * @return the found skeleton or null if not found at all.
  34761. */
  34762. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34763. /**
  34764. * Gets a skeleton using a given auto generated unique id
  34765. * @param uniqueId defines the unique id to search for
  34766. * @return the found skeleton or null if not found at all.
  34767. */
  34768. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34769. /**
  34770. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34771. * @param id defines the id to search for
  34772. * @return the found skeleton or null if not found at all.
  34773. */
  34774. getSkeletonById(id: string): Nullable<Skeleton>;
  34775. /**
  34776. * Gets a skeleton using a given name
  34777. * @param name defines the name to search for
  34778. * @return the found skeleton or null if not found at all.
  34779. */
  34780. getSkeletonByName(name: string): Nullable<Skeleton>;
  34781. /**
  34782. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34783. * @param id defines the id to search for
  34784. * @return the found morph target manager or null if not found at all.
  34785. */
  34786. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34787. /**
  34788. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34789. * @param id defines the id to search for
  34790. * @return the found morph target or null if not found at all.
  34791. */
  34792. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34793. /**
  34794. * Gets a boolean indicating if the given mesh is active
  34795. * @param mesh defines the mesh to look for
  34796. * @returns true if the mesh is in the active list
  34797. */
  34798. isActiveMesh(mesh: AbstractMesh): boolean;
  34799. /**
  34800. * Return a unique id as a string which can serve as an identifier for the scene
  34801. */
  34802. readonly uid: string;
  34803. /**
  34804. * Add an externaly attached data from its key.
  34805. * This method call will fail and return false, if such key already exists.
  34806. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34807. * @param key the unique key that identifies the data
  34808. * @param data the data object to associate to the key for this Engine instance
  34809. * @return true if no such key were already present and the data was added successfully, false otherwise
  34810. */
  34811. addExternalData<T>(key: string, data: T): boolean;
  34812. /**
  34813. * Get an externaly attached data from its key
  34814. * @param key the unique key that identifies the data
  34815. * @return the associated data, if present (can be null), or undefined if not present
  34816. */
  34817. getExternalData<T>(key: string): Nullable<T>;
  34818. /**
  34819. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34820. * @param key the unique key that identifies the data
  34821. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34822. * @return the associated data, can be null if the factory returned null.
  34823. */
  34824. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34825. /**
  34826. * Remove an externaly attached data from the Engine instance
  34827. * @param key the unique key that identifies the data
  34828. * @return true if the data was successfully removed, false if it doesn't exist
  34829. */
  34830. removeExternalData(key: string): boolean;
  34831. private _evaluateSubMesh;
  34832. /**
  34833. * Clear the processed materials smart array preventing retention point in material dispose.
  34834. */
  34835. freeProcessedMaterials(): void;
  34836. private _preventFreeActiveMeshesAndRenderingGroups;
  34837. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34838. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34839. * when disposing several meshes in a row or a hierarchy of meshes.
  34840. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34841. */
  34842. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34843. /**
  34844. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34845. */
  34846. freeActiveMeshes(): void;
  34847. /**
  34848. * Clear the info related to rendering groups preventing retention points during dispose.
  34849. */
  34850. freeRenderingGroups(): void;
  34851. /** @hidden */
  34852. _isInIntermediateRendering(): boolean;
  34853. /**
  34854. * Lambda returning the list of potentially active meshes.
  34855. */
  34856. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34857. /**
  34858. * Lambda returning the list of potentially active sub meshes.
  34859. */
  34860. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34861. /**
  34862. * Lambda returning the list of potentially intersecting sub meshes.
  34863. */
  34864. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34865. /**
  34866. * Lambda returning the list of potentially colliding sub meshes.
  34867. */
  34868. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34869. private _activeMeshesFrozen;
  34870. /**
  34871. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34872. * @returns the current scene
  34873. */
  34874. freezeActiveMeshes(): Scene;
  34875. /**
  34876. * Use this function to restart evaluating active meshes on every frame
  34877. * @returns the current scene
  34878. */
  34879. unfreezeActiveMeshes(): Scene;
  34880. private _evaluateActiveMeshes;
  34881. private _activeMesh;
  34882. /**
  34883. * Update the transform matrix to update from the current active camera
  34884. * @param force defines a boolean used to force the update even if cache is up to date
  34885. */
  34886. updateTransformMatrix(force?: boolean): void;
  34887. private _bindFrameBuffer;
  34888. /** @hidden */
  34889. _allowPostProcessClearColor: boolean;
  34890. /** @hidden */
  34891. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34892. private _processSubCameras;
  34893. private _checkIntersections;
  34894. /** @hidden */
  34895. _advancePhysicsEngineStep(step: number): void;
  34896. /**
  34897. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34898. */
  34899. getDeterministicFrameTime: () => number;
  34900. /** @hidden */
  34901. _animate(): void;
  34902. /** Execute all animations (for a frame) */
  34903. animate(): void;
  34904. /**
  34905. * Render the scene
  34906. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34907. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34908. */
  34909. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34910. /**
  34911. * Freeze all materials
  34912. * A frozen material will not be updatable but should be faster to render
  34913. */
  34914. freezeMaterials(): void;
  34915. /**
  34916. * Unfreeze all materials
  34917. * A frozen material will not be updatable but should be faster to render
  34918. */
  34919. unfreezeMaterials(): void;
  34920. /**
  34921. * Releases all held ressources
  34922. */
  34923. dispose(): void;
  34924. /**
  34925. * Gets if the scene is already disposed
  34926. */
  34927. readonly isDisposed: boolean;
  34928. /**
  34929. * Call this function to reduce memory footprint of the scene.
  34930. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34931. */
  34932. clearCachedVertexData(): void;
  34933. /**
  34934. * This function will remove the local cached buffer data from texture.
  34935. * It will save memory but will prevent the texture from being rebuilt
  34936. */
  34937. cleanCachedTextureBuffer(): void;
  34938. /**
  34939. * Get the world extend vectors with an optional filter
  34940. *
  34941. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34942. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34943. */
  34944. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34945. min: Vector3;
  34946. max: Vector3;
  34947. };
  34948. /**
  34949. * Creates a ray that can be used to pick in the scene
  34950. * @param x defines the x coordinate of the origin (on-screen)
  34951. * @param y defines the y coordinate of the origin (on-screen)
  34952. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34953. * @param camera defines the camera to use for the picking
  34954. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34955. * @returns a Ray
  34956. */
  34957. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34958. /**
  34959. * Creates a ray that can be used to pick in the scene
  34960. * @param x defines the x coordinate of the origin (on-screen)
  34961. * @param y defines the y coordinate of the origin (on-screen)
  34962. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34963. * @param result defines the ray where to store the picking ray
  34964. * @param camera defines the camera to use for the picking
  34965. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34966. * @returns the current scene
  34967. */
  34968. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34969. /**
  34970. * Creates a ray that can be used to pick in the scene
  34971. * @param x defines the x coordinate of the origin (on-screen)
  34972. * @param y defines the y coordinate of the origin (on-screen)
  34973. * @param camera defines the camera to use for the picking
  34974. * @returns a Ray
  34975. */
  34976. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34977. /**
  34978. * Creates a ray that can be used to pick in the scene
  34979. * @param x defines the x coordinate of the origin (on-screen)
  34980. * @param y defines the y coordinate of the origin (on-screen)
  34981. * @param result defines the ray where to store the picking ray
  34982. * @param camera defines the camera to use for the picking
  34983. * @returns the current scene
  34984. */
  34985. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34986. /** Launch a ray to try to pick a mesh in the scene
  34987. * @param x position on screen
  34988. * @param y position on screen
  34989. * @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
  34990. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34991. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34992. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34993. * @returns a PickingInfo
  34994. */
  34995. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34996. /** Use the given ray to pick a mesh in the scene
  34997. * @param ray The ray to use to pick meshes
  34998. * @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
  34999. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35000. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35001. * @returns a PickingInfo
  35002. */
  35003. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35004. /**
  35005. * Launch a ray to try to pick a mesh in the scene
  35006. * @param x X position on screen
  35007. * @param y Y position on screen
  35008. * @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
  35009. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35010. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35011. * @returns an array of PickingInfo
  35012. */
  35013. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35014. /**
  35015. * Launch a ray to try to pick a mesh in the scene
  35016. * @param ray Ray to use
  35017. * @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
  35018. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35019. * @returns an array of PickingInfo
  35020. */
  35021. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35022. /**
  35023. * Force the value of meshUnderPointer
  35024. * @param mesh defines the mesh to use
  35025. */
  35026. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35027. /**
  35028. * Gets the mesh under the pointer
  35029. * @returns a Mesh or null if no mesh is under the pointer
  35030. */
  35031. getPointerOverMesh(): Nullable<AbstractMesh>;
  35032. /** @hidden */
  35033. _rebuildGeometries(): void;
  35034. /** @hidden */
  35035. _rebuildTextures(): void;
  35036. private _getByTags;
  35037. /**
  35038. * Get a list of meshes by tags
  35039. * @param tagsQuery defines the tags query to use
  35040. * @param forEach defines a predicate used to filter results
  35041. * @returns an array of Mesh
  35042. */
  35043. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35044. /**
  35045. * Get a list of cameras by tags
  35046. * @param tagsQuery defines the tags query to use
  35047. * @param forEach defines a predicate used to filter results
  35048. * @returns an array of Camera
  35049. */
  35050. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35051. /**
  35052. * Get a list of lights by tags
  35053. * @param tagsQuery defines the tags query to use
  35054. * @param forEach defines a predicate used to filter results
  35055. * @returns an array of Light
  35056. */
  35057. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35058. /**
  35059. * Get a list of materials by tags
  35060. * @param tagsQuery defines the tags query to use
  35061. * @param forEach defines a predicate used to filter results
  35062. * @returns an array of Material
  35063. */
  35064. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35065. /**
  35066. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35067. * This allowed control for front to back rendering or reversly depending of the special needs.
  35068. *
  35069. * @param renderingGroupId The rendering group id corresponding to its index
  35070. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35071. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35072. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35073. */
  35074. 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;
  35075. /**
  35076. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35077. *
  35078. * @param renderingGroupId The rendering group id corresponding to its index
  35079. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35080. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35081. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35082. */
  35083. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35084. /**
  35085. * Gets the current auto clear configuration for one rendering group of the rendering
  35086. * manager.
  35087. * @param index the rendering group index to get the information for
  35088. * @returns The auto clear setup for the requested rendering group
  35089. */
  35090. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35091. private _blockMaterialDirtyMechanism;
  35092. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35093. blockMaterialDirtyMechanism: boolean;
  35094. /**
  35095. * Will flag all materials as dirty to trigger new shader compilation
  35096. * @param flag defines the flag used to specify which material part must be marked as dirty
  35097. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35098. */
  35099. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35100. /** @hidden */
  35101. _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;
  35102. /** @hidden */
  35103. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35104. /** @hidden */
  35105. _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;
  35106. /** @hidden */
  35107. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  35108. /** @hidden */
  35109. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35110. /** @hidden */
  35111. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35112. }
  35113. }
  35114. declare module BABYLON {
  35115. /**
  35116. * Set of assets to keep when moving a scene into an asset container.
  35117. */
  35118. export class KeepAssets extends AbstractScene {
  35119. }
  35120. /**
  35121. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  35122. */
  35123. export class InstantiatedEntries {
  35124. /**
  35125. * List of new root nodes (eg. nodes with no parent)
  35126. */
  35127. rootNodes: TransformNode[];
  35128. /**
  35129. * List of new skeletons
  35130. */
  35131. skeletons: Skeleton[];
  35132. /**
  35133. * List of new animation groups
  35134. */
  35135. animationGroups: AnimationGroup[];
  35136. }
  35137. /**
  35138. * Container with a set of assets that can be added or removed from a scene.
  35139. */
  35140. export class AssetContainer extends AbstractScene {
  35141. /**
  35142. * The scene the AssetContainer belongs to.
  35143. */
  35144. scene: Scene;
  35145. /**
  35146. * Instantiates an AssetContainer.
  35147. * @param scene The scene the AssetContainer belongs to.
  35148. */
  35149. constructor(scene: Scene);
  35150. /**
  35151. * Instantiate or clone all meshes and add the new ones to the scene.
  35152. * Skeletons and animation groups will all be cloned
  35153. * @param nameFunction defines an optional function used to get new names for clones
  35154. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  35155. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  35156. */
  35157. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  35158. /**
  35159. * Adds all the assets from the container to the scene.
  35160. */
  35161. addAllToScene(): void;
  35162. /**
  35163. * Removes all the assets in the container from the scene
  35164. */
  35165. removeAllFromScene(): void;
  35166. /**
  35167. * Disposes all the assets in the container
  35168. */
  35169. dispose(): void;
  35170. private _moveAssets;
  35171. /**
  35172. * Removes all the assets contained in the scene and adds them to the container.
  35173. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35174. */
  35175. moveAllFromScene(keepAssets?: KeepAssets): void;
  35176. /**
  35177. * 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.
  35178. * @returns the root mesh
  35179. */
  35180. createRootMesh(): Mesh;
  35181. }
  35182. }
  35183. declare module BABYLON {
  35184. /**
  35185. * Defines how the parser contract is defined.
  35186. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35187. */
  35188. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35189. /**
  35190. * Defines how the individual parser contract is defined.
  35191. * These parser can parse an individual asset
  35192. */
  35193. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35194. /**
  35195. * Base class of the scene acting as a container for the different elements composing a scene.
  35196. * This class is dynamically extended by the different components of the scene increasing
  35197. * flexibility and reducing coupling
  35198. */
  35199. export abstract class AbstractScene {
  35200. /**
  35201. * Stores the list of available parsers in the application.
  35202. */
  35203. private static _BabylonFileParsers;
  35204. /**
  35205. * Stores the list of available individual parsers in the application.
  35206. */
  35207. private static _IndividualBabylonFileParsers;
  35208. /**
  35209. * Adds a parser in the list of available ones
  35210. * @param name Defines the name of the parser
  35211. * @param parser Defines the parser to add
  35212. */
  35213. static AddParser(name: string, parser: BabylonFileParser): void;
  35214. /**
  35215. * Gets a general parser from the list of avaialble ones
  35216. * @param name Defines the name of the parser
  35217. * @returns the requested parser or null
  35218. */
  35219. static GetParser(name: string): Nullable<BabylonFileParser>;
  35220. /**
  35221. * Adds n individual parser in the list of available ones
  35222. * @param name Defines the name of the parser
  35223. * @param parser Defines the parser to add
  35224. */
  35225. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35226. /**
  35227. * Gets an individual parser from the list of avaialble ones
  35228. * @param name Defines the name of the parser
  35229. * @returns the requested parser or null
  35230. */
  35231. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35232. /**
  35233. * Parser json data and populate both a scene and its associated container object
  35234. * @param jsonData Defines the data to parse
  35235. * @param scene Defines the scene to parse the data for
  35236. * @param container Defines the container attached to the parsing sequence
  35237. * @param rootUrl Defines the root url of the data
  35238. */
  35239. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35240. /**
  35241. * Gets the list of root nodes (ie. nodes with no parent)
  35242. */
  35243. rootNodes: Node[];
  35244. /** All of the cameras added to this scene
  35245. * @see http://doc.babylonjs.com/babylon101/cameras
  35246. */
  35247. cameras: Camera[];
  35248. /**
  35249. * All of the lights added to this scene
  35250. * @see http://doc.babylonjs.com/babylon101/lights
  35251. */
  35252. lights: Light[];
  35253. /**
  35254. * All of the (abstract) meshes added to this scene
  35255. */
  35256. meshes: AbstractMesh[];
  35257. /**
  35258. * The list of skeletons added to the scene
  35259. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35260. */
  35261. skeletons: Skeleton[];
  35262. /**
  35263. * All of the particle systems added to this scene
  35264. * @see http://doc.babylonjs.com/babylon101/particles
  35265. */
  35266. particleSystems: IParticleSystem[];
  35267. /**
  35268. * Gets a list of Animations associated with the scene
  35269. */
  35270. animations: Animation[];
  35271. /**
  35272. * All of the animation groups added to this scene
  35273. * @see http://doc.babylonjs.com/how_to/group
  35274. */
  35275. animationGroups: AnimationGroup[];
  35276. /**
  35277. * All of the multi-materials added to this scene
  35278. * @see http://doc.babylonjs.com/how_to/multi_materials
  35279. */
  35280. multiMaterials: MultiMaterial[];
  35281. /**
  35282. * All of the materials added to this scene
  35283. * In the context of a Scene, it is not supposed to be modified manually.
  35284. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  35285. * Note also that the order of the Material within the array is not significant and might change.
  35286. * @see http://doc.babylonjs.com/babylon101/materials
  35287. */
  35288. materials: Material[];
  35289. /**
  35290. * The list of morph target managers added to the scene
  35291. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35292. */
  35293. morphTargetManagers: MorphTargetManager[];
  35294. /**
  35295. * The list of geometries used in the scene.
  35296. */
  35297. geometries: Geometry[];
  35298. /**
  35299. * All of the tranform nodes added to this scene
  35300. * In the context of a Scene, it is not supposed to be modified manually.
  35301. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35302. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35303. * @see http://doc.babylonjs.com/how_to/transformnode
  35304. */
  35305. transformNodes: TransformNode[];
  35306. /**
  35307. * ActionManagers available on the scene.
  35308. */
  35309. actionManagers: AbstractActionManager[];
  35310. /**
  35311. * Textures to keep.
  35312. */
  35313. textures: BaseTexture[];
  35314. /**
  35315. * Environment texture for the scene
  35316. */
  35317. environmentTexture: Nullable<BaseTexture>;
  35318. }
  35319. }
  35320. declare module BABYLON {
  35321. /**
  35322. * Interface used to define options for Sound class
  35323. */
  35324. export interface ISoundOptions {
  35325. /**
  35326. * Does the sound autoplay once loaded.
  35327. */
  35328. autoplay?: boolean;
  35329. /**
  35330. * Does the sound loop after it finishes playing once.
  35331. */
  35332. loop?: boolean;
  35333. /**
  35334. * Sound's volume
  35335. */
  35336. volume?: number;
  35337. /**
  35338. * Is it a spatial sound?
  35339. */
  35340. spatialSound?: boolean;
  35341. /**
  35342. * Maximum distance to hear that sound
  35343. */
  35344. maxDistance?: number;
  35345. /**
  35346. * Uses user defined attenuation function
  35347. */
  35348. useCustomAttenuation?: boolean;
  35349. /**
  35350. * Define the roll off factor of spatial sounds.
  35351. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35352. */
  35353. rolloffFactor?: number;
  35354. /**
  35355. * Define the reference distance the sound should be heard perfectly.
  35356. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35357. */
  35358. refDistance?: number;
  35359. /**
  35360. * Define the distance attenuation model the sound will follow.
  35361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35362. */
  35363. distanceModel?: string;
  35364. /**
  35365. * Defines the playback speed (1 by default)
  35366. */
  35367. playbackRate?: number;
  35368. /**
  35369. * Defines if the sound is from a streaming source
  35370. */
  35371. streaming?: boolean;
  35372. /**
  35373. * Defines an optional length (in seconds) inside the sound file
  35374. */
  35375. length?: number;
  35376. /**
  35377. * Defines an optional offset (in seconds) inside the sound file
  35378. */
  35379. offset?: number;
  35380. /**
  35381. * If true, URLs will not be required to state the audio file codec to use.
  35382. */
  35383. skipCodecCheck?: boolean;
  35384. }
  35385. /**
  35386. * Defines a sound that can be played in the application.
  35387. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35389. */
  35390. export class Sound {
  35391. /**
  35392. * The name of the sound in the scene.
  35393. */
  35394. name: string;
  35395. /**
  35396. * Does the sound autoplay once loaded.
  35397. */
  35398. autoplay: boolean;
  35399. /**
  35400. * Does the sound loop after it finishes playing once.
  35401. */
  35402. loop: boolean;
  35403. /**
  35404. * Does the sound use a custom attenuation curve to simulate the falloff
  35405. * happening when the source gets further away from the camera.
  35406. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35407. */
  35408. useCustomAttenuation: boolean;
  35409. /**
  35410. * The sound track id this sound belongs to.
  35411. */
  35412. soundTrackId: number;
  35413. /**
  35414. * Is this sound currently played.
  35415. */
  35416. isPlaying: boolean;
  35417. /**
  35418. * Is this sound currently paused.
  35419. */
  35420. isPaused: boolean;
  35421. /**
  35422. * Does this sound enables spatial sound.
  35423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35424. */
  35425. spatialSound: boolean;
  35426. /**
  35427. * Define the reference distance the sound should be heard perfectly.
  35428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35429. */
  35430. refDistance: number;
  35431. /**
  35432. * Define the roll off factor of spatial sounds.
  35433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35434. */
  35435. rolloffFactor: number;
  35436. /**
  35437. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35439. */
  35440. maxDistance: number;
  35441. /**
  35442. * Define the distance attenuation model the sound will follow.
  35443. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35444. */
  35445. distanceModel: string;
  35446. /**
  35447. * @hidden
  35448. * Back Compat
  35449. **/
  35450. onended: () => any;
  35451. /**
  35452. * Observable event when the current playing sound finishes.
  35453. */
  35454. onEndedObservable: Observable<Sound>;
  35455. private _panningModel;
  35456. private _playbackRate;
  35457. private _streaming;
  35458. private _startTime;
  35459. private _startOffset;
  35460. private _position;
  35461. /** @hidden */
  35462. _positionInEmitterSpace: boolean;
  35463. private _localDirection;
  35464. private _volume;
  35465. private _isReadyToPlay;
  35466. private _isDirectional;
  35467. private _readyToPlayCallback;
  35468. private _audioBuffer;
  35469. private _soundSource;
  35470. private _streamingSource;
  35471. private _soundPanner;
  35472. private _soundGain;
  35473. private _inputAudioNode;
  35474. private _outputAudioNode;
  35475. private _coneInnerAngle;
  35476. private _coneOuterAngle;
  35477. private _coneOuterGain;
  35478. private _scene;
  35479. private _connectedTransformNode;
  35480. private _customAttenuationFunction;
  35481. private _registerFunc;
  35482. private _isOutputConnected;
  35483. private _htmlAudioElement;
  35484. private _urlType;
  35485. private _length?;
  35486. private _offset?;
  35487. /** @hidden */
  35488. static _SceneComponentInitialization: (scene: Scene) => void;
  35489. /**
  35490. * Create a sound and attach it to a scene
  35491. * @param name Name of your sound
  35492. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35493. * @param scene defines the scene the sound belongs to
  35494. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35495. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35496. */
  35497. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35498. /**
  35499. * Release the sound and its associated resources
  35500. */
  35501. dispose(): void;
  35502. /**
  35503. * Gets if the sounds is ready to be played or not.
  35504. * @returns true if ready, otherwise false
  35505. */
  35506. isReady(): boolean;
  35507. private _soundLoaded;
  35508. /**
  35509. * Sets the data of the sound from an audiobuffer
  35510. * @param audioBuffer The audioBuffer containing the data
  35511. */
  35512. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35513. /**
  35514. * Updates the current sounds options such as maxdistance, loop...
  35515. * @param options A JSON object containing values named as the object properties
  35516. */
  35517. updateOptions(options: ISoundOptions): void;
  35518. private _createSpatialParameters;
  35519. private _updateSpatialParameters;
  35520. /**
  35521. * Switch the panning model to HRTF:
  35522. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35523. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35524. */
  35525. switchPanningModelToHRTF(): void;
  35526. /**
  35527. * Switch the panning model to Equal Power:
  35528. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35529. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35530. */
  35531. switchPanningModelToEqualPower(): void;
  35532. private _switchPanningModel;
  35533. /**
  35534. * Connect this sound to a sound track audio node like gain...
  35535. * @param soundTrackAudioNode the sound track audio node to connect to
  35536. */
  35537. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35538. /**
  35539. * Transform this sound into a directional source
  35540. * @param coneInnerAngle Size of the inner cone in degree
  35541. * @param coneOuterAngle Size of the outer cone in degree
  35542. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35543. */
  35544. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35545. /**
  35546. * Gets or sets the inner angle for the directional cone.
  35547. */
  35548. /**
  35549. * Gets or sets the inner angle for the directional cone.
  35550. */
  35551. directionalConeInnerAngle: number;
  35552. /**
  35553. * Gets or sets the outer angle for the directional cone.
  35554. */
  35555. /**
  35556. * Gets or sets the outer angle for the directional cone.
  35557. */
  35558. directionalConeOuterAngle: number;
  35559. /**
  35560. * Sets the position of the emitter if spatial sound is enabled
  35561. * @param newPosition Defines the new posisiton
  35562. */
  35563. setPosition(newPosition: Vector3): void;
  35564. /**
  35565. * Sets the local direction of the emitter if spatial sound is enabled
  35566. * @param newLocalDirection Defines the new local direction
  35567. */
  35568. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35569. private _updateDirection;
  35570. /** @hidden */
  35571. updateDistanceFromListener(): void;
  35572. /**
  35573. * Sets a new custom attenuation function for the sound.
  35574. * @param callback Defines the function used for the attenuation
  35575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35576. */
  35577. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35578. /**
  35579. * Play the sound
  35580. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35581. * @param offset (optional) Start the sound at a specific time in seconds
  35582. * @param length (optional) Sound duration (in seconds)
  35583. */
  35584. play(time?: number, offset?: number, length?: number): void;
  35585. private _onended;
  35586. /**
  35587. * Stop the sound
  35588. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35589. */
  35590. stop(time?: number): void;
  35591. /**
  35592. * Put the sound in pause
  35593. */
  35594. pause(): void;
  35595. /**
  35596. * Sets a dedicated volume for this sounds
  35597. * @param newVolume Define the new volume of the sound
  35598. * @param time Define time for gradual change to new volume
  35599. */
  35600. setVolume(newVolume: number, time?: number): void;
  35601. /**
  35602. * Set the sound play back rate
  35603. * @param newPlaybackRate Define the playback rate the sound should be played at
  35604. */
  35605. setPlaybackRate(newPlaybackRate: number): void;
  35606. /**
  35607. * Gets the volume of the sound.
  35608. * @returns the volume of the sound
  35609. */
  35610. getVolume(): number;
  35611. /**
  35612. * Attach the sound to a dedicated mesh
  35613. * @param transformNode The transform node to connect the sound with
  35614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35615. */
  35616. attachToMesh(transformNode: TransformNode): void;
  35617. /**
  35618. * Detach the sound from the previously attached mesh
  35619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35620. */
  35621. detachFromMesh(): void;
  35622. private _onRegisterAfterWorldMatrixUpdate;
  35623. /**
  35624. * Clone the current sound in the scene.
  35625. * @returns the new sound clone
  35626. */
  35627. clone(): Nullable<Sound>;
  35628. /**
  35629. * Gets the current underlying audio buffer containing the data
  35630. * @returns the audio buffer
  35631. */
  35632. getAudioBuffer(): Nullable<AudioBuffer>;
  35633. /**
  35634. * Serializes the Sound in a JSON representation
  35635. * @returns the JSON representation of the sound
  35636. */
  35637. serialize(): any;
  35638. /**
  35639. * Parse a JSON representation of a sound to innstantiate in a given scene
  35640. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35641. * @param scene Define the scene the new parsed sound should be created in
  35642. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35643. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35644. * @returns the newly parsed sound
  35645. */
  35646. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35647. }
  35648. }
  35649. declare module BABYLON {
  35650. /**
  35651. * This defines an action helpful to play a defined sound on a triggered action.
  35652. */
  35653. export class PlaySoundAction extends Action {
  35654. private _sound;
  35655. /**
  35656. * Instantiate the action
  35657. * @param triggerOptions defines the trigger options
  35658. * @param sound defines the sound to play
  35659. * @param condition defines the trigger related conditions
  35660. */
  35661. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35662. /** @hidden */
  35663. _prepare(): void;
  35664. /**
  35665. * Execute the action and play the sound.
  35666. */
  35667. execute(): void;
  35668. /**
  35669. * Serializes the actions and its related information.
  35670. * @param parent defines the object to serialize in
  35671. * @returns the serialized object
  35672. */
  35673. serialize(parent: any): any;
  35674. }
  35675. /**
  35676. * This defines an action helpful to stop a defined sound on a triggered action.
  35677. */
  35678. export class StopSoundAction extends Action {
  35679. private _sound;
  35680. /**
  35681. * Instantiate the action
  35682. * @param triggerOptions defines the trigger options
  35683. * @param sound defines the sound to stop
  35684. * @param condition defines the trigger related conditions
  35685. */
  35686. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35687. /** @hidden */
  35688. _prepare(): void;
  35689. /**
  35690. * Execute the action and stop the sound.
  35691. */
  35692. execute(): void;
  35693. /**
  35694. * Serializes the actions and its related information.
  35695. * @param parent defines the object to serialize in
  35696. * @returns the serialized object
  35697. */
  35698. serialize(parent: any): any;
  35699. }
  35700. }
  35701. declare module BABYLON {
  35702. /**
  35703. * This defines an action responsible to change the value of a property
  35704. * by interpolating between its current value and the newly set one once triggered.
  35705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35706. */
  35707. export class InterpolateValueAction extends Action {
  35708. /**
  35709. * Defines the path of the property where the value should be interpolated
  35710. */
  35711. propertyPath: string;
  35712. /**
  35713. * Defines the target value at the end of the interpolation.
  35714. */
  35715. value: any;
  35716. /**
  35717. * Defines the time it will take for the property to interpolate to the value.
  35718. */
  35719. duration: number;
  35720. /**
  35721. * Defines if the other scene animations should be stopped when the action has been triggered
  35722. */
  35723. stopOtherAnimations?: boolean;
  35724. /**
  35725. * Defines a callback raised once the interpolation animation has been done.
  35726. */
  35727. onInterpolationDone?: () => void;
  35728. /**
  35729. * Observable triggered once the interpolation animation has been done.
  35730. */
  35731. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35732. private _target;
  35733. private _effectiveTarget;
  35734. private _property;
  35735. /**
  35736. * Instantiate the action
  35737. * @param triggerOptions defines the trigger options
  35738. * @param target defines the object containing the value to interpolate
  35739. * @param propertyPath defines the path to the property in the target object
  35740. * @param value defines the target value at the end of the interpolation
  35741. * @param duration deines the time it will take for the property to interpolate to the value.
  35742. * @param condition defines the trigger related conditions
  35743. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35744. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35745. */
  35746. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35747. /** @hidden */
  35748. _prepare(): void;
  35749. /**
  35750. * Execute the action starts the value interpolation.
  35751. */
  35752. execute(): void;
  35753. /**
  35754. * Serializes the actions and its related information.
  35755. * @param parent defines the object to serialize in
  35756. * @returns the serialized object
  35757. */
  35758. serialize(parent: any): any;
  35759. }
  35760. }
  35761. declare module BABYLON {
  35762. /**
  35763. * Options allowed during the creation of a sound track.
  35764. */
  35765. export interface ISoundTrackOptions {
  35766. /**
  35767. * The volume the sound track should take during creation
  35768. */
  35769. volume?: number;
  35770. /**
  35771. * Define if the sound track is the main sound track of the scene
  35772. */
  35773. mainTrack?: boolean;
  35774. }
  35775. /**
  35776. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35777. * It will be also used in a future release to apply effects on a specific track.
  35778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35779. */
  35780. export class SoundTrack {
  35781. /**
  35782. * The unique identifier of the sound track in the scene.
  35783. */
  35784. id: number;
  35785. /**
  35786. * The list of sounds included in the sound track.
  35787. */
  35788. soundCollection: Array<Sound>;
  35789. private _outputAudioNode;
  35790. private _scene;
  35791. private _connectedAnalyser;
  35792. private _options;
  35793. private _isInitialized;
  35794. /**
  35795. * Creates a new sound track.
  35796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35797. * @param scene Define the scene the sound track belongs to
  35798. * @param options
  35799. */
  35800. constructor(scene: Scene, options?: ISoundTrackOptions);
  35801. private _initializeSoundTrackAudioGraph;
  35802. /**
  35803. * Release the sound track and its associated resources
  35804. */
  35805. dispose(): void;
  35806. /**
  35807. * Adds a sound to this sound track
  35808. * @param sound define the cound to add
  35809. * @ignoreNaming
  35810. */
  35811. AddSound(sound: Sound): void;
  35812. /**
  35813. * Removes a sound to this sound track
  35814. * @param sound define the cound to remove
  35815. * @ignoreNaming
  35816. */
  35817. RemoveSound(sound: Sound): void;
  35818. /**
  35819. * Set a global volume for the full sound track.
  35820. * @param newVolume Define the new volume of the sound track
  35821. */
  35822. setVolume(newVolume: number): void;
  35823. /**
  35824. * Switch the panning model to HRTF:
  35825. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35827. */
  35828. switchPanningModelToHRTF(): void;
  35829. /**
  35830. * Switch the panning model to Equal Power:
  35831. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35833. */
  35834. switchPanningModelToEqualPower(): void;
  35835. /**
  35836. * Connect the sound track to an audio analyser allowing some amazing
  35837. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35839. * @param analyser The analyser to connect to the engine
  35840. */
  35841. connectToAnalyser(analyser: Analyser): void;
  35842. }
  35843. }
  35844. declare module BABYLON {
  35845. interface AbstractScene {
  35846. /**
  35847. * The list of sounds used in the scene.
  35848. */
  35849. sounds: Nullable<Array<Sound>>;
  35850. }
  35851. interface Scene {
  35852. /**
  35853. * @hidden
  35854. * Backing field
  35855. */
  35856. _mainSoundTrack: SoundTrack;
  35857. /**
  35858. * The main sound track played by the scene.
  35859. * It cotains your primary collection of sounds.
  35860. */
  35861. mainSoundTrack: SoundTrack;
  35862. /**
  35863. * The list of sound tracks added to the scene
  35864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35865. */
  35866. soundTracks: Nullable<Array<SoundTrack>>;
  35867. /**
  35868. * Gets a sound using a given name
  35869. * @param name defines the name to search for
  35870. * @return the found sound or null if not found at all.
  35871. */
  35872. getSoundByName(name: string): Nullable<Sound>;
  35873. /**
  35874. * Gets or sets if audio support is enabled
  35875. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35876. */
  35877. audioEnabled: boolean;
  35878. /**
  35879. * Gets or sets if audio will be output to headphones
  35880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35881. */
  35882. headphone: boolean;
  35883. /**
  35884. * Gets or sets custom audio listener position provider
  35885. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35886. */
  35887. audioListenerPositionProvider: Nullable<() => Vector3>;
  35888. /**
  35889. * Gets or sets a refresh rate when using 3D audio positioning
  35890. */
  35891. audioPositioningRefreshRate: number;
  35892. }
  35893. /**
  35894. * Defines the sound scene component responsible to manage any sounds
  35895. * in a given scene.
  35896. */
  35897. export class AudioSceneComponent implements ISceneSerializableComponent {
  35898. /**
  35899. * The component name helpfull to identify the component in the list of scene components.
  35900. */
  35901. readonly name: string;
  35902. /**
  35903. * The scene the component belongs to.
  35904. */
  35905. scene: Scene;
  35906. private _audioEnabled;
  35907. /**
  35908. * Gets whether audio is enabled or not.
  35909. * Please use related enable/disable method to switch state.
  35910. */
  35911. readonly audioEnabled: boolean;
  35912. private _headphone;
  35913. /**
  35914. * Gets whether audio is outputing to headphone or not.
  35915. * Please use the according Switch methods to change output.
  35916. */
  35917. readonly headphone: boolean;
  35918. /**
  35919. * Gets or sets a refresh rate when using 3D audio positioning
  35920. */
  35921. audioPositioningRefreshRate: number;
  35922. private _audioListenerPositionProvider;
  35923. /**
  35924. * Gets the current audio listener position provider
  35925. */
  35926. /**
  35927. * Sets a custom listener position for all sounds in the scene
  35928. * By default, this is the position of the first active camera
  35929. */
  35930. audioListenerPositionProvider: Nullable<() => Vector3>;
  35931. /**
  35932. * Creates a new instance of the component for the given scene
  35933. * @param scene Defines the scene to register the component in
  35934. */
  35935. constructor(scene: Scene);
  35936. /**
  35937. * Registers the component in a given scene
  35938. */
  35939. register(): void;
  35940. /**
  35941. * Rebuilds the elements related to this component in case of
  35942. * context lost for instance.
  35943. */
  35944. rebuild(): void;
  35945. /**
  35946. * Serializes the component data to the specified json object
  35947. * @param serializationObject The object to serialize to
  35948. */
  35949. serialize(serializationObject: any): void;
  35950. /**
  35951. * Adds all the elements from the container to the scene
  35952. * @param container the container holding the elements
  35953. */
  35954. addFromContainer(container: AbstractScene): void;
  35955. /**
  35956. * Removes all the elements in the container from the scene
  35957. * @param container contains the elements to remove
  35958. * @param dispose if the removed element should be disposed (default: false)
  35959. */
  35960. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35961. /**
  35962. * Disposes the component and the associated ressources.
  35963. */
  35964. dispose(): void;
  35965. /**
  35966. * Disables audio in the associated scene.
  35967. */
  35968. disableAudio(): void;
  35969. /**
  35970. * Enables audio in the associated scene.
  35971. */
  35972. enableAudio(): void;
  35973. /**
  35974. * Switch audio to headphone output.
  35975. */
  35976. switchAudioModeForHeadphones(): void;
  35977. /**
  35978. * Switch audio to normal speakers.
  35979. */
  35980. switchAudioModeForNormalSpeakers(): void;
  35981. private _cachedCameraDirection;
  35982. private _cachedCameraPosition;
  35983. private _lastCheck;
  35984. private _afterRender;
  35985. }
  35986. }
  35987. declare module BABYLON {
  35988. /**
  35989. * Wraps one or more Sound objects and selects one with random weight for playback.
  35990. */
  35991. export class WeightedSound {
  35992. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35993. loop: boolean;
  35994. private _coneInnerAngle;
  35995. private _coneOuterAngle;
  35996. private _volume;
  35997. /** A Sound is currently playing. */
  35998. isPlaying: boolean;
  35999. /** A Sound is currently paused. */
  36000. isPaused: boolean;
  36001. private _sounds;
  36002. private _weights;
  36003. private _currentIndex?;
  36004. /**
  36005. * Creates a new WeightedSound from the list of sounds given.
  36006. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36007. * @param sounds Array of Sounds that will be selected from.
  36008. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36009. */
  36010. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36011. /**
  36012. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36013. */
  36014. /**
  36015. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36016. */
  36017. directionalConeInnerAngle: number;
  36018. /**
  36019. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36020. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36021. */
  36022. /**
  36023. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36024. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36025. */
  36026. directionalConeOuterAngle: number;
  36027. /**
  36028. * Playback volume.
  36029. */
  36030. /**
  36031. * Playback volume.
  36032. */
  36033. volume: number;
  36034. private _onended;
  36035. /**
  36036. * Suspend playback
  36037. */
  36038. pause(): void;
  36039. /**
  36040. * Stop playback
  36041. */
  36042. stop(): void;
  36043. /**
  36044. * Start playback.
  36045. * @param startOffset Position the clip head at a specific time in seconds.
  36046. */
  36047. play(startOffset?: number): void;
  36048. }
  36049. }
  36050. declare module BABYLON {
  36051. /**
  36052. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36053. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36054. */
  36055. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36056. /**
  36057. * Gets the name of the behavior.
  36058. */
  36059. readonly name: string;
  36060. /**
  36061. * The easing function used by animations
  36062. */
  36063. static EasingFunction: BackEase;
  36064. /**
  36065. * The easing mode used by animations
  36066. */
  36067. static EasingMode: number;
  36068. /**
  36069. * The duration of the animation, in milliseconds
  36070. */
  36071. transitionDuration: number;
  36072. /**
  36073. * Length of the distance animated by the transition when lower radius is reached
  36074. */
  36075. lowerRadiusTransitionRange: number;
  36076. /**
  36077. * Length of the distance animated by the transition when upper radius is reached
  36078. */
  36079. upperRadiusTransitionRange: number;
  36080. private _autoTransitionRange;
  36081. /**
  36082. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36083. */
  36084. /**
  36085. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36086. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36087. */
  36088. autoTransitionRange: boolean;
  36089. private _attachedCamera;
  36090. private _onAfterCheckInputsObserver;
  36091. private _onMeshTargetChangedObserver;
  36092. /**
  36093. * Initializes the behavior.
  36094. */
  36095. init(): void;
  36096. /**
  36097. * Attaches the behavior to its arc rotate camera.
  36098. * @param camera Defines the camera to attach the behavior to
  36099. */
  36100. attach(camera: ArcRotateCamera): void;
  36101. /**
  36102. * Detaches the behavior from its current arc rotate camera.
  36103. */
  36104. detach(): void;
  36105. private _radiusIsAnimating;
  36106. private _radiusBounceTransition;
  36107. private _animatables;
  36108. private _cachedWheelPrecision;
  36109. /**
  36110. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36111. * @param radiusLimit The limit to check against.
  36112. * @return Bool to indicate if at limit.
  36113. */
  36114. private _isRadiusAtLimit;
  36115. /**
  36116. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36117. * @param radiusDelta The delta by which to animate to. Can be negative.
  36118. */
  36119. private _applyBoundRadiusAnimation;
  36120. /**
  36121. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36122. */
  36123. protected _clearAnimationLocks(): void;
  36124. /**
  36125. * Stops and removes all animations that have been applied to the camera
  36126. */
  36127. stopAllAnimations(): void;
  36128. }
  36129. }
  36130. declare module BABYLON {
  36131. /**
  36132. * 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.
  36133. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36134. */
  36135. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36136. /**
  36137. * Gets the name of the behavior.
  36138. */
  36139. readonly name: string;
  36140. private _mode;
  36141. private _radiusScale;
  36142. private _positionScale;
  36143. private _defaultElevation;
  36144. private _elevationReturnTime;
  36145. private _elevationReturnWaitTime;
  36146. private _zoomStopsAnimation;
  36147. private _framingTime;
  36148. /**
  36149. * The easing function used by animations
  36150. */
  36151. static EasingFunction: ExponentialEase;
  36152. /**
  36153. * The easing mode used by animations
  36154. */
  36155. static EasingMode: number;
  36156. /**
  36157. * Sets the current mode used by the behavior
  36158. */
  36159. /**
  36160. * Gets current mode used by the behavior.
  36161. */
  36162. mode: number;
  36163. /**
  36164. * Sets the scale applied to the radius (1 by default)
  36165. */
  36166. /**
  36167. * Gets the scale applied to the radius
  36168. */
  36169. radiusScale: number;
  36170. /**
  36171. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36172. */
  36173. /**
  36174. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36175. */
  36176. positionScale: number;
  36177. /**
  36178. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36179. * behaviour is triggered, in radians.
  36180. */
  36181. /**
  36182. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36183. * behaviour is triggered, in radians.
  36184. */
  36185. defaultElevation: number;
  36186. /**
  36187. * Sets the time (in milliseconds) taken to return to the default beta position.
  36188. * Negative value indicates camera should not return to default.
  36189. */
  36190. /**
  36191. * Gets the time (in milliseconds) taken to return to the default beta position.
  36192. * Negative value indicates camera should not return to default.
  36193. */
  36194. elevationReturnTime: number;
  36195. /**
  36196. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36197. */
  36198. /**
  36199. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36200. */
  36201. elevationReturnWaitTime: number;
  36202. /**
  36203. * Sets the flag that indicates if user zooming should stop animation.
  36204. */
  36205. /**
  36206. * Gets the flag that indicates if user zooming should stop animation.
  36207. */
  36208. zoomStopsAnimation: boolean;
  36209. /**
  36210. * Sets the transition time when framing the mesh, in milliseconds
  36211. */
  36212. /**
  36213. * Gets the transition time when framing the mesh, in milliseconds
  36214. */
  36215. framingTime: number;
  36216. /**
  36217. * Define if the behavior should automatically change the configured
  36218. * camera limits and sensibilities.
  36219. */
  36220. autoCorrectCameraLimitsAndSensibility: boolean;
  36221. private _onPrePointerObservableObserver;
  36222. private _onAfterCheckInputsObserver;
  36223. private _onMeshTargetChangedObserver;
  36224. private _attachedCamera;
  36225. private _isPointerDown;
  36226. private _lastInteractionTime;
  36227. /**
  36228. * Initializes the behavior.
  36229. */
  36230. init(): void;
  36231. /**
  36232. * Attaches the behavior to its arc rotate camera.
  36233. * @param camera Defines the camera to attach the behavior to
  36234. */
  36235. attach(camera: ArcRotateCamera): void;
  36236. /**
  36237. * Detaches the behavior from its current arc rotate camera.
  36238. */
  36239. detach(): void;
  36240. private _animatables;
  36241. private _betaIsAnimating;
  36242. private _betaTransition;
  36243. private _radiusTransition;
  36244. private _vectorTransition;
  36245. /**
  36246. * Targets the given mesh and updates zoom level accordingly.
  36247. * @param mesh The mesh to target.
  36248. * @param radius Optional. If a cached radius position already exists, overrides default.
  36249. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36250. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36251. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36252. */
  36253. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36254. /**
  36255. * Targets the given mesh with its children and updates zoom level accordingly.
  36256. * @param mesh The mesh to target.
  36257. * @param radius Optional. If a cached radius position already exists, overrides default.
  36258. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36259. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36260. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36261. */
  36262. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36263. /**
  36264. * Targets the given meshes with their children and updates zoom level accordingly.
  36265. * @param meshes The mesh to target.
  36266. * @param radius Optional. If a cached radius position already exists, overrides default.
  36267. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36268. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36269. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36270. */
  36271. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36272. /**
  36273. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36274. * @param minimumWorld Determines the smaller position of the bounding box extend
  36275. * @param maximumWorld Determines the bigger position of the bounding box extend
  36276. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36277. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36278. */
  36279. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36280. /**
  36281. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36282. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36283. * frustum width.
  36284. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36285. * to fully enclose the mesh in the viewing frustum.
  36286. */
  36287. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36288. /**
  36289. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36290. * is automatically returned to its default position (expected to be above ground plane).
  36291. */
  36292. private _maintainCameraAboveGround;
  36293. /**
  36294. * Returns the frustum slope based on the canvas ratio and camera FOV
  36295. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36296. */
  36297. private _getFrustumSlope;
  36298. /**
  36299. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36300. */
  36301. private _clearAnimationLocks;
  36302. /**
  36303. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36304. */
  36305. private _applyUserInteraction;
  36306. /**
  36307. * Stops and removes all animations that have been applied to the camera
  36308. */
  36309. stopAllAnimations(): void;
  36310. /**
  36311. * Gets a value indicating if the user is moving the camera
  36312. */
  36313. readonly isUserIsMoving: boolean;
  36314. /**
  36315. * The camera can move all the way towards the mesh.
  36316. */
  36317. static IgnoreBoundsSizeMode: number;
  36318. /**
  36319. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36320. */
  36321. static FitFrustumSidesMode: number;
  36322. }
  36323. }
  36324. declare module BABYLON {
  36325. /**
  36326. * Base class for Camera Pointer Inputs.
  36327. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36328. * for example usage.
  36329. */
  36330. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36331. /**
  36332. * Defines the camera the input is attached to.
  36333. */
  36334. abstract camera: Camera;
  36335. /**
  36336. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36337. */
  36338. protected _altKey: boolean;
  36339. protected _ctrlKey: boolean;
  36340. protected _metaKey: boolean;
  36341. protected _shiftKey: boolean;
  36342. /**
  36343. * Which mouse buttons were pressed at time of last mouse event.
  36344. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36345. */
  36346. protected _buttonsPressed: number;
  36347. /**
  36348. * Defines the buttons associated with the input to handle camera move.
  36349. */
  36350. buttons: number[];
  36351. /**
  36352. * Attach the input controls to a specific dom element to get the input from.
  36353. * @param element Defines the element the controls should be listened from
  36354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36355. */
  36356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36357. /**
  36358. * Detach the current controls from the specified dom element.
  36359. * @param element Defines the element to stop listening the inputs from
  36360. */
  36361. detachControl(element: Nullable<HTMLElement>): void;
  36362. /**
  36363. * Gets the class name of the current input.
  36364. * @returns the class name
  36365. */
  36366. getClassName(): string;
  36367. /**
  36368. * Get the friendly name associated with the input class.
  36369. * @returns the input friendly name
  36370. */
  36371. getSimpleName(): string;
  36372. /**
  36373. * Called on pointer POINTERDOUBLETAP event.
  36374. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36375. */
  36376. protected onDoubleTap(type: string): void;
  36377. /**
  36378. * Called on pointer POINTERMOVE event if only a single touch is active.
  36379. * Override this method to provide functionality.
  36380. */
  36381. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36382. /**
  36383. * Called on pointer POINTERMOVE event if multiple touches are active.
  36384. * Override this method to provide functionality.
  36385. */
  36386. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36387. /**
  36388. * Called on JS contextmenu event.
  36389. * Override this method to provide functionality.
  36390. */
  36391. protected onContextMenu(evt: PointerEvent): void;
  36392. /**
  36393. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36394. * press.
  36395. * Override this method to provide functionality.
  36396. */
  36397. protected onButtonDown(evt: PointerEvent): void;
  36398. /**
  36399. * Called each time a new POINTERUP event occurs. Ie, for each button
  36400. * release.
  36401. * Override this method to provide functionality.
  36402. */
  36403. protected onButtonUp(evt: PointerEvent): void;
  36404. /**
  36405. * Called when window becomes inactive.
  36406. * Override this method to provide functionality.
  36407. */
  36408. protected onLostFocus(): void;
  36409. private _pointerInput;
  36410. private _observer;
  36411. private _onLostFocus;
  36412. private pointA;
  36413. private pointB;
  36414. }
  36415. }
  36416. declare module BABYLON {
  36417. /**
  36418. * Manage the pointers inputs to control an arc rotate camera.
  36419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36420. */
  36421. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36422. /**
  36423. * Defines the camera the input is attached to.
  36424. */
  36425. camera: ArcRotateCamera;
  36426. /**
  36427. * Gets the class name of the current input.
  36428. * @returns the class name
  36429. */
  36430. getClassName(): string;
  36431. /**
  36432. * Defines the buttons associated with the input to handle camera move.
  36433. */
  36434. buttons: number[];
  36435. /**
  36436. * Defines the pointer angular sensibility along the X axis or how fast is
  36437. * the camera rotating.
  36438. */
  36439. angularSensibilityX: number;
  36440. /**
  36441. * Defines the pointer angular sensibility along the Y axis or how fast is
  36442. * the camera rotating.
  36443. */
  36444. angularSensibilityY: number;
  36445. /**
  36446. * Defines the pointer pinch precision or how fast is the camera zooming.
  36447. */
  36448. pinchPrecision: number;
  36449. /**
  36450. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36451. * from 0.
  36452. * It defines the percentage of current camera.radius to use as delta when
  36453. * pinch zoom is used.
  36454. */
  36455. pinchDeltaPercentage: number;
  36456. /**
  36457. * Defines the pointer panning sensibility or how fast is the camera moving.
  36458. */
  36459. panningSensibility: number;
  36460. /**
  36461. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36462. */
  36463. multiTouchPanning: boolean;
  36464. /**
  36465. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36466. * zoom (pinch) through multitouch.
  36467. */
  36468. multiTouchPanAndZoom: boolean;
  36469. /**
  36470. * Revers pinch action direction.
  36471. */
  36472. pinchInwards: boolean;
  36473. private _isPanClick;
  36474. private _twoFingerActivityCount;
  36475. private _isPinching;
  36476. /**
  36477. * Called on pointer POINTERMOVE event if only a single touch is active.
  36478. */
  36479. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36480. /**
  36481. * Called on pointer POINTERDOUBLETAP event.
  36482. */
  36483. protected onDoubleTap(type: string): void;
  36484. /**
  36485. * Called on pointer POINTERMOVE event if multiple touches are active.
  36486. */
  36487. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36488. /**
  36489. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36490. * press.
  36491. */
  36492. protected onButtonDown(evt: PointerEvent): void;
  36493. /**
  36494. * Called each time a new POINTERUP event occurs. Ie, for each button
  36495. * release.
  36496. */
  36497. protected onButtonUp(evt: PointerEvent): void;
  36498. /**
  36499. * Called when window becomes inactive.
  36500. */
  36501. protected onLostFocus(): void;
  36502. }
  36503. }
  36504. declare module BABYLON {
  36505. /**
  36506. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36508. */
  36509. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36510. /**
  36511. * Defines the camera the input is attached to.
  36512. */
  36513. camera: ArcRotateCamera;
  36514. /**
  36515. * Defines the list of key codes associated with the up action (increase alpha)
  36516. */
  36517. keysUp: number[];
  36518. /**
  36519. * Defines the list of key codes associated with the down action (decrease alpha)
  36520. */
  36521. keysDown: number[];
  36522. /**
  36523. * Defines the list of key codes associated with the left action (increase beta)
  36524. */
  36525. keysLeft: number[];
  36526. /**
  36527. * Defines the list of key codes associated with the right action (decrease beta)
  36528. */
  36529. keysRight: number[];
  36530. /**
  36531. * Defines the list of key codes associated with the reset action.
  36532. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36533. */
  36534. keysReset: number[];
  36535. /**
  36536. * Defines the panning sensibility of the inputs.
  36537. * (How fast is the camera paning)
  36538. */
  36539. panningSensibility: number;
  36540. /**
  36541. * Defines the zooming sensibility of the inputs.
  36542. * (How fast is the camera zooming)
  36543. */
  36544. zoomingSensibility: number;
  36545. /**
  36546. * Defines wether maintaining the alt key down switch the movement mode from
  36547. * orientation to zoom.
  36548. */
  36549. useAltToZoom: boolean;
  36550. /**
  36551. * Rotation speed of the camera
  36552. */
  36553. angularSpeed: number;
  36554. private _keys;
  36555. private _ctrlPressed;
  36556. private _altPressed;
  36557. private _onCanvasBlurObserver;
  36558. private _onKeyboardObserver;
  36559. private _engine;
  36560. private _scene;
  36561. /**
  36562. * Attach the input controls to a specific dom element to get the input from.
  36563. * @param element Defines the element the controls should be listened from
  36564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36565. */
  36566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36567. /**
  36568. * Detach the current controls from the specified dom element.
  36569. * @param element Defines the element to stop listening the inputs from
  36570. */
  36571. detachControl(element: Nullable<HTMLElement>): void;
  36572. /**
  36573. * Update the current camera state depending on the inputs that have been used this frame.
  36574. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36575. */
  36576. checkInputs(): void;
  36577. /**
  36578. * Gets the class name of the current intput.
  36579. * @returns the class name
  36580. */
  36581. getClassName(): string;
  36582. /**
  36583. * Get the friendly name associated with the input class.
  36584. * @returns the input friendly name
  36585. */
  36586. getSimpleName(): string;
  36587. }
  36588. }
  36589. declare module BABYLON {
  36590. /**
  36591. * Manage the mouse wheel inputs to control an arc rotate camera.
  36592. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36593. */
  36594. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36595. /**
  36596. * Defines the camera the input is attached to.
  36597. */
  36598. camera: ArcRotateCamera;
  36599. /**
  36600. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36601. */
  36602. wheelPrecision: number;
  36603. /**
  36604. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36605. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36606. */
  36607. wheelDeltaPercentage: number;
  36608. private _wheel;
  36609. private _observer;
  36610. private computeDeltaFromMouseWheelLegacyEvent;
  36611. /**
  36612. * Attach the input controls to a specific dom element to get the input from.
  36613. * @param element Defines the element the controls should be listened from
  36614. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36615. */
  36616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36617. /**
  36618. * Detach the current controls from the specified dom element.
  36619. * @param element Defines the element to stop listening the inputs from
  36620. */
  36621. detachControl(element: Nullable<HTMLElement>): void;
  36622. /**
  36623. * Gets the class name of the current intput.
  36624. * @returns the class name
  36625. */
  36626. getClassName(): string;
  36627. /**
  36628. * Get the friendly name associated with the input class.
  36629. * @returns the input friendly name
  36630. */
  36631. getSimpleName(): string;
  36632. }
  36633. }
  36634. declare module BABYLON {
  36635. /**
  36636. * Default Inputs manager for the ArcRotateCamera.
  36637. * It groups all the default supported inputs for ease of use.
  36638. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36639. */
  36640. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36641. /**
  36642. * Instantiates a new ArcRotateCameraInputsManager.
  36643. * @param camera Defines the camera the inputs belong to
  36644. */
  36645. constructor(camera: ArcRotateCamera);
  36646. /**
  36647. * Add mouse wheel input support to the input manager.
  36648. * @returns the current input manager
  36649. */
  36650. addMouseWheel(): ArcRotateCameraInputsManager;
  36651. /**
  36652. * Add pointers input support to the input manager.
  36653. * @returns the current input manager
  36654. */
  36655. addPointers(): ArcRotateCameraInputsManager;
  36656. /**
  36657. * Add keyboard input support to the input manager.
  36658. * @returns the current input manager
  36659. */
  36660. addKeyboard(): ArcRotateCameraInputsManager;
  36661. }
  36662. }
  36663. declare module BABYLON {
  36664. /**
  36665. * This represents an orbital type of camera.
  36666. *
  36667. * 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.
  36668. * 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.
  36669. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36670. */
  36671. export class ArcRotateCamera extends TargetCamera {
  36672. /**
  36673. * Defines the rotation angle of the camera along the longitudinal axis.
  36674. */
  36675. alpha: number;
  36676. /**
  36677. * Defines the rotation angle of the camera along the latitudinal axis.
  36678. */
  36679. beta: number;
  36680. /**
  36681. * Defines the radius of the camera from it s target point.
  36682. */
  36683. radius: number;
  36684. protected _target: Vector3;
  36685. protected _targetHost: Nullable<AbstractMesh>;
  36686. /**
  36687. * Defines the target point of the camera.
  36688. * The camera looks towards it form the radius distance.
  36689. */
  36690. target: Vector3;
  36691. /**
  36692. * Define the current local position of the camera in the scene
  36693. */
  36694. position: Vector3;
  36695. protected _upVector: Vector3;
  36696. protected _upToYMatrix: Matrix;
  36697. protected _YToUpMatrix: Matrix;
  36698. /**
  36699. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36700. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36701. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36702. */
  36703. upVector: Vector3;
  36704. /**
  36705. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36706. */
  36707. setMatUp(): void;
  36708. /**
  36709. * Current inertia value on the longitudinal axis.
  36710. * The bigger this number the longer it will take for the camera to stop.
  36711. */
  36712. inertialAlphaOffset: number;
  36713. /**
  36714. * Current inertia value on the latitudinal axis.
  36715. * The bigger this number the longer it will take for the camera to stop.
  36716. */
  36717. inertialBetaOffset: number;
  36718. /**
  36719. * Current inertia value on the radius axis.
  36720. * The bigger this number the longer it will take for the camera to stop.
  36721. */
  36722. inertialRadiusOffset: number;
  36723. /**
  36724. * Minimum allowed angle on the longitudinal axis.
  36725. * This can help limiting how the Camera is able to move in the scene.
  36726. */
  36727. lowerAlphaLimit: Nullable<number>;
  36728. /**
  36729. * Maximum allowed angle on the longitudinal axis.
  36730. * This can help limiting how the Camera is able to move in the scene.
  36731. */
  36732. upperAlphaLimit: Nullable<number>;
  36733. /**
  36734. * Minimum allowed angle on the latitudinal axis.
  36735. * This can help limiting how the Camera is able to move in the scene.
  36736. */
  36737. lowerBetaLimit: number;
  36738. /**
  36739. * Maximum allowed angle on the latitudinal axis.
  36740. * This can help limiting how the Camera is able to move in the scene.
  36741. */
  36742. upperBetaLimit: number;
  36743. /**
  36744. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36745. * This can help limiting how the Camera is able to move in the scene.
  36746. */
  36747. lowerRadiusLimit: Nullable<number>;
  36748. /**
  36749. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36750. * This can help limiting how the Camera is able to move in the scene.
  36751. */
  36752. upperRadiusLimit: Nullable<number>;
  36753. /**
  36754. * Defines the current inertia value used during panning of the camera along the X axis.
  36755. */
  36756. inertialPanningX: number;
  36757. /**
  36758. * Defines the current inertia value used during panning of the camera along the Y axis.
  36759. */
  36760. inertialPanningY: number;
  36761. /**
  36762. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36763. * Basically if your fingers moves away from more than this distance you will be considered
  36764. * in pinch mode.
  36765. */
  36766. pinchToPanMaxDistance: number;
  36767. /**
  36768. * Defines the maximum distance the camera can pan.
  36769. * This could help keeping the cammera always in your scene.
  36770. */
  36771. panningDistanceLimit: Nullable<number>;
  36772. /**
  36773. * Defines the target of the camera before paning.
  36774. */
  36775. panningOriginTarget: Vector3;
  36776. /**
  36777. * Defines the value of the inertia used during panning.
  36778. * 0 would mean stop inertia and one would mean no decelleration at all.
  36779. */
  36780. panningInertia: number;
  36781. /**
  36782. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36783. */
  36784. angularSensibilityX: number;
  36785. /**
  36786. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36787. */
  36788. angularSensibilityY: number;
  36789. /**
  36790. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36791. */
  36792. pinchPrecision: number;
  36793. /**
  36794. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36795. * It will be used instead of pinchDeltaPrecision if different from 0.
  36796. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36797. */
  36798. pinchDeltaPercentage: number;
  36799. /**
  36800. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36801. */
  36802. panningSensibility: number;
  36803. /**
  36804. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36805. */
  36806. keysUp: number[];
  36807. /**
  36808. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36809. */
  36810. keysDown: number[];
  36811. /**
  36812. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36813. */
  36814. keysLeft: number[];
  36815. /**
  36816. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36817. */
  36818. keysRight: number[];
  36819. /**
  36820. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36821. */
  36822. wheelPrecision: number;
  36823. /**
  36824. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36825. * It will be used instead of pinchDeltaPrecision if different from 0.
  36826. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36827. */
  36828. wheelDeltaPercentage: number;
  36829. /**
  36830. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36831. */
  36832. zoomOnFactor: number;
  36833. /**
  36834. * Defines a screen offset for the camera position.
  36835. */
  36836. targetScreenOffset: Vector2;
  36837. /**
  36838. * Allows the camera to be completely reversed.
  36839. * If false the camera can not arrive upside down.
  36840. */
  36841. allowUpsideDown: boolean;
  36842. /**
  36843. * Define if double tap/click is used to restore the previously saved state of the camera.
  36844. */
  36845. useInputToRestoreState: boolean;
  36846. /** @hidden */
  36847. _viewMatrix: Matrix;
  36848. /** @hidden */
  36849. _useCtrlForPanning: boolean;
  36850. /** @hidden */
  36851. _panningMouseButton: number;
  36852. /**
  36853. * Defines the input associated to the camera.
  36854. */
  36855. inputs: ArcRotateCameraInputsManager;
  36856. /** @hidden */
  36857. _reset: () => void;
  36858. /**
  36859. * Defines the allowed panning axis.
  36860. */
  36861. panningAxis: Vector3;
  36862. protected _localDirection: Vector3;
  36863. protected _transformedDirection: Vector3;
  36864. private _bouncingBehavior;
  36865. /**
  36866. * Gets the bouncing behavior of the camera if it has been enabled.
  36867. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36868. */
  36869. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36870. /**
  36871. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36872. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36873. */
  36874. useBouncingBehavior: boolean;
  36875. private _framingBehavior;
  36876. /**
  36877. * Gets the framing behavior of the camera if it has been enabled.
  36878. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36879. */
  36880. readonly framingBehavior: Nullable<FramingBehavior>;
  36881. /**
  36882. * Defines if the framing behavior of the camera is enabled on the camera.
  36883. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36884. */
  36885. useFramingBehavior: boolean;
  36886. private _autoRotationBehavior;
  36887. /**
  36888. * Gets the auto rotation behavior of the camera if it has been enabled.
  36889. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36890. */
  36891. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36892. /**
  36893. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36894. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36895. */
  36896. useAutoRotationBehavior: boolean;
  36897. /**
  36898. * Observable triggered when the mesh target has been changed on the camera.
  36899. */
  36900. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36901. /**
  36902. * Event raised when the camera is colliding with a mesh.
  36903. */
  36904. onCollide: (collidedMesh: AbstractMesh) => void;
  36905. /**
  36906. * Defines whether the camera should check collision with the objects oh the scene.
  36907. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36908. */
  36909. checkCollisions: boolean;
  36910. /**
  36911. * Defines the collision radius of the camera.
  36912. * This simulates a sphere around the camera.
  36913. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36914. */
  36915. collisionRadius: Vector3;
  36916. protected _collider: Collider;
  36917. protected _previousPosition: Vector3;
  36918. protected _collisionVelocity: Vector3;
  36919. protected _newPosition: Vector3;
  36920. protected _previousAlpha: number;
  36921. protected _previousBeta: number;
  36922. protected _previousRadius: number;
  36923. protected _collisionTriggered: boolean;
  36924. protected _targetBoundingCenter: Nullable<Vector3>;
  36925. private _computationVector;
  36926. /**
  36927. * Instantiates a new ArcRotateCamera in a given scene
  36928. * @param name Defines the name of the camera
  36929. * @param alpha Defines the camera rotation along the logitudinal axis
  36930. * @param beta Defines the camera rotation along the latitudinal axis
  36931. * @param radius Defines the camera distance from its target
  36932. * @param target Defines the camera target
  36933. * @param scene Defines the scene the camera belongs to
  36934. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36935. */
  36936. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36937. /** @hidden */
  36938. _initCache(): void;
  36939. /** @hidden */
  36940. _updateCache(ignoreParentClass?: boolean): void;
  36941. protected _getTargetPosition(): Vector3;
  36942. private _storedAlpha;
  36943. private _storedBeta;
  36944. private _storedRadius;
  36945. private _storedTarget;
  36946. private _storedTargetScreenOffset;
  36947. /**
  36948. * Stores the current state of the camera (alpha, beta, radius and target)
  36949. * @returns the camera itself
  36950. */
  36951. storeState(): Camera;
  36952. /**
  36953. * @hidden
  36954. * Restored camera state. You must call storeState() first
  36955. */
  36956. _restoreStateValues(): boolean;
  36957. /** @hidden */
  36958. _isSynchronizedViewMatrix(): boolean;
  36959. /**
  36960. * Attached controls to the current camera.
  36961. * @param element Defines the element the controls should be listened from
  36962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36963. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36964. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36965. */
  36966. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36967. /**
  36968. * Detach the current controls from the camera.
  36969. * The camera will stop reacting to inputs.
  36970. * @param element Defines the element to stop listening the inputs from
  36971. */
  36972. detachControl(element: HTMLElement): void;
  36973. /** @hidden */
  36974. _checkInputs(): void;
  36975. protected _checkLimits(): void;
  36976. /**
  36977. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36978. */
  36979. rebuildAnglesAndRadius(): void;
  36980. /**
  36981. * Use a position to define the current camera related information like alpha, beta and radius
  36982. * @param position Defines the position to set the camera at
  36983. */
  36984. setPosition(position: Vector3): void;
  36985. /**
  36986. * Defines the target the camera should look at.
  36987. * This will automatically adapt alpha beta and radius to fit within the new target.
  36988. * @param target Defines the new target as a Vector or a mesh
  36989. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36990. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36991. */
  36992. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36993. /** @hidden */
  36994. _getViewMatrix(): Matrix;
  36995. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36996. /**
  36997. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36998. * @param meshes Defines the mesh to zoom on
  36999. * @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)
  37000. */
  37001. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37002. /**
  37003. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37004. * The target will be changed but the radius
  37005. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37006. * @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)
  37007. */
  37008. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37009. min: Vector3;
  37010. max: Vector3;
  37011. distance: number;
  37012. }, doNotUpdateMaxZ?: boolean): void;
  37013. /**
  37014. * @override
  37015. * Override Camera.createRigCamera
  37016. */
  37017. createRigCamera(name: string, cameraIndex: number): Camera;
  37018. /**
  37019. * @hidden
  37020. * @override
  37021. * Override Camera._updateRigCameras
  37022. */
  37023. _updateRigCameras(): void;
  37024. /**
  37025. * Destroy the camera and release the current resources hold by it.
  37026. */
  37027. dispose(): void;
  37028. /**
  37029. * Gets the current object class name.
  37030. * @return the class name
  37031. */
  37032. getClassName(): string;
  37033. }
  37034. }
  37035. declare module BABYLON {
  37036. /**
  37037. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37038. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37039. */
  37040. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37041. /**
  37042. * Gets the name of the behavior.
  37043. */
  37044. readonly name: string;
  37045. private _zoomStopsAnimation;
  37046. private _idleRotationSpeed;
  37047. private _idleRotationWaitTime;
  37048. private _idleRotationSpinupTime;
  37049. /**
  37050. * Sets the flag that indicates if user zooming should stop animation.
  37051. */
  37052. /**
  37053. * Gets the flag that indicates if user zooming should stop animation.
  37054. */
  37055. zoomStopsAnimation: boolean;
  37056. /**
  37057. * Sets the default speed at which the camera rotates around the model.
  37058. */
  37059. /**
  37060. * Gets the default speed at which the camera rotates around the model.
  37061. */
  37062. idleRotationSpeed: number;
  37063. /**
  37064. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37065. */
  37066. /**
  37067. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37068. */
  37069. idleRotationWaitTime: number;
  37070. /**
  37071. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37072. */
  37073. /**
  37074. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37075. */
  37076. idleRotationSpinupTime: number;
  37077. /**
  37078. * Gets a value indicating if the camera is currently rotating because of this behavior
  37079. */
  37080. readonly rotationInProgress: boolean;
  37081. private _onPrePointerObservableObserver;
  37082. private _onAfterCheckInputsObserver;
  37083. private _attachedCamera;
  37084. private _isPointerDown;
  37085. private _lastFrameTime;
  37086. private _lastInteractionTime;
  37087. private _cameraRotationSpeed;
  37088. /**
  37089. * Initializes the behavior.
  37090. */
  37091. init(): void;
  37092. /**
  37093. * Attaches the behavior to its arc rotate camera.
  37094. * @param camera Defines the camera to attach the behavior to
  37095. */
  37096. attach(camera: ArcRotateCamera): void;
  37097. /**
  37098. * Detaches the behavior from its current arc rotate camera.
  37099. */
  37100. detach(): void;
  37101. /**
  37102. * Returns true if user is scrolling.
  37103. * @return true if user is scrolling.
  37104. */
  37105. private _userIsZooming;
  37106. private _lastFrameRadius;
  37107. private _shouldAnimationStopForInteraction;
  37108. /**
  37109. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37110. */
  37111. private _applyUserInteraction;
  37112. private _userIsMoving;
  37113. }
  37114. }
  37115. declare module BABYLON {
  37116. /**
  37117. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37118. */
  37119. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37120. private ui;
  37121. /**
  37122. * The name of the behavior
  37123. */
  37124. name: string;
  37125. /**
  37126. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37127. */
  37128. distanceAwayFromFace: number;
  37129. /**
  37130. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37131. */
  37132. distanceAwayFromBottomOfFace: number;
  37133. private _faceVectors;
  37134. private _target;
  37135. private _scene;
  37136. private _onRenderObserver;
  37137. private _tmpMatrix;
  37138. private _tmpVector;
  37139. /**
  37140. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37141. * @param ui The transform node that should be attched to the mesh
  37142. */
  37143. constructor(ui: TransformNode);
  37144. /**
  37145. * Initializes the behavior
  37146. */
  37147. init(): void;
  37148. private _closestFace;
  37149. private _zeroVector;
  37150. private _lookAtTmpMatrix;
  37151. private _lookAtToRef;
  37152. /**
  37153. * Attaches the AttachToBoxBehavior to the passed in mesh
  37154. * @param target The mesh that the specified node will be attached to
  37155. */
  37156. attach(target: Mesh): void;
  37157. /**
  37158. * Detaches the behavior from the mesh
  37159. */
  37160. detach(): void;
  37161. }
  37162. }
  37163. declare module BABYLON {
  37164. /**
  37165. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37166. */
  37167. export class FadeInOutBehavior implements Behavior<Mesh> {
  37168. /**
  37169. * Time in milliseconds to delay before fading in (Default: 0)
  37170. */
  37171. delay: number;
  37172. /**
  37173. * Time in milliseconds for the mesh to fade in (Default: 300)
  37174. */
  37175. fadeInTime: number;
  37176. private _millisecondsPerFrame;
  37177. private _hovered;
  37178. private _hoverValue;
  37179. private _ownerNode;
  37180. /**
  37181. * Instatiates the FadeInOutBehavior
  37182. */
  37183. constructor();
  37184. /**
  37185. * The name of the behavior
  37186. */
  37187. readonly name: string;
  37188. /**
  37189. * Initializes the behavior
  37190. */
  37191. init(): void;
  37192. /**
  37193. * Attaches the fade behavior on the passed in mesh
  37194. * @param ownerNode The mesh that will be faded in/out once attached
  37195. */
  37196. attach(ownerNode: Mesh): void;
  37197. /**
  37198. * Detaches the behavior from the mesh
  37199. */
  37200. detach(): void;
  37201. /**
  37202. * Triggers the mesh to begin fading in or out
  37203. * @param value if the object should fade in or out (true to fade in)
  37204. */
  37205. fadeIn(value: boolean): void;
  37206. private _update;
  37207. private _setAllVisibility;
  37208. }
  37209. }
  37210. declare module BABYLON {
  37211. /**
  37212. * Class containing a set of static utilities functions for managing Pivots
  37213. * @hidden
  37214. */
  37215. export class PivotTools {
  37216. private static _PivotCached;
  37217. private static _OldPivotPoint;
  37218. private static _PivotTranslation;
  37219. private static _PivotTmpVector;
  37220. /** @hidden */
  37221. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37222. /** @hidden */
  37223. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37224. }
  37225. }
  37226. declare module BABYLON {
  37227. /**
  37228. * Class containing static functions to help procedurally build meshes
  37229. */
  37230. export class PlaneBuilder {
  37231. /**
  37232. * Creates a plane mesh
  37233. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37234. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37235. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37237. * * 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
  37238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37239. * @param name defines the name of the mesh
  37240. * @param options defines the options used to create the mesh
  37241. * @param scene defines the hosting scene
  37242. * @returns the plane mesh
  37243. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37244. */
  37245. static CreatePlane(name: string, options: {
  37246. size?: number;
  37247. width?: number;
  37248. height?: number;
  37249. sideOrientation?: number;
  37250. frontUVs?: Vector4;
  37251. backUVs?: Vector4;
  37252. updatable?: boolean;
  37253. sourcePlane?: Plane;
  37254. }, scene?: Nullable<Scene>): Mesh;
  37255. }
  37256. }
  37257. declare module BABYLON {
  37258. /**
  37259. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37260. */
  37261. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37262. private static _AnyMouseID;
  37263. /**
  37264. * Abstract mesh the behavior is set on
  37265. */
  37266. attachedNode: AbstractMesh;
  37267. private _dragPlane;
  37268. private _scene;
  37269. private _pointerObserver;
  37270. private _beforeRenderObserver;
  37271. private static _planeScene;
  37272. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37273. /**
  37274. * 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)
  37275. */
  37276. maxDragAngle: number;
  37277. /**
  37278. * @hidden
  37279. */
  37280. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37281. /**
  37282. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37283. */
  37284. currentDraggingPointerID: number;
  37285. /**
  37286. * The last position where the pointer hit the drag plane in world space
  37287. */
  37288. lastDragPosition: Vector3;
  37289. /**
  37290. * If the behavior is currently in a dragging state
  37291. */
  37292. dragging: boolean;
  37293. /**
  37294. * 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)
  37295. */
  37296. dragDeltaRatio: number;
  37297. /**
  37298. * If the drag plane orientation should be updated during the dragging (Default: true)
  37299. */
  37300. updateDragPlane: boolean;
  37301. private _debugMode;
  37302. private _moving;
  37303. /**
  37304. * Fires each time the attached mesh is dragged with the pointer
  37305. * * delta between last drag position and current drag position in world space
  37306. * * dragDistance along the drag axis
  37307. * * dragPlaneNormal normal of the current drag plane used during the drag
  37308. * * dragPlanePoint in world space where the drag intersects the drag plane
  37309. */
  37310. onDragObservable: Observable<{
  37311. delta: Vector3;
  37312. dragPlanePoint: Vector3;
  37313. dragPlaneNormal: Vector3;
  37314. dragDistance: number;
  37315. pointerId: number;
  37316. }>;
  37317. /**
  37318. * Fires each time a drag begins (eg. mouse down on mesh)
  37319. */
  37320. onDragStartObservable: Observable<{
  37321. dragPlanePoint: Vector3;
  37322. pointerId: number;
  37323. }>;
  37324. /**
  37325. * Fires each time a drag ends (eg. mouse release after drag)
  37326. */
  37327. onDragEndObservable: Observable<{
  37328. dragPlanePoint: Vector3;
  37329. pointerId: number;
  37330. }>;
  37331. /**
  37332. * If the attached mesh should be moved when dragged
  37333. */
  37334. moveAttached: boolean;
  37335. /**
  37336. * If the drag behavior will react to drag events (Default: true)
  37337. */
  37338. enabled: boolean;
  37339. /**
  37340. * If pointer events should start and release the drag (Default: true)
  37341. */
  37342. startAndReleaseDragOnPointerEvents: boolean;
  37343. /**
  37344. * If camera controls should be detached during the drag
  37345. */
  37346. detachCameraControls: boolean;
  37347. /**
  37348. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37349. */
  37350. useObjectOrienationForDragging: boolean;
  37351. private _options;
  37352. /**
  37353. * Creates a pointer drag behavior that can be attached to a mesh
  37354. * @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)
  37355. */
  37356. constructor(options?: {
  37357. dragAxis?: Vector3;
  37358. dragPlaneNormal?: Vector3;
  37359. });
  37360. /**
  37361. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37362. */
  37363. validateDrag: (targetPosition: Vector3) => boolean;
  37364. /**
  37365. * The name of the behavior
  37366. */
  37367. readonly name: string;
  37368. /**
  37369. * Initializes the behavior
  37370. */
  37371. init(): void;
  37372. private _tmpVector;
  37373. private _alternatePickedPoint;
  37374. private _worldDragAxis;
  37375. private _targetPosition;
  37376. private _attachedElement;
  37377. /**
  37378. * Attaches the drag behavior the passed in mesh
  37379. * @param ownerNode The mesh that will be dragged around once attached
  37380. * @param predicate Predicate to use for pick filtering
  37381. */
  37382. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37383. /**
  37384. * Force relase the drag action by code.
  37385. */
  37386. releaseDrag(): void;
  37387. private _startDragRay;
  37388. private _lastPointerRay;
  37389. /**
  37390. * Simulates the start of a pointer drag event on the behavior
  37391. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37392. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37393. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37394. */
  37395. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37396. private _startDrag;
  37397. private _dragDelta;
  37398. private _moveDrag;
  37399. private _pickWithRayOnDragPlane;
  37400. private _pointA;
  37401. private _pointB;
  37402. private _pointC;
  37403. private _lineA;
  37404. private _lineB;
  37405. private _localAxis;
  37406. private _lookAt;
  37407. private _updateDragPlanePosition;
  37408. /**
  37409. * Detaches the behavior from the mesh
  37410. */
  37411. detach(): void;
  37412. }
  37413. }
  37414. declare module BABYLON {
  37415. /**
  37416. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37417. */
  37418. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37419. private _dragBehaviorA;
  37420. private _dragBehaviorB;
  37421. private _startDistance;
  37422. private _initialScale;
  37423. private _targetScale;
  37424. private _ownerNode;
  37425. private _sceneRenderObserver;
  37426. /**
  37427. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37428. */
  37429. constructor();
  37430. /**
  37431. * The name of the behavior
  37432. */
  37433. readonly name: string;
  37434. /**
  37435. * Initializes the behavior
  37436. */
  37437. init(): void;
  37438. private _getCurrentDistance;
  37439. /**
  37440. * Attaches the scale behavior the passed in mesh
  37441. * @param ownerNode The mesh that will be scaled around once attached
  37442. */
  37443. attach(ownerNode: Mesh): void;
  37444. /**
  37445. * Detaches the behavior from the mesh
  37446. */
  37447. detach(): void;
  37448. }
  37449. }
  37450. declare module BABYLON {
  37451. /**
  37452. * 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
  37453. */
  37454. export class SixDofDragBehavior implements Behavior<Mesh> {
  37455. private static _virtualScene;
  37456. private _ownerNode;
  37457. private _sceneRenderObserver;
  37458. private _scene;
  37459. private _targetPosition;
  37460. private _virtualOriginMesh;
  37461. private _virtualDragMesh;
  37462. private _pointerObserver;
  37463. private _moving;
  37464. private _startingOrientation;
  37465. /**
  37466. * 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)
  37467. */
  37468. private zDragFactor;
  37469. /**
  37470. * If the object should rotate to face the drag origin
  37471. */
  37472. rotateDraggedObject: boolean;
  37473. /**
  37474. * If the behavior is currently in a dragging state
  37475. */
  37476. dragging: boolean;
  37477. /**
  37478. * 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)
  37479. */
  37480. dragDeltaRatio: number;
  37481. /**
  37482. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37483. */
  37484. currentDraggingPointerID: number;
  37485. /**
  37486. * If camera controls should be detached during the drag
  37487. */
  37488. detachCameraControls: boolean;
  37489. /**
  37490. * Fires each time a drag starts
  37491. */
  37492. onDragStartObservable: Observable<{}>;
  37493. /**
  37494. * Fires each time a drag ends (eg. mouse release after drag)
  37495. */
  37496. onDragEndObservable: Observable<{}>;
  37497. /**
  37498. * 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
  37499. */
  37500. constructor();
  37501. /**
  37502. * The name of the behavior
  37503. */
  37504. readonly name: string;
  37505. /**
  37506. * Initializes the behavior
  37507. */
  37508. init(): void;
  37509. /**
  37510. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37511. */
  37512. private readonly _pointerCamera;
  37513. /**
  37514. * Attaches the scale behavior the passed in mesh
  37515. * @param ownerNode The mesh that will be scaled around once attached
  37516. */
  37517. attach(ownerNode: Mesh): void;
  37518. /**
  37519. * Detaches the behavior from the mesh
  37520. */
  37521. detach(): void;
  37522. }
  37523. }
  37524. declare module BABYLON {
  37525. /**
  37526. * Class used to apply inverse kinematics to bones
  37527. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37528. */
  37529. export class BoneIKController {
  37530. private static _tmpVecs;
  37531. private static _tmpQuat;
  37532. private static _tmpMats;
  37533. /**
  37534. * Gets or sets the target mesh
  37535. */
  37536. targetMesh: AbstractMesh;
  37537. /** Gets or sets the mesh used as pole */
  37538. poleTargetMesh: AbstractMesh;
  37539. /**
  37540. * Gets or sets the bone used as pole
  37541. */
  37542. poleTargetBone: Nullable<Bone>;
  37543. /**
  37544. * Gets or sets the target position
  37545. */
  37546. targetPosition: Vector3;
  37547. /**
  37548. * Gets or sets the pole target position
  37549. */
  37550. poleTargetPosition: Vector3;
  37551. /**
  37552. * Gets or sets the pole target local offset
  37553. */
  37554. poleTargetLocalOffset: Vector3;
  37555. /**
  37556. * Gets or sets the pole angle
  37557. */
  37558. poleAngle: number;
  37559. /**
  37560. * Gets or sets the mesh associated with the controller
  37561. */
  37562. mesh: AbstractMesh;
  37563. /**
  37564. * 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)
  37565. */
  37566. slerpAmount: number;
  37567. private _bone1Quat;
  37568. private _bone1Mat;
  37569. private _bone2Ang;
  37570. private _bone1;
  37571. private _bone2;
  37572. private _bone1Length;
  37573. private _bone2Length;
  37574. private _maxAngle;
  37575. private _maxReach;
  37576. private _rightHandedSystem;
  37577. private _bendAxis;
  37578. private _slerping;
  37579. private _adjustRoll;
  37580. /**
  37581. * Gets or sets maximum allowed angle
  37582. */
  37583. maxAngle: number;
  37584. /**
  37585. * Creates a new BoneIKController
  37586. * @param mesh defines the mesh to control
  37587. * @param bone defines the bone to control
  37588. * @param options defines options to set up the controller
  37589. */
  37590. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37591. targetMesh?: AbstractMesh;
  37592. poleTargetMesh?: AbstractMesh;
  37593. poleTargetBone?: Bone;
  37594. poleTargetLocalOffset?: Vector3;
  37595. poleAngle?: number;
  37596. bendAxis?: Vector3;
  37597. maxAngle?: number;
  37598. slerpAmount?: number;
  37599. });
  37600. private _setMaxAngle;
  37601. /**
  37602. * Force the controller to update the bones
  37603. */
  37604. update(): void;
  37605. }
  37606. }
  37607. declare module BABYLON {
  37608. /**
  37609. * Class used to make a bone look toward a point in space
  37610. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37611. */
  37612. export class BoneLookController {
  37613. private static _tmpVecs;
  37614. private static _tmpQuat;
  37615. private static _tmpMats;
  37616. /**
  37617. * The target Vector3 that the bone will look at
  37618. */
  37619. target: Vector3;
  37620. /**
  37621. * The mesh that the bone is attached to
  37622. */
  37623. mesh: AbstractMesh;
  37624. /**
  37625. * The bone that will be looking to the target
  37626. */
  37627. bone: Bone;
  37628. /**
  37629. * The up axis of the coordinate system that is used when the bone is rotated
  37630. */
  37631. upAxis: Vector3;
  37632. /**
  37633. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37634. */
  37635. upAxisSpace: Space;
  37636. /**
  37637. * Used to make an adjustment to the yaw of the bone
  37638. */
  37639. adjustYaw: number;
  37640. /**
  37641. * Used to make an adjustment to the pitch of the bone
  37642. */
  37643. adjustPitch: number;
  37644. /**
  37645. * Used to make an adjustment to the roll of the bone
  37646. */
  37647. adjustRoll: number;
  37648. /**
  37649. * 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)
  37650. */
  37651. slerpAmount: number;
  37652. private _minYaw;
  37653. private _maxYaw;
  37654. private _minPitch;
  37655. private _maxPitch;
  37656. private _minYawSin;
  37657. private _minYawCos;
  37658. private _maxYawSin;
  37659. private _maxYawCos;
  37660. private _midYawConstraint;
  37661. private _minPitchTan;
  37662. private _maxPitchTan;
  37663. private _boneQuat;
  37664. private _slerping;
  37665. private _transformYawPitch;
  37666. private _transformYawPitchInv;
  37667. private _firstFrameSkipped;
  37668. private _yawRange;
  37669. private _fowardAxis;
  37670. /**
  37671. * Gets or sets the minimum yaw angle that the bone can look to
  37672. */
  37673. minYaw: number;
  37674. /**
  37675. * Gets or sets the maximum yaw angle that the bone can look to
  37676. */
  37677. maxYaw: number;
  37678. /**
  37679. * Gets or sets the minimum pitch angle that the bone can look to
  37680. */
  37681. minPitch: number;
  37682. /**
  37683. * Gets or sets the maximum pitch angle that the bone can look to
  37684. */
  37685. maxPitch: number;
  37686. /**
  37687. * Create a BoneLookController
  37688. * @param mesh the mesh that the bone belongs to
  37689. * @param bone the bone that will be looking to the target
  37690. * @param target the target Vector3 to look at
  37691. * @param options optional settings:
  37692. * * maxYaw: the maximum angle the bone will yaw to
  37693. * * minYaw: the minimum angle the bone will yaw to
  37694. * * maxPitch: the maximum angle the bone will pitch to
  37695. * * minPitch: the minimum angle the bone will yaw to
  37696. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37697. * * upAxis: the up axis of the coordinate system
  37698. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37699. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37700. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37701. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37702. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37703. * * adjustRoll: used to make an adjustment to the roll of the bone
  37704. **/
  37705. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37706. maxYaw?: number;
  37707. minYaw?: number;
  37708. maxPitch?: number;
  37709. minPitch?: number;
  37710. slerpAmount?: number;
  37711. upAxis?: Vector3;
  37712. upAxisSpace?: Space;
  37713. yawAxis?: Vector3;
  37714. pitchAxis?: Vector3;
  37715. adjustYaw?: number;
  37716. adjustPitch?: number;
  37717. adjustRoll?: number;
  37718. });
  37719. /**
  37720. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37721. */
  37722. update(): void;
  37723. private _getAngleDiff;
  37724. private _getAngleBetween;
  37725. private _isAngleBetween;
  37726. }
  37727. }
  37728. declare module BABYLON {
  37729. /**
  37730. * Manage the gamepad inputs to control an arc rotate camera.
  37731. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37732. */
  37733. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37734. /**
  37735. * Defines the camera the input is attached to.
  37736. */
  37737. camera: ArcRotateCamera;
  37738. /**
  37739. * Defines the gamepad the input is gathering event from.
  37740. */
  37741. gamepad: Nullable<Gamepad>;
  37742. /**
  37743. * Defines the gamepad rotation sensiblity.
  37744. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37745. */
  37746. gamepadRotationSensibility: number;
  37747. /**
  37748. * Defines the gamepad move sensiblity.
  37749. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37750. */
  37751. gamepadMoveSensibility: number;
  37752. private _yAxisScale;
  37753. /**
  37754. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  37755. */
  37756. invertYAxis: boolean;
  37757. private _onGamepadConnectedObserver;
  37758. private _onGamepadDisconnectedObserver;
  37759. /**
  37760. * Attach the input controls to a specific dom element to get the input from.
  37761. * @param element Defines the element the controls should be listened from
  37762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37763. */
  37764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37765. /**
  37766. * Detach the current controls from the specified dom element.
  37767. * @param element Defines the element to stop listening the inputs from
  37768. */
  37769. detachControl(element: Nullable<HTMLElement>): void;
  37770. /**
  37771. * Update the current camera state depending on the inputs that have been used this frame.
  37772. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37773. */
  37774. checkInputs(): void;
  37775. /**
  37776. * Gets the class name of the current intput.
  37777. * @returns the class name
  37778. */
  37779. getClassName(): string;
  37780. /**
  37781. * Get the friendly name associated with the input class.
  37782. * @returns the input friendly name
  37783. */
  37784. getSimpleName(): string;
  37785. }
  37786. }
  37787. declare module BABYLON {
  37788. interface ArcRotateCameraInputsManager {
  37789. /**
  37790. * Add orientation input support to the input manager.
  37791. * @returns the current input manager
  37792. */
  37793. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37794. }
  37795. /**
  37796. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37798. */
  37799. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37800. /**
  37801. * Defines the camera the input is attached to.
  37802. */
  37803. camera: ArcRotateCamera;
  37804. /**
  37805. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37806. */
  37807. alphaCorrection: number;
  37808. /**
  37809. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37810. */
  37811. gammaCorrection: number;
  37812. private _alpha;
  37813. private _gamma;
  37814. private _dirty;
  37815. private _deviceOrientationHandler;
  37816. /**
  37817. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37818. */
  37819. constructor();
  37820. /**
  37821. * Attach the input controls to a specific dom element to get the input from.
  37822. * @param element Defines the element the controls should be listened from
  37823. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37824. */
  37825. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37826. /** @hidden */
  37827. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37828. /**
  37829. * Update the current camera state depending on the inputs that have been used this frame.
  37830. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37831. */
  37832. checkInputs(): void;
  37833. /**
  37834. * Detach the current controls from the specified dom element.
  37835. * @param element Defines the element to stop listening the inputs from
  37836. */
  37837. detachControl(element: Nullable<HTMLElement>): void;
  37838. /**
  37839. * Gets the class name of the current intput.
  37840. * @returns the class name
  37841. */
  37842. getClassName(): string;
  37843. /**
  37844. * Get the friendly name associated with the input class.
  37845. * @returns the input friendly name
  37846. */
  37847. getSimpleName(): string;
  37848. }
  37849. }
  37850. declare module BABYLON {
  37851. /**
  37852. * Listen to mouse events to control the camera.
  37853. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37854. */
  37855. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37856. /**
  37857. * Defines the camera the input is attached to.
  37858. */
  37859. camera: FlyCamera;
  37860. /**
  37861. * Defines if touch is enabled. (Default is true.)
  37862. */
  37863. touchEnabled: boolean;
  37864. /**
  37865. * Defines the buttons associated with the input to handle camera rotation.
  37866. */
  37867. buttons: number[];
  37868. /**
  37869. * Assign buttons for Yaw control.
  37870. */
  37871. buttonsYaw: number[];
  37872. /**
  37873. * Assign buttons for Pitch control.
  37874. */
  37875. buttonsPitch: number[];
  37876. /**
  37877. * Assign buttons for Roll control.
  37878. */
  37879. buttonsRoll: number[];
  37880. /**
  37881. * Detect if any button is being pressed while mouse is moved.
  37882. * -1 = Mouse locked.
  37883. * 0 = Left button.
  37884. * 1 = Middle Button.
  37885. * 2 = Right Button.
  37886. */
  37887. activeButton: number;
  37888. /**
  37889. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37890. * Higher values reduce its sensitivity.
  37891. */
  37892. angularSensibility: number;
  37893. private _mousemoveCallback;
  37894. private _observer;
  37895. private _rollObserver;
  37896. private previousPosition;
  37897. private noPreventDefault;
  37898. private element;
  37899. /**
  37900. * Listen to mouse events to control the camera.
  37901. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37903. */
  37904. constructor(touchEnabled?: boolean);
  37905. /**
  37906. * Attach the mouse control to the HTML DOM element.
  37907. * @param element Defines the element that listens to the input events.
  37908. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37909. */
  37910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37911. /**
  37912. * Detach the current controls from the specified dom element.
  37913. * @param element Defines the element to stop listening the inputs from
  37914. */
  37915. detachControl(element: Nullable<HTMLElement>): void;
  37916. /**
  37917. * Gets the class name of the current input.
  37918. * @returns the class name.
  37919. */
  37920. getClassName(): string;
  37921. /**
  37922. * Get the friendly name associated with the input class.
  37923. * @returns the input's friendly name.
  37924. */
  37925. getSimpleName(): string;
  37926. private _pointerInput;
  37927. private _onMouseMove;
  37928. /**
  37929. * Rotate camera by mouse offset.
  37930. */
  37931. private rotateCamera;
  37932. }
  37933. }
  37934. declare module BABYLON {
  37935. /**
  37936. * Default Inputs manager for the FlyCamera.
  37937. * It groups all the default supported inputs for ease of use.
  37938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37939. */
  37940. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37941. /**
  37942. * Instantiates a new FlyCameraInputsManager.
  37943. * @param camera Defines the camera the inputs belong to.
  37944. */
  37945. constructor(camera: FlyCamera);
  37946. /**
  37947. * Add keyboard input support to the input manager.
  37948. * @returns the new FlyCameraKeyboardMoveInput().
  37949. */
  37950. addKeyboard(): FlyCameraInputsManager;
  37951. /**
  37952. * Add mouse input support to the input manager.
  37953. * @param touchEnabled Enable touch screen support.
  37954. * @returns the new FlyCameraMouseInput().
  37955. */
  37956. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37957. }
  37958. }
  37959. declare module BABYLON {
  37960. /**
  37961. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37962. * such as in a 3D Space Shooter or a Flight Simulator.
  37963. */
  37964. export class FlyCamera extends TargetCamera {
  37965. /**
  37966. * Define the collision ellipsoid of the camera.
  37967. * This is helpful for simulating a camera body, like a player's body.
  37968. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37969. */
  37970. ellipsoid: Vector3;
  37971. /**
  37972. * Define an offset for the position of the ellipsoid around the camera.
  37973. * This can be helpful if the camera is attached away from the player's body center,
  37974. * such as at its head.
  37975. */
  37976. ellipsoidOffset: Vector3;
  37977. /**
  37978. * Enable or disable collisions of the camera with the rest of the scene objects.
  37979. */
  37980. checkCollisions: boolean;
  37981. /**
  37982. * Enable or disable gravity on the camera.
  37983. */
  37984. applyGravity: boolean;
  37985. /**
  37986. * Define the current direction the camera is moving to.
  37987. */
  37988. cameraDirection: Vector3;
  37989. /**
  37990. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37991. * This overrides and empties cameraRotation.
  37992. */
  37993. rotationQuaternion: Quaternion;
  37994. /**
  37995. * Track Roll to maintain the wanted Rolling when looking around.
  37996. */
  37997. _trackRoll: number;
  37998. /**
  37999. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38000. */
  38001. rollCorrect: number;
  38002. /**
  38003. * Mimic a banked turn, Rolling the camera when Yawing.
  38004. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38005. */
  38006. bankedTurn: boolean;
  38007. /**
  38008. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38009. */
  38010. bankedTurnLimit: number;
  38011. /**
  38012. * Value of 0 disables the banked Roll.
  38013. * Value of 1 is equal to the Yaw angle in radians.
  38014. */
  38015. bankedTurnMultiplier: number;
  38016. /**
  38017. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38018. */
  38019. inputs: FlyCameraInputsManager;
  38020. /**
  38021. * Gets the input sensibility for mouse input.
  38022. * Higher values reduce sensitivity.
  38023. */
  38024. /**
  38025. * Sets the input sensibility for a mouse input.
  38026. * Higher values reduce sensitivity.
  38027. */
  38028. angularSensibility: number;
  38029. /**
  38030. * Get the keys for camera movement forward.
  38031. */
  38032. /**
  38033. * Set the keys for camera movement forward.
  38034. */
  38035. keysForward: number[];
  38036. /**
  38037. * Get the keys for camera movement backward.
  38038. */
  38039. keysBackward: number[];
  38040. /**
  38041. * Get the keys for camera movement up.
  38042. */
  38043. /**
  38044. * Set the keys for camera movement up.
  38045. */
  38046. keysUp: number[];
  38047. /**
  38048. * Get the keys for camera movement down.
  38049. */
  38050. /**
  38051. * Set the keys for camera movement down.
  38052. */
  38053. keysDown: number[];
  38054. /**
  38055. * Get the keys for camera movement left.
  38056. */
  38057. /**
  38058. * Set the keys for camera movement left.
  38059. */
  38060. keysLeft: number[];
  38061. /**
  38062. * Set the keys for camera movement right.
  38063. */
  38064. /**
  38065. * Set the keys for camera movement right.
  38066. */
  38067. keysRight: number[];
  38068. /**
  38069. * Event raised when the camera collides with a mesh in the scene.
  38070. */
  38071. onCollide: (collidedMesh: AbstractMesh) => void;
  38072. private _collider;
  38073. private _needMoveForGravity;
  38074. private _oldPosition;
  38075. private _diffPosition;
  38076. private _newPosition;
  38077. /** @hidden */
  38078. _localDirection: Vector3;
  38079. /** @hidden */
  38080. _transformedDirection: Vector3;
  38081. /**
  38082. * Instantiates a FlyCamera.
  38083. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38084. * such as in a 3D Space Shooter or a Flight Simulator.
  38085. * @param name Define the name of the camera in the scene.
  38086. * @param position Define the starting position of the camera in the scene.
  38087. * @param scene Define the scene the camera belongs to.
  38088. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38089. */
  38090. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38091. /**
  38092. * Attach a control to the HTML DOM element.
  38093. * @param element Defines the element that listens to the input events.
  38094. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38095. */
  38096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38097. /**
  38098. * Detach a control from the HTML DOM element.
  38099. * The camera will stop reacting to that input.
  38100. * @param element Defines the element that listens to the input events.
  38101. */
  38102. detachControl(element: HTMLElement): void;
  38103. private _collisionMask;
  38104. /**
  38105. * Get the mask that the camera ignores in collision events.
  38106. */
  38107. /**
  38108. * Set the mask that the camera ignores in collision events.
  38109. */
  38110. collisionMask: number;
  38111. /** @hidden */
  38112. _collideWithWorld(displacement: Vector3): void;
  38113. /** @hidden */
  38114. private _onCollisionPositionChange;
  38115. /** @hidden */
  38116. _checkInputs(): void;
  38117. /** @hidden */
  38118. _decideIfNeedsToMove(): boolean;
  38119. /** @hidden */
  38120. _updatePosition(): void;
  38121. /**
  38122. * Restore the Roll to its target value at the rate specified.
  38123. * @param rate - Higher means slower restoring.
  38124. * @hidden
  38125. */
  38126. restoreRoll(rate: number): void;
  38127. /**
  38128. * Destroy the camera and release the current resources held by it.
  38129. */
  38130. dispose(): void;
  38131. /**
  38132. * Get the current object class name.
  38133. * @returns the class name.
  38134. */
  38135. getClassName(): string;
  38136. }
  38137. }
  38138. declare module BABYLON {
  38139. /**
  38140. * Listen to keyboard events to control the camera.
  38141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38142. */
  38143. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38144. /**
  38145. * Defines the camera the input is attached to.
  38146. */
  38147. camera: FlyCamera;
  38148. /**
  38149. * The list of keyboard keys used to control the forward move of the camera.
  38150. */
  38151. keysForward: number[];
  38152. /**
  38153. * The list of keyboard keys used to control the backward move of the camera.
  38154. */
  38155. keysBackward: number[];
  38156. /**
  38157. * The list of keyboard keys used to control the forward move of the camera.
  38158. */
  38159. keysUp: number[];
  38160. /**
  38161. * The list of keyboard keys used to control the backward move of the camera.
  38162. */
  38163. keysDown: number[];
  38164. /**
  38165. * The list of keyboard keys used to control the right strafe move of the camera.
  38166. */
  38167. keysRight: number[];
  38168. /**
  38169. * The list of keyboard keys used to control the left strafe move of the camera.
  38170. */
  38171. keysLeft: number[];
  38172. private _keys;
  38173. private _onCanvasBlurObserver;
  38174. private _onKeyboardObserver;
  38175. private _engine;
  38176. private _scene;
  38177. /**
  38178. * Attach the input controls to a specific dom element to get the input from.
  38179. * @param element Defines the element the controls should be listened from
  38180. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38181. */
  38182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38183. /**
  38184. * Detach the current controls from the specified dom element.
  38185. * @param element Defines the element to stop listening the inputs from
  38186. */
  38187. detachControl(element: Nullable<HTMLElement>): void;
  38188. /**
  38189. * Gets the class name of the current intput.
  38190. * @returns the class name
  38191. */
  38192. getClassName(): string;
  38193. /** @hidden */
  38194. _onLostFocus(e: FocusEvent): void;
  38195. /**
  38196. * Get the friendly name associated with the input class.
  38197. * @returns the input friendly name
  38198. */
  38199. getSimpleName(): string;
  38200. /**
  38201. * Update the current camera state depending on the inputs that have been used this frame.
  38202. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38203. */
  38204. checkInputs(): void;
  38205. }
  38206. }
  38207. declare module BABYLON {
  38208. /**
  38209. * Manage the mouse wheel inputs to control a follow camera.
  38210. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38211. */
  38212. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38213. /**
  38214. * Defines the camera the input is attached to.
  38215. */
  38216. camera: FollowCamera;
  38217. /**
  38218. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38219. */
  38220. axisControlRadius: boolean;
  38221. /**
  38222. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38223. */
  38224. axisControlHeight: boolean;
  38225. /**
  38226. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38227. */
  38228. axisControlRotation: boolean;
  38229. /**
  38230. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38231. * relation to mouseWheel events.
  38232. */
  38233. wheelPrecision: number;
  38234. /**
  38235. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38236. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38237. */
  38238. wheelDeltaPercentage: number;
  38239. private _wheel;
  38240. private _observer;
  38241. /**
  38242. * Attach the input controls to a specific dom element to get the input from.
  38243. * @param element Defines the element the controls should be listened from
  38244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38245. */
  38246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38247. /**
  38248. * Detach the current controls from the specified dom element.
  38249. * @param element Defines the element to stop listening the inputs from
  38250. */
  38251. detachControl(element: Nullable<HTMLElement>): void;
  38252. /**
  38253. * Gets the class name of the current intput.
  38254. * @returns the class name
  38255. */
  38256. getClassName(): string;
  38257. /**
  38258. * Get the friendly name associated with the input class.
  38259. * @returns the input friendly name
  38260. */
  38261. getSimpleName(): string;
  38262. }
  38263. }
  38264. declare module BABYLON {
  38265. /**
  38266. * Manage the pointers inputs to control an follow camera.
  38267. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38268. */
  38269. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38270. /**
  38271. * Defines the camera the input is attached to.
  38272. */
  38273. camera: FollowCamera;
  38274. /**
  38275. * Gets the class name of the current input.
  38276. * @returns the class name
  38277. */
  38278. getClassName(): string;
  38279. /**
  38280. * Defines the pointer angular sensibility along the X axis or how fast is
  38281. * the camera rotating.
  38282. * A negative number will reverse the axis direction.
  38283. */
  38284. angularSensibilityX: number;
  38285. /**
  38286. * Defines the pointer angular sensibility along the Y axis or how fast is
  38287. * the camera rotating.
  38288. * A negative number will reverse the axis direction.
  38289. */
  38290. angularSensibilityY: number;
  38291. /**
  38292. * Defines the pointer pinch precision or how fast is the camera zooming.
  38293. * A negative number will reverse the axis direction.
  38294. */
  38295. pinchPrecision: number;
  38296. /**
  38297. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38298. * from 0.
  38299. * It defines the percentage of current camera.radius to use as delta when
  38300. * pinch zoom is used.
  38301. */
  38302. pinchDeltaPercentage: number;
  38303. /**
  38304. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38305. */
  38306. axisXControlRadius: boolean;
  38307. /**
  38308. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38309. */
  38310. axisXControlHeight: boolean;
  38311. /**
  38312. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38313. */
  38314. axisXControlRotation: boolean;
  38315. /**
  38316. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38317. */
  38318. axisYControlRadius: boolean;
  38319. /**
  38320. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38321. */
  38322. axisYControlHeight: boolean;
  38323. /**
  38324. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38325. */
  38326. axisYControlRotation: boolean;
  38327. /**
  38328. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38329. */
  38330. axisPinchControlRadius: boolean;
  38331. /**
  38332. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38333. */
  38334. axisPinchControlHeight: boolean;
  38335. /**
  38336. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38337. */
  38338. axisPinchControlRotation: boolean;
  38339. /**
  38340. * Log error messages if basic misconfiguration has occurred.
  38341. */
  38342. warningEnable: boolean;
  38343. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38344. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38345. private _warningCounter;
  38346. private _warning;
  38347. }
  38348. }
  38349. declare module BABYLON {
  38350. /**
  38351. * Default Inputs manager for the FollowCamera.
  38352. * It groups all the default supported inputs for ease of use.
  38353. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38354. */
  38355. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38356. /**
  38357. * Instantiates a new FollowCameraInputsManager.
  38358. * @param camera Defines the camera the inputs belong to
  38359. */
  38360. constructor(camera: FollowCamera);
  38361. /**
  38362. * Add keyboard input support to the input manager.
  38363. * @returns the current input manager
  38364. */
  38365. addKeyboard(): FollowCameraInputsManager;
  38366. /**
  38367. * Add mouse wheel input support to the input manager.
  38368. * @returns the current input manager
  38369. */
  38370. addMouseWheel(): FollowCameraInputsManager;
  38371. /**
  38372. * Add pointers input support to the input manager.
  38373. * @returns the current input manager
  38374. */
  38375. addPointers(): FollowCameraInputsManager;
  38376. /**
  38377. * Add orientation input support to the input manager.
  38378. * @returns the current input manager
  38379. */
  38380. addVRDeviceOrientation(): FollowCameraInputsManager;
  38381. }
  38382. }
  38383. declare module BABYLON {
  38384. /**
  38385. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38386. * an arc rotate version arcFollowCamera are available.
  38387. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38388. */
  38389. export class FollowCamera extends TargetCamera {
  38390. /**
  38391. * Distance the follow camera should follow an object at
  38392. */
  38393. radius: number;
  38394. /**
  38395. * Minimum allowed distance of the camera to the axis of rotation
  38396. * (The camera can not get closer).
  38397. * This can help limiting how the Camera is able to move in the scene.
  38398. */
  38399. lowerRadiusLimit: Nullable<number>;
  38400. /**
  38401. * Maximum allowed distance of the camera to the axis of rotation
  38402. * (The camera can not get further).
  38403. * This can help limiting how the Camera is able to move in the scene.
  38404. */
  38405. upperRadiusLimit: Nullable<number>;
  38406. /**
  38407. * Define a rotation offset between the camera and the object it follows
  38408. */
  38409. rotationOffset: number;
  38410. /**
  38411. * Minimum allowed angle to camera position relative to target object.
  38412. * This can help limiting how the Camera is able to move in the scene.
  38413. */
  38414. lowerRotationOffsetLimit: Nullable<number>;
  38415. /**
  38416. * Maximum allowed angle to camera position relative to target object.
  38417. * This can help limiting how the Camera is able to move in the scene.
  38418. */
  38419. upperRotationOffsetLimit: Nullable<number>;
  38420. /**
  38421. * Define a height offset between the camera and the object it follows.
  38422. * It can help following an object from the top (like a car chaing a plane)
  38423. */
  38424. heightOffset: number;
  38425. /**
  38426. * Minimum allowed height of camera position relative to target object.
  38427. * This can help limiting how the Camera is able to move in the scene.
  38428. */
  38429. lowerHeightOffsetLimit: Nullable<number>;
  38430. /**
  38431. * Maximum allowed height of camera position relative to target object.
  38432. * This can help limiting how the Camera is able to move in the scene.
  38433. */
  38434. upperHeightOffsetLimit: Nullable<number>;
  38435. /**
  38436. * Define how fast the camera can accelerate to follow it s target.
  38437. */
  38438. cameraAcceleration: number;
  38439. /**
  38440. * Define the speed limit of the camera following an object.
  38441. */
  38442. maxCameraSpeed: number;
  38443. /**
  38444. * Define the target of the camera.
  38445. */
  38446. lockedTarget: Nullable<AbstractMesh>;
  38447. /**
  38448. * Defines the input associated with the camera.
  38449. */
  38450. inputs: FollowCameraInputsManager;
  38451. /**
  38452. * Instantiates the follow camera.
  38453. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38454. * @param name Define the name of the camera in the scene
  38455. * @param position Define the position of the camera
  38456. * @param scene Define the scene the camera belong to
  38457. * @param lockedTarget Define the target of the camera
  38458. */
  38459. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38460. private _follow;
  38461. /**
  38462. * Attached controls to the current camera.
  38463. * @param element Defines the element the controls should be listened from
  38464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38465. */
  38466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38467. /**
  38468. * Detach the current controls from the camera.
  38469. * The camera will stop reacting to inputs.
  38470. * @param element Defines the element to stop listening the inputs from
  38471. */
  38472. detachControl(element: HTMLElement): void;
  38473. /** @hidden */
  38474. _checkInputs(): void;
  38475. private _checkLimits;
  38476. /**
  38477. * Gets the camera class name.
  38478. * @returns the class name
  38479. */
  38480. getClassName(): string;
  38481. }
  38482. /**
  38483. * Arc Rotate version of the follow camera.
  38484. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38485. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38486. */
  38487. export class ArcFollowCamera extends TargetCamera {
  38488. /** The longitudinal angle of the camera */
  38489. alpha: number;
  38490. /** The latitudinal angle of the camera */
  38491. beta: number;
  38492. /** The radius of the camera from its target */
  38493. radius: number;
  38494. /** Define the camera target (the messh it should follow) */
  38495. target: Nullable<AbstractMesh>;
  38496. private _cartesianCoordinates;
  38497. /**
  38498. * Instantiates a new ArcFollowCamera
  38499. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38500. * @param name Define the name of the camera
  38501. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38502. * @param beta Define the rotation angle of the camera around the elevation axis
  38503. * @param radius Define the radius of the camera from its target point
  38504. * @param target Define the target of the camera
  38505. * @param scene Define the scene the camera belongs to
  38506. */
  38507. constructor(name: string,
  38508. /** The longitudinal angle of the camera */
  38509. alpha: number,
  38510. /** The latitudinal angle of the camera */
  38511. beta: number,
  38512. /** The radius of the camera from its target */
  38513. radius: number,
  38514. /** Define the camera target (the messh it should follow) */
  38515. target: Nullable<AbstractMesh>, scene: Scene);
  38516. private _follow;
  38517. /** @hidden */
  38518. _checkInputs(): void;
  38519. /**
  38520. * Returns the class name of the object.
  38521. * It is mostly used internally for serialization purposes.
  38522. */
  38523. getClassName(): string;
  38524. }
  38525. }
  38526. declare module BABYLON {
  38527. /**
  38528. * Manage the keyboard inputs to control the movement of a follow camera.
  38529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38530. */
  38531. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38532. /**
  38533. * Defines the camera the input is attached to.
  38534. */
  38535. camera: FollowCamera;
  38536. /**
  38537. * Defines the list of key codes associated with the up action (increase heightOffset)
  38538. */
  38539. keysHeightOffsetIncr: number[];
  38540. /**
  38541. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38542. */
  38543. keysHeightOffsetDecr: number[];
  38544. /**
  38545. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38546. */
  38547. keysHeightOffsetModifierAlt: boolean;
  38548. /**
  38549. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38550. */
  38551. keysHeightOffsetModifierCtrl: boolean;
  38552. /**
  38553. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38554. */
  38555. keysHeightOffsetModifierShift: boolean;
  38556. /**
  38557. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38558. */
  38559. keysRotationOffsetIncr: number[];
  38560. /**
  38561. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38562. */
  38563. keysRotationOffsetDecr: number[];
  38564. /**
  38565. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38566. */
  38567. keysRotationOffsetModifierAlt: boolean;
  38568. /**
  38569. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38570. */
  38571. keysRotationOffsetModifierCtrl: boolean;
  38572. /**
  38573. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38574. */
  38575. keysRotationOffsetModifierShift: boolean;
  38576. /**
  38577. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38578. */
  38579. keysRadiusIncr: number[];
  38580. /**
  38581. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38582. */
  38583. keysRadiusDecr: number[];
  38584. /**
  38585. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38586. */
  38587. keysRadiusModifierAlt: boolean;
  38588. /**
  38589. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38590. */
  38591. keysRadiusModifierCtrl: boolean;
  38592. /**
  38593. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38594. */
  38595. keysRadiusModifierShift: boolean;
  38596. /**
  38597. * Defines the rate of change of heightOffset.
  38598. */
  38599. heightSensibility: number;
  38600. /**
  38601. * Defines the rate of change of rotationOffset.
  38602. */
  38603. rotationSensibility: number;
  38604. /**
  38605. * Defines the rate of change of radius.
  38606. */
  38607. radiusSensibility: number;
  38608. private _keys;
  38609. private _ctrlPressed;
  38610. private _altPressed;
  38611. private _shiftPressed;
  38612. private _onCanvasBlurObserver;
  38613. private _onKeyboardObserver;
  38614. private _engine;
  38615. private _scene;
  38616. /**
  38617. * Attach the input controls to a specific dom element to get the input from.
  38618. * @param element Defines the element the controls should be listened from
  38619. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38620. */
  38621. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38622. /**
  38623. * Detach the current controls from the specified dom element.
  38624. * @param element Defines the element to stop listening the inputs from
  38625. */
  38626. detachControl(element: Nullable<HTMLElement>): void;
  38627. /**
  38628. * Update the current camera state depending on the inputs that have been used this frame.
  38629. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38630. */
  38631. checkInputs(): void;
  38632. /**
  38633. * Gets the class name of the current input.
  38634. * @returns the class name
  38635. */
  38636. getClassName(): string;
  38637. /**
  38638. * Get the friendly name associated with the input class.
  38639. * @returns the input friendly name
  38640. */
  38641. getSimpleName(): string;
  38642. /**
  38643. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38644. * allow modification of the heightOffset value.
  38645. */
  38646. private _modifierHeightOffset;
  38647. /**
  38648. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38649. * allow modification of the rotationOffset value.
  38650. */
  38651. private _modifierRotationOffset;
  38652. /**
  38653. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38654. * allow modification of the radius value.
  38655. */
  38656. private _modifierRadius;
  38657. }
  38658. }
  38659. declare module BABYLON {
  38660. interface FreeCameraInputsManager {
  38661. /**
  38662. * @hidden
  38663. */
  38664. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38665. /**
  38666. * Add orientation input support to the input manager.
  38667. * @returns the current input manager
  38668. */
  38669. addDeviceOrientation(): FreeCameraInputsManager;
  38670. }
  38671. /**
  38672. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38673. * Screen rotation is taken into account.
  38674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38675. */
  38676. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38677. private _camera;
  38678. private _screenOrientationAngle;
  38679. private _constantTranform;
  38680. private _screenQuaternion;
  38681. private _alpha;
  38682. private _beta;
  38683. private _gamma;
  38684. /**
  38685. * Can be used to detect if a device orientation sensor is availible on a device
  38686. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38687. * @returns a promise that will resolve on orientation change
  38688. */
  38689. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38690. /**
  38691. * @hidden
  38692. */
  38693. _onDeviceOrientationChangedObservable: Observable<void>;
  38694. /**
  38695. * Instantiates a new input
  38696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38697. */
  38698. constructor();
  38699. /**
  38700. * Define the camera controlled by the input.
  38701. */
  38702. camera: FreeCamera;
  38703. /**
  38704. * Attach the input controls to a specific dom element to get the input from.
  38705. * @param element Defines the element the controls should be listened from
  38706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38707. */
  38708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38709. private _orientationChanged;
  38710. private _deviceOrientation;
  38711. /**
  38712. * Detach the current controls from the specified dom element.
  38713. * @param element Defines the element to stop listening the inputs from
  38714. */
  38715. detachControl(element: Nullable<HTMLElement>): void;
  38716. /**
  38717. * Update the current camera state depending on the inputs that have been used this frame.
  38718. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38719. */
  38720. checkInputs(): void;
  38721. /**
  38722. * Gets the class name of the current intput.
  38723. * @returns the class name
  38724. */
  38725. getClassName(): string;
  38726. /**
  38727. * Get the friendly name associated with the input class.
  38728. * @returns the input friendly name
  38729. */
  38730. getSimpleName(): string;
  38731. }
  38732. }
  38733. declare module BABYLON {
  38734. /**
  38735. * Manage the gamepad inputs to control a free camera.
  38736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38737. */
  38738. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38739. /**
  38740. * Define the camera the input is attached to.
  38741. */
  38742. camera: FreeCamera;
  38743. /**
  38744. * Define the Gamepad controlling the input
  38745. */
  38746. gamepad: Nullable<Gamepad>;
  38747. /**
  38748. * Defines the gamepad rotation sensiblity.
  38749. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38750. */
  38751. gamepadAngularSensibility: number;
  38752. /**
  38753. * Defines the gamepad move sensiblity.
  38754. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38755. */
  38756. gamepadMoveSensibility: number;
  38757. private _yAxisScale;
  38758. /**
  38759. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38760. */
  38761. invertYAxis: boolean;
  38762. private _onGamepadConnectedObserver;
  38763. private _onGamepadDisconnectedObserver;
  38764. private _cameraTransform;
  38765. private _deltaTransform;
  38766. private _vector3;
  38767. private _vector2;
  38768. /**
  38769. * Attach the input controls to a specific dom element to get the input from.
  38770. * @param element Defines the element the controls should be listened from
  38771. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38772. */
  38773. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38774. /**
  38775. * Detach the current controls from the specified dom element.
  38776. * @param element Defines the element to stop listening the inputs from
  38777. */
  38778. detachControl(element: Nullable<HTMLElement>): void;
  38779. /**
  38780. * Update the current camera state depending on the inputs that have been used this frame.
  38781. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38782. */
  38783. checkInputs(): void;
  38784. /**
  38785. * Gets the class name of the current intput.
  38786. * @returns the class name
  38787. */
  38788. getClassName(): string;
  38789. /**
  38790. * Get the friendly name associated with the input class.
  38791. * @returns the input friendly name
  38792. */
  38793. getSimpleName(): string;
  38794. }
  38795. }
  38796. declare module BABYLON {
  38797. /**
  38798. * Defines the potential axis of a Joystick
  38799. */
  38800. export enum JoystickAxis {
  38801. /** X axis */
  38802. X = 0,
  38803. /** Y axis */
  38804. Y = 1,
  38805. /** Z axis */
  38806. Z = 2
  38807. }
  38808. /**
  38809. * Class used to define virtual joystick (used in touch mode)
  38810. */
  38811. export class VirtualJoystick {
  38812. /**
  38813. * Gets or sets a boolean indicating that left and right values must be inverted
  38814. */
  38815. reverseLeftRight: boolean;
  38816. /**
  38817. * Gets or sets a boolean indicating that up and down values must be inverted
  38818. */
  38819. reverseUpDown: boolean;
  38820. /**
  38821. * Gets the offset value for the position (ie. the change of the position value)
  38822. */
  38823. deltaPosition: Vector3;
  38824. /**
  38825. * Gets a boolean indicating if the virtual joystick was pressed
  38826. */
  38827. pressed: boolean;
  38828. /**
  38829. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38830. */
  38831. static Canvas: Nullable<HTMLCanvasElement>;
  38832. private static _globalJoystickIndex;
  38833. private static vjCanvasContext;
  38834. private static vjCanvasWidth;
  38835. private static vjCanvasHeight;
  38836. private static halfWidth;
  38837. private _action;
  38838. private _axisTargetedByLeftAndRight;
  38839. private _axisTargetedByUpAndDown;
  38840. private _joystickSensibility;
  38841. private _inversedSensibility;
  38842. private _joystickPointerID;
  38843. private _joystickColor;
  38844. private _joystickPointerPos;
  38845. private _joystickPreviousPointerPos;
  38846. private _joystickPointerStartPos;
  38847. private _deltaJoystickVector;
  38848. private _leftJoystick;
  38849. private _touches;
  38850. private _onPointerDownHandlerRef;
  38851. private _onPointerMoveHandlerRef;
  38852. private _onPointerUpHandlerRef;
  38853. private _onResize;
  38854. /**
  38855. * Creates a new virtual joystick
  38856. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38857. */
  38858. constructor(leftJoystick?: boolean);
  38859. /**
  38860. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38861. * @param newJoystickSensibility defines the new sensibility
  38862. */
  38863. setJoystickSensibility(newJoystickSensibility: number): void;
  38864. private _onPointerDown;
  38865. private _onPointerMove;
  38866. private _onPointerUp;
  38867. /**
  38868. * Change the color of the virtual joystick
  38869. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38870. */
  38871. setJoystickColor(newColor: string): void;
  38872. /**
  38873. * Defines a callback to call when the joystick is touched
  38874. * @param action defines the callback
  38875. */
  38876. setActionOnTouch(action: () => any): void;
  38877. /**
  38878. * Defines which axis you'd like to control for left & right
  38879. * @param axis defines the axis to use
  38880. */
  38881. setAxisForLeftRight(axis: JoystickAxis): void;
  38882. /**
  38883. * Defines which axis you'd like to control for up & down
  38884. * @param axis defines the axis to use
  38885. */
  38886. setAxisForUpDown(axis: JoystickAxis): void;
  38887. private _drawVirtualJoystick;
  38888. /**
  38889. * Release internal HTML canvas
  38890. */
  38891. releaseCanvas(): void;
  38892. }
  38893. }
  38894. declare module BABYLON {
  38895. interface FreeCameraInputsManager {
  38896. /**
  38897. * Add virtual joystick input support to the input manager.
  38898. * @returns the current input manager
  38899. */
  38900. addVirtualJoystick(): FreeCameraInputsManager;
  38901. }
  38902. /**
  38903. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38905. */
  38906. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38907. /**
  38908. * Defines the camera the input is attached to.
  38909. */
  38910. camera: FreeCamera;
  38911. private _leftjoystick;
  38912. private _rightjoystick;
  38913. /**
  38914. * Gets the left stick of the virtual joystick.
  38915. * @returns The virtual Joystick
  38916. */
  38917. getLeftJoystick(): VirtualJoystick;
  38918. /**
  38919. * Gets the right stick of the virtual joystick.
  38920. * @returns The virtual Joystick
  38921. */
  38922. getRightJoystick(): VirtualJoystick;
  38923. /**
  38924. * Update the current camera state depending on the inputs that have been used this frame.
  38925. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38926. */
  38927. checkInputs(): void;
  38928. /**
  38929. * Attach the input controls to a specific dom element to get the input from.
  38930. * @param element Defines the element the controls should be listened from
  38931. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38932. */
  38933. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38934. /**
  38935. * Detach the current controls from the specified dom element.
  38936. * @param element Defines the element to stop listening the inputs from
  38937. */
  38938. detachControl(element: Nullable<HTMLElement>): void;
  38939. /**
  38940. * Gets the class name of the current intput.
  38941. * @returns the class name
  38942. */
  38943. getClassName(): string;
  38944. /**
  38945. * Get the friendly name associated with the input class.
  38946. * @returns the input friendly name
  38947. */
  38948. getSimpleName(): string;
  38949. }
  38950. }
  38951. declare module BABYLON {
  38952. /**
  38953. * This represents a FPS type of camera controlled by touch.
  38954. * This is like a universal camera minus the Gamepad controls.
  38955. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38956. */
  38957. export class TouchCamera extends FreeCamera {
  38958. /**
  38959. * Defines the touch sensibility for rotation.
  38960. * The higher the faster.
  38961. */
  38962. touchAngularSensibility: number;
  38963. /**
  38964. * Defines the touch sensibility for move.
  38965. * The higher the faster.
  38966. */
  38967. touchMoveSensibility: number;
  38968. /**
  38969. * Instantiates a new touch camera.
  38970. * This represents a FPS type of camera controlled by touch.
  38971. * This is like a universal camera minus the Gamepad controls.
  38972. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38973. * @param name Define the name of the camera in the scene
  38974. * @param position Define the start position of the camera in the scene
  38975. * @param scene Define the scene the camera belongs to
  38976. */
  38977. constructor(name: string, position: Vector3, scene: Scene);
  38978. /**
  38979. * Gets the current object class name.
  38980. * @return the class name
  38981. */
  38982. getClassName(): string;
  38983. /** @hidden */
  38984. _setupInputs(): void;
  38985. }
  38986. }
  38987. declare module BABYLON {
  38988. /**
  38989. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38990. * being tilted forward or back and left or right.
  38991. */
  38992. export class DeviceOrientationCamera extends FreeCamera {
  38993. private _initialQuaternion;
  38994. private _quaternionCache;
  38995. private _tmpDragQuaternion;
  38996. private _disablePointerInputWhenUsingDeviceOrientation;
  38997. /**
  38998. * Creates a new device orientation camera
  38999. * @param name The name of the camera
  39000. * @param position The start position camera
  39001. * @param scene The scene the camera belongs to
  39002. */
  39003. constructor(name: string, position: Vector3, scene: Scene);
  39004. /**
  39005. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39006. */
  39007. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39008. private _dragFactor;
  39009. /**
  39010. * Enabled turning on the y axis when the orientation sensor is active
  39011. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39012. */
  39013. enableHorizontalDragging(dragFactor?: number): void;
  39014. /**
  39015. * Gets the current instance class name ("DeviceOrientationCamera").
  39016. * This helps avoiding instanceof at run time.
  39017. * @returns the class name
  39018. */
  39019. getClassName(): string;
  39020. /**
  39021. * @hidden
  39022. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39023. */
  39024. _checkInputs(): void;
  39025. /**
  39026. * Reset the camera to its default orientation on the specified axis only.
  39027. * @param axis The axis to reset
  39028. */
  39029. resetToCurrentRotation(axis?: Axis): void;
  39030. }
  39031. }
  39032. declare module BABYLON {
  39033. /**
  39034. * Defines supported buttons for XBox360 compatible gamepads
  39035. */
  39036. export enum Xbox360Button {
  39037. /** A */
  39038. A = 0,
  39039. /** B */
  39040. B = 1,
  39041. /** X */
  39042. X = 2,
  39043. /** Y */
  39044. Y = 3,
  39045. /** Start */
  39046. Start = 4,
  39047. /** Back */
  39048. Back = 5,
  39049. /** Left button */
  39050. LB = 6,
  39051. /** Right button */
  39052. RB = 7,
  39053. /** Left stick */
  39054. LeftStick = 8,
  39055. /** Right stick */
  39056. RightStick = 9
  39057. }
  39058. /** Defines values for XBox360 DPad */
  39059. export enum Xbox360Dpad {
  39060. /** Up */
  39061. Up = 0,
  39062. /** Down */
  39063. Down = 1,
  39064. /** Left */
  39065. Left = 2,
  39066. /** Right */
  39067. Right = 3
  39068. }
  39069. /**
  39070. * Defines a XBox360 gamepad
  39071. */
  39072. export class Xbox360Pad extends Gamepad {
  39073. private _leftTrigger;
  39074. private _rightTrigger;
  39075. private _onlefttriggerchanged;
  39076. private _onrighttriggerchanged;
  39077. private _onbuttondown;
  39078. private _onbuttonup;
  39079. private _ondpaddown;
  39080. private _ondpadup;
  39081. /** Observable raised when a button is pressed */
  39082. onButtonDownObservable: Observable<Xbox360Button>;
  39083. /** Observable raised when a button is released */
  39084. onButtonUpObservable: Observable<Xbox360Button>;
  39085. /** Observable raised when a pad is pressed */
  39086. onPadDownObservable: Observable<Xbox360Dpad>;
  39087. /** Observable raised when a pad is released */
  39088. onPadUpObservable: Observable<Xbox360Dpad>;
  39089. private _buttonA;
  39090. private _buttonB;
  39091. private _buttonX;
  39092. private _buttonY;
  39093. private _buttonBack;
  39094. private _buttonStart;
  39095. private _buttonLB;
  39096. private _buttonRB;
  39097. private _buttonLeftStick;
  39098. private _buttonRightStick;
  39099. private _dPadUp;
  39100. private _dPadDown;
  39101. private _dPadLeft;
  39102. private _dPadRight;
  39103. private _isXboxOnePad;
  39104. /**
  39105. * Creates a new XBox360 gamepad object
  39106. * @param id defines the id of this gamepad
  39107. * @param index defines its index
  39108. * @param gamepad defines the internal HTML gamepad object
  39109. * @param xboxOne defines if it is a XBox One gamepad
  39110. */
  39111. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39112. /**
  39113. * Defines the callback to call when left trigger is pressed
  39114. * @param callback defines the callback to use
  39115. */
  39116. onlefttriggerchanged(callback: (value: number) => void): void;
  39117. /**
  39118. * Defines the callback to call when right trigger is pressed
  39119. * @param callback defines the callback to use
  39120. */
  39121. onrighttriggerchanged(callback: (value: number) => void): void;
  39122. /**
  39123. * Gets the left trigger value
  39124. */
  39125. /**
  39126. * Sets the left trigger value
  39127. */
  39128. leftTrigger: number;
  39129. /**
  39130. * Gets the right trigger value
  39131. */
  39132. /**
  39133. * Sets the right trigger value
  39134. */
  39135. rightTrigger: number;
  39136. /**
  39137. * Defines the callback to call when a button is pressed
  39138. * @param callback defines the callback to use
  39139. */
  39140. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39141. /**
  39142. * Defines the callback to call when a button is released
  39143. * @param callback defines the callback to use
  39144. */
  39145. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39146. /**
  39147. * Defines the callback to call when a pad is pressed
  39148. * @param callback defines the callback to use
  39149. */
  39150. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39151. /**
  39152. * Defines the callback to call when a pad is released
  39153. * @param callback defines the callback to use
  39154. */
  39155. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39156. private _setButtonValue;
  39157. private _setDPadValue;
  39158. /**
  39159. * Gets the value of the `A` button
  39160. */
  39161. /**
  39162. * Sets the value of the `A` button
  39163. */
  39164. buttonA: number;
  39165. /**
  39166. * Gets the value of the `B` button
  39167. */
  39168. /**
  39169. * Sets the value of the `B` button
  39170. */
  39171. buttonB: number;
  39172. /**
  39173. * Gets the value of the `X` button
  39174. */
  39175. /**
  39176. * Sets the value of the `X` button
  39177. */
  39178. buttonX: number;
  39179. /**
  39180. * Gets the value of the `Y` button
  39181. */
  39182. /**
  39183. * Sets the value of the `Y` button
  39184. */
  39185. buttonY: number;
  39186. /**
  39187. * Gets the value of the `Start` button
  39188. */
  39189. /**
  39190. * Sets the value of the `Start` button
  39191. */
  39192. buttonStart: number;
  39193. /**
  39194. * Gets the value of the `Back` button
  39195. */
  39196. /**
  39197. * Sets the value of the `Back` button
  39198. */
  39199. buttonBack: number;
  39200. /**
  39201. * Gets the value of the `Left` button
  39202. */
  39203. /**
  39204. * Sets the value of the `Left` button
  39205. */
  39206. buttonLB: number;
  39207. /**
  39208. * Gets the value of the `Right` button
  39209. */
  39210. /**
  39211. * Sets the value of the `Right` button
  39212. */
  39213. buttonRB: number;
  39214. /**
  39215. * Gets the value of the Left joystick
  39216. */
  39217. /**
  39218. * Sets the value of the Left joystick
  39219. */
  39220. buttonLeftStick: number;
  39221. /**
  39222. * Gets the value of the Right joystick
  39223. */
  39224. /**
  39225. * Sets the value of the Right joystick
  39226. */
  39227. buttonRightStick: number;
  39228. /**
  39229. * Gets the value of D-pad up
  39230. */
  39231. /**
  39232. * Sets the value of D-pad up
  39233. */
  39234. dPadUp: number;
  39235. /**
  39236. * Gets the value of D-pad down
  39237. */
  39238. /**
  39239. * Sets the value of D-pad down
  39240. */
  39241. dPadDown: number;
  39242. /**
  39243. * Gets the value of D-pad left
  39244. */
  39245. /**
  39246. * Sets the value of D-pad left
  39247. */
  39248. dPadLeft: number;
  39249. /**
  39250. * Gets the value of D-pad right
  39251. */
  39252. /**
  39253. * Sets the value of D-pad right
  39254. */
  39255. dPadRight: number;
  39256. /**
  39257. * Force the gamepad to synchronize with device values
  39258. */
  39259. update(): void;
  39260. /**
  39261. * Disposes the gamepad
  39262. */
  39263. dispose(): void;
  39264. }
  39265. }
  39266. declare module BABYLON {
  39267. /**
  39268. * Defines supported buttons for DualShock compatible gamepads
  39269. */
  39270. export enum DualShockButton {
  39271. /** Cross */
  39272. Cross = 0,
  39273. /** Circle */
  39274. Circle = 1,
  39275. /** Square */
  39276. Square = 2,
  39277. /** Triangle */
  39278. Triangle = 3,
  39279. /** Options */
  39280. Options = 4,
  39281. /** Share */
  39282. Share = 5,
  39283. /** L1 */
  39284. L1 = 6,
  39285. /** R1 */
  39286. R1 = 7,
  39287. /** Left stick */
  39288. LeftStick = 8,
  39289. /** Right stick */
  39290. RightStick = 9
  39291. }
  39292. /** Defines values for DualShock DPad */
  39293. export enum DualShockDpad {
  39294. /** Up */
  39295. Up = 0,
  39296. /** Down */
  39297. Down = 1,
  39298. /** Left */
  39299. Left = 2,
  39300. /** Right */
  39301. Right = 3
  39302. }
  39303. /**
  39304. * Defines a DualShock gamepad
  39305. */
  39306. export class DualShockPad extends Gamepad {
  39307. private _leftTrigger;
  39308. private _rightTrigger;
  39309. private _onlefttriggerchanged;
  39310. private _onrighttriggerchanged;
  39311. private _onbuttondown;
  39312. private _onbuttonup;
  39313. private _ondpaddown;
  39314. private _ondpadup;
  39315. /** Observable raised when a button is pressed */
  39316. onButtonDownObservable: Observable<DualShockButton>;
  39317. /** Observable raised when a button is released */
  39318. onButtonUpObservable: Observable<DualShockButton>;
  39319. /** Observable raised when a pad is pressed */
  39320. onPadDownObservable: Observable<DualShockDpad>;
  39321. /** Observable raised when a pad is released */
  39322. onPadUpObservable: Observable<DualShockDpad>;
  39323. private _buttonCross;
  39324. private _buttonCircle;
  39325. private _buttonSquare;
  39326. private _buttonTriangle;
  39327. private _buttonShare;
  39328. private _buttonOptions;
  39329. private _buttonL1;
  39330. private _buttonR1;
  39331. private _buttonLeftStick;
  39332. private _buttonRightStick;
  39333. private _dPadUp;
  39334. private _dPadDown;
  39335. private _dPadLeft;
  39336. private _dPadRight;
  39337. /**
  39338. * Creates a new DualShock gamepad object
  39339. * @param id defines the id of this gamepad
  39340. * @param index defines its index
  39341. * @param gamepad defines the internal HTML gamepad object
  39342. */
  39343. constructor(id: string, index: number, gamepad: any);
  39344. /**
  39345. * Defines the callback to call when left trigger is pressed
  39346. * @param callback defines the callback to use
  39347. */
  39348. onlefttriggerchanged(callback: (value: number) => void): void;
  39349. /**
  39350. * Defines the callback to call when right trigger is pressed
  39351. * @param callback defines the callback to use
  39352. */
  39353. onrighttriggerchanged(callback: (value: number) => void): void;
  39354. /**
  39355. * Gets the left trigger value
  39356. */
  39357. /**
  39358. * Sets the left trigger value
  39359. */
  39360. leftTrigger: number;
  39361. /**
  39362. * Gets the right trigger value
  39363. */
  39364. /**
  39365. * Sets the right trigger value
  39366. */
  39367. rightTrigger: number;
  39368. /**
  39369. * Defines the callback to call when a button is pressed
  39370. * @param callback defines the callback to use
  39371. */
  39372. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39373. /**
  39374. * Defines the callback to call when a button is released
  39375. * @param callback defines the callback to use
  39376. */
  39377. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39378. /**
  39379. * Defines the callback to call when a pad is pressed
  39380. * @param callback defines the callback to use
  39381. */
  39382. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39383. /**
  39384. * Defines the callback to call when a pad is released
  39385. * @param callback defines the callback to use
  39386. */
  39387. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39388. private _setButtonValue;
  39389. private _setDPadValue;
  39390. /**
  39391. * Gets the value of the `Cross` button
  39392. */
  39393. /**
  39394. * Sets the value of the `Cross` button
  39395. */
  39396. buttonCross: number;
  39397. /**
  39398. * Gets the value of the `Circle` button
  39399. */
  39400. /**
  39401. * Sets the value of the `Circle` button
  39402. */
  39403. buttonCircle: number;
  39404. /**
  39405. * Gets the value of the `Square` button
  39406. */
  39407. /**
  39408. * Sets the value of the `Square` button
  39409. */
  39410. buttonSquare: number;
  39411. /**
  39412. * Gets the value of the `Triangle` button
  39413. */
  39414. /**
  39415. * Sets the value of the `Triangle` button
  39416. */
  39417. buttonTriangle: number;
  39418. /**
  39419. * Gets the value of the `Options` button
  39420. */
  39421. /**
  39422. * Sets the value of the `Options` button
  39423. */
  39424. buttonOptions: number;
  39425. /**
  39426. * Gets the value of the `Share` button
  39427. */
  39428. /**
  39429. * Sets the value of the `Share` button
  39430. */
  39431. buttonShare: number;
  39432. /**
  39433. * Gets the value of the `L1` button
  39434. */
  39435. /**
  39436. * Sets the value of the `L1` button
  39437. */
  39438. buttonL1: number;
  39439. /**
  39440. * Gets the value of the `R1` button
  39441. */
  39442. /**
  39443. * Sets the value of the `R1` button
  39444. */
  39445. buttonR1: number;
  39446. /**
  39447. * Gets the value of the Left joystick
  39448. */
  39449. /**
  39450. * Sets the value of the Left joystick
  39451. */
  39452. buttonLeftStick: number;
  39453. /**
  39454. * Gets the value of the Right joystick
  39455. */
  39456. /**
  39457. * Sets the value of the Right joystick
  39458. */
  39459. buttonRightStick: number;
  39460. /**
  39461. * Gets the value of D-pad up
  39462. */
  39463. /**
  39464. * Sets the value of D-pad up
  39465. */
  39466. dPadUp: number;
  39467. /**
  39468. * Gets the value of D-pad down
  39469. */
  39470. /**
  39471. * Sets the value of D-pad down
  39472. */
  39473. dPadDown: number;
  39474. /**
  39475. * Gets the value of D-pad left
  39476. */
  39477. /**
  39478. * Sets the value of D-pad left
  39479. */
  39480. dPadLeft: number;
  39481. /**
  39482. * Gets the value of D-pad right
  39483. */
  39484. /**
  39485. * Sets the value of D-pad right
  39486. */
  39487. dPadRight: number;
  39488. /**
  39489. * Force the gamepad to synchronize with device values
  39490. */
  39491. update(): void;
  39492. /**
  39493. * Disposes the gamepad
  39494. */
  39495. dispose(): void;
  39496. }
  39497. }
  39498. declare module BABYLON {
  39499. /**
  39500. * Manager for handling gamepads
  39501. */
  39502. export class GamepadManager {
  39503. private _scene?;
  39504. private _babylonGamepads;
  39505. private _oneGamepadConnected;
  39506. /** @hidden */
  39507. _isMonitoring: boolean;
  39508. private _gamepadEventSupported;
  39509. private _gamepadSupport;
  39510. /**
  39511. * observable to be triggered when the gamepad controller has been connected
  39512. */
  39513. onGamepadConnectedObservable: Observable<Gamepad>;
  39514. /**
  39515. * observable to be triggered when the gamepad controller has been disconnected
  39516. */
  39517. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39518. private _onGamepadConnectedEvent;
  39519. private _onGamepadDisconnectedEvent;
  39520. /**
  39521. * Initializes the gamepad manager
  39522. * @param _scene BabylonJS scene
  39523. */
  39524. constructor(_scene?: Scene | undefined);
  39525. /**
  39526. * The gamepads in the game pad manager
  39527. */
  39528. readonly gamepads: Gamepad[];
  39529. /**
  39530. * Get the gamepad controllers based on type
  39531. * @param type The type of gamepad controller
  39532. * @returns Nullable gamepad
  39533. */
  39534. getGamepadByType(type?: number): Nullable<Gamepad>;
  39535. /**
  39536. * Disposes the gamepad manager
  39537. */
  39538. dispose(): void;
  39539. private _addNewGamepad;
  39540. private _startMonitoringGamepads;
  39541. private _stopMonitoringGamepads;
  39542. /** @hidden */
  39543. _checkGamepadsStatus(): void;
  39544. private _updateGamepadObjects;
  39545. }
  39546. }
  39547. declare module BABYLON {
  39548. interface Scene {
  39549. /** @hidden */
  39550. _gamepadManager: Nullable<GamepadManager>;
  39551. /**
  39552. * Gets the gamepad manager associated with the scene
  39553. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39554. */
  39555. gamepadManager: GamepadManager;
  39556. }
  39557. /**
  39558. * Interface representing a free camera inputs manager
  39559. */
  39560. interface FreeCameraInputsManager {
  39561. /**
  39562. * Adds gamepad input support to the FreeCameraInputsManager.
  39563. * @returns the FreeCameraInputsManager
  39564. */
  39565. addGamepad(): FreeCameraInputsManager;
  39566. }
  39567. /**
  39568. * Interface representing an arc rotate camera inputs manager
  39569. */
  39570. interface ArcRotateCameraInputsManager {
  39571. /**
  39572. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39573. * @returns the camera inputs manager
  39574. */
  39575. addGamepad(): ArcRotateCameraInputsManager;
  39576. }
  39577. /**
  39578. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39579. */
  39580. export class GamepadSystemSceneComponent implements ISceneComponent {
  39581. /**
  39582. * The component name helpfull to identify the component in the list of scene components.
  39583. */
  39584. readonly name: string;
  39585. /**
  39586. * The scene the component belongs to.
  39587. */
  39588. scene: Scene;
  39589. /**
  39590. * Creates a new instance of the component for the given scene
  39591. * @param scene Defines the scene to register the component in
  39592. */
  39593. constructor(scene: Scene);
  39594. /**
  39595. * Registers the component in a given scene
  39596. */
  39597. register(): void;
  39598. /**
  39599. * Rebuilds the elements related to this component in case of
  39600. * context lost for instance.
  39601. */
  39602. rebuild(): void;
  39603. /**
  39604. * Disposes the component and the associated ressources
  39605. */
  39606. dispose(): void;
  39607. private _beforeCameraUpdate;
  39608. }
  39609. }
  39610. declare module BABYLON {
  39611. /**
  39612. * 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,
  39613. * which still works and will still be found in many Playgrounds.
  39614. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39615. */
  39616. export class UniversalCamera extends TouchCamera {
  39617. /**
  39618. * Defines the gamepad rotation sensiblity.
  39619. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39620. */
  39621. gamepadAngularSensibility: number;
  39622. /**
  39623. * Defines the gamepad move sensiblity.
  39624. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39625. */
  39626. gamepadMoveSensibility: number;
  39627. /**
  39628. * 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,
  39629. * which still works and will still be found in many Playgrounds.
  39630. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39631. * @param name Define the name of the camera in the scene
  39632. * @param position Define the start position of the camera in the scene
  39633. * @param scene Define the scene the camera belongs to
  39634. */
  39635. constructor(name: string, position: Vector3, scene: Scene);
  39636. /**
  39637. * Gets the current object class name.
  39638. * @return the class name
  39639. */
  39640. getClassName(): string;
  39641. }
  39642. }
  39643. declare module BABYLON {
  39644. /**
  39645. * This represents a FPS type of camera. This is only here for back compat purpose.
  39646. * Please use the UniversalCamera instead as both are identical.
  39647. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39648. */
  39649. export class GamepadCamera extends UniversalCamera {
  39650. /**
  39651. * Instantiates a new Gamepad Camera
  39652. * This represents a FPS type of camera. This is only here for back compat purpose.
  39653. * Please use the UniversalCamera instead as both are identical.
  39654. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39655. * @param name Define the name of the camera in the scene
  39656. * @param position Define the start position of the camera in the scene
  39657. * @param scene Define the scene the camera belongs to
  39658. */
  39659. constructor(name: string, position: Vector3, scene: Scene);
  39660. /**
  39661. * Gets the current object class name.
  39662. * @return the class name
  39663. */
  39664. getClassName(): string;
  39665. }
  39666. }
  39667. declare module BABYLON {
  39668. /** @hidden */
  39669. export var passPixelShader: {
  39670. name: string;
  39671. shader: string;
  39672. };
  39673. }
  39674. declare module BABYLON {
  39675. /** @hidden */
  39676. export var passCubePixelShader: {
  39677. name: string;
  39678. shader: string;
  39679. };
  39680. }
  39681. declare module BABYLON {
  39682. /**
  39683. * PassPostProcess which produces an output the same as it's input
  39684. */
  39685. export class PassPostProcess extends PostProcess {
  39686. /**
  39687. * Creates the PassPostProcess
  39688. * @param name The name of the effect.
  39689. * @param options The required width/height ratio to downsize to before computing the render pass.
  39690. * @param camera The camera to apply the render pass to.
  39691. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39692. * @param engine The engine which the post process will be applied. (default: current engine)
  39693. * @param reusable If the post process can be reused on the same frame. (default: false)
  39694. * @param textureType The type of texture to be used when performing the post processing.
  39695. * @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)
  39696. */
  39697. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39698. }
  39699. /**
  39700. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39701. */
  39702. export class PassCubePostProcess extends PostProcess {
  39703. private _face;
  39704. /**
  39705. * Gets or sets the cube face to display.
  39706. * * 0 is +X
  39707. * * 1 is -X
  39708. * * 2 is +Y
  39709. * * 3 is -Y
  39710. * * 4 is +Z
  39711. * * 5 is -Z
  39712. */
  39713. face: number;
  39714. /**
  39715. * Creates the PassCubePostProcess
  39716. * @param name The name of the effect.
  39717. * @param options The required width/height ratio to downsize to before computing the render pass.
  39718. * @param camera The camera to apply the render pass to.
  39719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39720. * @param engine The engine which the post process will be applied. (default: current engine)
  39721. * @param reusable If the post process can be reused on the same frame. (default: false)
  39722. * @param textureType The type of texture to be used when performing the post processing.
  39723. * @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)
  39724. */
  39725. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39726. }
  39727. }
  39728. declare module BABYLON {
  39729. /** @hidden */
  39730. export var anaglyphPixelShader: {
  39731. name: string;
  39732. shader: string;
  39733. };
  39734. }
  39735. declare module BABYLON {
  39736. /**
  39737. * Postprocess used to generate anaglyphic rendering
  39738. */
  39739. export class AnaglyphPostProcess extends PostProcess {
  39740. private _passedProcess;
  39741. /**
  39742. * Creates a new AnaglyphPostProcess
  39743. * @param name defines postprocess name
  39744. * @param options defines creation options or target ratio scale
  39745. * @param rigCameras defines cameras using this postprocess
  39746. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39747. * @param engine defines hosting engine
  39748. * @param reusable defines if the postprocess will be reused multiple times per frame
  39749. */
  39750. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39751. }
  39752. }
  39753. declare module BABYLON {
  39754. /**
  39755. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39756. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39757. */
  39758. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39759. /**
  39760. * Creates a new AnaglyphArcRotateCamera
  39761. * @param name defines camera name
  39762. * @param alpha defines alpha angle (in radians)
  39763. * @param beta defines beta angle (in radians)
  39764. * @param radius defines radius
  39765. * @param target defines camera target
  39766. * @param interaxialDistance defines distance between each color axis
  39767. * @param scene defines the hosting scene
  39768. */
  39769. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39770. /**
  39771. * Gets camera class name
  39772. * @returns AnaglyphArcRotateCamera
  39773. */
  39774. getClassName(): string;
  39775. }
  39776. }
  39777. declare module BABYLON {
  39778. /**
  39779. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39780. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39781. */
  39782. export class AnaglyphFreeCamera extends FreeCamera {
  39783. /**
  39784. * Creates a new AnaglyphFreeCamera
  39785. * @param name defines camera name
  39786. * @param position defines initial position
  39787. * @param interaxialDistance defines distance between each color axis
  39788. * @param scene defines the hosting scene
  39789. */
  39790. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39791. /**
  39792. * Gets camera class name
  39793. * @returns AnaglyphFreeCamera
  39794. */
  39795. getClassName(): string;
  39796. }
  39797. }
  39798. declare module BABYLON {
  39799. /**
  39800. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39801. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39802. */
  39803. export class AnaglyphGamepadCamera extends GamepadCamera {
  39804. /**
  39805. * Creates a new AnaglyphGamepadCamera
  39806. * @param name defines camera name
  39807. * @param position defines initial position
  39808. * @param interaxialDistance defines distance between each color axis
  39809. * @param scene defines the hosting scene
  39810. */
  39811. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39812. /**
  39813. * Gets camera class name
  39814. * @returns AnaglyphGamepadCamera
  39815. */
  39816. getClassName(): string;
  39817. }
  39818. }
  39819. declare module BABYLON {
  39820. /**
  39821. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39822. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39823. */
  39824. export class AnaglyphUniversalCamera extends UniversalCamera {
  39825. /**
  39826. * Creates a new AnaglyphUniversalCamera
  39827. * @param name defines camera name
  39828. * @param position defines initial position
  39829. * @param interaxialDistance defines distance between each color axis
  39830. * @param scene defines the hosting scene
  39831. */
  39832. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39833. /**
  39834. * Gets camera class name
  39835. * @returns AnaglyphUniversalCamera
  39836. */
  39837. getClassName(): string;
  39838. }
  39839. }
  39840. declare module BABYLON {
  39841. /** @hidden */
  39842. export var stereoscopicInterlacePixelShader: {
  39843. name: string;
  39844. shader: string;
  39845. };
  39846. }
  39847. declare module BABYLON {
  39848. /**
  39849. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39850. */
  39851. export class StereoscopicInterlacePostProcess extends PostProcess {
  39852. private _stepSize;
  39853. private _passedProcess;
  39854. /**
  39855. * Initializes a StereoscopicInterlacePostProcess
  39856. * @param name The name of the effect.
  39857. * @param rigCameras The rig cameras to be appled to the post process
  39858. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39859. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39860. * @param engine The engine which the post process will be applied. (default: current engine)
  39861. * @param reusable If the post process can be reused on the same frame. (default: false)
  39862. */
  39863. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39864. }
  39865. }
  39866. declare module BABYLON {
  39867. /**
  39868. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39869. * @see http://doc.babylonjs.com/features/cameras
  39870. */
  39871. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39872. /**
  39873. * Creates a new StereoscopicArcRotateCamera
  39874. * @param name defines camera name
  39875. * @param alpha defines alpha angle (in radians)
  39876. * @param beta defines beta angle (in radians)
  39877. * @param radius defines radius
  39878. * @param target defines camera target
  39879. * @param interaxialDistance defines distance between each color axis
  39880. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39881. * @param scene defines the hosting scene
  39882. */
  39883. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39884. /**
  39885. * Gets camera class name
  39886. * @returns StereoscopicArcRotateCamera
  39887. */
  39888. getClassName(): string;
  39889. }
  39890. }
  39891. declare module BABYLON {
  39892. /**
  39893. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39894. * @see http://doc.babylonjs.com/features/cameras
  39895. */
  39896. export class StereoscopicFreeCamera extends FreeCamera {
  39897. /**
  39898. * Creates a new StereoscopicFreeCamera
  39899. * @param name defines camera name
  39900. * @param position defines initial position
  39901. * @param interaxialDistance defines distance between each color axis
  39902. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39903. * @param scene defines the hosting scene
  39904. */
  39905. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39906. /**
  39907. * Gets camera class name
  39908. * @returns StereoscopicFreeCamera
  39909. */
  39910. getClassName(): string;
  39911. }
  39912. }
  39913. declare module BABYLON {
  39914. /**
  39915. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39916. * @see http://doc.babylonjs.com/features/cameras
  39917. */
  39918. export class StereoscopicGamepadCamera extends GamepadCamera {
  39919. /**
  39920. * Creates a new StereoscopicGamepadCamera
  39921. * @param name defines camera name
  39922. * @param position defines initial position
  39923. * @param interaxialDistance defines distance between each color axis
  39924. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39925. * @param scene defines the hosting scene
  39926. */
  39927. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39928. /**
  39929. * Gets camera class name
  39930. * @returns StereoscopicGamepadCamera
  39931. */
  39932. getClassName(): string;
  39933. }
  39934. }
  39935. declare module BABYLON {
  39936. /**
  39937. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39938. * @see http://doc.babylonjs.com/features/cameras
  39939. */
  39940. export class StereoscopicUniversalCamera extends UniversalCamera {
  39941. /**
  39942. * Creates a new StereoscopicUniversalCamera
  39943. * @param name defines camera name
  39944. * @param position defines initial position
  39945. * @param interaxialDistance defines distance between each color axis
  39946. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39947. * @param scene defines the hosting scene
  39948. */
  39949. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39950. /**
  39951. * Gets camera class name
  39952. * @returns StereoscopicUniversalCamera
  39953. */
  39954. getClassName(): string;
  39955. }
  39956. }
  39957. declare module BABYLON {
  39958. /**
  39959. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39960. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39961. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39962. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39963. */
  39964. export class VirtualJoysticksCamera extends FreeCamera {
  39965. /**
  39966. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39967. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39968. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39969. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39970. * @param name Define the name of the camera in the scene
  39971. * @param position Define the start position of the camera in the scene
  39972. * @param scene Define the scene the camera belongs to
  39973. */
  39974. constructor(name: string, position: Vector3, scene: Scene);
  39975. /**
  39976. * Gets the current object class name.
  39977. * @return the class name
  39978. */
  39979. getClassName(): string;
  39980. }
  39981. }
  39982. declare module BABYLON {
  39983. /**
  39984. * This represents all the required metrics to create a VR camera.
  39985. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39986. */
  39987. export class VRCameraMetrics {
  39988. /**
  39989. * Define the horizontal resolution off the screen.
  39990. */
  39991. hResolution: number;
  39992. /**
  39993. * Define the vertical resolution off the screen.
  39994. */
  39995. vResolution: number;
  39996. /**
  39997. * Define the horizontal screen size.
  39998. */
  39999. hScreenSize: number;
  40000. /**
  40001. * Define the vertical screen size.
  40002. */
  40003. vScreenSize: number;
  40004. /**
  40005. * Define the vertical screen center position.
  40006. */
  40007. vScreenCenter: number;
  40008. /**
  40009. * Define the distance of the eyes to the screen.
  40010. */
  40011. eyeToScreenDistance: number;
  40012. /**
  40013. * Define the distance between both lenses
  40014. */
  40015. lensSeparationDistance: number;
  40016. /**
  40017. * Define the distance between both viewer's eyes.
  40018. */
  40019. interpupillaryDistance: number;
  40020. /**
  40021. * Define the distortion factor of the VR postprocess.
  40022. * Please, touch with care.
  40023. */
  40024. distortionK: number[];
  40025. /**
  40026. * Define the chromatic aberration correction factors for the VR post process.
  40027. */
  40028. chromaAbCorrection: number[];
  40029. /**
  40030. * Define the scale factor of the post process.
  40031. * The smaller the better but the slower.
  40032. */
  40033. postProcessScaleFactor: number;
  40034. /**
  40035. * Define an offset for the lens center.
  40036. */
  40037. lensCenterOffset: number;
  40038. /**
  40039. * Define if the current vr camera should compensate the distortion of the lense or not.
  40040. */
  40041. compensateDistortion: boolean;
  40042. /**
  40043. * Defines if multiview should be enabled when rendering (Default: false)
  40044. */
  40045. multiviewEnabled: boolean;
  40046. /**
  40047. * Gets the rendering aspect ratio based on the provided resolutions.
  40048. */
  40049. readonly aspectRatio: number;
  40050. /**
  40051. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40052. */
  40053. readonly aspectRatioFov: number;
  40054. /**
  40055. * @hidden
  40056. */
  40057. readonly leftHMatrix: Matrix;
  40058. /**
  40059. * @hidden
  40060. */
  40061. readonly rightHMatrix: Matrix;
  40062. /**
  40063. * @hidden
  40064. */
  40065. readonly leftPreViewMatrix: Matrix;
  40066. /**
  40067. * @hidden
  40068. */
  40069. readonly rightPreViewMatrix: Matrix;
  40070. /**
  40071. * Get the default VRMetrics based on the most generic setup.
  40072. * @returns the default vr metrics
  40073. */
  40074. static GetDefault(): VRCameraMetrics;
  40075. }
  40076. }
  40077. declare module BABYLON {
  40078. /** @hidden */
  40079. export var vrDistortionCorrectionPixelShader: {
  40080. name: string;
  40081. shader: string;
  40082. };
  40083. }
  40084. declare module BABYLON {
  40085. /**
  40086. * VRDistortionCorrectionPostProcess used for mobile VR
  40087. */
  40088. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40089. private _isRightEye;
  40090. private _distortionFactors;
  40091. private _postProcessScaleFactor;
  40092. private _lensCenterOffset;
  40093. private _scaleIn;
  40094. private _scaleFactor;
  40095. private _lensCenter;
  40096. /**
  40097. * Initializes the VRDistortionCorrectionPostProcess
  40098. * @param name The name of the effect.
  40099. * @param camera The camera to apply the render pass to.
  40100. * @param isRightEye If this is for the right eye distortion
  40101. * @param vrMetrics All the required metrics for the VR camera
  40102. */
  40103. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40104. }
  40105. }
  40106. declare module BABYLON {
  40107. /**
  40108. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40109. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40110. */
  40111. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40112. /**
  40113. * Creates a new VRDeviceOrientationArcRotateCamera
  40114. * @param name defines camera name
  40115. * @param alpha defines the camera rotation along the logitudinal axis
  40116. * @param beta defines the camera rotation along the latitudinal axis
  40117. * @param radius defines the camera distance from its target
  40118. * @param target defines the camera target
  40119. * @param scene defines the scene the camera belongs to
  40120. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40121. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40122. */
  40123. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40124. /**
  40125. * Gets camera class name
  40126. * @returns VRDeviceOrientationArcRotateCamera
  40127. */
  40128. getClassName(): string;
  40129. }
  40130. }
  40131. declare module BABYLON {
  40132. /**
  40133. * Camera used to simulate VR rendering (based on FreeCamera)
  40134. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40135. */
  40136. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40137. /**
  40138. * Creates a new VRDeviceOrientationFreeCamera
  40139. * @param name defines camera name
  40140. * @param position defines the start position of the camera
  40141. * @param scene defines the scene the camera belongs to
  40142. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40143. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40144. */
  40145. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40146. /**
  40147. * Gets camera class name
  40148. * @returns VRDeviceOrientationFreeCamera
  40149. */
  40150. getClassName(): string;
  40151. }
  40152. }
  40153. declare module BABYLON {
  40154. /**
  40155. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40156. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40157. */
  40158. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40159. /**
  40160. * Creates a new VRDeviceOrientationGamepadCamera
  40161. * @param name defines camera name
  40162. * @param position defines the start position of the camera
  40163. * @param scene defines the scene the camera belongs to
  40164. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40165. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40166. */
  40167. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40168. /**
  40169. * Gets camera class name
  40170. * @returns VRDeviceOrientationGamepadCamera
  40171. */
  40172. getClassName(): string;
  40173. }
  40174. }
  40175. declare module BABYLON {
  40176. /**
  40177. * Base class of materials working in push mode in babylon JS
  40178. * @hidden
  40179. */
  40180. export class PushMaterial extends Material {
  40181. protected _activeEffect: Effect;
  40182. protected _normalMatrix: Matrix;
  40183. /**
  40184. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40185. * This means that the material can keep using a previous shader while a new one is being compiled.
  40186. * This is mostly used when shader parallel compilation is supported (true by default)
  40187. */
  40188. allowShaderHotSwapping: boolean;
  40189. constructor(name: string, scene: Scene);
  40190. getEffect(): Effect;
  40191. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40192. /**
  40193. * Binds the given world matrix to the active effect
  40194. *
  40195. * @param world the matrix to bind
  40196. */
  40197. bindOnlyWorldMatrix(world: Matrix): void;
  40198. /**
  40199. * Binds the given normal matrix to the active effect
  40200. *
  40201. * @param normalMatrix the matrix to bind
  40202. */
  40203. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40204. bind(world: Matrix, mesh?: Mesh): void;
  40205. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40206. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40207. }
  40208. }
  40209. declare module BABYLON {
  40210. /**
  40211. * This groups all the flags used to control the materials channel.
  40212. */
  40213. export class MaterialFlags {
  40214. private static _DiffuseTextureEnabled;
  40215. /**
  40216. * Are diffuse textures enabled in the application.
  40217. */
  40218. static DiffuseTextureEnabled: boolean;
  40219. private static _AmbientTextureEnabled;
  40220. /**
  40221. * Are ambient textures enabled in the application.
  40222. */
  40223. static AmbientTextureEnabled: boolean;
  40224. private static _OpacityTextureEnabled;
  40225. /**
  40226. * Are opacity textures enabled in the application.
  40227. */
  40228. static OpacityTextureEnabled: boolean;
  40229. private static _ReflectionTextureEnabled;
  40230. /**
  40231. * Are reflection textures enabled in the application.
  40232. */
  40233. static ReflectionTextureEnabled: boolean;
  40234. private static _EmissiveTextureEnabled;
  40235. /**
  40236. * Are emissive textures enabled in the application.
  40237. */
  40238. static EmissiveTextureEnabled: boolean;
  40239. private static _SpecularTextureEnabled;
  40240. /**
  40241. * Are specular textures enabled in the application.
  40242. */
  40243. static SpecularTextureEnabled: boolean;
  40244. private static _BumpTextureEnabled;
  40245. /**
  40246. * Are bump textures enabled in the application.
  40247. */
  40248. static BumpTextureEnabled: boolean;
  40249. private static _LightmapTextureEnabled;
  40250. /**
  40251. * Are lightmap textures enabled in the application.
  40252. */
  40253. static LightmapTextureEnabled: boolean;
  40254. private static _RefractionTextureEnabled;
  40255. /**
  40256. * Are refraction textures enabled in the application.
  40257. */
  40258. static RefractionTextureEnabled: boolean;
  40259. private static _ColorGradingTextureEnabled;
  40260. /**
  40261. * Are color grading textures enabled in the application.
  40262. */
  40263. static ColorGradingTextureEnabled: boolean;
  40264. private static _FresnelEnabled;
  40265. /**
  40266. * Are fresnels enabled in the application.
  40267. */
  40268. static FresnelEnabled: boolean;
  40269. private static _ClearCoatTextureEnabled;
  40270. /**
  40271. * Are clear coat textures enabled in the application.
  40272. */
  40273. static ClearCoatTextureEnabled: boolean;
  40274. private static _ClearCoatBumpTextureEnabled;
  40275. /**
  40276. * Are clear coat bump textures enabled in the application.
  40277. */
  40278. static ClearCoatBumpTextureEnabled: boolean;
  40279. private static _ClearCoatTintTextureEnabled;
  40280. /**
  40281. * Are clear coat tint textures enabled in the application.
  40282. */
  40283. static ClearCoatTintTextureEnabled: boolean;
  40284. private static _SheenTextureEnabled;
  40285. /**
  40286. * Are sheen textures enabled in the application.
  40287. */
  40288. static SheenTextureEnabled: boolean;
  40289. private static _AnisotropicTextureEnabled;
  40290. /**
  40291. * Are anisotropic textures enabled in the application.
  40292. */
  40293. static AnisotropicTextureEnabled: boolean;
  40294. private static _ThicknessTextureEnabled;
  40295. /**
  40296. * Are thickness textures enabled in the application.
  40297. */
  40298. static ThicknessTextureEnabled: boolean;
  40299. }
  40300. }
  40301. declare module BABYLON {
  40302. /** @hidden */
  40303. export var defaultFragmentDeclaration: {
  40304. name: string;
  40305. shader: string;
  40306. };
  40307. }
  40308. declare module BABYLON {
  40309. /** @hidden */
  40310. export var defaultUboDeclaration: {
  40311. name: string;
  40312. shader: string;
  40313. };
  40314. }
  40315. declare module BABYLON {
  40316. /** @hidden */
  40317. export var lightFragmentDeclaration: {
  40318. name: string;
  40319. shader: string;
  40320. };
  40321. }
  40322. declare module BABYLON {
  40323. /** @hidden */
  40324. export var lightUboDeclaration: {
  40325. name: string;
  40326. shader: string;
  40327. };
  40328. }
  40329. declare module BABYLON {
  40330. /** @hidden */
  40331. export var lightsFragmentFunctions: {
  40332. name: string;
  40333. shader: string;
  40334. };
  40335. }
  40336. declare module BABYLON {
  40337. /** @hidden */
  40338. export var shadowsFragmentFunctions: {
  40339. name: string;
  40340. shader: string;
  40341. };
  40342. }
  40343. declare module BABYLON {
  40344. /** @hidden */
  40345. export var fresnelFunction: {
  40346. name: string;
  40347. shader: string;
  40348. };
  40349. }
  40350. declare module BABYLON {
  40351. /** @hidden */
  40352. export var reflectionFunction: {
  40353. name: string;
  40354. shader: string;
  40355. };
  40356. }
  40357. declare module BABYLON {
  40358. /** @hidden */
  40359. export var bumpFragmentFunctions: {
  40360. name: string;
  40361. shader: string;
  40362. };
  40363. }
  40364. declare module BABYLON {
  40365. /** @hidden */
  40366. export var logDepthDeclaration: {
  40367. name: string;
  40368. shader: string;
  40369. };
  40370. }
  40371. declare module BABYLON {
  40372. /** @hidden */
  40373. export var bumpFragment: {
  40374. name: string;
  40375. shader: string;
  40376. };
  40377. }
  40378. declare module BABYLON {
  40379. /** @hidden */
  40380. export var depthPrePass: {
  40381. name: string;
  40382. shader: string;
  40383. };
  40384. }
  40385. declare module BABYLON {
  40386. /** @hidden */
  40387. export var lightFragment: {
  40388. name: string;
  40389. shader: string;
  40390. };
  40391. }
  40392. declare module BABYLON {
  40393. /** @hidden */
  40394. export var logDepthFragment: {
  40395. name: string;
  40396. shader: string;
  40397. };
  40398. }
  40399. declare module BABYLON {
  40400. /** @hidden */
  40401. export var defaultPixelShader: {
  40402. name: string;
  40403. shader: string;
  40404. };
  40405. }
  40406. declare module BABYLON {
  40407. /** @hidden */
  40408. export var defaultVertexDeclaration: {
  40409. name: string;
  40410. shader: string;
  40411. };
  40412. }
  40413. declare module BABYLON {
  40414. /** @hidden */
  40415. export var bumpVertexDeclaration: {
  40416. name: string;
  40417. shader: string;
  40418. };
  40419. }
  40420. declare module BABYLON {
  40421. /** @hidden */
  40422. export var bumpVertex: {
  40423. name: string;
  40424. shader: string;
  40425. };
  40426. }
  40427. declare module BABYLON {
  40428. /** @hidden */
  40429. export var fogVertex: {
  40430. name: string;
  40431. shader: string;
  40432. };
  40433. }
  40434. declare module BABYLON {
  40435. /** @hidden */
  40436. export var shadowsVertex: {
  40437. name: string;
  40438. shader: string;
  40439. };
  40440. }
  40441. declare module BABYLON {
  40442. /** @hidden */
  40443. export var pointCloudVertex: {
  40444. name: string;
  40445. shader: string;
  40446. };
  40447. }
  40448. declare module BABYLON {
  40449. /** @hidden */
  40450. export var logDepthVertex: {
  40451. name: string;
  40452. shader: string;
  40453. };
  40454. }
  40455. declare module BABYLON {
  40456. /** @hidden */
  40457. export var defaultVertexShader: {
  40458. name: string;
  40459. shader: string;
  40460. };
  40461. }
  40462. declare module BABYLON {
  40463. /** @hidden */
  40464. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40465. MAINUV1: boolean;
  40466. MAINUV2: boolean;
  40467. DIFFUSE: boolean;
  40468. DIFFUSEDIRECTUV: number;
  40469. AMBIENT: boolean;
  40470. AMBIENTDIRECTUV: number;
  40471. OPACITY: boolean;
  40472. OPACITYDIRECTUV: number;
  40473. OPACITYRGB: boolean;
  40474. REFLECTION: boolean;
  40475. EMISSIVE: boolean;
  40476. EMISSIVEDIRECTUV: number;
  40477. SPECULAR: boolean;
  40478. SPECULARDIRECTUV: number;
  40479. BUMP: boolean;
  40480. BUMPDIRECTUV: number;
  40481. PARALLAX: boolean;
  40482. PARALLAXOCCLUSION: boolean;
  40483. SPECULAROVERALPHA: boolean;
  40484. CLIPPLANE: boolean;
  40485. CLIPPLANE2: boolean;
  40486. CLIPPLANE3: boolean;
  40487. CLIPPLANE4: boolean;
  40488. ALPHATEST: boolean;
  40489. DEPTHPREPASS: boolean;
  40490. ALPHAFROMDIFFUSE: boolean;
  40491. POINTSIZE: boolean;
  40492. FOG: boolean;
  40493. SPECULARTERM: boolean;
  40494. DIFFUSEFRESNEL: boolean;
  40495. OPACITYFRESNEL: boolean;
  40496. REFLECTIONFRESNEL: boolean;
  40497. REFRACTIONFRESNEL: boolean;
  40498. EMISSIVEFRESNEL: boolean;
  40499. FRESNEL: boolean;
  40500. NORMAL: boolean;
  40501. UV1: boolean;
  40502. UV2: boolean;
  40503. VERTEXCOLOR: boolean;
  40504. VERTEXALPHA: boolean;
  40505. NUM_BONE_INFLUENCERS: number;
  40506. BonesPerMesh: number;
  40507. BONETEXTURE: boolean;
  40508. INSTANCES: boolean;
  40509. GLOSSINESS: boolean;
  40510. ROUGHNESS: boolean;
  40511. EMISSIVEASILLUMINATION: boolean;
  40512. LINKEMISSIVEWITHDIFFUSE: boolean;
  40513. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40514. LIGHTMAP: boolean;
  40515. LIGHTMAPDIRECTUV: number;
  40516. OBJECTSPACE_NORMALMAP: boolean;
  40517. USELIGHTMAPASSHADOWMAP: boolean;
  40518. REFLECTIONMAP_3D: boolean;
  40519. REFLECTIONMAP_SPHERICAL: boolean;
  40520. REFLECTIONMAP_PLANAR: boolean;
  40521. REFLECTIONMAP_CUBIC: boolean;
  40522. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40523. REFLECTIONMAP_PROJECTION: boolean;
  40524. REFLECTIONMAP_SKYBOX: boolean;
  40525. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40526. REFLECTIONMAP_EXPLICIT: boolean;
  40527. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40528. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40529. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40530. INVERTCUBICMAP: boolean;
  40531. LOGARITHMICDEPTH: boolean;
  40532. REFRACTION: boolean;
  40533. REFRACTIONMAP_3D: boolean;
  40534. REFLECTIONOVERALPHA: boolean;
  40535. TWOSIDEDLIGHTING: boolean;
  40536. SHADOWFLOAT: boolean;
  40537. MORPHTARGETS: boolean;
  40538. MORPHTARGETS_NORMAL: boolean;
  40539. MORPHTARGETS_TANGENT: boolean;
  40540. MORPHTARGETS_UV: boolean;
  40541. NUM_MORPH_INFLUENCERS: number;
  40542. NONUNIFORMSCALING: boolean;
  40543. PREMULTIPLYALPHA: boolean;
  40544. IMAGEPROCESSING: boolean;
  40545. VIGNETTE: boolean;
  40546. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40547. VIGNETTEBLENDMODEOPAQUE: boolean;
  40548. TONEMAPPING: boolean;
  40549. TONEMAPPING_ACES: boolean;
  40550. CONTRAST: boolean;
  40551. COLORCURVES: boolean;
  40552. COLORGRADING: boolean;
  40553. COLORGRADING3D: boolean;
  40554. SAMPLER3DGREENDEPTH: boolean;
  40555. SAMPLER3DBGRMAP: boolean;
  40556. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40557. MULTIVIEW: boolean;
  40558. /**
  40559. * If the reflection texture on this material is in linear color space
  40560. * @hidden
  40561. */
  40562. IS_REFLECTION_LINEAR: boolean;
  40563. /**
  40564. * If the refraction texture on this material is in linear color space
  40565. * @hidden
  40566. */
  40567. IS_REFRACTION_LINEAR: boolean;
  40568. EXPOSURE: boolean;
  40569. constructor();
  40570. setReflectionMode(modeToEnable: string): void;
  40571. }
  40572. /**
  40573. * This is the default material used in Babylon. It is the best trade off between quality
  40574. * and performances.
  40575. * @see http://doc.babylonjs.com/babylon101/materials
  40576. */
  40577. export class StandardMaterial extends PushMaterial {
  40578. private _diffuseTexture;
  40579. /**
  40580. * The basic texture of the material as viewed under a light.
  40581. */
  40582. diffuseTexture: Nullable<BaseTexture>;
  40583. private _ambientTexture;
  40584. /**
  40585. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40586. */
  40587. ambientTexture: Nullable<BaseTexture>;
  40588. private _opacityTexture;
  40589. /**
  40590. * Define the transparency of the material from a texture.
  40591. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40592. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40593. */
  40594. opacityTexture: Nullable<BaseTexture>;
  40595. private _reflectionTexture;
  40596. /**
  40597. * Define the texture used to display the reflection.
  40598. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40599. */
  40600. reflectionTexture: Nullable<BaseTexture>;
  40601. private _emissiveTexture;
  40602. /**
  40603. * Define texture of the material as if self lit.
  40604. * This will be mixed in the final result even in the absence of light.
  40605. */
  40606. emissiveTexture: Nullable<BaseTexture>;
  40607. private _specularTexture;
  40608. /**
  40609. * Define how the color and intensity of the highlight given by the light in the material.
  40610. */
  40611. specularTexture: Nullable<BaseTexture>;
  40612. private _bumpTexture;
  40613. /**
  40614. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40615. * 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.
  40616. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40617. */
  40618. bumpTexture: Nullable<BaseTexture>;
  40619. private _lightmapTexture;
  40620. /**
  40621. * Complex lighting can be computationally expensive to compute at runtime.
  40622. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40623. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40624. */
  40625. lightmapTexture: Nullable<BaseTexture>;
  40626. private _refractionTexture;
  40627. /**
  40628. * Define the texture used to display the refraction.
  40629. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40630. */
  40631. refractionTexture: Nullable<BaseTexture>;
  40632. /**
  40633. * The color of the material lit by the environmental background lighting.
  40634. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40635. */
  40636. ambientColor: Color3;
  40637. /**
  40638. * The basic color of the material as viewed under a light.
  40639. */
  40640. diffuseColor: Color3;
  40641. /**
  40642. * Define how the color and intensity of the highlight given by the light in the material.
  40643. */
  40644. specularColor: Color3;
  40645. /**
  40646. * Define the color of the material as if self lit.
  40647. * This will be mixed in the final result even in the absence of light.
  40648. */
  40649. emissiveColor: Color3;
  40650. /**
  40651. * Defines how sharp are the highlights in the material.
  40652. * The bigger the value the sharper giving a more glossy feeling to the result.
  40653. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40654. */
  40655. specularPower: number;
  40656. private _useAlphaFromDiffuseTexture;
  40657. /**
  40658. * Does the transparency come from the diffuse texture alpha channel.
  40659. */
  40660. useAlphaFromDiffuseTexture: boolean;
  40661. private _useEmissiveAsIllumination;
  40662. /**
  40663. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40664. */
  40665. useEmissiveAsIllumination: boolean;
  40666. private _linkEmissiveWithDiffuse;
  40667. /**
  40668. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40669. * the emissive level when the final color is close to one.
  40670. */
  40671. linkEmissiveWithDiffuse: boolean;
  40672. private _useSpecularOverAlpha;
  40673. /**
  40674. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40675. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40676. */
  40677. useSpecularOverAlpha: boolean;
  40678. private _useReflectionOverAlpha;
  40679. /**
  40680. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40681. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40682. */
  40683. useReflectionOverAlpha: boolean;
  40684. private _disableLighting;
  40685. /**
  40686. * Does lights from the scene impacts this material.
  40687. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40688. */
  40689. disableLighting: boolean;
  40690. private _useObjectSpaceNormalMap;
  40691. /**
  40692. * Allows using an object space normal map (instead of tangent space).
  40693. */
  40694. useObjectSpaceNormalMap: boolean;
  40695. private _useParallax;
  40696. /**
  40697. * Is parallax enabled or not.
  40698. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40699. */
  40700. useParallax: boolean;
  40701. private _useParallaxOcclusion;
  40702. /**
  40703. * Is parallax occlusion enabled or not.
  40704. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40705. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40706. */
  40707. useParallaxOcclusion: boolean;
  40708. /**
  40709. * 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.
  40710. */
  40711. parallaxScaleBias: number;
  40712. private _roughness;
  40713. /**
  40714. * Helps to define how blurry the reflections should appears in the material.
  40715. */
  40716. roughness: number;
  40717. /**
  40718. * In case of refraction, define the value of the index of refraction.
  40719. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40720. */
  40721. indexOfRefraction: number;
  40722. /**
  40723. * Invert the refraction texture alongside the y axis.
  40724. * It can be useful with procedural textures or probe for instance.
  40725. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40726. */
  40727. invertRefractionY: boolean;
  40728. /**
  40729. * Defines the alpha limits in alpha test mode.
  40730. */
  40731. alphaCutOff: number;
  40732. private _useLightmapAsShadowmap;
  40733. /**
  40734. * In case of light mapping, define whether the map contains light or shadow informations.
  40735. */
  40736. useLightmapAsShadowmap: boolean;
  40737. private _diffuseFresnelParameters;
  40738. /**
  40739. * Define the diffuse fresnel parameters of the material.
  40740. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40741. */
  40742. diffuseFresnelParameters: FresnelParameters;
  40743. private _opacityFresnelParameters;
  40744. /**
  40745. * Define the opacity fresnel parameters of the material.
  40746. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40747. */
  40748. opacityFresnelParameters: FresnelParameters;
  40749. private _reflectionFresnelParameters;
  40750. /**
  40751. * Define the reflection fresnel parameters of the material.
  40752. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40753. */
  40754. reflectionFresnelParameters: FresnelParameters;
  40755. private _refractionFresnelParameters;
  40756. /**
  40757. * Define the refraction fresnel parameters of the material.
  40758. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40759. */
  40760. refractionFresnelParameters: FresnelParameters;
  40761. private _emissiveFresnelParameters;
  40762. /**
  40763. * Define the emissive fresnel parameters of the material.
  40764. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40765. */
  40766. emissiveFresnelParameters: FresnelParameters;
  40767. private _useReflectionFresnelFromSpecular;
  40768. /**
  40769. * If true automatically deducts the fresnels values from the material specularity.
  40770. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40771. */
  40772. useReflectionFresnelFromSpecular: boolean;
  40773. private _useGlossinessFromSpecularMapAlpha;
  40774. /**
  40775. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40776. */
  40777. useGlossinessFromSpecularMapAlpha: boolean;
  40778. private _maxSimultaneousLights;
  40779. /**
  40780. * Defines the maximum number of lights that can be used in the material
  40781. */
  40782. maxSimultaneousLights: number;
  40783. private _invertNormalMapX;
  40784. /**
  40785. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40786. */
  40787. invertNormalMapX: boolean;
  40788. private _invertNormalMapY;
  40789. /**
  40790. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40791. */
  40792. invertNormalMapY: boolean;
  40793. private _twoSidedLighting;
  40794. /**
  40795. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40796. */
  40797. twoSidedLighting: boolean;
  40798. /**
  40799. * Default configuration related to image processing available in the standard Material.
  40800. */
  40801. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40802. /**
  40803. * Gets the image processing configuration used either in this material.
  40804. */
  40805. /**
  40806. * Sets the Default image processing configuration used either in the this material.
  40807. *
  40808. * If sets to null, the scene one is in use.
  40809. */
  40810. imageProcessingConfiguration: ImageProcessingConfiguration;
  40811. /**
  40812. * Keep track of the image processing observer to allow dispose and replace.
  40813. */
  40814. private _imageProcessingObserver;
  40815. /**
  40816. * Attaches a new image processing configuration to the Standard Material.
  40817. * @param configuration
  40818. */
  40819. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40820. /**
  40821. * Gets wether the color curves effect is enabled.
  40822. */
  40823. /**
  40824. * Sets wether the color curves effect is enabled.
  40825. */
  40826. cameraColorCurvesEnabled: boolean;
  40827. /**
  40828. * Gets wether the color grading effect is enabled.
  40829. */
  40830. /**
  40831. * Gets wether the color grading effect is enabled.
  40832. */
  40833. cameraColorGradingEnabled: boolean;
  40834. /**
  40835. * Gets wether tonemapping is enabled or not.
  40836. */
  40837. /**
  40838. * Sets wether tonemapping is enabled or not
  40839. */
  40840. cameraToneMappingEnabled: boolean;
  40841. /**
  40842. * The camera exposure used on this material.
  40843. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40844. * This corresponds to a photographic exposure.
  40845. */
  40846. /**
  40847. * The camera exposure used on this material.
  40848. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40849. * This corresponds to a photographic exposure.
  40850. */
  40851. cameraExposure: number;
  40852. /**
  40853. * Gets The camera contrast used on this material.
  40854. */
  40855. /**
  40856. * Sets The camera contrast used on this material.
  40857. */
  40858. cameraContrast: number;
  40859. /**
  40860. * Gets the Color Grading 2D Lookup Texture.
  40861. */
  40862. /**
  40863. * Sets the Color Grading 2D Lookup Texture.
  40864. */
  40865. cameraColorGradingTexture: Nullable<BaseTexture>;
  40866. /**
  40867. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40868. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40869. * 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;
  40870. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40871. */
  40872. /**
  40873. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40874. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40875. * 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;
  40876. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40877. */
  40878. cameraColorCurves: Nullable<ColorCurves>;
  40879. /**
  40880. * Custom callback helping to override the default shader used in the material.
  40881. */
  40882. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40883. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40884. protected _worldViewProjectionMatrix: Matrix;
  40885. protected _globalAmbientColor: Color3;
  40886. protected _useLogarithmicDepth: boolean;
  40887. protected _rebuildInParallel: boolean;
  40888. /**
  40889. * Instantiates a new standard material.
  40890. * This is the default material used in Babylon. It is the best trade off between quality
  40891. * and performances.
  40892. * @see http://doc.babylonjs.com/babylon101/materials
  40893. * @param name Define the name of the material in the scene
  40894. * @param scene Define the scene the material belong to
  40895. */
  40896. constructor(name: string, scene: Scene);
  40897. /**
  40898. * Gets a boolean indicating that current material needs to register RTT
  40899. */
  40900. readonly hasRenderTargetTextures: boolean;
  40901. /**
  40902. * Gets the current class name of the material e.g. "StandardMaterial"
  40903. * Mainly use in serialization.
  40904. * @returns the class name
  40905. */
  40906. getClassName(): string;
  40907. /**
  40908. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40909. * You can try switching to logarithmic depth.
  40910. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40911. */
  40912. useLogarithmicDepth: boolean;
  40913. /**
  40914. * Specifies if the material will require alpha blending
  40915. * @returns a boolean specifying if alpha blending is needed
  40916. */
  40917. needAlphaBlending(): boolean;
  40918. /**
  40919. * Specifies if this material should be rendered in alpha test mode
  40920. * @returns a boolean specifying if an alpha test is needed.
  40921. */
  40922. needAlphaTesting(): boolean;
  40923. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40924. /**
  40925. * Get the texture used for alpha test purpose.
  40926. * @returns the diffuse texture in case of the standard material.
  40927. */
  40928. getAlphaTestTexture(): Nullable<BaseTexture>;
  40929. /**
  40930. * Get if the submesh is ready to be used and all its information available.
  40931. * Child classes can use it to update shaders
  40932. * @param mesh defines the mesh to check
  40933. * @param subMesh defines which submesh to check
  40934. * @param useInstances specifies that instances should be used
  40935. * @returns a boolean indicating that the submesh is ready or not
  40936. */
  40937. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40938. /**
  40939. * Builds the material UBO layouts.
  40940. * Used internally during the effect preparation.
  40941. */
  40942. buildUniformLayout(): void;
  40943. /**
  40944. * Unbinds the material from the mesh
  40945. */
  40946. unbind(): void;
  40947. /**
  40948. * Binds the submesh to this material by preparing the effect and shader to draw
  40949. * @param world defines the world transformation matrix
  40950. * @param mesh defines the mesh containing the submesh
  40951. * @param subMesh defines the submesh to bind the material to
  40952. */
  40953. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40954. /**
  40955. * Get the list of animatables in the material.
  40956. * @returns the list of animatables object used in the material
  40957. */
  40958. getAnimatables(): IAnimatable[];
  40959. /**
  40960. * Gets the active textures from the material
  40961. * @returns an array of textures
  40962. */
  40963. getActiveTextures(): BaseTexture[];
  40964. /**
  40965. * Specifies if the material uses a texture
  40966. * @param texture defines the texture to check against the material
  40967. * @returns a boolean specifying if the material uses the texture
  40968. */
  40969. hasTexture(texture: BaseTexture): boolean;
  40970. /**
  40971. * Disposes the material
  40972. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40973. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40974. */
  40975. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40976. /**
  40977. * Makes a duplicate of the material, and gives it a new name
  40978. * @param name defines the new name for the duplicated material
  40979. * @returns the cloned material
  40980. */
  40981. clone(name: string): StandardMaterial;
  40982. /**
  40983. * Serializes this material in a JSON representation
  40984. * @returns the serialized material object
  40985. */
  40986. serialize(): any;
  40987. /**
  40988. * Creates a standard material from parsed material data
  40989. * @param source defines the JSON representation of the material
  40990. * @param scene defines the hosting scene
  40991. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40992. * @returns a new standard material
  40993. */
  40994. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40995. /**
  40996. * Are diffuse textures enabled in the application.
  40997. */
  40998. static DiffuseTextureEnabled: boolean;
  40999. /**
  41000. * Are ambient textures enabled in the application.
  41001. */
  41002. static AmbientTextureEnabled: boolean;
  41003. /**
  41004. * Are opacity textures enabled in the application.
  41005. */
  41006. static OpacityTextureEnabled: boolean;
  41007. /**
  41008. * Are reflection textures enabled in the application.
  41009. */
  41010. static ReflectionTextureEnabled: boolean;
  41011. /**
  41012. * Are emissive textures enabled in the application.
  41013. */
  41014. static EmissiveTextureEnabled: boolean;
  41015. /**
  41016. * Are specular textures enabled in the application.
  41017. */
  41018. static SpecularTextureEnabled: boolean;
  41019. /**
  41020. * Are bump textures enabled in the application.
  41021. */
  41022. static BumpTextureEnabled: boolean;
  41023. /**
  41024. * Are lightmap textures enabled in the application.
  41025. */
  41026. static LightmapTextureEnabled: boolean;
  41027. /**
  41028. * Are refraction textures enabled in the application.
  41029. */
  41030. static RefractionTextureEnabled: boolean;
  41031. /**
  41032. * Are color grading textures enabled in the application.
  41033. */
  41034. static ColorGradingTextureEnabled: boolean;
  41035. /**
  41036. * Are fresnels enabled in the application.
  41037. */
  41038. static FresnelEnabled: boolean;
  41039. }
  41040. }
  41041. declare module BABYLON {
  41042. /** @hidden */
  41043. export var imageProcessingPixelShader: {
  41044. name: string;
  41045. shader: string;
  41046. };
  41047. }
  41048. declare module BABYLON {
  41049. /**
  41050. * ImageProcessingPostProcess
  41051. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41052. */
  41053. export class ImageProcessingPostProcess extends PostProcess {
  41054. /**
  41055. * Default configuration related to image processing available in the PBR Material.
  41056. */
  41057. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41058. /**
  41059. * Gets the image processing configuration used either in this material.
  41060. */
  41061. /**
  41062. * Sets the Default image processing configuration used either in the this material.
  41063. *
  41064. * If sets to null, the scene one is in use.
  41065. */
  41066. imageProcessingConfiguration: ImageProcessingConfiguration;
  41067. /**
  41068. * Keep track of the image processing observer to allow dispose and replace.
  41069. */
  41070. private _imageProcessingObserver;
  41071. /**
  41072. * Attaches a new image processing configuration to the PBR Material.
  41073. * @param configuration
  41074. */
  41075. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41076. /**
  41077. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41078. */
  41079. /**
  41080. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41081. */
  41082. colorCurves: Nullable<ColorCurves>;
  41083. /**
  41084. * Gets wether the color curves effect is enabled.
  41085. */
  41086. /**
  41087. * Sets wether the color curves effect is enabled.
  41088. */
  41089. colorCurvesEnabled: boolean;
  41090. /**
  41091. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41092. */
  41093. /**
  41094. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41095. */
  41096. colorGradingTexture: Nullable<BaseTexture>;
  41097. /**
  41098. * Gets wether the color grading effect is enabled.
  41099. */
  41100. /**
  41101. * Gets wether the color grading effect is enabled.
  41102. */
  41103. colorGradingEnabled: boolean;
  41104. /**
  41105. * Gets exposure used in the effect.
  41106. */
  41107. /**
  41108. * Sets exposure used in the effect.
  41109. */
  41110. exposure: number;
  41111. /**
  41112. * Gets wether tonemapping is enabled or not.
  41113. */
  41114. /**
  41115. * Sets wether tonemapping is enabled or not
  41116. */
  41117. toneMappingEnabled: boolean;
  41118. /**
  41119. * Gets the type of tone mapping effect.
  41120. */
  41121. /**
  41122. * Sets the type of tone mapping effect.
  41123. */
  41124. toneMappingType: number;
  41125. /**
  41126. * Gets contrast used in the effect.
  41127. */
  41128. /**
  41129. * Sets contrast used in the effect.
  41130. */
  41131. contrast: number;
  41132. /**
  41133. * Gets Vignette stretch size.
  41134. */
  41135. /**
  41136. * Sets Vignette stretch size.
  41137. */
  41138. vignetteStretch: number;
  41139. /**
  41140. * Gets Vignette centre X Offset.
  41141. */
  41142. /**
  41143. * Sets Vignette centre X Offset.
  41144. */
  41145. vignetteCentreX: number;
  41146. /**
  41147. * Gets Vignette centre Y Offset.
  41148. */
  41149. /**
  41150. * Sets Vignette centre Y Offset.
  41151. */
  41152. vignetteCentreY: number;
  41153. /**
  41154. * Gets Vignette weight or intensity of the vignette effect.
  41155. */
  41156. /**
  41157. * Sets Vignette weight or intensity of the vignette effect.
  41158. */
  41159. vignetteWeight: number;
  41160. /**
  41161. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41162. * if vignetteEnabled is set to true.
  41163. */
  41164. /**
  41165. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41166. * if vignetteEnabled is set to true.
  41167. */
  41168. vignetteColor: Color4;
  41169. /**
  41170. * Gets Camera field of view used by the Vignette effect.
  41171. */
  41172. /**
  41173. * Sets Camera field of view used by the Vignette effect.
  41174. */
  41175. vignetteCameraFov: number;
  41176. /**
  41177. * Gets the vignette blend mode allowing different kind of effect.
  41178. */
  41179. /**
  41180. * Sets the vignette blend mode allowing different kind of effect.
  41181. */
  41182. vignetteBlendMode: number;
  41183. /**
  41184. * Gets wether the vignette effect is enabled.
  41185. */
  41186. /**
  41187. * Sets wether the vignette effect is enabled.
  41188. */
  41189. vignetteEnabled: boolean;
  41190. private _fromLinearSpace;
  41191. /**
  41192. * Gets wether the input of the processing is in Gamma or Linear Space.
  41193. */
  41194. /**
  41195. * Sets wether the input of the processing is in Gamma or Linear Space.
  41196. */
  41197. fromLinearSpace: boolean;
  41198. /**
  41199. * Defines cache preventing GC.
  41200. */
  41201. private _defines;
  41202. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41203. /**
  41204. * "ImageProcessingPostProcess"
  41205. * @returns "ImageProcessingPostProcess"
  41206. */
  41207. getClassName(): string;
  41208. protected _updateParameters(): void;
  41209. dispose(camera?: Camera): void;
  41210. }
  41211. }
  41212. declare module BABYLON {
  41213. /**
  41214. * Class containing static functions to help procedurally build meshes
  41215. */
  41216. export class GroundBuilder {
  41217. /**
  41218. * Creates a ground mesh
  41219. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41220. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41222. * @param name defines the name of the mesh
  41223. * @param options defines the options used to create the mesh
  41224. * @param scene defines the hosting scene
  41225. * @returns the ground mesh
  41226. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41227. */
  41228. static CreateGround(name: string, options: {
  41229. width?: number;
  41230. height?: number;
  41231. subdivisions?: number;
  41232. subdivisionsX?: number;
  41233. subdivisionsY?: number;
  41234. updatable?: boolean;
  41235. }, scene: any): Mesh;
  41236. /**
  41237. * Creates a tiled ground mesh
  41238. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41239. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41240. * * 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
  41241. * * 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
  41242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41243. * @param name defines the name of the mesh
  41244. * @param options defines the options used to create the mesh
  41245. * @param scene defines the hosting scene
  41246. * @returns the tiled ground mesh
  41247. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41248. */
  41249. static CreateTiledGround(name: string, options: {
  41250. xmin: number;
  41251. zmin: number;
  41252. xmax: number;
  41253. zmax: number;
  41254. subdivisions?: {
  41255. w: number;
  41256. h: number;
  41257. };
  41258. precision?: {
  41259. w: number;
  41260. h: number;
  41261. };
  41262. updatable?: boolean;
  41263. }, scene?: Nullable<Scene>): Mesh;
  41264. /**
  41265. * Creates a ground mesh from a height map
  41266. * * The parameter `url` sets the URL of the height map image resource.
  41267. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41268. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41269. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41270. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41271. * * 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.
  41272. * * 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).
  41273. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41275. * @param name defines the name of the mesh
  41276. * @param url defines the url to the height map
  41277. * @param options defines the options used to create the mesh
  41278. * @param scene defines the hosting scene
  41279. * @returns the ground mesh
  41280. * @see https://doc.babylonjs.com/babylon101/height_map
  41281. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41282. */
  41283. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41284. width?: number;
  41285. height?: number;
  41286. subdivisions?: number;
  41287. minHeight?: number;
  41288. maxHeight?: number;
  41289. colorFilter?: Color3;
  41290. alphaFilter?: number;
  41291. updatable?: boolean;
  41292. onReady?: (mesh: GroundMesh) => void;
  41293. }, scene?: Nullable<Scene>): GroundMesh;
  41294. }
  41295. }
  41296. declare module BABYLON {
  41297. /**
  41298. * Class containing static functions to help procedurally build meshes
  41299. */
  41300. export class TorusBuilder {
  41301. /**
  41302. * Creates a torus mesh
  41303. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41304. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41305. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41307. * * 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
  41308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41309. * @param name defines the name of the mesh
  41310. * @param options defines the options used to create the mesh
  41311. * @param scene defines the hosting scene
  41312. * @returns the torus mesh
  41313. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41314. */
  41315. static CreateTorus(name: string, options: {
  41316. diameter?: number;
  41317. thickness?: number;
  41318. tessellation?: number;
  41319. updatable?: boolean;
  41320. sideOrientation?: number;
  41321. frontUVs?: Vector4;
  41322. backUVs?: Vector4;
  41323. }, scene: any): Mesh;
  41324. }
  41325. }
  41326. declare module BABYLON {
  41327. /**
  41328. * Class containing static functions to help procedurally build meshes
  41329. */
  41330. export class CylinderBuilder {
  41331. /**
  41332. * Creates a cylinder or a cone mesh
  41333. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41334. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41335. * * 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.
  41336. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41337. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41338. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41339. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41340. * * 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).
  41341. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41342. * * 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).
  41343. * * 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
  41344. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41345. * * 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
  41346. * * 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.
  41347. * * If `enclose` is false, a ring surface is one element.
  41348. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41349. * * 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
  41350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41351. * * 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
  41352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41353. * @param name defines the name of the mesh
  41354. * @param options defines the options used to create the mesh
  41355. * @param scene defines the hosting scene
  41356. * @returns the cylinder mesh
  41357. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41358. */
  41359. static CreateCylinder(name: string, options: {
  41360. height?: number;
  41361. diameterTop?: number;
  41362. diameterBottom?: number;
  41363. diameter?: number;
  41364. tessellation?: number;
  41365. subdivisions?: number;
  41366. arc?: number;
  41367. faceColors?: Color4[];
  41368. faceUV?: Vector4[];
  41369. updatable?: boolean;
  41370. hasRings?: boolean;
  41371. enclose?: boolean;
  41372. cap?: number;
  41373. sideOrientation?: number;
  41374. frontUVs?: Vector4;
  41375. backUVs?: Vector4;
  41376. }, scene: any): Mesh;
  41377. }
  41378. }
  41379. declare module BABYLON {
  41380. /**
  41381. * Options to modify the vr teleportation behavior.
  41382. */
  41383. export interface VRTeleportationOptions {
  41384. /**
  41385. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41386. */
  41387. floorMeshName?: string;
  41388. /**
  41389. * A list of meshes to be used as the teleportation floor. (default: empty)
  41390. */
  41391. floorMeshes?: Mesh[];
  41392. }
  41393. /**
  41394. * Options to modify the vr experience helper's behavior.
  41395. */
  41396. export interface VRExperienceHelperOptions extends WebVROptions {
  41397. /**
  41398. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41399. */
  41400. createDeviceOrientationCamera?: boolean;
  41401. /**
  41402. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41403. */
  41404. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41405. /**
  41406. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41407. */
  41408. laserToggle?: boolean;
  41409. /**
  41410. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41411. */
  41412. floorMeshes?: Mesh[];
  41413. /**
  41414. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41415. */
  41416. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41417. }
  41418. /**
  41419. * Event containing information after VR has been entered
  41420. */
  41421. export class OnAfterEnteringVRObservableEvent {
  41422. /**
  41423. * If entering vr was successful
  41424. */
  41425. success: boolean;
  41426. }
  41427. /**
  41428. * Helps to quickly add VR support to an existing scene.
  41429. * See http://doc.babylonjs.com/how_to/webvr_helper
  41430. */
  41431. export class VRExperienceHelper {
  41432. /** Options to modify the vr experience helper's behavior. */
  41433. webVROptions: VRExperienceHelperOptions;
  41434. private _scene;
  41435. private _position;
  41436. private _btnVR;
  41437. private _btnVRDisplayed;
  41438. private _webVRsupported;
  41439. private _webVRready;
  41440. private _webVRrequesting;
  41441. private _webVRpresenting;
  41442. private _hasEnteredVR;
  41443. private _fullscreenVRpresenting;
  41444. private _inputElement;
  41445. private _webVRCamera;
  41446. private _vrDeviceOrientationCamera;
  41447. private _deviceOrientationCamera;
  41448. private _existingCamera;
  41449. private _onKeyDown;
  41450. private _onVrDisplayPresentChange;
  41451. private _onVRDisplayChanged;
  41452. private _onVRRequestPresentStart;
  41453. private _onVRRequestPresentComplete;
  41454. /**
  41455. * 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)
  41456. */
  41457. enableGazeEvenWhenNoPointerLock: boolean;
  41458. /**
  41459. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41460. */
  41461. exitVROnDoubleTap: boolean;
  41462. /**
  41463. * Observable raised right before entering VR.
  41464. */
  41465. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41466. /**
  41467. * Observable raised when entering VR has completed.
  41468. */
  41469. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41470. /**
  41471. * Observable raised when exiting VR.
  41472. */
  41473. onExitingVRObservable: Observable<VRExperienceHelper>;
  41474. /**
  41475. * Observable raised when controller mesh is loaded.
  41476. */
  41477. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41478. /** Return this.onEnteringVRObservable
  41479. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41480. */
  41481. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41482. /** Return this.onExitingVRObservable
  41483. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41484. */
  41485. readonly onExitingVR: Observable<VRExperienceHelper>;
  41486. /** Return this.onControllerMeshLoadedObservable
  41487. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41488. */
  41489. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41490. private _rayLength;
  41491. private _useCustomVRButton;
  41492. private _teleportationRequested;
  41493. private _teleportActive;
  41494. private _floorMeshName;
  41495. private _floorMeshesCollection;
  41496. private _rotationAllowed;
  41497. private _teleportBackwardsVector;
  41498. private _teleportationTarget;
  41499. private _isDefaultTeleportationTarget;
  41500. private _postProcessMove;
  41501. private _teleportationFillColor;
  41502. private _teleportationBorderColor;
  41503. private _rotationAngle;
  41504. private _haloCenter;
  41505. private _cameraGazer;
  41506. private _padSensibilityUp;
  41507. private _padSensibilityDown;
  41508. private _leftController;
  41509. private _rightController;
  41510. /**
  41511. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41512. */
  41513. onNewMeshSelected: Observable<AbstractMesh>;
  41514. /**
  41515. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41516. * This observable will provide the mesh and the controller used to select the mesh
  41517. */
  41518. onMeshSelectedWithController: Observable<{
  41519. mesh: AbstractMesh;
  41520. controller: WebVRController;
  41521. }>;
  41522. /**
  41523. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41524. */
  41525. onNewMeshPicked: Observable<PickingInfo>;
  41526. private _circleEase;
  41527. /**
  41528. * Observable raised before camera teleportation
  41529. */
  41530. onBeforeCameraTeleport: Observable<Vector3>;
  41531. /**
  41532. * Observable raised after camera teleportation
  41533. */
  41534. onAfterCameraTeleport: Observable<Vector3>;
  41535. /**
  41536. * Observable raised when current selected mesh gets unselected
  41537. */
  41538. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41539. private _raySelectionPredicate;
  41540. /**
  41541. * To be optionaly changed by user to define custom ray selection
  41542. */
  41543. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41544. /**
  41545. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41546. */
  41547. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41548. /**
  41549. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41550. */
  41551. teleportationEnabled: boolean;
  41552. private _defaultHeight;
  41553. private _teleportationInitialized;
  41554. private _interactionsEnabled;
  41555. private _interactionsRequested;
  41556. private _displayGaze;
  41557. private _displayLaserPointer;
  41558. /**
  41559. * The mesh used to display where the user is going to teleport.
  41560. */
  41561. /**
  41562. * Sets the mesh to be used to display where the user is going to teleport.
  41563. */
  41564. teleportationTarget: Mesh;
  41565. /**
  41566. * 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
  41567. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41568. * See http://doc.babylonjs.com/resources/baking_transformations
  41569. */
  41570. gazeTrackerMesh: Mesh;
  41571. /**
  41572. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41573. */
  41574. updateGazeTrackerScale: boolean;
  41575. /**
  41576. * If the gaze trackers color should be updated when selecting meshes
  41577. */
  41578. updateGazeTrackerColor: boolean;
  41579. /**
  41580. * If the controller laser color should be updated when selecting meshes
  41581. */
  41582. updateControllerLaserColor: boolean;
  41583. /**
  41584. * The gaze tracking mesh corresponding to the left controller
  41585. */
  41586. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41587. /**
  41588. * The gaze tracking mesh corresponding to the right controller
  41589. */
  41590. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41591. /**
  41592. * If the ray of the gaze should be displayed.
  41593. */
  41594. /**
  41595. * Sets if the ray of the gaze should be displayed.
  41596. */
  41597. displayGaze: boolean;
  41598. /**
  41599. * If the ray of the LaserPointer should be displayed.
  41600. */
  41601. /**
  41602. * Sets if the ray of the LaserPointer should be displayed.
  41603. */
  41604. displayLaserPointer: boolean;
  41605. /**
  41606. * The deviceOrientationCamera used as the camera when not in VR.
  41607. */
  41608. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41609. /**
  41610. * Based on the current WebVR support, returns the current VR camera used.
  41611. */
  41612. readonly currentVRCamera: Nullable<Camera>;
  41613. /**
  41614. * The webVRCamera which is used when in VR.
  41615. */
  41616. readonly webVRCamera: WebVRFreeCamera;
  41617. /**
  41618. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41619. */
  41620. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41621. /**
  41622. * The html button that is used to trigger entering into VR.
  41623. */
  41624. readonly vrButton: Nullable<HTMLButtonElement>;
  41625. private readonly _teleportationRequestInitiated;
  41626. /**
  41627. * Defines wether or not Pointer lock should be requested when switching to
  41628. * full screen.
  41629. */
  41630. requestPointerLockOnFullScreen: boolean;
  41631. /**
  41632. * Instantiates a VRExperienceHelper.
  41633. * Helps to quickly add VR support to an existing scene.
  41634. * @param scene The scene the VRExperienceHelper belongs to.
  41635. * @param webVROptions Options to modify the vr experience helper's behavior.
  41636. */
  41637. constructor(scene: Scene,
  41638. /** Options to modify the vr experience helper's behavior. */
  41639. webVROptions?: VRExperienceHelperOptions);
  41640. private _onDefaultMeshLoaded;
  41641. private _onResize;
  41642. private _onFullscreenChange;
  41643. /**
  41644. * Gets a value indicating if we are currently in VR mode.
  41645. */
  41646. readonly isInVRMode: boolean;
  41647. private onVrDisplayPresentChange;
  41648. private onVRDisplayChanged;
  41649. private moveButtonToBottomRight;
  41650. private displayVRButton;
  41651. private updateButtonVisibility;
  41652. private _cachedAngularSensibility;
  41653. /**
  41654. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41655. * Otherwise, will use the fullscreen API.
  41656. */
  41657. enterVR(): void;
  41658. /**
  41659. * Attempt to exit VR, or fullscreen.
  41660. */
  41661. exitVR(): void;
  41662. /**
  41663. * The position of the vr experience helper.
  41664. */
  41665. /**
  41666. * Sets the position of the vr experience helper.
  41667. */
  41668. position: Vector3;
  41669. /**
  41670. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41671. */
  41672. enableInteractions(): void;
  41673. private readonly _noControllerIsActive;
  41674. private beforeRender;
  41675. private _isTeleportationFloor;
  41676. /**
  41677. * Adds a floor mesh to be used for teleportation.
  41678. * @param floorMesh the mesh to be used for teleportation.
  41679. */
  41680. addFloorMesh(floorMesh: Mesh): void;
  41681. /**
  41682. * Removes a floor mesh from being used for teleportation.
  41683. * @param floorMesh the mesh to be removed.
  41684. */
  41685. removeFloorMesh(floorMesh: Mesh): void;
  41686. /**
  41687. * Enables interactions and teleportation using the VR controllers and gaze.
  41688. * @param vrTeleportationOptions options to modify teleportation behavior.
  41689. */
  41690. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41691. private _onNewGamepadConnected;
  41692. private _tryEnableInteractionOnController;
  41693. private _onNewGamepadDisconnected;
  41694. private _enableInteractionOnController;
  41695. private _checkTeleportWithRay;
  41696. private _checkRotate;
  41697. private _checkTeleportBackwards;
  41698. private _enableTeleportationOnController;
  41699. private _createTeleportationCircles;
  41700. private _displayTeleportationTarget;
  41701. private _hideTeleportationTarget;
  41702. private _rotateCamera;
  41703. private _moveTeleportationSelectorTo;
  41704. private _workingVector;
  41705. private _workingQuaternion;
  41706. private _workingMatrix;
  41707. /**
  41708. * Teleports the users feet to the desired location
  41709. * @param location The location where the user's feet should be placed
  41710. */
  41711. teleportCamera(location: Vector3): void;
  41712. private _convertNormalToDirectionOfRay;
  41713. private _castRayAndSelectObject;
  41714. private _notifySelectedMeshUnselected;
  41715. /**
  41716. * Sets the color of the laser ray from the vr controllers.
  41717. * @param color new color for the ray.
  41718. */
  41719. changeLaserColor(color: Color3): void;
  41720. /**
  41721. * Sets the color of the ray from the vr headsets gaze.
  41722. * @param color new color for the ray.
  41723. */
  41724. changeGazeColor(color: Color3): void;
  41725. /**
  41726. * Exits VR and disposes of the vr experience helper
  41727. */
  41728. dispose(): void;
  41729. /**
  41730. * Gets the name of the VRExperienceHelper class
  41731. * @returns "VRExperienceHelper"
  41732. */
  41733. getClassName(): string;
  41734. }
  41735. }
  41736. declare module BABYLON {
  41737. /**
  41738. * States of the webXR experience
  41739. */
  41740. export enum WebXRState {
  41741. /**
  41742. * Transitioning to being in XR mode
  41743. */
  41744. ENTERING_XR = 0,
  41745. /**
  41746. * Transitioning to non XR mode
  41747. */
  41748. EXITING_XR = 1,
  41749. /**
  41750. * In XR mode and presenting
  41751. */
  41752. IN_XR = 2,
  41753. /**
  41754. * Not entered XR mode
  41755. */
  41756. NOT_IN_XR = 3
  41757. }
  41758. /**
  41759. * Abstraction of the XR render target
  41760. */
  41761. export interface WebXRRenderTarget extends IDisposable {
  41762. /**
  41763. * xrpresent context of the canvas which can be used to display/mirror xr content
  41764. */
  41765. canvasContext: WebGLRenderingContext;
  41766. /**
  41767. * xr layer for the canvas
  41768. */
  41769. xrLayer: Nullable<XRWebGLLayer>;
  41770. /**
  41771. * Initializes the xr layer for the session
  41772. * @param xrSession xr session
  41773. * @returns a promise that will resolve once the XR Layer has been created
  41774. */
  41775. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  41776. }
  41777. }
  41778. declare module BABYLON {
  41779. /**
  41780. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41781. */
  41782. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  41783. private _engine;
  41784. private _canvas;
  41785. /**
  41786. * xrpresent context of the canvas which can be used to display/mirror xr content
  41787. */
  41788. canvasContext: WebGLRenderingContext;
  41789. /**
  41790. * xr layer for the canvas
  41791. */
  41792. xrLayer: Nullable<XRWebGLLayer>;
  41793. /**
  41794. * Initializes the xr layer for the session
  41795. * @param xrSession xr session
  41796. * @returns a promise that will resolve once the XR Layer has been created
  41797. */
  41798. initializeXRLayerAsync(xrSession: any): any;
  41799. /**
  41800. * Initializes the canvas to be added/removed upon entering/exiting xr
  41801. * @param engine the Babylon engine
  41802. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41803. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  41804. */
  41805. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  41806. /**
  41807. * Disposes of the object
  41808. */
  41809. dispose(): void;
  41810. private _setManagedOutputCanvas;
  41811. private _addCanvas;
  41812. private _removeCanvas;
  41813. }
  41814. }
  41815. declare module BABYLON {
  41816. /**
  41817. * Manages an XRSession to work with Babylon's engine
  41818. * @see https://doc.babylonjs.com/how_to/webxr
  41819. */
  41820. export class WebXRSessionManager implements IDisposable {
  41821. private scene;
  41822. /**
  41823. * Fires every time a new xrFrame arrives which can be used to update the camera
  41824. */
  41825. onXRFrameObservable: Observable<any>;
  41826. /**
  41827. * Fires when the xr session is ended either by the device or manually done
  41828. */
  41829. onXRSessionEnded: Observable<any>;
  41830. /**
  41831. * Underlying xr session
  41832. */
  41833. session: XRSession;
  41834. /**
  41835. * Type of reference space used when creating the session
  41836. */
  41837. referenceSpace: XRReferenceSpace;
  41838. /**
  41839. * Current XR frame
  41840. */
  41841. currentFrame: Nullable<XRFrame>;
  41842. private _xrNavigator;
  41843. private baseLayer;
  41844. private _rttProvider;
  41845. private _sessionEnded;
  41846. /**
  41847. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41848. * @param scene The scene which the session should be created for
  41849. */
  41850. constructor(scene: Scene);
  41851. /**
  41852. * Initializes the manager
  41853. * After initialization enterXR can be called to start an XR session
  41854. * @returns Promise which resolves after it is initialized
  41855. */
  41856. initializeAsync(): Promise<void>;
  41857. /**
  41858. * Initializes an xr session
  41859. * @param xrSessionMode mode to initialize
  41860. * @param optionalFeatures defines optional values to pass to the session builder
  41861. * @returns a promise which will resolve once the session has been initialized
  41862. */
  41863. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  41864. /**
  41865. * Sets the reference space on the xr session
  41866. * @param referenceSpace space to set
  41867. * @returns a promise that will resolve once the reference space has been set
  41868. */
  41869. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41870. /**
  41871. * Updates the render state of the session
  41872. * @param state state to set
  41873. * @returns a promise that resolves once the render state has been updated
  41874. */
  41875. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41876. /**
  41877. * Starts rendering to the xr layer
  41878. * @returns a promise that will resolve once rendering has started
  41879. */
  41880. startRenderingToXRAsync(): Promise<void>;
  41881. /**
  41882. * Gets the correct render target texture to be rendered this frame for this eye
  41883. * @param eye the eye for which to get the render target
  41884. * @returns the render target for the specified eye
  41885. */
  41886. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  41887. /**
  41888. * Stops the xrSession and restores the renderloop
  41889. * @returns Promise which resolves after it exits XR
  41890. */
  41891. exitXRAsync(): Promise<void>;
  41892. /**
  41893. * Checks if a session would be supported for the creation options specified
  41894. * @param sessionMode session mode to check if supported eg. immersive-vr
  41895. * @returns true if supported
  41896. */
  41897. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41898. /**
  41899. * Creates a WebXRRenderTarget object for the XR session
  41900. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  41901. * @returns a WebXR render target to which the session can render
  41902. */
  41903. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  41904. /**
  41905. * @hidden
  41906. * Converts the render layer of xrSession to a render target
  41907. * @param session session to create render target for
  41908. * @param scene scene the new render target should be created for
  41909. */
  41910. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41911. /**
  41912. * Disposes of the session manager
  41913. */
  41914. dispose(): void;
  41915. }
  41916. }
  41917. declare module BABYLON {
  41918. /**
  41919. * WebXR Camera which holds the views for the xrSession
  41920. * @see https://doc.babylonjs.com/how_to/webxr
  41921. */
  41922. export class WebXRCamera extends FreeCamera {
  41923. private static _TmpMatrix;
  41924. /**
  41925. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41926. * @param name the name of the camera
  41927. * @param scene the scene to add the camera to
  41928. */
  41929. constructor(name: string, scene: Scene);
  41930. private _updateNumberOfRigCameras;
  41931. /** @hidden */
  41932. _updateForDualEyeDebugging(): void;
  41933. /**
  41934. * Updates the cameras position from the current pose information of the XR session
  41935. * @param xrSessionManager the session containing pose information
  41936. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41937. */
  41938. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41939. }
  41940. }
  41941. declare module BABYLON {
  41942. /**
  41943. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41944. * @see https://doc.babylonjs.com/how_to/webxr
  41945. */
  41946. export class WebXRExperienceHelper implements IDisposable {
  41947. private scene;
  41948. /**
  41949. * 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
  41950. */
  41951. container: AbstractMesh;
  41952. /**
  41953. * Camera used to render xr content
  41954. */
  41955. camera: WebXRCamera;
  41956. /**
  41957. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41958. */
  41959. state: WebXRState;
  41960. private _setState;
  41961. private static _TmpVector;
  41962. /**
  41963. * Fires when the state of the experience helper has changed
  41964. */
  41965. onStateChangedObservable: Observable<WebXRState>;
  41966. /** Session manager used to keep track of xr session */
  41967. sessionManager: WebXRSessionManager;
  41968. private _nonVRCamera;
  41969. private _originalSceneAutoClear;
  41970. private _supported;
  41971. /**
  41972. * Creates the experience helper
  41973. * @param scene the scene to attach the experience helper to
  41974. * @returns a promise for the experience helper
  41975. */
  41976. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41977. /**
  41978. * Creates a WebXRExperienceHelper
  41979. * @param scene The scene the helper should be created in
  41980. */
  41981. private constructor();
  41982. /**
  41983. * Exits XR mode and returns the scene to its original state
  41984. * @returns promise that resolves after xr mode has exited
  41985. */
  41986. exitXRAsync(): Promise<void>;
  41987. /**
  41988. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41989. * @param sessionMode options for the XR session
  41990. * @param referenceSpaceType frame of reference of the XR session
  41991. * @param renderTarget the output canvas that will be used to enter XR mode
  41992. * @returns promise that resolves after xr mode has entered
  41993. */
  41994. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  41995. /**
  41996. * Updates the global position of the camera by moving the camera's container
  41997. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41998. * @param position The desired global position of the camera
  41999. */
  42000. setPositionOfCameraUsingContainer(position: Vector3): void;
  42001. /**
  42002. * Rotates the xr camera by rotating the camera's container around the camera's position
  42003. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42004. * @param rotation the desired quaternion rotation to apply to the camera
  42005. */
  42006. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42007. /**
  42008. * Disposes of the experience helper
  42009. */
  42010. dispose(): void;
  42011. }
  42012. }
  42013. declare module BABYLON {
  42014. /**
  42015. * Button which can be used to enter a different mode of XR
  42016. */
  42017. export class WebXREnterExitUIButton {
  42018. /** button element */
  42019. element: HTMLElement;
  42020. /** XR initialization options for the button */
  42021. sessionMode: XRSessionMode;
  42022. /** Reference space type */
  42023. referenceSpaceType: XRReferenceSpaceType;
  42024. /**
  42025. * Creates a WebXREnterExitUIButton
  42026. * @param element button element
  42027. * @param sessionMode XR initialization session mode
  42028. * @param referenceSpaceType the type of reference space to be used
  42029. */
  42030. constructor(
  42031. /** button element */
  42032. element: HTMLElement,
  42033. /** XR initialization options for the button */
  42034. sessionMode: XRSessionMode,
  42035. /** Reference space type */
  42036. referenceSpaceType: XRReferenceSpaceType);
  42037. /**
  42038. * Overwritable function which can be used to update the button's visuals when the state changes
  42039. * @param activeButton the current active button in the UI
  42040. */
  42041. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42042. }
  42043. /**
  42044. * Options to create the webXR UI
  42045. */
  42046. export class WebXREnterExitUIOptions {
  42047. /**
  42048. * Context to enter xr with
  42049. */
  42050. renderTarget?: Nullable<WebXRRenderTarget>;
  42051. /**
  42052. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42053. */
  42054. customButtons?: Array<WebXREnterExitUIButton>;
  42055. }
  42056. /**
  42057. * UI to allow the user to enter/exit XR mode
  42058. */
  42059. export class WebXREnterExitUI implements IDisposable {
  42060. private scene;
  42061. private _overlay;
  42062. private _buttons;
  42063. private _activeButton;
  42064. /**
  42065. * Fired every time the active button is changed.
  42066. *
  42067. * When xr is entered via a button that launches xr that button will be the callback parameter
  42068. *
  42069. * When exiting xr the callback parameter will be null)
  42070. */
  42071. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42072. /**
  42073. * Creates UI to allow the user to enter/exit XR mode
  42074. * @param scene the scene to add the ui to
  42075. * @param helper the xr experience helper to enter/exit xr with
  42076. * @param options options to configure the UI
  42077. * @returns the created ui
  42078. */
  42079. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42080. private constructor();
  42081. private _updateButtons;
  42082. /**
  42083. * Disposes of the object
  42084. */
  42085. dispose(): void;
  42086. }
  42087. }
  42088. declare module BABYLON {
  42089. /**
  42090. * Represents an XR input
  42091. */
  42092. export class WebXRController {
  42093. private scene;
  42094. /** The underlying input source for the controller */
  42095. inputSource: XRInputSource;
  42096. private parentContainer;
  42097. /**
  42098. * 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
  42099. */
  42100. grip?: AbstractMesh;
  42101. /**
  42102. * Pointer which can be used to select objects or attach a visible laser to
  42103. */
  42104. pointer: AbstractMesh;
  42105. private _gamepadMode;
  42106. /**
  42107. * If available, this is the gamepad object related to this controller.
  42108. * Using this object it is possible to get click events and trackpad changes of the
  42109. * webxr controller that is currently being used.
  42110. */
  42111. gamepadController?: WebVRController;
  42112. /**
  42113. * Event that fires when the controller is removed/disposed
  42114. */
  42115. onDisposeObservable: Observable<{}>;
  42116. private _tmpMatrix;
  42117. private _tmpQuaternion;
  42118. private _tmpVector;
  42119. /**
  42120. * Creates the controller
  42121. * @see https://doc.babylonjs.com/how_to/webxr
  42122. * @param scene the scene which the controller should be associated to
  42123. * @param inputSource the underlying input source for the controller
  42124. * @param parentContainer parent that the controller meshes should be children of
  42125. */
  42126. constructor(scene: Scene,
  42127. /** The underlying input source for the controller */
  42128. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42129. /**
  42130. * Updates the controller pose based on the given XRFrame
  42131. * @param xrFrame xr frame to update the pose with
  42132. * @param referenceSpace reference space to use
  42133. */
  42134. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42135. /**
  42136. * Gets a world space ray coming from the controller
  42137. * @param result the resulting ray
  42138. */
  42139. getWorldPointerRayToRef(result: Ray): void;
  42140. /**
  42141. * Get the scene associated with this controller
  42142. * @returns the scene object
  42143. */
  42144. getScene(): Scene;
  42145. /**
  42146. * Disposes of the object
  42147. */
  42148. dispose(): void;
  42149. }
  42150. }
  42151. declare module BABYLON {
  42152. /**
  42153. * XR input used to track XR inputs such as controllers/rays
  42154. */
  42155. export class WebXRInput implements IDisposable {
  42156. /**
  42157. * Base experience the input listens to
  42158. */
  42159. baseExperience: WebXRExperienceHelper;
  42160. /**
  42161. * XR controllers being tracked
  42162. */
  42163. controllers: Array<WebXRController>;
  42164. private _frameObserver;
  42165. private _stateObserver;
  42166. /**
  42167. * Event when a controller has been connected/added
  42168. */
  42169. onControllerAddedObservable: Observable<WebXRController>;
  42170. /**
  42171. * Event when a controller has been removed/disconnected
  42172. */
  42173. onControllerRemovedObservable: Observable<WebXRController>;
  42174. /**
  42175. * Initializes the WebXRInput
  42176. * @param baseExperience experience helper which the input should be created for
  42177. */
  42178. constructor(
  42179. /**
  42180. * Base experience the input listens to
  42181. */
  42182. baseExperience: WebXRExperienceHelper);
  42183. private _onInputSourcesChange;
  42184. private _addAndRemoveControllers;
  42185. /**
  42186. * Disposes of the object
  42187. */
  42188. dispose(): void;
  42189. }
  42190. }
  42191. declare module BABYLON {
  42192. /**
  42193. * Enables teleportation
  42194. */
  42195. export class WebXRControllerTeleportation {
  42196. private _teleportationFillColor;
  42197. private _teleportationBorderColor;
  42198. private _tmpRay;
  42199. private _tmpVector;
  42200. /**
  42201. * Creates a WebXRControllerTeleportation
  42202. * @param input input manager to add teleportation to
  42203. * @param floorMeshes floormeshes which can be teleported to
  42204. */
  42205. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42206. }
  42207. }
  42208. declare module BABYLON {
  42209. /**
  42210. * Handles pointer input automatically for the pointer of XR controllers
  42211. */
  42212. export class WebXRControllerPointerSelection {
  42213. private static _idCounter;
  42214. private _tmpRay;
  42215. /**
  42216. * Creates a WebXRControllerPointerSelection
  42217. * @param input input manager to setup pointer selection
  42218. */
  42219. constructor(input: WebXRInput);
  42220. private _convertNormalToDirectionOfRay;
  42221. private _updatePointerDistance;
  42222. }
  42223. }
  42224. declare module BABYLON {
  42225. /**
  42226. * Class used to represent data loading progression
  42227. */
  42228. export class SceneLoaderProgressEvent {
  42229. /** defines if data length to load can be evaluated */
  42230. readonly lengthComputable: boolean;
  42231. /** defines the loaded data length */
  42232. readonly loaded: number;
  42233. /** defines the data length to load */
  42234. readonly total: number;
  42235. /**
  42236. * Create a new progress event
  42237. * @param lengthComputable defines if data length to load can be evaluated
  42238. * @param loaded defines the loaded data length
  42239. * @param total defines the data length to load
  42240. */
  42241. constructor(
  42242. /** defines if data length to load can be evaluated */
  42243. lengthComputable: boolean,
  42244. /** defines the loaded data length */
  42245. loaded: number,
  42246. /** defines the data length to load */
  42247. total: number);
  42248. /**
  42249. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42250. * @param event defines the source event
  42251. * @returns a new SceneLoaderProgressEvent
  42252. */
  42253. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42254. }
  42255. /**
  42256. * Interface used by SceneLoader plugins to define supported file extensions
  42257. */
  42258. export interface ISceneLoaderPluginExtensions {
  42259. /**
  42260. * Defines the list of supported extensions
  42261. */
  42262. [extension: string]: {
  42263. isBinary: boolean;
  42264. };
  42265. }
  42266. /**
  42267. * Interface used by SceneLoader plugin factory
  42268. */
  42269. export interface ISceneLoaderPluginFactory {
  42270. /**
  42271. * Defines the name of the factory
  42272. */
  42273. name: string;
  42274. /**
  42275. * Function called to create a new plugin
  42276. * @return the new plugin
  42277. */
  42278. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42279. /**
  42280. * The callback that returns true if the data can be directly loaded.
  42281. * @param data string containing the file data
  42282. * @returns if the data can be loaded directly
  42283. */
  42284. canDirectLoad?(data: string): boolean;
  42285. }
  42286. /**
  42287. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42288. */
  42289. export interface ISceneLoaderPluginBase {
  42290. /**
  42291. * The friendly name of this plugin.
  42292. */
  42293. name: string;
  42294. /**
  42295. * The file extensions supported by this plugin.
  42296. */
  42297. extensions: string | ISceneLoaderPluginExtensions;
  42298. /**
  42299. * The callback called when loading from a url.
  42300. * @param scene scene loading this url
  42301. * @param url url to load
  42302. * @param onSuccess callback called when the file successfully loads
  42303. * @param onProgress callback called while file is loading (if the server supports this mode)
  42304. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42305. * @param onError callback called when the file fails to load
  42306. * @returns a file request object
  42307. */
  42308. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42309. /**
  42310. * The callback called when loading from a file object.
  42311. * @param scene scene loading this file
  42312. * @param file defines the file to load
  42313. * @param onSuccess defines the callback to call when data is loaded
  42314. * @param onProgress defines the callback to call during loading process
  42315. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42316. * @param onError defines the callback to call when an error occurs
  42317. * @returns a file request object
  42318. */
  42319. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42320. /**
  42321. * The callback that returns true if the data can be directly loaded.
  42322. * @param data string containing the file data
  42323. * @returns if the data can be loaded directly
  42324. */
  42325. canDirectLoad?(data: string): boolean;
  42326. /**
  42327. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42328. * @param scene scene loading this data
  42329. * @param data string containing the data
  42330. * @returns data to pass to the plugin
  42331. */
  42332. directLoad?(scene: Scene, data: string): any;
  42333. /**
  42334. * The callback that allows custom handling of the root url based on the response url.
  42335. * @param rootUrl the original root url
  42336. * @param responseURL the response url if available
  42337. * @returns the new root url
  42338. */
  42339. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42340. }
  42341. /**
  42342. * Interface used to define a SceneLoader plugin
  42343. */
  42344. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42345. /**
  42346. * Import meshes into a scene.
  42347. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42348. * @param scene The scene to import into
  42349. * @param data The data to import
  42350. * @param rootUrl The root url for scene and resources
  42351. * @param meshes The meshes array to import into
  42352. * @param particleSystems The particle systems array to import into
  42353. * @param skeletons The skeletons array to import into
  42354. * @param onError The callback when import fails
  42355. * @returns True if successful or false otherwise
  42356. */
  42357. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42358. /**
  42359. * Load into a scene.
  42360. * @param scene The scene to load into
  42361. * @param data The data to import
  42362. * @param rootUrl The root url for scene and resources
  42363. * @param onError The callback when import fails
  42364. * @returns True if successful or false otherwise
  42365. */
  42366. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42367. /**
  42368. * Load into an asset container.
  42369. * @param scene The scene to load into
  42370. * @param data The data to import
  42371. * @param rootUrl The root url for scene and resources
  42372. * @param onError The callback when import fails
  42373. * @returns The loaded asset container
  42374. */
  42375. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42376. }
  42377. /**
  42378. * Interface used to define an async SceneLoader plugin
  42379. */
  42380. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42381. /**
  42382. * Import meshes into a scene.
  42383. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42384. * @param scene The scene to import into
  42385. * @param data The data to import
  42386. * @param rootUrl The root url for scene and resources
  42387. * @param onProgress The callback when the load progresses
  42388. * @param fileName Defines the name of the file to load
  42389. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42390. */
  42391. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42392. meshes: AbstractMesh[];
  42393. particleSystems: IParticleSystem[];
  42394. skeletons: Skeleton[];
  42395. animationGroups: AnimationGroup[];
  42396. }>;
  42397. /**
  42398. * Load into a scene.
  42399. * @param scene The scene to load into
  42400. * @param data The data to import
  42401. * @param rootUrl The root url for scene and resources
  42402. * @param onProgress The callback when the load progresses
  42403. * @param fileName Defines the name of the file to load
  42404. * @returns Nothing
  42405. */
  42406. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42407. /**
  42408. * Load into an asset container.
  42409. * @param scene The scene to load into
  42410. * @param data The data to import
  42411. * @param rootUrl The root url for scene and resources
  42412. * @param onProgress The callback when the load progresses
  42413. * @param fileName Defines the name of the file to load
  42414. * @returns The loaded asset container
  42415. */
  42416. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42417. }
  42418. /**
  42419. * Class used to load scene from various file formats using registered plugins
  42420. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42421. */
  42422. export class SceneLoader {
  42423. /**
  42424. * No logging while loading
  42425. */
  42426. static readonly NO_LOGGING: number;
  42427. /**
  42428. * Minimal logging while loading
  42429. */
  42430. static readonly MINIMAL_LOGGING: number;
  42431. /**
  42432. * Summary logging while loading
  42433. */
  42434. static readonly SUMMARY_LOGGING: number;
  42435. /**
  42436. * Detailled logging while loading
  42437. */
  42438. static readonly DETAILED_LOGGING: number;
  42439. /**
  42440. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42441. */
  42442. static ForceFullSceneLoadingForIncremental: boolean;
  42443. /**
  42444. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42445. */
  42446. static ShowLoadingScreen: boolean;
  42447. /**
  42448. * Defines the current logging level (while loading the scene)
  42449. * @ignorenaming
  42450. */
  42451. static loggingLevel: number;
  42452. /**
  42453. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42454. */
  42455. static CleanBoneMatrixWeights: boolean;
  42456. /**
  42457. * Event raised when a plugin is used to load a scene
  42458. */
  42459. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42460. private static _registeredPlugins;
  42461. private static _getDefaultPlugin;
  42462. private static _getPluginForExtension;
  42463. private static _getPluginForDirectLoad;
  42464. private static _getPluginForFilename;
  42465. private static _getDirectLoad;
  42466. private static _loadData;
  42467. private static _getFileInfo;
  42468. /**
  42469. * Gets a plugin that can load the given extension
  42470. * @param extension defines the extension to load
  42471. * @returns a plugin or null if none works
  42472. */
  42473. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42474. /**
  42475. * Gets a boolean indicating that the given extension can be loaded
  42476. * @param extension defines the extension to load
  42477. * @returns true if the extension is supported
  42478. */
  42479. static IsPluginForExtensionAvailable(extension: string): boolean;
  42480. /**
  42481. * Adds a new plugin to the list of registered plugins
  42482. * @param plugin defines the plugin to add
  42483. */
  42484. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42485. /**
  42486. * Import meshes into a scene
  42487. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42488. * @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)
  42489. * @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)
  42490. * @param scene the instance of BABYLON.Scene to append to
  42491. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42492. * @param onProgress a callback with a progress event for each file being loaded
  42493. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42494. * @param pluginExtension the extension used to determine the plugin
  42495. * @returns The loaded plugin
  42496. */
  42497. 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>;
  42498. /**
  42499. * Import meshes into a scene
  42500. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42501. * @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)
  42502. * @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)
  42503. * @param scene the instance of BABYLON.Scene to append to
  42504. * @param onProgress a callback with a progress event for each file being loaded
  42505. * @param pluginExtension the extension used to determine the plugin
  42506. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42507. */
  42508. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42509. meshes: AbstractMesh[];
  42510. particleSystems: IParticleSystem[];
  42511. skeletons: Skeleton[];
  42512. animationGroups: AnimationGroup[];
  42513. }>;
  42514. /**
  42515. * Load a scene
  42516. * @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)
  42517. * @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)
  42518. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42519. * @param onSuccess a callback with the scene when import succeeds
  42520. * @param onProgress a callback with a progress event for each file being loaded
  42521. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42522. * @param pluginExtension the extension used to determine the plugin
  42523. * @returns The loaded plugin
  42524. */
  42525. 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>;
  42526. /**
  42527. * Load a scene
  42528. * @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)
  42529. * @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)
  42530. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42531. * @param onProgress a callback with a progress event for each file being loaded
  42532. * @param pluginExtension the extension used to determine the plugin
  42533. * @returns The loaded scene
  42534. */
  42535. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42536. /**
  42537. * Append a scene
  42538. * @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)
  42539. * @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)
  42540. * @param scene is the instance of BABYLON.Scene to append to
  42541. * @param onSuccess a callback with the scene when import succeeds
  42542. * @param onProgress a callback with a progress event for each file being loaded
  42543. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42544. * @param pluginExtension the extension used to determine the plugin
  42545. * @returns The loaded plugin
  42546. */
  42547. 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>;
  42548. /**
  42549. * Append a scene
  42550. * @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)
  42551. * @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)
  42552. * @param scene is the instance of BABYLON.Scene to append to
  42553. * @param onProgress a callback with a progress event for each file being loaded
  42554. * @param pluginExtension the extension used to determine the plugin
  42555. * @returns The given scene
  42556. */
  42557. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42558. /**
  42559. * Load a scene into an asset container
  42560. * @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)
  42561. * @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)
  42562. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42563. * @param onSuccess a callback with the scene when import succeeds
  42564. * @param onProgress a callback with a progress event for each file being loaded
  42565. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42566. * @param pluginExtension the extension used to determine the plugin
  42567. * @returns The loaded plugin
  42568. */
  42569. 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>;
  42570. /**
  42571. * Load a scene into an asset container
  42572. * @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)
  42573. * @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)
  42574. * @param scene is the instance of Scene to append to
  42575. * @param onProgress a callback with a progress event for each file being loaded
  42576. * @param pluginExtension the extension used to determine the plugin
  42577. * @returns The loaded asset container
  42578. */
  42579. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42580. }
  42581. }
  42582. declare module BABYLON {
  42583. /**
  42584. * Generic Controller
  42585. */
  42586. export class GenericController extends WebVRController {
  42587. /**
  42588. * Base Url for the controller model.
  42589. */
  42590. static readonly MODEL_BASE_URL: string;
  42591. /**
  42592. * File name for the controller model.
  42593. */
  42594. static readonly MODEL_FILENAME: string;
  42595. /**
  42596. * Creates a new GenericController from a gamepad
  42597. * @param vrGamepad the gamepad that the controller should be created from
  42598. */
  42599. constructor(vrGamepad: any);
  42600. /**
  42601. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42602. * @param scene scene in which to add meshes
  42603. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42604. */
  42605. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42606. /**
  42607. * Called once for each button that changed state since the last frame
  42608. * @param buttonIdx Which button index changed
  42609. * @param state New state of the button
  42610. * @param changes Which properties on the state changed since last frame
  42611. */
  42612. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42613. }
  42614. }
  42615. declare module BABYLON {
  42616. /**
  42617. * Defines the WindowsMotionController object that the state of the windows motion controller
  42618. */
  42619. export class WindowsMotionController extends WebVRController {
  42620. /**
  42621. * The base url used to load the left and right controller models
  42622. */
  42623. static MODEL_BASE_URL: string;
  42624. /**
  42625. * The name of the left controller model file
  42626. */
  42627. static MODEL_LEFT_FILENAME: string;
  42628. /**
  42629. * The name of the right controller model file
  42630. */
  42631. static MODEL_RIGHT_FILENAME: string;
  42632. /**
  42633. * The controller name prefix for this controller type
  42634. */
  42635. static readonly GAMEPAD_ID_PREFIX: string;
  42636. /**
  42637. * The controller id pattern for this controller type
  42638. */
  42639. private static readonly GAMEPAD_ID_PATTERN;
  42640. private _loadedMeshInfo;
  42641. private readonly _mapping;
  42642. /**
  42643. * Fired when the trackpad on this controller is clicked
  42644. */
  42645. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42646. /**
  42647. * Fired when the trackpad on this controller is modified
  42648. */
  42649. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42650. /**
  42651. * The current x and y values of this controller's trackpad
  42652. */
  42653. trackpad: StickValues;
  42654. /**
  42655. * Creates a new WindowsMotionController from a gamepad
  42656. * @param vrGamepad the gamepad that the controller should be created from
  42657. */
  42658. constructor(vrGamepad: any);
  42659. /**
  42660. * Fired when the trigger on this controller is modified
  42661. */
  42662. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42663. /**
  42664. * Fired when the menu button on this controller is modified
  42665. */
  42666. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42667. /**
  42668. * Fired when the grip button on this controller is modified
  42669. */
  42670. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42671. /**
  42672. * Fired when the thumbstick button on this controller is modified
  42673. */
  42674. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42675. /**
  42676. * Fired when the touchpad button on this controller is modified
  42677. */
  42678. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42679. /**
  42680. * Fired when the touchpad values on this controller are modified
  42681. */
  42682. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42683. private _updateTrackpad;
  42684. /**
  42685. * Called once per frame by the engine.
  42686. */
  42687. update(): void;
  42688. /**
  42689. * Called once for each button that changed state since the last frame
  42690. * @param buttonIdx Which button index changed
  42691. * @param state New state of the button
  42692. * @param changes Which properties on the state changed since last frame
  42693. */
  42694. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42695. /**
  42696. * Moves the buttons on the controller mesh based on their current state
  42697. * @param buttonName the name of the button to move
  42698. * @param buttonValue the value of the button which determines the buttons new position
  42699. */
  42700. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42701. /**
  42702. * Moves the axis on the controller mesh based on its current state
  42703. * @param axis the index of the axis
  42704. * @param axisValue the value of the axis which determines the meshes new position
  42705. * @hidden
  42706. */
  42707. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42708. /**
  42709. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42710. * @param scene scene in which to add meshes
  42711. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42712. */
  42713. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42714. /**
  42715. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42716. * can be transformed by button presses and axes values, based on this._mapping.
  42717. *
  42718. * @param scene scene in which the meshes exist
  42719. * @param meshes list of meshes that make up the controller model to process
  42720. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42721. */
  42722. private processModel;
  42723. private createMeshInfo;
  42724. /**
  42725. * Gets the ray of the controller in the direction the controller is pointing
  42726. * @param length the length the resulting ray should be
  42727. * @returns a ray in the direction the controller is pointing
  42728. */
  42729. getForwardRay(length?: number): Ray;
  42730. /**
  42731. * Disposes of the controller
  42732. */
  42733. dispose(): void;
  42734. }
  42735. }
  42736. declare module BABYLON {
  42737. /**
  42738. * Oculus Touch Controller
  42739. */
  42740. export class OculusTouchController extends WebVRController {
  42741. /**
  42742. * Base Url for the controller model.
  42743. */
  42744. static MODEL_BASE_URL: string;
  42745. /**
  42746. * File name for the left controller model.
  42747. */
  42748. static MODEL_LEFT_FILENAME: string;
  42749. /**
  42750. * File name for the right controller model.
  42751. */
  42752. static MODEL_RIGHT_FILENAME: string;
  42753. /**
  42754. * Base Url for the Quest controller model.
  42755. */
  42756. static QUEST_MODEL_BASE_URL: string;
  42757. /**
  42758. * @hidden
  42759. * If the controllers are running on a device that needs the updated Quest controller models
  42760. */
  42761. static _IsQuest: boolean;
  42762. /**
  42763. * Fired when the secondary trigger on this controller is modified
  42764. */
  42765. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42766. /**
  42767. * Fired when the thumb rest on this controller is modified
  42768. */
  42769. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42770. /**
  42771. * Creates a new OculusTouchController from a gamepad
  42772. * @param vrGamepad the gamepad that the controller should be created from
  42773. */
  42774. constructor(vrGamepad: any);
  42775. /**
  42776. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42777. * @param scene scene in which to add meshes
  42778. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42779. */
  42780. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42781. /**
  42782. * Fired when the A button on this controller is modified
  42783. */
  42784. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42785. /**
  42786. * Fired when the B button on this controller is modified
  42787. */
  42788. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42789. /**
  42790. * Fired when the X button on this controller is modified
  42791. */
  42792. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42793. /**
  42794. * Fired when the Y button on this controller is modified
  42795. */
  42796. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42797. /**
  42798. * Called once for each button that changed state since the last frame
  42799. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42800. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42801. * 2) secondary trigger (same)
  42802. * 3) A (right) X (left), touch, pressed = value
  42803. * 4) B / Y
  42804. * 5) thumb rest
  42805. * @param buttonIdx Which button index changed
  42806. * @param state New state of the button
  42807. * @param changes Which properties on the state changed since last frame
  42808. */
  42809. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42810. }
  42811. }
  42812. declare module BABYLON {
  42813. /**
  42814. * Vive Controller
  42815. */
  42816. export class ViveController extends WebVRController {
  42817. /**
  42818. * Base Url for the controller model.
  42819. */
  42820. static MODEL_BASE_URL: string;
  42821. /**
  42822. * File name for the controller model.
  42823. */
  42824. static MODEL_FILENAME: string;
  42825. /**
  42826. * Creates a new ViveController from a gamepad
  42827. * @param vrGamepad the gamepad that the controller should be created from
  42828. */
  42829. constructor(vrGamepad: any);
  42830. /**
  42831. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42832. * @param scene scene in which to add meshes
  42833. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42834. */
  42835. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42836. /**
  42837. * Fired when the left button on this controller is modified
  42838. */
  42839. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42840. /**
  42841. * Fired when the right button on this controller is modified
  42842. */
  42843. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42844. /**
  42845. * Fired when the menu button on this controller is modified
  42846. */
  42847. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42848. /**
  42849. * Called once for each button that changed state since the last frame
  42850. * Vive mapping:
  42851. * 0: touchpad
  42852. * 1: trigger
  42853. * 2: left AND right buttons
  42854. * 3: menu button
  42855. * @param buttonIdx Which button index changed
  42856. * @param state New state of the button
  42857. * @param changes Which properties on the state changed since last frame
  42858. */
  42859. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42860. }
  42861. }
  42862. declare module BABYLON {
  42863. /**
  42864. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42865. */
  42866. export class WebXRControllerModelLoader {
  42867. /**
  42868. * Creates the WebXRControllerModelLoader
  42869. * @param input xr input that creates the controllers
  42870. */
  42871. constructor(input: WebXRInput);
  42872. }
  42873. }
  42874. declare module BABYLON {
  42875. /**
  42876. * Contains an array of blocks representing the octree
  42877. */
  42878. export interface IOctreeContainer<T> {
  42879. /**
  42880. * Blocks within the octree
  42881. */
  42882. blocks: Array<OctreeBlock<T>>;
  42883. }
  42884. /**
  42885. * Class used to store a cell in an octree
  42886. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42887. */
  42888. export class OctreeBlock<T> {
  42889. /**
  42890. * Gets the content of the current block
  42891. */
  42892. entries: T[];
  42893. /**
  42894. * Gets the list of block children
  42895. */
  42896. blocks: Array<OctreeBlock<T>>;
  42897. private _depth;
  42898. private _maxDepth;
  42899. private _capacity;
  42900. private _minPoint;
  42901. private _maxPoint;
  42902. private _boundingVectors;
  42903. private _creationFunc;
  42904. /**
  42905. * Creates a new block
  42906. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42907. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42908. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42909. * @param depth defines the current depth of this block in the octree
  42910. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42911. * @param creationFunc defines a callback to call when an element is added to the block
  42912. */
  42913. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42914. /**
  42915. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42916. */
  42917. readonly capacity: number;
  42918. /**
  42919. * Gets the minimum vector (in world space) of the block's bounding box
  42920. */
  42921. readonly minPoint: Vector3;
  42922. /**
  42923. * Gets the maximum vector (in world space) of the block's bounding box
  42924. */
  42925. readonly maxPoint: Vector3;
  42926. /**
  42927. * Add a new element to this block
  42928. * @param entry defines the element to add
  42929. */
  42930. addEntry(entry: T): void;
  42931. /**
  42932. * Remove an element from this block
  42933. * @param entry defines the element to remove
  42934. */
  42935. removeEntry(entry: T): void;
  42936. /**
  42937. * Add an array of elements to this block
  42938. * @param entries defines the array of elements to add
  42939. */
  42940. addEntries(entries: T[]): void;
  42941. /**
  42942. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42943. * @param frustumPlanes defines the frustum planes to test
  42944. * @param selection defines the array to store current content if selection is positive
  42945. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42946. */
  42947. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42948. /**
  42949. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42950. * @param sphereCenter defines the bounding sphere center
  42951. * @param sphereRadius defines the bounding sphere radius
  42952. * @param selection defines the array to store current content if selection is positive
  42953. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42954. */
  42955. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42956. /**
  42957. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42958. * @param ray defines the ray to test with
  42959. * @param selection defines the array to store current content if selection is positive
  42960. */
  42961. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42962. /**
  42963. * Subdivide the content into child blocks (this block will then be empty)
  42964. */
  42965. createInnerBlocks(): void;
  42966. /**
  42967. * @hidden
  42968. */
  42969. 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;
  42970. }
  42971. }
  42972. declare module BABYLON {
  42973. /**
  42974. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42975. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42976. */
  42977. export class Octree<T> {
  42978. /** 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.) */
  42979. maxDepth: number;
  42980. /**
  42981. * Blocks within the octree containing objects
  42982. */
  42983. blocks: Array<OctreeBlock<T>>;
  42984. /**
  42985. * Content stored in the octree
  42986. */
  42987. dynamicContent: T[];
  42988. private _maxBlockCapacity;
  42989. private _selectionContent;
  42990. private _creationFunc;
  42991. /**
  42992. * Creates a octree
  42993. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42994. * @param creationFunc function to be used to instatiate the octree
  42995. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42996. * @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.)
  42997. */
  42998. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42999. /** 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.) */
  43000. maxDepth?: number);
  43001. /**
  43002. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43003. * @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);
  43004. * @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);
  43005. * @param entries meshes to be added to the octree blocks
  43006. */
  43007. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43008. /**
  43009. * Adds a mesh to the octree
  43010. * @param entry Mesh to add to the octree
  43011. */
  43012. addMesh(entry: T): void;
  43013. /**
  43014. * Remove an element from the octree
  43015. * @param entry defines the element to remove
  43016. */
  43017. removeMesh(entry: T): void;
  43018. /**
  43019. * Selects an array of meshes within the frustum
  43020. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43021. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43022. * @returns array of meshes within the frustum
  43023. */
  43024. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43025. /**
  43026. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43027. * @param sphereCenter defines the bounding sphere center
  43028. * @param sphereRadius defines the bounding sphere radius
  43029. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43030. * @returns an array of objects that intersect the sphere
  43031. */
  43032. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43033. /**
  43034. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43035. * @param ray defines the ray to test with
  43036. * @returns array of intersected objects
  43037. */
  43038. intersectsRay(ray: Ray): SmartArray<T>;
  43039. /**
  43040. * Adds a mesh into the octree block if it intersects the block
  43041. */
  43042. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43043. /**
  43044. * Adds a submesh into the octree block if it intersects the block
  43045. */
  43046. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43047. }
  43048. }
  43049. declare module BABYLON {
  43050. interface Scene {
  43051. /**
  43052. * @hidden
  43053. * Backing Filed
  43054. */
  43055. _selectionOctree: Octree<AbstractMesh>;
  43056. /**
  43057. * Gets the octree used to boost mesh selection (picking)
  43058. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43059. */
  43060. selectionOctree: Octree<AbstractMesh>;
  43061. /**
  43062. * Creates or updates the octree used to boost selection (picking)
  43063. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43064. * @param maxCapacity defines the maximum capacity per leaf
  43065. * @param maxDepth defines the maximum depth of the octree
  43066. * @returns an octree of AbstractMesh
  43067. */
  43068. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43069. }
  43070. interface AbstractMesh {
  43071. /**
  43072. * @hidden
  43073. * Backing Field
  43074. */
  43075. _submeshesOctree: Octree<SubMesh>;
  43076. /**
  43077. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43078. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43079. * @param maxCapacity defines the maximum size of each block (64 by default)
  43080. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43081. * @returns the new octree
  43082. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43083. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43084. */
  43085. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43086. }
  43087. /**
  43088. * Defines the octree scene component responsible to manage any octrees
  43089. * in a given scene.
  43090. */
  43091. export class OctreeSceneComponent {
  43092. /**
  43093. * The component name help to identify the component in the list of scene components.
  43094. */
  43095. readonly name: string;
  43096. /**
  43097. * The scene the component belongs to.
  43098. */
  43099. scene: Scene;
  43100. /**
  43101. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43102. */
  43103. readonly checksIsEnabled: boolean;
  43104. /**
  43105. * Creates a new instance of the component for the given scene
  43106. * @param scene Defines the scene to register the component in
  43107. */
  43108. constructor(scene: Scene);
  43109. /**
  43110. * Registers the component in a given scene
  43111. */
  43112. register(): void;
  43113. /**
  43114. * Return the list of active meshes
  43115. * @returns the list of active meshes
  43116. */
  43117. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43118. /**
  43119. * Return the list of active sub meshes
  43120. * @param mesh The mesh to get the candidates sub meshes from
  43121. * @returns the list of active sub meshes
  43122. */
  43123. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43124. private _tempRay;
  43125. /**
  43126. * Return the list of sub meshes intersecting with a given local ray
  43127. * @param mesh defines the mesh to find the submesh for
  43128. * @param localRay defines the ray in local space
  43129. * @returns the list of intersecting sub meshes
  43130. */
  43131. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43132. /**
  43133. * Return the list of sub meshes colliding with a collider
  43134. * @param mesh defines the mesh to find the submesh for
  43135. * @param collider defines the collider to evaluate the collision against
  43136. * @returns the list of colliding sub meshes
  43137. */
  43138. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43139. /**
  43140. * Rebuilds the elements related to this component in case of
  43141. * context lost for instance.
  43142. */
  43143. rebuild(): void;
  43144. /**
  43145. * Disposes the component and the associated ressources.
  43146. */
  43147. dispose(): void;
  43148. }
  43149. }
  43150. declare module BABYLON {
  43151. /**
  43152. * Renders a layer on top of an existing scene
  43153. */
  43154. export class UtilityLayerRenderer implements IDisposable {
  43155. /** the original scene that will be rendered on top of */
  43156. originalScene: Scene;
  43157. private _pointerCaptures;
  43158. private _lastPointerEvents;
  43159. private static _DefaultUtilityLayer;
  43160. private static _DefaultKeepDepthUtilityLayer;
  43161. private _sharedGizmoLight;
  43162. private _renderCamera;
  43163. /**
  43164. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43165. * @returns the camera that is used when rendering the utility layer
  43166. */
  43167. getRenderCamera(): Nullable<Camera>;
  43168. /**
  43169. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43170. * @param cam the camera that should be used when rendering the utility layer
  43171. */
  43172. setRenderCamera(cam: Nullable<Camera>): void;
  43173. /**
  43174. * @hidden
  43175. * Light which used by gizmos to get light shading
  43176. */
  43177. _getSharedGizmoLight(): HemisphericLight;
  43178. /**
  43179. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43180. */
  43181. pickUtilitySceneFirst: boolean;
  43182. /**
  43183. * 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)
  43184. */
  43185. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43186. /**
  43187. * 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)
  43188. */
  43189. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43190. /**
  43191. * The scene that is rendered on top of the original scene
  43192. */
  43193. utilityLayerScene: Scene;
  43194. /**
  43195. * If the utility layer should automatically be rendered on top of existing scene
  43196. */
  43197. shouldRender: boolean;
  43198. /**
  43199. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  43200. */
  43201. onlyCheckPointerDownEvents: boolean;
  43202. /**
  43203. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  43204. */
  43205. processAllEvents: boolean;
  43206. /**
  43207. * Observable raised when the pointer move from the utility layer scene to the main scene
  43208. */
  43209. onPointerOutObservable: Observable<number>;
  43210. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43211. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43212. private _afterRenderObserver;
  43213. private _sceneDisposeObserver;
  43214. private _originalPointerObserver;
  43215. /**
  43216. * Instantiates a UtilityLayerRenderer
  43217. * @param originalScene the original scene that will be rendered on top of
  43218. * @param handleEvents boolean indicating if the utility layer should handle events
  43219. */
  43220. constructor(
  43221. /** the original scene that will be rendered on top of */
  43222. originalScene: Scene, handleEvents?: boolean);
  43223. private _notifyObservers;
  43224. /**
  43225. * Renders the utility layers scene on top of the original scene
  43226. */
  43227. render(): void;
  43228. /**
  43229. * Disposes of the renderer
  43230. */
  43231. dispose(): void;
  43232. private _updateCamera;
  43233. }
  43234. }
  43235. declare module BABYLON {
  43236. /**
  43237. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43238. */
  43239. export class Gizmo implements IDisposable {
  43240. /** The utility layer the gizmo will be added to */
  43241. gizmoLayer: UtilityLayerRenderer;
  43242. /**
  43243. * The root mesh of the gizmo
  43244. */
  43245. _rootMesh: Mesh;
  43246. private _attachedMesh;
  43247. /**
  43248. * Ratio for the scale of the gizmo (Default: 1)
  43249. */
  43250. scaleRatio: number;
  43251. /**
  43252. * If a custom mesh has been set (Default: false)
  43253. */
  43254. protected _customMeshSet: boolean;
  43255. /**
  43256. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43257. * * When set, interactions will be enabled
  43258. */
  43259. attachedMesh: Nullable<AbstractMesh>;
  43260. /**
  43261. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43262. * @param mesh The mesh to replace the default mesh of the gizmo
  43263. */
  43264. setCustomMesh(mesh: Mesh): void;
  43265. /**
  43266. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43267. */
  43268. updateGizmoRotationToMatchAttachedMesh: boolean;
  43269. /**
  43270. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43271. */
  43272. updateGizmoPositionToMatchAttachedMesh: boolean;
  43273. /**
  43274. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  43275. */
  43276. updateScale: boolean;
  43277. protected _interactionsEnabled: boolean;
  43278. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43279. private _beforeRenderObserver;
  43280. private _tempVector;
  43281. /**
  43282. * Creates a gizmo
  43283. * @param gizmoLayer The utility layer the gizmo will be added to
  43284. */
  43285. constructor(
  43286. /** The utility layer the gizmo will be added to */
  43287. gizmoLayer?: UtilityLayerRenderer);
  43288. /**
  43289. * Updates the gizmo to match the attached mesh's position/rotation
  43290. */
  43291. protected _update(): void;
  43292. /**
  43293. * Disposes of the gizmo
  43294. */
  43295. dispose(): void;
  43296. }
  43297. }
  43298. declare module BABYLON {
  43299. /**
  43300. * Single plane drag gizmo
  43301. */
  43302. export class PlaneDragGizmo extends Gizmo {
  43303. /**
  43304. * Drag behavior responsible for the gizmos dragging interactions
  43305. */
  43306. dragBehavior: PointerDragBehavior;
  43307. private _pointerObserver;
  43308. /**
  43309. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43310. */
  43311. snapDistance: number;
  43312. /**
  43313. * Event that fires each time the gizmo snaps to a new location.
  43314. * * snapDistance is the the change in distance
  43315. */
  43316. onSnapObservable: Observable<{
  43317. snapDistance: number;
  43318. }>;
  43319. private _plane;
  43320. private _coloredMaterial;
  43321. private _hoverMaterial;
  43322. private _isEnabled;
  43323. private _parent;
  43324. /** @hidden */
  43325. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43326. /** @hidden */
  43327. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43328. /**
  43329. * Creates a PlaneDragGizmo
  43330. * @param gizmoLayer The utility layer the gizmo will be added to
  43331. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43332. * @param color The color of the gizmo
  43333. */
  43334. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43335. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43336. /**
  43337. * If the gizmo is enabled
  43338. */
  43339. isEnabled: boolean;
  43340. /**
  43341. * Disposes of the gizmo
  43342. */
  43343. dispose(): void;
  43344. }
  43345. }
  43346. declare module BABYLON {
  43347. /**
  43348. * Gizmo that enables dragging a mesh along 3 axis
  43349. */
  43350. export class PositionGizmo extends Gizmo {
  43351. /**
  43352. * Internal gizmo used for interactions on the x axis
  43353. */
  43354. xGizmo: AxisDragGizmo;
  43355. /**
  43356. * Internal gizmo used for interactions on the y axis
  43357. */
  43358. yGizmo: AxisDragGizmo;
  43359. /**
  43360. * Internal gizmo used for interactions on the z axis
  43361. */
  43362. zGizmo: AxisDragGizmo;
  43363. /**
  43364. * Internal gizmo used for interactions on the yz plane
  43365. */
  43366. xPlaneGizmo: PlaneDragGizmo;
  43367. /**
  43368. * Internal gizmo used for interactions on the xz plane
  43369. */
  43370. yPlaneGizmo: PlaneDragGizmo;
  43371. /**
  43372. * Internal gizmo used for interactions on the xy plane
  43373. */
  43374. zPlaneGizmo: PlaneDragGizmo;
  43375. /**
  43376. * private variables
  43377. */
  43378. private _meshAttached;
  43379. private _updateGizmoRotationToMatchAttachedMesh;
  43380. private _snapDistance;
  43381. private _scaleRatio;
  43382. /** Fires an event when any of it's sub gizmos are dragged */
  43383. onDragStartObservable: Observable<unknown>;
  43384. /** Fires an event when any of it's sub gizmos are released from dragging */
  43385. onDragEndObservable: Observable<unknown>;
  43386. /**
  43387. * If set to true, planar drag is enabled
  43388. */
  43389. private _planarGizmoEnabled;
  43390. attachedMesh: Nullable<AbstractMesh>;
  43391. /**
  43392. * Creates a PositionGizmo
  43393. * @param gizmoLayer The utility layer the gizmo will be added to
  43394. */
  43395. constructor(gizmoLayer?: UtilityLayerRenderer);
  43396. /**
  43397. * If the planar drag gizmo is enabled
  43398. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43399. */
  43400. planarGizmoEnabled: boolean;
  43401. updateGizmoRotationToMatchAttachedMesh: boolean;
  43402. /**
  43403. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43404. */
  43405. snapDistance: number;
  43406. /**
  43407. * Ratio for the scale of the gizmo (Default: 1)
  43408. */
  43409. scaleRatio: number;
  43410. /**
  43411. * Disposes of the gizmo
  43412. */
  43413. dispose(): void;
  43414. /**
  43415. * CustomMeshes are not supported by this gizmo
  43416. * @param mesh The mesh to replace the default mesh of the gizmo
  43417. */
  43418. setCustomMesh(mesh: Mesh): void;
  43419. }
  43420. }
  43421. declare module BABYLON {
  43422. /**
  43423. * Single axis drag gizmo
  43424. */
  43425. export class AxisDragGizmo extends Gizmo {
  43426. /**
  43427. * Drag behavior responsible for the gizmos dragging interactions
  43428. */
  43429. dragBehavior: PointerDragBehavior;
  43430. private _pointerObserver;
  43431. /**
  43432. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43433. */
  43434. snapDistance: number;
  43435. /**
  43436. * Event that fires each time the gizmo snaps to a new location.
  43437. * * snapDistance is the the change in distance
  43438. */
  43439. onSnapObservable: Observable<{
  43440. snapDistance: number;
  43441. }>;
  43442. private _isEnabled;
  43443. private _parent;
  43444. private _arrow;
  43445. private _coloredMaterial;
  43446. private _hoverMaterial;
  43447. /** @hidden */
  43448. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43449. /** @hidden */
  43450. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43451. /**
  43452. * Creates an AxisDragGizmo
  43453. * @param gizmoLayer The utility layer the gizmo will be added to
  43454. * @param dragAxis The axis which the gizmo will be able to drag on
  43455. * @param color The color of the gizmo
  43456. */
  43457. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43458. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43459. /**
  43460. * If the gizmo is enabled
  43461. */
  43462. isEnabled: boolean;
  43463. /**
  43464. * Disposes of the gizmo
  43465. */
  43466. dispose(): void;
  43467. }
  43468. }
  43469. declare module BABYLON.Debug {
  43470. /**
  43471. * The Axes viewer will show 3 axes in a specific point in space
  43472. */
  43473. export class AxesViewer {
  43474. private _xAxis;
  43475. private _yAxis;
  43476. private _zAxis;
  43477. private _scaleLinesFactor;
  43478. private _instanced;
  43479. /**
  43480. * Gets the hosting scene
  43481. */
  43482. scene: Scene;
  43483. /**
  43484. * Gets or sets a number used to scale line length
  43485. */
  43486. scaleLines: number;
  43487. /** Gets the node hierarchy used to render x-axis */
  43488. readonly xAxis: TransformNode;
  43489. /** Gets the node hierarchy used to render y-axis */
  43490. readonly yAxis: TransformNode;
  43491. /** Gets the node hierarchy used to render z-axis */
  43492. readonly zAxis: TransformNode;
  43493. /**
  43494. * Creates a new AxesViewer
  43495. * @param scene defines the hosting scene
  43496. * @param scaleLines defines a number used to scale line length (1 by default)
  43497. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43498. * @param xAxis defines the node hierarchy used to render the x-axis
  43499. * @param yAxis defines the node hierarchy used to render the y-axis
  43500. * @param zAxis defines the node hierarchy used to render the z-axis
  43501. */
  43502. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43503. /**
  43504. * Force the viewer to update
  43505. * @param position defines the position of the viewer
  43506. * @param xaxis defines the x axis of the viewer
  43507. * @param yaxis defines the y axis of the viewer
  43508. * @param zaxis defines the z axis of the viewer
  43509. */
  43510. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43511. /**
  43512. * Creates an instance of this axes viewer.
  43513. * @returns a new axes viewer with instanced meshes
  43514. */
  43515. createInstance(): AxesViewer;
  43516. /** Releases resources */
  43517. dispose(): void;
  43518. private static _SetRenderingGroupId;
  43519. }
  43520. }
  43521. declare module BABYLON.Debug {
  43522. /**
  43523. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43524. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43525. */
  43526. export class BoneAxesViewer extends AxesViewer {
  43527. /**
  43528. * Gets or sets the target mesh where to display the axes viewer
  43529. */
  43530. mesh: Nullable<Mesh>;
  43531. /**
  43532. * Gets or sets the target bone where to display the axes viewer
  43533. */
  43534. bone: Nullable<Bone>;
  43535. /** Gets current position */
  43536. pos: Vector3;
  43537. /** Gets direction of X axis */
  43538. xaxis: Vector3;
  43539. /** Gets direction of Y axis */
  43540. yaxis: Vector3;
  43541. /** Gets direction of Z axis */
  43542. zaxis: Vector3;
  43543. /**
  43544. * Creates a new BoneAxesViewer
  43545. * @param scene defines the hosting scene
  43546. * @param bone defines the target bone
  43547. * @param mesh defines the target mesh
  43548. * @param scaleLines defines a scaling factor for line length (1 by default)
  43549. */
  43550. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43551. /**
  43552. * Force the viewer to update
  43553. */
  43554. update(): void;
  43555. /** Releases resources */
  43556. dispose(): void;
  43557. }
  43558. }
  43559. declare module BABYLON {
  43560. /**
  43561. * Interface used to define scene explorer extensibility option
  43562. */
  43563. export interface IExplorerExtensibilityOption {
  43564. /**
  43565. * Define the option label
  43566. */
  43567. label: string;
  43568. /**
  43569. * Defines the action to execute on click
  43570. */
  43571. action: (entity: any) => void;
  43572. }
  43573. /**
  43574. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43575. */
  43576. export interface IExplorerExtensibilityGroup {
  43577. /**
  43578. * Defines a predicate to test if a given type mut be extended
  43579. */
  43580. predicate: (entity: any) => boolean;
  43581. /**
  43582. * Gets the list of options added to a type
  43583. */
  43584. entries: IExplorerExtensibilityOption[];
  43585. }
  43586. /**
  43587. * Interface used to define the options to use to create the Inspector
  43588. */
  43589. export interface IInspectorOptions {
  43590. /**
  43591. * Display in overlay mode (default: false)
  43592. */
  43593. overlay?: boolean;
  43594. /**
  43595. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43596. */
  43597. globalRoot?: HTMLElement;
  43598. /**
  43599. * Display the Scene explorer
  43600. */
  43601. showExplorer?: boolean;
  43602. /**
  43603. * Display the property inspector
  43604. */
  43605. showInspector?: boolean;
  43606. /**
  43607. * Display in embed mode (both panes on the right)
  43608. */
  43609. embedMode?: boolean;
  43610. /**
  43611. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43612. */
  43613. handleResize?: boolean;
  43614. /**
  43615. * Allow the panes to popup (default: true)
  43616. */
  43617. enablePopup?: boolean;
  43618. /**
  43619. * Allow the panes to be closed by users (default: true)
  43620. */
  43621. enableClose?: boolean;
  43622. /**
  43623. * Optional list of extensibility entries
  43624. */
  43625. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43626. /**
  43627. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43628. */
  43629. inspectorURL?: string;
  43630. }
  43631. interface Scene {
  43632. /**
  43633. * @hidden
  43634. * Backing field
  43635. */
  43636. _debugLayer: DebugLayer;
  43637. /**
  43638. * Gets the debug layer (aka Inspector) associated with the scene
  43639. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43640. */
  43641. debugLayer: DebugLayer;
  43642. }
  43643. /**
  43644. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43645. * what is happening in your scene
  43646. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43647. */
  43648. export class DebugLayer {
  43649. /**
  43650. * Define the url to get the inspector script from.
  43651. * By default it uses the babylonjs CDN.
  43652. * @ignoreNaming
  43653. */
  43654. static InspectorURL: string;
  43655. private _scene;
  43656. private BJSINSPECTOR;
  43657. private _onPropertyChangedObservable?;
  43658. /**
  43659. * Observable triggered when a property is changed through the inspector.
  43660. */
  43661. readonly onPropertyChangedObservable: any;
  43662. /**
  43663. * Instantiates a new debug layer.
  43664. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43665. * what is happening in your scene
  43666. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43667. * @param scene Defines the scene to inspect
  43668. */
  43669. constructor(scene: Scene);
  43670. /** Creates the inspector window. */
  43671. private _createInspector;
  43672. /**
  43673. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43674. * @param entity defines the entity to select
  43675. * @param lineContainerTitle defines the specific block to highlight
  43676. */
  43677. select(entity: any, lineContainerTitle?: string): void;
  43678. /** Get the inspector from bundle or global */
  43679. private _getGlobalInspector;
  43680. /**
  43681. * Get if the inspector is visible or not.
  43682. * @returns true if visible otherwise, false
  43683. */
  43684. isVisible(): boolean;
  43685. /**
  43686. * Hide the inspector and close its window.
  43687. */
  43688. hide(): void;
  43689. /**
  43690. * Launch the debugLayer.
  43691. * @param config Define the configuration of the inspector
  43692. * @return a promise fulfilled when the debug layer is visible
  43693. */
  43694. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43695. }
  43696. }
  43697. declare module BABYLON {
  43698. /**
  43699. * Class containing static functions to help procedurally build meshes
  43700. */
  43701. export class BoxBuilder {
  43702. /**
  43703. * Creates a box mesh
  43704. * * The parameter `size` sets the size (float) of each box side (default 1)
  43705. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43706. * * 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)
  43707. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43709. * * 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
  43710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43711. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43712. * @param name defines the name of the mesh
  43713. * @param options defines the options used to create the mesh
  43714. * @param scene defines the hosting scene
  43715. * @returns the box mesh
  43716. */
  43717. static CreateBox(name: string, options: {
  43718. size?: number;
  43719. width?: number;
  43720. height?: number;
  43721. depth?: number;
  43722. faceUV?: Vector4[];
  43723. faceColors?: Color4[];
  43724. sideOrientation?: number;
  43725. frontUVs?: Vector4;
  43726. backUVs?: Vector4;
  43727. wrap?: boolean;
  43728. topBaseAt?: number;
  43729. bottomBaseAt?: number;
  43730. updatable?: boolean;
  43731. }, scene?: Nullable<Scene>): Mesh;
  43732. }
  43733. }
  43734. declare module BABYLON {
  43735. /**
  43736. * Class containing static functions to help procedurally build meshes
  43737. */
  43738. export class SphereBuilder {
  43739. /**
  43740. * Creates a sphere mesh
  43741. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43742. * * 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`)
  43743. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43744. * * 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
  43745. * * 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)
  43746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43747. * * 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
  43748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43749. * @param name defines the name of the mesh
  43750. * @param options defines the options used to create the mesh
  43751. * @param scene defines the hosting scene
  43752. * @returns the sphere mesh
  43753. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43754. */
  43755. static CreateSphere(name: string, options: {
  43756. segments?: number;
  43757. diameter?: number;
  43758. diameterX?: number;
  43759. diameterY?: number;
  43760. diameterZ?: number;
  43761. arc?: number;
  43762. slice?: number;
  43763. sideOrientation?: number;
  43764. frontUVs?: Vector4;
  43765. backUVs?: Vector4;
  43766. updatable?: boolean;
  43767. }, scene?: Nullable<Scene>): Mesh;
  43768. }
  43769. }
  43770. declare module BABYLON.Debug {
  43771. /**
  43772. * Used to show the physics impostor around the specific mesh
  43773. */
  43774. export class PhysicsViewer {
  43775. /** @hidden */
  43776. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43777. /** @hidden */
  43778. protected _meshes: Array<Nullable<AbstractMesh>>;
  43779. /** @hidden */
  43780. protected _scene: Nullable<Scene>;
  43781. /** @hidden */
  43782. protected _numMeshes: number;
  43783. /** @hidden */
  43784. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43785. private _renderFunction;
  43786. private _utilityLayer;
  43787. private _debugBoxMesh;
  43788. private _debugSphereMesh;
  43789. private _debugCylinderMesh;
  43790. private _debugMaterial;
  43791. private _debugMeshMeshes;
  43792. /**
  43793. * Creates a new PhysicsViewer
  43794. * @param scene defines the hosting scene
  43795. */
  43796. constructor(scene: Scene);
  43797. /** @hidden */
  43798. protected _updateDebugMeshes(): void;
  43799. /**
  43800. * Renders a specified physic impostor
  43801. * @param impostor defines the impostor to render
  43802. * @param targetMesh defines the mesh represented by the impostor
  43803. * @returns the new debug mesh used to render the impostor
  43804. */
  43805. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43806. /**
  43807. * Hides a specified physic impostor
  43808. * @param impostor defines the impostor to hide
  43809. */
  43810. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43811. private _getDebugMaterial;
  43812. private _getDebugBoxMesh;
  43813. private _getDebugSphereMesh;
  43814. private _getDebugCylinderMesh;
  43815. private _getDebugMeshMesh;
  43816. private _getDebugMesh;
  43817. /** Releases all resources */
  43818. dispose(): void;
  43819. }
  43820. }
  43821. declare module BABYLON {
  43822. /**
  43823. * Class containing static functions to help procedurally build meshes
  43824. */
  43825. export class LinesBuilder {
  43826. /**
  43827. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43828. * * 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
  43829. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43830. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43831. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43832. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43833. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43834. * * 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
  43835. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43837. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43838. * @param name defines the name of the new line system
  43839. * @param options defines the options used to create the line system
  43840. * @param scene defines the hosting scene
  43841. * @returns a new line system mesh
  43842. */
  43843. static CreateLineSystem(name: string, options: {
  43844. lines: Vector3[][];
  43845. updatable?: boolean;
  43846. instance?: Nullable<LinesMesh>;
  43847. colors?: Nullable<Color4[][]>;
  43848. useVertexAlpha?: boolean;
  43849. }, scene: Nullable<Scene>): LinesMesh;
  43850. /**
  43851. * Creates a line mesh
  43852. * 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
  43853. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43854. * * The parameter `points` is an array successive Vector3
  43855. * * 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
  43856. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43857. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43858. * * When updating an instance, remember that only point positions can change, not the number of points
  43859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43860. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43861. * @param name defines the name of the new line system
  43862. * @param options defines the options used to create the line system
  43863. * @param scene defines the hosting scene
  43864. * @returns a new line mesh
  43865. */
  43866. static CreateLines(name: string, options: {
  43867. points: Vector3[];
  43868. updatable?: boolean;
  43869. instance?: Nullable<LinesMesh>;
  43870. colors?: Color4[];
  43871. useVertexAlpha?: boolean;
  43872. }, scene?: Nullable<Scene>): LinesMesh;
  43873. /**
  43874. * Creates a dashed line mesh
  43875. * * 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
  43876. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43877. * * The parameter `points` is an array successive Vector3
  43878. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43879. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43880. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43881. * * 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
  43882. * * When updating an instance, remember that only point positions can change, not the number of points
  43883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43884. * @param name defines the name of the mesh
  43885. * @param options defines the options used to create the mesh
  43886. * @param scene defines the hosting scene
  43887. * @returns the dashed line mesh
  43888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43889. */
  43890. static CreateDashedLines(name: string, options: {
  43891. points: Vector3[];
  43892. dashSize?: number;
  43893. gapSize?: number;
  43894. dashNb?: number;
  43895. updatable?: boolean;
  43896. instance?: LinesMesh;
  43897. }, scene?: Nullable<Scene>): LinesMesh;
  43898. }
  43899. }
  43900. declare module BABYLON {
  43901. /**
  43902. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43903. * in order to better appreciate the issue one might have.
  43904. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43905. */
  43906. export class RayHelper {
  43907. /**
  43908. * Defines the ray we are currently tryin to visualize.
  43909. */
  43910. ray: Nullable<Ray>;
  43911. private _renderPoints;
  43912. private _renderLine;
  43913. private _renderFunction;
  43914. private _scene;
  43915. private _updateToMeshFunction;
  43916. private _attachedToMesh;
  43917. private _meshSpaceDirection;
  43918. private _meshSpaceOrigin;
  43919. /**
  43920. * Helper function to create a colored helper in a scene in one line.
  43921. * @param ray Defines the ray we are currently tryin to visualize
  43922. * @param scene Defines the scene the ray is used in
  43923. * @param color Defines the color we want to see the ray in
  43924. * @returns The newly created ray helper.
  43925. */
  43926. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43927. /**
  43928. * Instantiate a new ray helper.
  43929. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43930. * in order to better appreciate the issue one might have.
  43931. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43932. * @param ray Defines the ray we are currently tryin to visualize
  43933. */
  43934. constructor(ray: Ray);
  43935. /**
  43936. * Shows the ray we are willing to debug.
  43937. * @param scene Defines the scene the ray needs to be rendered in
  43938. * @param color Defines the color the ray needs to be rendered in
  43939. */
  43940. show(scene: Scene, color?: Color3): void;
  43941. /**
  43942. * Hides the ray we are debugging.
  43943. */
  43944. hide(): void;
  43945. private _render;
  43946. /**
  43947. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43948. * @param mesh Defines the mesh we want the helper attached to
  43949. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43950. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43951. * @param length Defines the length of the ray
  43952. */
  43953. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43954. /**
  43955. * Detach the ray helper from the mesh it has previously been attached to.
  43956. */
  43957. detachFromMesh(): void;
  43958. private _updateToMesh;
  43959. /**
  43960. * Dispose the helper and release its associated resources.
  43961. */
  43962. dispose(): void;
  43963. }
  43964. }
  43965. declare module BABYLON.Debug {
  43966. /**
  43967. * Class used to render a debug view of a given skeleton
  43968. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43969. */
  43970. export class SkeletonViewer {
  43971. /** defines the skeleton to render */
  43972. skeleton: Skeleton;
  43973. /** defines the mesh attached to the skeleton */
  43974. mesh: AbstractMesh;
  43975. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43976. autoUpdateBonesMatrices: boolean;
  43977. /** defines the rendering group id to use with the viewer */
  43978. renderingGroupId: number;
  43979. /** Gets or sets the color used to render the skeleton */
  43980. color: Color3;
  43981. private _scene;
  43982. private _debugLines;
  43983. private _debugMesh;
  43984. private _isEnabled;
  43985. private _renderFunction;
  43986. private _utilityLayer;
  43987. /**
  43988. * Returns the mesh used to render the bones
  43989. */
  43990. readonly debugMesh: Nullable<LinesMesh>;
  43991. /**
  43992. * Creates a new SkeletonViewer
  43993. * @param skeleton defines the skeleton to render
  43994. * @param mesh defines the mesh attached to the skeleton
  43995. * @param scene defines the hosting scene
  43996. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43997. * @param renderingGroupId defines the rendering group id to use with the viewer
  43998. */
  43999. constructor(
  44000. /** defines the skeleton to render */
  44001. skeleton: Skeleton,
  44002. /** defines the mesh attached to the skeleton */
  44003. mesh: AbstractMesh, scene: Scene,
  44004. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44005. autoUpdateBonesMatrices?: boolean,
  44006. /** defines the rendering group id to use with the viewer */
  44007. renderingGroupId?: number);
  44008. /** Gets or sets a boolean indicating if the viewer is enabled */
  44009. isEnabled: boolean;
  44010. private _getBonePosition;
  44011. private _getLinesForBonesWithLength;
  44012. private _getLinesForBonesNoLength;
  44013. /** Update the viewer to sync with current skeleton state */
  44014. update(): void;
  44015. /** Release associated resources */
  44016. dispose(): void;
  44017. }
  44018. }
  44019. declare module BABYLON {
  44020. /**
  44021. * Options to create the null engine
  44022. */
  44023. export class NullEngineOptions {
  44024. /**
  44025. * Render width (Default: 512)
  44026. */
  44027. renderWidth: number;
  44028. /**
  44029. * Render height (Default: 256)
  44030. */
  44031. renderHeight: number;
  44032. /**
  44033. * Texture size (Default: 512)
  44034. */
  44035. textureSize: number;
  44036. /**
  44037. * If delta time between frames should be constant
  44038. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44039. */
  44040. deterministicLockstep: boolean;
  44041. /**
  44042. * Maximum about of steps between frames (Default: 4)
  44043. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44044. */
  44045. lockstepMaxSteps: number;
  44046. }
  44047. /**
  44048. * The null engine class provides support for headless version of babylon.js.
  44049. * This can be used in server side scenario or for testing purposes
  44050. */
  44051. export class NullEngine extends Engine {
  44052. private _options;
  44053. /**
  44054. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  44055. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44056. * @returns true if engine is in deterministic lock step mode
  44057. */
  44058. isDeterministicLockStep(): boolean;
  44059. /**
  44060. * Gets the max steps when engine is running in deterministic lock step
  44061. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44062. * @returns the max steps
  44063. */
  44064. getLockstepMaxSteps(): number;
  44065. /**
  44066. * Gets the current hardware scaling level.
  44067. * By default the hardware scaling level is computed from the window device ratio.
  44068. * 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.
  44069. * @returns a number indicating the current hardware scaling level
  44070. */
  44071. getHardwareScalingLevel(): number;
  44072. constructor(options?: NullEngineOptions);
  44073. /**
  44074. * Creates a vertex buffer
  44075. * @param vertices the data for the vertex buffer
  44076. * @returns the new WebGL static buffer
  44077. */
  44078. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44079. /**
  44080. * Creates a new index buffer
  44081. * @param indices defines the content of the index buffer
  44082. * @param updatable defines if the index buffer must be updatable
  44083. * @returns a new webGL buffer
  44084. */
  44085. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44086. /**
  44087. * Clear the current render buffer or the current render target (if any is set up)
  44088. * @param color defines the color to use
  44089. * @param backBuffer defines if the back buffer must be cleared
  44090. * @param depth defines if the depth buffer must be cleared
  44091. * @param stencil defines if the stencil buffer must be cleared
  44092. */
  44093. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44094. /**
  44095. * Gets the current render width
  44096. * @param useScreen defines if screen size must be used (or the current render target if any)
  44097. * @returns a number defining the current render width
  44098. */
  44099. getRenderWidth(useScreen?: boolean): number;
  44100. /**
  44101. * Gets the current render height
  44102. * @param useScreen defines if screen size must be used (or the current render target if any)
  44103. * @returns a number defining the current render height
  44104. */
  44105. getRenderHeight(useScreen?: boolean): number;
  44106. /**
  44107. * Set the WebGL's viewport
  44108. * @param viewport defines the viewport element to be used
  44109. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  44110. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  44111. */
  44112. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44113. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44114. /**
  44115. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  44116. * @param pipelineContext defines the pipeline context to use
  44117. * @param uniformsNames defines the list of uniform names
  44118. * @returns an array of webGL uniform locations
  44119. */
  44120. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44121. /**
  44122. * Gets the lsit of active attributes for a given webGL program
  44123. * @param pipelineContext defines the pipeline context to use
  44124. * @param attributesNames defines the list of attribute names to get
  44125. * @returns an array of indices indicating the offset of each attribute
  44126. */
  44127. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44128. /**
  44129. * Binds an effect to the webGL context
  44130. * @param effect defines the effect to bind
  44131. */
  44132. bindSamplers(effect: Effect): void;
  44133. /**
  44134. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  44135. * @param effect defines the effect to activate
  44136. */
  44137. enableEffect(effect: Effect): void;
  44138. /**
  44139. * Set various states to the webGL context
  44140. * @param culling defines backface culling state
  44141. * @param zOffset defines the value to apply to zOffset (0 by default)
  44142. * @param force defines if states must be applied even if cache is up to date
  44143. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  44144. */
  44145. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44146. /**
  44147. * Set the value of an uniform to an array of int32
  44148. * @param uniform defines the webGL uniform location where to store the value
  44149. * @param array defines the array of int32 to store
  44150. */
  44151. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44152. /**
  44153. * Set the value of an uniform to an array of int32 (stored as vec2)
  44154. * @param uniform defines the webGL uniform location where to store the value
  44155. * @param array defines the array of int32 to store
  44156. */
  44157. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44158. /**
  44159. * Set the value of an uniform to an array of int32 (stored as vec3)
  44160. * @param uniform defines the webGL uniform location where to store the value
  44161. * @param array defines the array of int32 to store
  44162. */
  44163. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44164. /**
  44165. * Set the value of an uniform to an array of int32 (stored as vec4)
  44166. * @param uniform defines the webGL uniform location where to store the value
  44167. * @param array defines the array of int32 to store
  44168. */
  44169. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44170. /**
  44171. * Set the value of an uniform to an array of float32
  44172. * @param uniform defines the webGL uniform location where to store the value
  44173. * @param array defines the array of float32 to store
  44174. */
  44175. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44176. /**
  44177. * Set the value of an uniform to an array of float32 (stored as vec2)
  44178. * @param uniform defines the webGL uniform location where to store the value
  44179. * @param array defines the array of float32 to store
  44180. */
  44181. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44182. /**
  44183. * Set the value of an uniform to an array of float32 (stored as vec3)
  44184. * @param uniform defines the webGL uniform location where to store the value
  44185. * @param array defines the array of float32 to store
  44186. */
  44187. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44188. /**
  44189. * Set the value of an uniform to an array of float32 (stored as vec4)
  44190. * @param uniform defines the webGL uniform location where to store the value
  44191. * @param array defines the array of float32 to store
  44192. */
  44193. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44194. /**
  44195. * Set the value of an uniform to an array of number
  44196. * @param uniform defines the webGL uniform location where to store the value
  44197. * @param array defines the array of number to store
  44198. */
  44199. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44200. /**
  44201. * Set the value of an uniform to an array of number (stored as vec2)
  44202. * @param uniform defines the webGL uniform location where to store the value
  44203. * @param array defines the array of number to store
  44204. */
  44205. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44206. /**
  44207. * Set the value of an uniform to an array of number (stored as vec3)
  44208. * @param uniform defines the webGL uniform location where to store the value
  44209. * @param array defines the array of number to store
  44210. */
  44211. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44212. /**
  44213. * Set the value of an uniform to an array of number (stored as vec4)
  44214. * @param uniform defines the webGL uniform location where to store the value
  44215. * @param array defines the array of number to store
  44216. */
  44217. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44218. /**
  44219. * Set the value of an uniform to an array of float32 (stored as matrices)
  44220. * @param uniform defines the webGL uniform location where to store the value
  44221. * @param matrices defines the array of float32 to store
  44222. */
  44223. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44224. /**
  44225. * Set the value of an uniform to a matrix (3x3)
  44226. * @param uniform defines the webGL uniform location where to store the value
  44227. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  44228. */
  44229. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44230. /**
  44231. * Set the value of an uniform to a matrix (2x2)
  44232. * @param uniform defines the webGL uniform location where to store the value
  44233. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  44234. */
  44235. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44236. /**
  44237. * Set the value of an uniform to a number (float)
  44238. * @param uniform defines the webGL uniform location where to store the value
  44239. * @param value defines the float number to store
  44240. */
  44241. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44242. /**
  44243. * Set the value of an uniform to a vec2
  44244. * @param uniform defines the webGL uniform location where to store the value
  44245. * @param x defines the 1st component of the value
  44246. * @param y defines the 2nd component of the value
  44247. */
  44248. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44249. /**
  44250. * Set the value of an uniform to a vec3
  44251. * @param uniform defines the webGL uniform location where to store the value
  44252. * @param x defines the 1st component of the value
  44253. * @param y defines the 2nd component of the value
  44254. * @param z defines the 3rd component of the value
  44255. */
  44256. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44257. /**
  44258. * Set the value of an uniform to a boolean
  44259. * @param uniform defines the webGL uniform location where to store the value
  44260. * @param bool defines the boolean to store
  44261. */
  44262. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44263. /**
  44264. * Set the value of an uniform to a vec4
  44265. * @param uniform defines the webGL uniform location where to store the value
  44266. * @param x defines the 1st component of the value
  44267. * @param y defines the 2nd component of the value
  44268. * @param z defines the 3rd component of the value
  44269. * @param w defines the 4th component of the value
  44270. */
  44271. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44272. /**
  44273. * Sets the current alpha mode
  44274. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  44275. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44276. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44277. */
  44278. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44279. /**
  44280. * Bind webGl buffers directly to the webGL context
  44281. * @param vertexBuffers defines the vertex buffer to bind
  44282. * @param indexBuffer defines the index buffer to bind
  44283. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  44284. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  44285. * @param effect defines the effect associated with the vertex buffer
  44286. */
  44287. bindBuffers(vertexBuffers: {
  44288. [key: string]: VertexBuffer;
  44289. }, indexBuffer: DataBuffer, effect: Effect): void;
  44290. /**
  44291. * Force the entire cache to be cleared
  44292. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  44293. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  44294. */
  44295. wipeCaches(bruteForce?: boolean): void;
  44296. /**
  44297. * Send a draw order
  44298. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  44299. * @param indexStart defines the starting index
  44300. * @param indexCount defines the number of index to draw
  44301. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44302. */
  44303. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44304. /**
  44305. * Draw a list of indexed primitives
  44306. * @param fillMode defines the primitive to use
  44307. * @param indexStart defines the starting index
  44308. * @param indexCount defines the number of index to draw
  44309. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44310. */
  44311. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44312. /**
  44313. * Draw a list of unindexed primitives
  44314. * @param fillMode defines the primitive to use
  44315. * @param verticesStart defines the index of first vertex to draw
  44316. * @param verticesCount defines the count of vertices to draw
  44317. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44318. */
  44319. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44320. /** @hidden */
  44321. _createTexture(): WebGLTexture;
  44322. /** @hidden */
  44323. _releaseTexture(texture: InternalTexture): void;
  44324. /**
  44325. * Usually called from Texture.ts.
  44326. * Passed information to create a WebGLTexture
  44327. * @param urlArg defines a value which contains one of the following:
  44328. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44329. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44330. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44331. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44332. * @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)
  44333. * @param scene needed for loading to the correct scene
  44334. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  44335. * @param onLoad optional callback to be called upon successful completion
  44336. * @param onError optional callback to be called upon failure
  44337. * @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
  44338. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44339. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44340. * @param forcedExtension defines the extension to use to pick the right loader
  44341. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  44342. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44343. */
  44344. 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;
  44345. /**
  44346. * Creates a new render target texture
  44347. * @param size defines the size of the texture
  44348. * @param options defines the options used to create the texture
  44349. * @returns a new render target texture stored in an InternalTexture
  44350. */
  44351. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44352. /**
  44353. * Update the sampling mode of a given texture
  44354. * @param samplingMode defines the required sampling mode
  44355. * @param texture defines the texture to update
  44356. */
  44357. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44358. /**
  44359. * Binds the frame buffer to the specified texture.
  44360. * @param texture The texture to render to or null for the default canvas
  44361. * @param faceIndex The face of the texture to render to in case of cube texture
  44362. * @param requiredWidth The width of the target to render to
  44363. * @param requiredHeight The height of the target to render to
  44364. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  44365. * @param depthStencilTexture The depth stencil texture to use to render
  44366. * @param lodLevel defines le lod level to bind to the frame buffer
  44367. */
  44368. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44369. /**
  44370. * Unbind the current render target texture from the webGL context
  44371. * @param texture defines the render target texture to unbind
  44372. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44373. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44374. */
  44375. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44376. /**
  44377. * Creates a dynamic vertex buffer
  44378. * @param vertices the data for the dynamic vertex buffer
  44379. * @returns the new WebGL dynamic buffer
  44380. */
  44381. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44382. /**
  44383. * Update the content of a dynamic texture
  44384. * @param texture defines the texture to update
  44385. * @param canvas defines the canvas containing the source
  44386. * @param invertY defines if data must be stored with Y axis inverted
  44387. * @param premulAlpha defines if alpha is stored as premultiplied
  44388. * @param format defines the format of the data
  44389. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  44390. */
  44391. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44392. /**
  44393. * Gets a boolean indicating if all created effects are ready
  44394. * @returns true if all effects are ready
  44395. */
  44396. areAllEffectsReady(): boolean;
  44397. /**
  44398. * @hidden
  44399. * Get the current error code of the webGL context
  44400. * @returns the error code
  44401. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44402. */
  44403. getError(): number;
  44404. /** @hidden */
  44405. _getUnpackAlignement(): number;
  44406. /** @hidden */
  44407. _unpackFlipY(value: boolean): void;
  44408. /**
  44409. * Update a dynamic index buffer
  44410. * @param indexBuffer defines the target index buffer
  44411. * @param indices defines the data to update
  44412. * @param offset defines the offset in the target index buffer where update should start
  44413. */
  44414. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44415. /**
  44416. * Updates a dynamic vertex buffer.
  44417. * @param vertexBuffer the vertex buffer to update
  44418. * @param vertices the data used to update the vertex buffer
  44419. * @param byteOffset the byte offset of the data (optional)
  44420. * @param byteLength the byte length of the data (optional)
  44421. */
  44422. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44423. /** @hidden */
  44424. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44425. /** @hidden */
  44426. _bindTexture(channel: number, texture: InternalTexture): void;
  44427. protected _deleteBuffer(buffer: WebGLBuffer): void;
  44428. /**
  44429. * 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
  44430. */
  44431. releaseEffects(): void;
  44432. displayLoadingUI(): void;
  44433. hideLoadingUI(): void;
  44434. /** @hidden */
  44435. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44436. /** @hidden */
  44437. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44438. /** @hidden */
  44439. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44440. /** @hidden */
  44441. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44442. }
  44443. }
  44444. declare module BABYLON {
  44445. /** @hidden */
  44446. export class _OcclusionDataStorage {
  44447. /** @hidden */
  44448. occlusionInternalRetryCounter: number;
  44449. /** @hidden */
  44450. isOcclusionQueryInProgress: boolean;
  44451. /** @hidden */
  44452. isOccluded: boolean;
  44453. /** @hidden */
  44454. occlusionRetryCount: number;
  44455. /** @hidden */
  44456. occlusionType: number;
  44457. /** @hidden */
  44458. occlusionQueryAlgorithmType: number;
  44459. }
  44460. interface Engine {
  44461. /**
  44462. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44463. * @return the new query
  44464. */
  44465. createQuery(): WebGLQuery;
  44466. /**
  44467. * Delete and release a webGL query
  44468. * @param query defines the query to delete
  44469. * @return the current engine
  44470. */
  44471. deleteQuery(query: WebGLQuery): Engine;
  44472. /**
  44473. * Check if a given query has resolved and got its value
  44474. * @param query defines the query to check
  44475. * @returns true if the query got its value
  44476. */
  44477. isQueryResultAvailable(query: WebGLQuery): boolean;
  44478. /**
  44479. * Gets the value of a given query
  44480. * @param query defines the query to check
  44481. * @returns the value of the query
  44482. */
  44483. getQueryResult(query: WebGLQuery): number;
  44484. /**
  44485. * Initiates an occlusion query
  44486. * @param algorithmType defines the algorithm to use
  44487. * @param query defines the query to use
  44488. * @returns the current engine
  44489. * @see http://doc.babylonjs.com/features/occlusionquery
  44490. */
  44491. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44492. /**
  44493. * Ends an occlusion query
  44494. * @see http://doc.babylonjs.com/features/occlusionquery
  44495. * @param algorithmType defines the algorithm to use
  44496. * @returns the current engine
  44497. */
  44498. endOcclusionQuery(algorithmType: number): Engine;
  44499. /**
  44500. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44501. * Please note that only one query can be issued at a time
  44502. * @returns a time token used to track the time span
  44503. */
  44504. startTimeQuery(): Nullable<_TimeToken>;
  44505. /**
  44506. * Ends a time query
  44507. * @param token defines the token used to measure the time span
  44508. * @returns the time spent (in ns)
  44509. */
  44510. endTimeQuery(token: _TimeToken): int;
  44511. /** @hidden */
  44512. _currentNonTimestampToken: Nullable<_TimeToken>;
  44513. /** @hidden */
  44514. _createTimeQuery(): WebGLQuery;
  44515. /** @hidden */
  44516. _deleteTimeQuery(query: WebGLQuery): void;
  44517. /** @hidden */
  44518. _getGlAlgorithmType(algorithmType: number): number;
  44519. /** @hidden */
  44520. _getTimeQueryResult(query: WebGLQuery): any;
  44521. /** @hidden */
  44522. _getTimeQueryAvailability(query: WebGLQuery): any;
  44523. }
  44524. interface AbstractMesh {
  44525. /**
  44526. * Backing filed
  44527. * @hidden
  44528. */
  44529. __occlusionDataStorage: _OcclusionDataStorage;
  44530. /**
  44531. * Access property
  44532. * @hidden
  44533. */
  44534. _occlusionDataStorage: _OcclusionDataStorage;
  44535. /**
  44536. * 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.
  44537. * The default value is -1 which means don't break the query and wait till the result
  44538. * @see http://doc.babylonjs.com/features/occlusionquery
  44539. */
  44540. occlusionRetryCount: number;
  44541. /**
  44542. * 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:
  44543. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44544. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44545. * * 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.
  44546. * @see http://doc.babylonjs.com/features/occlusionquery
  44547. */
  44548. occlusionType: number;
  44549. /**
  44550. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44551. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44552. * * 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.
  44553. * @see http://doc.babylonjs.com/features/occlusionquery
  44554. */
  44555. occlusionQueryAlgorithmType: number;
  44556. /**
  44557. * 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
  44558. * @see http://doc.babylonjs.com/features/occlusionquery
  44559. */
  44560. isOccluded: boolean;
  44561. /**
  44562. * Flag to check the progress status of the query
  44563. * @see http://doc.babylonjs.com/features/occlusionquery
  44564. */
  44565. isOcclusionQueryInProgress: boolean;
  44566. }
  44567. }
  44568. declare module BABYLON {
  44569. /** @hidden */
  44570. export var _forceTransformFeedbackToBundle: boolean;
  44571. interface Engine {
  44572. /**
  44573. * Creates a webGL transform feedback object
  44574. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44575. * @returns the webGL transform feedback object
  44576. */
  44577. createTransformFeedback(): WebGLTransformFeedback;
  44578. /**
  44579. * Delete a webGL transform feedback object
  44580. * @param value defines the webGL transform feedback object to delete
  44581. */
  44582. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44583. /**
  44584. * Bind a webGL transform feedback object to the webgl context
  44585. * @param value defines the webGL transform feedback object to bind
  44586. */
  44587. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44588. /**
  44589. * Begins a transform feedback operation
  44590. * @param usePoints defines if points or triangles must be used
  44591. */
  44592. beginTransformFeedback(usePoints: boolean): void;
  44593. /**
  44594. * Ends a transform feedback operation
  44595. */
  44596. endTransformFeedback(): void;
  44597. /**
  44598. * Specify the varyings to use with transform feedback
  44599. * @param program defines the associated webGL program
  44600. * @param value defines the list of strings representing the varying names
  44601. */
  44602. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44603. /**
  44604. * Bind a webGL buffer for a transform feedback operation
  44605. * @param value defines the webGL buffer to bind
  44606. */
  44607. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44608. }
  44609. }
  44610. declare module BABYLON {
  44611. /**
  44612. * Creation options of the multi render target texture.
  44613. */
  44614. export interface IMultiRenderTargetOptions {
  44615. /**
  44616. * Define if the texture needs to create mip maps after render.
  44617. */
  44618. generateMipMaps?: boolean;
  44619. /**
  44620. * Define the types of all the draw buffers we want to create
  44621. */
  44622. types?: number[];
  44623. /**
  44624. * Define the sampling modes of all the draw buffers we want to create
  44625. */
  44626. samplingModes?: number[];
  44627. /**
  44628. * Define if a depth buffer is required
  44629. */
  44630. generateDepthBuffer?: boolean;
  44631. /**
  44632. * Define if a stencil buffer is required
  44633. */
  44634. generateStencilBuffer?: boolean;
  44635. /**
  44636. * Define if a depth texture is required instead of a depth buffer
  44637. */
  44638. generateDepthTexture?: boolean;
  44639. /**
  44640. * Define the number of desired draw buffers
  44641. */
  44642. textureCount?: number;
  44643. /**
  44644. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44645. */
  44646. doNotChangeAspectRatio?: boolean;
  44647. /**
  44648. * Define the default type of the buffers we are creating
  44649. */
  44650. defaultType?: number;
  44651. }
  44652. /**
  44653. * A multi render target, like a render target provides the ability to render to a texture.
  44654. * Unlike the render target, it can render to several draw buffers in one draw.
  44655. * This is specially interesting in deferred rendering or for any effects requiring more than
  44656. * just one color from a single pass.
  44657. */
  44658. export class MultiRenderTarget extends RenderTargetTexture {
  44659. private _internalTextures;
  44660. private _textures;
  44661. private _multiRenderTargetOptions;
  44662. /**
  44663. * Get if draw buffers are currently supported by the used hardware and browser.
  44664. */
  44665. readonly isSupported: boolean;
  44666. /**
  44667. * Get the list of textures generated by the multi render target.
  44668. */
  44669. readonly textures: Texture[];
  44670. /**
  44671. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44672. */
  44673. readonly depthTexture: Texture;
  44674. /**
  44675. * Set the wrapping mode on U of all the textures we are rendering to.
  44676. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44677. */
  44678. wrapU: number;
  44679. /**
  44680. * Set the wrapping mode on V of all the textures we are rendering to.
  44681. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44682. */
  44683. wrapV: number;
  44684. /**
  44685. * Instantiate a new multi render target texture.
  44686. * A multi render target, like a render target provides the ability to render to a texture.
  44687. * Unlike the render target, it can render to several draw buffers in one draw.
  44688. * This is specially interesting in deferred rendering or for any effects requiring more than
  44689. * just one color from a single pass.
  44690. * @param name Define the name of the texture
  44691. * @param size Define the size of the buffers to render to
  44692. * @param count Define the number of target we are rendering into
  44693. * @param scene Define the scene the texture belongs to
  44694. * @param options Define the options used to create the multi render target
  44695. */
  44696. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44697. /** @hidden */
  44698. _rebuild(): void;
  44699. private _createInternalTextures;
  44700. private _createTextures;
  44701. /**
  44702. * Define the number of samples used if MSAA is enabled.
  44703. */
  44704. samples: number;
  44705. /**
  44706. * Resize all the textures in the multi render target.
  44707. * Be carrefull as it will recreate all the data in the new texture.
  44708. * @param size Define the new size
  44709. */
  44710. resize(size: any): void;
  44711. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44712. /**
  44713. * Dispose the render targets and their associated resources
  44714. */
  44715. dispose(): void;
  44716. /**
  44717. * Release all the underlying texture used as draw buffers.
  44718. */
  44719. releaseInternalTextures(): void;
  44720. }
  44721. }
  44722. declare module BABYLON {
  44723. interface ThinEngine {
  44724. /**
  44725. * Unbind a list of render target textures from the webGL context
  44726. * This is used only when drawBuffer extension or webGL2 are active
  44727. * @param textures defines the render target textures to unbind
  44728. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44729. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44730. */
  44731. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44732. /**
  44733. * Create a multi render target texture
  44734. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44735. * @param size defines the size of the texture
  44736. * @param options defines the creation options
  44737. * @returns the cube texture as an InternalTexture
  44738. */
  44739. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44740. /**
  44741. * Update the sample count for a given multiple render target texture
  44742. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44743. * @param textures defines the textures to update
  44744. * @param samples defines the sample count to set
  44745. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44746. */
  44747. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44748. }
  44749. }
  44750. declare module BABYLON {
  44751. /**
  44752. * Class used to define an additional view for the engine
  44753. * @see https://doc.babylonjs.com/how_to/multi_canvases
  44754. */
  44755. export class EngineView {
  44756. /** Defines the canvas where to render the view */
  44757. target: HTMLCanvasElement;
  44758. /** Defines an optional camera used to render the view (will use active camera else) */
  44759. camera?: Camera;
  44760. }
  44761. interface Engine {
  44762. /**
  44763. * Gets or sets the HTML element to use for attaching events
  44764. */
  44765. inputElement: Nullable<HTMLElement>;
  44766. /**
  44767. * Gets the current engine view
  44768. * @see https://doc.babylonjs.com/how_to/multi_canvases
  44769. */
  44770. activeView: Nullable<EngineView>;
  44771. /** Gets or sets the list of views */
  44772. views: EngineView[];
  44773. /**
  44774. * Register a new child canvas
  44775. * @param canvas defines the canvas to register
  44776. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  44777. * @returns the associated view
  44778. */
  44779. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  44780. /**
  44781. * Remove a registered child canvas
  44782. * @param canvas defines the canvas to remove
  44783. * @returns the current engine
  44784. */
  44785. unRegisterView(canvas: HTMLCanvasElement): Engine;
  44786. }
  44787. }
  44788. declare module BABYLON {
  44789. /**
  44790. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  44791. */
  44792. export interface CubeMapInfo {
  44793. /**
  44794. * The pixel array for the front face.
  44795. * This is stored in format, left to right, up to down format.
  44796. */
  44797. front: Nullable<ArrayBufferView>;
  44798. /**
  44799. * The pixel array for the back face.
  44800. * This is stored in format, left to right, up to down format.
  44801. */
  44802. back: Nullable<ArrayBufferView>;
  44803. /**
  44804. * The pixel array for the left face.
  44805. * This is stored in format, left to right, up to down format.
  44806. */
  44807. left: Nullable<ArrayBufferView>;
  44808. /**
  44809. * The pixel array for the right face.
  44810. * This is stored in format, left to right, up to down format.
  44811. */
  44812. right: Nullable<ArrayBufferView>;
  44813. /**
  44814. * The pixel array for the up face.
  44815. * This is stored in format, left to right, up to down format.
  44816. */
  44817. up: Nullable<ArrayBufferView>;
  44818. /**
  44819. * The pixel array for the down face.
  44820. * This is stored in format, left to right, up to down format.
  44821. */
  44822. down: Nullable<ArrayBufferView>;
  44823. /**
  44824. * The size of the cubemap stored.
  44825. *
  44826. * Each faces will be size * size pixels.
  44827. */
  44828. size: number;
  44829. /**
  44830. * The format of the texture.
  44831. *
  44832. * RGBA, RGB.
  44833. */
  44834. format: number;
  44835. /**
  44836. * The type of the texture data.
  44837. *
  44838. * UNSIGNED_INT, FLOAT.
  44839. */
  44840. type: number;
  44841. /**
  44842. * Specifies whether the texture is in gamma space.
  44843. */
  44844. gammaSpace: boolean;
  44845. }
  44846. /**
  44847. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  44848. */
  44849. export class PanoramaToCubeMapTools {
  44850. private static FACE_FRONT;
  44851. private static FACE_BACK;
  44852. private static FACE_RIGHT;
  44853. private static FACE_LEFT;
  44854. private static FACE_DOWN;
  44855. private static FACE_UP;
  44856. /**
  44857. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  44858. *
  44859. * @param float32Array The source data.
  44860. * @param inputWidth The width of the input panorama.
  44861. * @param inputHeight The height of the input panorama.
  44862. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  44863. * @return The cubemap data
  44864. */
  44865. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  44866. private static CreateCubemapTexture;
  44867. private static CalcProjectionSpherical;
  44868. }
  44869. }
  44870. declare module BABYLON {
  44871. /**
  44872. * Helper class dealing with the extraction of spherical polynomial dataArray
  44873. * from a cube map.
  44874. */
  44875. export class CubeMapToSphericalPolynomialTools {
  44876. private static FileFaces;
  44877. /**
  44878. * Converts a texture to the according Spherical Polynomial data.
  44879. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44880. *
  44881. * @param texture The texture to extract the information from.
  44882. * @return The Spherical Polynomial data.
  44883. */
  44884. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  44885. /**
  44886. * Converts a cubemap to the according Spherical Polynomial data.
  44887. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44888. *
  44889. * @param cubeInfo The Cube map to extract the information from.
  44890. * @return The Spherical Polynomial data.
  44891. */
  44892. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  44893. }
  44894. }
  44895. declare module BABYLON {
  44896. interface BaseTexture {
  44897. /**
  44898. * Get the polynomial representation of the texture data.
  44899. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  44900. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  44901. */
  44902. sphericalPolynomial: Nullable<SphericalPolynomial>;
  44903. }
  44904. }
  44905. declare module BABYLON {
  44906. /** @hidden */
  44907. export var rgbdEncodePixelShader: {
  44908. name: string;
  44909. shader: string;
  44910. };
  44911. }
  44912. declare module BABYLON {
  44913. /** @hidden */
  44914. export var rgbdDecodePixelShader: {
  44915. name: string;
  44916. shader: string;
  44917. };
  44918. }
  44919. declare module BABYLON {
  44920. /**
  44921. * Raw texture data and descriptor sufficient for WebGL texture upload
  44922. */
  44923. export interface EnvironmentTextureInfo {
  44924. /**
  44925. * Version of the environment map
  44926. */
  44927. version: number;
  44928. /**
  44929. * Width of image
  44930. */
  44931. width: number;
  44932. /**
  44933. * Irradiance information stored in the file.
  44934. */
  44935. irradiance: any;
  44936. /**
  44937. * Specular information stored in the file.
  44938. */
  44939. specular: any;
  44940. }
  44941. /**
  44942. * Defines One Image in the file. It requires only the position in the file
  44943. * as well as the length.
  44944. */
  44945. interface BufferImageData {
  44946. /**
  44947. * Length of the image data.
  44948. */
  44949. length: number;
  44950. /**
  44951. * Position of the data from the null terminator delimiting the end of the JSON.
  44952. */
  44953. position: number;
  44954. }
  44955. /**
  44956. * Defines the specular data enclosed in the file.
  44957. * This corresponds to the version 1 of the data.
  44958. */
  44959. export interface EnvironmentTextureSpecularInfoV1 {
  44960. /**
  44961. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44962. */
  44963. specularDataPosition?: number;
  44964. /**
  44965. * This contains all the images data needed to reconstruct the cubemap.
  44966. */
  44967. mipmaps: Array<BufferImageData>;
  44968. /**
  44969. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44970. */
  44971. lodGenerationScale: number;
  44972. }
  44973. /**
  44974. * Sets of helpers addressing the serialization and deserialization of environment texture
  44975. * stored in a BabylonJS env file.
  44976. * Those files are usually stored as .env files.
  44977. */
  44978. export class EnvironmentTextureTools {
  44979. /**
  44980. * Magic number identifying the env file.
  44981. */
  44982. private static _MagicBytes;
  44983. /**
  44984. * Gets the environment info from an env file.
  44985. * @param data The array buffer containing the .env bytes.
  44986. * @returns the environment file info (the json header) if successfully parsed.
  44987. */
  44988. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44989. /**
  44990. * Creates an environment texture from a loaded cube texture.
  44991. * @param texture defines the cube texture to convert in env file
  44992. * @return a promise containing the environment data if succesfull.
  44993. */
  44994. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44995. /**
  44996. * Creates a JSON representation of the spherical data.
  44997. * @param texture defines the texture containing the polynomials
  44998. * @return the JSON representation of the spherical info
  44999. */
  45000. private static _CreateEnvTextureIrradiance;
  45001. /**
  45002. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45003. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45004. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45005. * @return the views described by info providing access to the underlying buffer
  45006. */
  45007. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45008. /**
  45009. * Uploads the texture info contained in the env file to the GPU.
  45010. * @param texture defines the internal texture to upload to
  45011. * @param arrayBuffer defines the buffer cotaining the data to load
  45012. * @param info defines the texture info retrieved through the GetEnvInfo method
  45013. * @returns a promise
  45014. */
  45015. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45016. private static _OnImageReadyAsync;
  45017. /**
  45018. * Uploads the levels of image data to the GPU.
  45019. * @param texture defines the internal texture to upload to
  45020. * @param imageData defines the array buffer views of image data [mipmap][face]
  45021. * @returns a promise
  45022. */
  45023. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45024. /**
  45025. * Uploads spherical polynomials information to the texture.
  45026. * @param texture defines the texture we are trying to upload the information to
  45027. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45028. */
  45029. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45030. /** @hidden */
  45031. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45032. }
  45033. }
  45034. declare module BABYLON {
  45035. /**
  45036. * Contains position and normal vectors for a vertex
  45037. */
  45038. export class PositionNormalVertex {
  45039. /** the position of the vertex (defaut: 0,0,0) */
  45040. position: Vector3;
  45041. /** the normal of the vertex (defaut: 0,1,0) */
  45042. normal: Vector3;
  45043. /**
  45044. * Creates a PositionNormalVertex
  45045. * @param position the position of the vertex (defaut: 0,0,0)
  45046. * @param normal the normal of the vertex (defaut: 0,1,0)
  45047. */
  45048. constructor(
  45049. /** the position of the vertex (defaut: 0,0,0) */
  45050. position?: Vector3,
  45051. /** the normal of the vertex (defaut: 0,1,0) */
  45052. normal?: Vector3);
  45053. /**
  45054. * Clones the PositionNormalVertex
  45055. * @returns the cloned PositionNormalVertex
  45056. */
  45057. clone(): PositionNormalVertex;
  45058. }
  45059. /**
  45060. * Contains position, normal and uv vectors for a vertex
  45061. */
  45062. export class PositionNormalTextureVertex {
  45063. /** the position of the vertex (defaut: 0,0,0) */
  45064. position: Vector3;
  45065. /** the normal of the vertex (defaut: 0,1,0) */
  45066. normal: Vector3;
  45067. /** the uv of the vertex (default: 0,0) */
  45068. uv: Vector2;
  45069. /**
  45070. * Creates a PositionNormalTextureVertex
  45071. * @param position the position of the vertex (defaut: 0,0,0)
  45072. * @param normal the normal of the vertex (defaut: 0,1,0)
  45073. * @param uv the uv of the vertex (default: 0,0)
  45074. */
  45075. constructor(
  45076. /** the position of the vertex (defaut: 0,0,0) */
  45077. position?: Vector3,
  45078. /** the normal of the vertex (defaut: 0,1,0) */
  45079. normal?: Vector3,
  45080. /** the uv of the vertex (default: 0,0) */
  45081. uv?: Vector2);
  45082. /**
  45083. * Clones the PositionNormalTextureVertex
  45084. * @returns the cloned PositionNormalTextureVertex
  45085. */
  45086. clone(): PositionNormalTextureVertex;
  45087. }
  45088. }
  45089. declare module BABYLON {
  45090. /** @hidden */
  45091. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45092. private _genericAttributeLocation;
  45093. private _varyingLocationCount;
  45094. private _varyingLocationMap;
  45095. private _replacements;
  45096. private _textureCount;
  45097. private _uniforms;
  45098. lineProcessor(line: string): string;
  45099. attributeProcessor(attribute: string): string;
  45100. varyingProcessor(varying: string, isFragment: boolean): string;
  45101. uniformProcessor(uniform: string): string;
  45102. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45103. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45104. }
  45105. }
  45106. declare module BABYLON {
  45107. /**
  45108. * Container for accessors for natively-stored mesh data buffers.
  45109. */
  45110. class NativeDataBuffer extends DataBuffer {
  45111. /**
  45112. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45113. */
  45114. nativeIndexBuffer?: any;
  45115. /**
  45116. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45117. */
  45118. nativeVertexBuffer?: any;
  45119. }
  45120. /** @hidden */
  45121. class NativeTexture extends InternalTexture {
  45122. getInternalTexture(): InternalTexture;
  45123. getViewCount(): number;
  45124. }
  45125. /** @hidden */
  45126. export class NativeEngine extends Engine {
  45127. private readonly _native;
  45128. getHardwareScalingLevel(): number;
  45129. constructor();
  45130. /**
  45131. * Can be used to override the current requestAnimationFrame requester.
  45132. * @hidden
  45133. */
  45134. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  45135. /**
  45136. * Override default engine behavior.
  45137. * @param color
  45138. * @param backBuffer
  45139. * @param depth
  45140. * @param stencil
  45141. */
  45142. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  45143. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45144. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45145. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45146. recordVertexArrayObject(vertexBuffers: {
  45147. [key: string]: VertexBuffer;
  45148. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45149. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45150. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45151. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45152. /**
  45153. * Draw a list of indexed primitives
  45154. * @param fillMode defines the primitive to use
  45155. * @param indexStart defines the starting index
  45156. * @param indexCount defines the number of index to draw
  45157. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45158. */
  45159. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45160. /**
  45161. * Draw a list of unindexed primitives
  45162. * @param fillMode defines the primitive to use
  45163. * @param verticesStart defines the index of first vertex to draw
  45164. * @param verticesCount defines the count of vertices to draw
  45165. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45166. */
  45167. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45168. createPipelineContext(): IPipelineContext;
  45169. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45170. /** @hidden */
  45171. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45172. /** @hidden */
  45173. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45174. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45175. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45176. protected _setProgram(program: WebGLProgram): void;
  45177. _releaseEffect(effect: Effect): void;
  45178. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45179. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45180. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45181. bindSamplers(effect: Effect): void;
  45182. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45183. getRenderWidth(useScreen?: boolean): number;
  45184. getRenderHeight(useScreen?: boolean): number;
  45185. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45186. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45187. /**
  45188. * Set the z offset to apply to current rendering
  45189. * @param value defines the offset to apply
  45190. */
  45191. setZOffset(value: number): void;
  45192. /**
  45193. * Gets the current value of the zOffset
  45194. * @returns the current zOffset state
  45195. */
  45196. getZOffset(): number;
  45197. /**
  45198. * Enable or disable depth buffering
  45199. * @param enable defines the state to set
  45200. */
  45201. setDepthBuffer(enable: boolean): void;
  45202. /**
  45203. * Gets a boolean indicating if depth writing is enabled
  45204. * @returns the current depth writing state
  45205. */
  45206. getDepthWrite(): boolean;
  45207. /**
  45208. * Enable or disable depth writing
  45209. * @param enable defines the state to set
  45210. */
  45211. setDepthWrite(enable: boolean): void;
  45212. /**
  45213. * Enable or disable color writing
  45214. * @param enable defines the state to set
  45215. */
  45216. setColorWrite(enable: boolean): void;
  45217. /**
  45218. * Gets a boolean indicating if color writing is enabled
  45219. * @returns the current color writing state
  45220. */
  45221. getColorWrite(): boolean;
  45222. /**
  45223. * Sets alpha constants used by some alpha blending modes
  45224. * @param r defines the red component
  45225. * @param g defines the green component
  45226. * @param b defines the blue component
  45227. * @param a defines the alpha component
  45228. */
  45229. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45230. /**
  45231. * Sets the current alpha mode
  45232. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  45233. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45234. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45235. */
  45236. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45237. /**
  45238. * Gets the current alpha mode
  45239. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45240. * @returns the current alpha mode
  45241. */
  45242. getAlphaMode(): number;
  45243. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45244. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45245. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45246. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45247. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45248. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45249. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45250. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45251. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45252. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45253. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45254. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45255. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45256. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45257. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45258. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45259. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45260. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45261. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45262. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45263. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45264. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45265. wipeCaches(bruteForce?: boolean): void;
  45266. _createTexture(): WebGLTexture;
  45267. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45268. /**
  45269. * Usually called from BABYLON.Texture.ts.
  45270. * Passed information to create a WebGLTexture
  45271. * @param urlArg defines a value which contains one of the following:
  45272. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45273. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45274. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45275. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45276. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45277. * @param scene needed for loading to the correct scene
  45278. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45279. * @param onLoad optional callback to be called upon successful completion
  45280. * @param onError optional callback to be called upon failure
  45281. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45282. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45283. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45284. * @param forcedExtension defines the extension to use to pick the right loader
  45285. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45286. */
  45287. 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;
  45288. /**
  45289. * Creates a cube texture
  45290. * @param rootUrl defines the url where the files to load is located
  45291. * @param scene defines the current scene
  45292. * @param files defines the list of files to load (1 per face)
  45293. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45294. * @param onLoad defines an optional callback raised when the texture is loaded
  45295. * @param onError defines an optional callback raised if there is an issue to load the texture
  45296. * @param format defines the format of the data
  45297. * @param forcedExtension defines the extension to use to pick the right loader
  45298. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45299. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45300. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45301. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45302. * @returns the cube texture as an InternalTexture
  45303. */
  45304. 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;
  45305. private _getSamplingFilter;
  45306. private static _GetNativeTextureFormat;
  45307. createRenderTargetTexture(size: number | {
  45308. width: number;
  45309. height: number;
  45310. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  45311. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45312. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45313. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45314. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45315. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45316. /**
  45317. * Updates a dynamic vertex buffer.
  45318. * @param vertexBuffer the vertex buffer to update
  45319. * @param data the data used to update the vertex buffer
  45320. * @param byteOffset the byte offset of the data (optional)
  45321. * @param byteLength the byte length of the data (optional)
  45322. */
  45323. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45324. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  45325. private _updateAnisotropicLevel;
  45326. private _getAddressMode;
  45327. /** @hidden */
  45328. _bindTexture(channel: number, texture: InternalTexture): void;
  45329. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  45330. releaseEffects(): void;
  45331. /** @hidden */
  45332. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45333. /** @hidden */
  45334. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45335. /** @hidden */
  45336. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45337. /** @hidden */
  45338. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45339. }
  45340. }
  45341. declare module BABYLON {
  45342. /**
  45343. * Gather the list of clipboard event types as constants.
  45344. */
  45345. export class ClipboardEventTypes {
  45346. /**
  45347. * The clipboard event is fired when a copy command is active (pressed).
  45348. */
  45349. static readonly COPY: number;
  45350. /**
  45351. * The clipboard event is fired when a cut command is active (pressed).
  45352. */
  45353. static readonly CUT: number;
  45354. /**
  45355. * The clipboard event is fired when a paste command is active (pressed).
  45356. */
  45357. static readonly PASTE: number;
  45358. }
  45359. /**
  45360. * This class is used to store clipboard related info for the onClipboardObservable event.
  45361. */
  45362. export class ClipboardInfo {
  45363. /**
  45364. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45365. */
  45366. type: number;
  45367. /**
  45368. * Defines the related dom event
  45369. */
  45370. event: ClipboardEvent;
  45371. /**
  45372. *Creates an instance of ClipboardInfo.
  45373. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45374. * @param event Defines the related dom event
  45375. */
  45376. constructor(
  45377. /**
  45378. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45379. */
  45380. type: number,
  45381. /**
  45382. * Defines the related dom event
  45383. */
  45384. event: ClipboardEvent);
  45385. /**
  45386. * Get the clipboard event's type from the keycode.
  45387. * @param keyCode Defines the keyCode for the current keyboard event.
  45388. * @return {number}
  45389. */
  45390. static GetTypeFromCharacter(keyCode: number): number;
  45391. }
  45392. }
  45393. declare module BABYLON {
  45394. /**
  45395. * Google Daydream controller
  45396. */
  45397. export class DaydreamController extends WebVRController {
  45398. /**
  45399. * Base Url for the controller model.
  45400. */
  45401. static MODEL_BASE_URL: string;
  45402. /**
  45403. * File name for the controller model.
  45404. */
  45405. static MODEL_FILENAME: string;
  45406. /**
  45407. * Gamepad Id prefix used to identify Daydream Controller.
  45408. */
  45409. static readonly GAMEPAD_ID_PREFIX: string;
  45410. /**
  45411. * Creates a new DaydreamController from a gamepad
  45412. * @param vrGamepad the gamepad that the controller should be created from
  45413. */
  45414. constructor(vrGamepad: any);
  45415. /**
  45416. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45417. * @param scene scene in which to add meshes
  45418. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45419. */
  45420. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45421. /**
  45422. * Called once for each button that changed state since the last frame
  45423. * @param buttonIdx Which button index changed
  45424. * @param state New state of the button
  45425. * @param changes Which properties on the state changed since last frame
  45426. */
  45427. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45428. }
  45429. }
  45430. declare module BABYLON {
  45431. /**
  45432. * Gear VR Controller
  45433. */
  45434. export class GearVRController extends WebVRController {
  45435. /**
  45436. * Base Url for the controller model.
  45437. */
  45438. static MODEL_BASE_URL: string;
  45439. /**
  45440. * File name for the controller model.
  45441. */
  45442. static MODEL_FILENAME: string;
  45443. /**
  45444. * Gamepad Id prefix used to identify this controller.
  45445. */
  45446. static readonly GAMEPAD_ID_PREFIX: string;
  45447. private readonly _buttonIndexToObservableNameMap;
  45448. /**
  45449. * Creates a new GearVRController from a gamepad
  45450. * @param vrGamepad the gamepad that the controller should be created from
  45451. */
  45452. constructor(vrGamepad: any);
  45453. /**
  45454. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45455. * @param scene scene in which to add meshes
  45456. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45457. */
  45458. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45459. /**
  45460. * Called once for each button that changed state since the last frame
  45461. * @param buttonIdx Which button index changed
  45462. * @param state New state of the button
  45463. * @param changes Which properties on the state changed since last frame
  45464. */
  45465. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45466. }
  45467. }
  45468. declare module BABYLON {
  45469. /**
  45470. * Class containing static functions to help procedurally build meshes
  45471. */
  45472. export class PolyhedronBuilder {
  45473. /**
  45474. * Creates a polyhedron mesh
  45475. * * 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
  45476. * * The parameter `size` (positive float, default 1) sets the polygon size
  45477. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45478. * * 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`
  45479. * * 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
  45480. * * 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)`)
  45481. * * 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
  45482. * * 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
  45483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45484. * * 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
  45485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45486. * @param name defines the name of the mesh
  45487. * @param options defines the options used to create the mesh
  45488. * @param scene defines the hosting scene
  45489. * @returns the polyhedron mesh
  45490. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45491. */
  45492. static CreatePolyhedron(name: string, options: {
  45493. type?: number;
  45494. size?: number;
  45495. sizeX?: number;
  45496. sizeY?: number;
  45497. sizeZ?: number;
  45498. custom?: any;
  45499. faceUV?: Vector4[];
  45500. faceColors?: Color4[];
  45501. flat?: boolean;
  45502. updatable?: boolean;
  45503. sideOrientation?: number;
  45504. frontUVs?: Vector4;
  45505. backUVs?: Vector4;
  45506. }, scene?: Nullable<Scene>): Mesh;
  45507. }
  45508. }
  45509. declare module BABYLON {
  45510. /**
  45511. * Gizmo that enables scaling a mesh along 3 axis
  45512. */
  45513. export class ScaleGizmo extends Gizmo {
  45514. /**
  45515. * Internal gizmo used for interactions on the x axis
  45516. */
  45517. xGizmo: AxisScaleGizmo;
  45518. /**
  45519. * Internal gizmo used for interactions on the y axis
  45520. */
  45521. yGizmo: AxisScaleGizmo;
  45522. /**
  45523. * Internal gizmo used for interactions on the z axis
  45524. */
  45525. zGizmo: AxisScaleGizmo;
  45526. /**
  45527. * Internal gizmo used to scale all axis equally
  45528. */
  45529. uniformScaleGizmo: AxisScaleGizmo;
  45530. private _meshAttached;
  45531. private _updateGizmoRotationToMatchAttachedMesh;
  45532. private _snapDistance;
  45533. private _scaleRatio;
  45534. private _uniformScalingMesh;
  45535. private _octahedron;
  45536. /** Fires an event when any of it's sub gizmos are dragged */
  45537. onDragStartObservable: Observable<unknown>;
  45538. /** Fires an event when any of it's sub gizmos are released from dragging */
  45539. onDragEndObservable: Observable<unknown>;
  45540. attachedMesh: Nullable<AbstractMesh>;
  45541. /**
  45542. * Creates a ScaleGizmo
  45543. * @param gizmoLayer The utility layer the gizmo will be added to
  45544. */
  45545. constructor(gizmoLayer?: UtilityLayerRenderer);
  45546. updateGizmoRotationToMatchAttachedMesh: boolean;
  45547. /**
  45548. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45549. */
  45550. snapDistance: number;
  45551. /**
  45552. * Ratio for the scale of the gizmo (Default: 1)
  45553. */
  45554. scaleRatio: number;
  45555. /**
  45556. * Disposes of the gizmo
  45557. */
  45558. dispose(): void;
  45559. }
  45560. }
  45561. declare module BABYLON {
  45562. /**
  45563. * Single axis scale gizmo
  45564. */
  45565. export class AxisScaleGizmo extends Gizmo {
  45566. /**
  45567. * Drag behavior responsible for the gizmos dragging interactions
  45568. */
  45569. dragBehavior: PointerDragBehavior;
  45570. private _pointerObserver;
  45571. /**
  45572. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45573. */
  45574. snapDistance: number;
  45575. /**
  45576. * Event that fires each time the gizmo snaps to a new location.
  45577. * * snapDistance is the the change in distance
  45578. */
  45579. onSnapObservable: Observable<{
  45580. snapDistance: number;
  45581. }>;
  45582. /**
  45583. * If the scaling operation should be done on all axis (default: false)
  45584. */
  45585. uniformScaling: boolean;
  45586. private _isEnabled;
  45587. private _parent;
  45588. private _arrow;
  45589. private _coloredMaterial;
  45590. private _hoverMaterial;
  45591. /**
  45592. * Creates an AxisScaleGizmo
  45593. * @param gizmoLayer The utility layer the gizmo will be added to
  45594. * @param dragAxis The axis which the gizmo will be able to scale on
  45595. * @param color The color of the gizmo
  45596. */
  45597. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45598. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45599. /**
  45600. * If the gizmo is enabled
  45601. */
  45602. isEnabled: boolean;
  45603. /**
  45604. * Disposes of the gizmo
  45605. */
  45606. dispose(): void;
  45607. /**
  45608. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45609. * @param mesh The mesh to replace the default mesh of the gizmo
  45610. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45611. */
  45612. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45613. }
  45614. }
  45615. declare module BABYLON {
  45616. /**
  45617. * Bounding box gizmo
  45618. */
  45619. export class BoundingBoxGizmo extends Gizmo {
  45620. private _lineBoundingBox;
  45621. private _rotateSpheresParent;
  45622. private _scaleBoxesParent;
  45623. private _boundingDimensions;
  45624. private _renderObserver;
  45625. private _pointerObserver;
  45626. private _scaleDragSpeed;
  45627. private _tmpQuaternion;
  45628. private _tmpVector;
  45629. private _tmpRotationMatrix;
  45630. /**
  45631. * 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)
  45632. */
  45633. ignoreChildren: boolean;
  45634. /**
  45635. * 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)
  45636. */
  45637. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45638. /**
  45639. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45640. */
  45641. rotationSphereSize: number;
  45642. /**
  45643. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45644. */
  45645. scaleBoxSize: number;
  45646. /**
  45647. * 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)
  45648. */
  45649. fixedDragMeshScreenSize: boolean;
  45650. /**
  45651. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45652. */
  45653. fixedDragMeshScreenSizeDistanceFactor: number;
  45654. /**
  45655. * Fired when a rotation sphere or scale box is dragged
  45656. */
  45657. onDragStartObservable: Observable<{}>;
  45658. /**
  45659. * Fired when a scale box is dragged
  45660. */
  45661. onScaleBoxDragObservable: Observable<{}>;
  45662. /**
  45663. * Fired when a scale box drag is ended
  45664. */
  45665. onScaleBoxDragEndObservable: Observable<{}>;
  45666. /**
  45667. * Fired when a rotation sphere is dragged
  45668. */
  45669. onRotationSphereDragObservable: Observable<{}>;
  45670. /**
  45671. * Fired when a rotation sphere drag is ended
  45672. */
  45673. onRotationSphereDragEndObservable: Observable<{}>;
  45674. /**
  45675. * 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)
  45676. */
  45677. scalePivot: Nullable<Vector3>;
  45678. /**
  45679. * Mesh used as a pivot to rotate the attached mesh
  45680. */
  45681. private _anchorMesh;
  45682. private _existingMeshScale;
  45683. private _dragMesh;
  45684. private pointerDragBehavior;
  45685. private coloredMaterial;
  45686. private hoverColoredMaterial;
  45687. /**
  45688. * Sets the color of the bounding box gizmo
  45689. * @param color the color to set
  45690. */
  45691. setColor(color: Color3): void;
  45692. /**
  45693. * Creates an BoundingBoxGizmo
  45694. * @param gizmoLayer The utility layer the gizmo will be added to
  45695. * @param color The color of the gizmo
  45696. */
  45697. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45698. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45699. private _selectNode;
  45700. /**
  45701. * Updates the bounding box information for the Gizmo
  45702. */
  45703. updateBoundingBox(): void;
  45704. private _updateRotationSpheres;
  45705. private _updateScaleBoxes;
  45706. /**
  45707. * Enables rotation on the specified axis and disables rotation on the others
  45708. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45709. */
  45710. setEnabledRotationAxis(axis: string): void;
  45711. /**
  45712. * Enables/disables scaling
  45713. * @param enable if scaling should be enabled
  45714. */
  45715. setEnabledScaling(enable: boolean): void;
  45716. private _updateDummy;
  45717. /**
  45718. * Enables a pointer drag behavior on the bounding box of the gizmo
  45719. */
  45720. enableDragBehavior(): void;
  45721. /**
  45722. * Disposes of the gizmo
  45723. */
  45724. dispose(): void;
  45725. /**
  45726. * 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)
  45727. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45728. * @returns the bounding box mesh with the passed in mesh as a child
  45729. */
  45730. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45731. /**
  45732. * CustomMeshes are not supported by this gizmo
  45733. * @param mesh The mesh to replace the default mesh of the gizmo
  45734. */
  45735. setCustomMesh(mesh: Mesh): void;
  45736. }
  45737. }
  45738. declare module BABYLON {
  45739. /**
  45740. * Single plane rotation gizmo
  45741. */
  45742. export class PlaneRotationGizmo extends Gizmo {
  45743. /**
  45744. * Drag behavior responsible for the gizmos dragging interactions
  45745. */
  45746. dragBehavior: PointerDragBehavior;
  45747. private _pointerObserver;
  45748. /**
  45749. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45750. */
  45751. snapDistance: number;
  45752. /**
  45753. * Event that fires each time the gizmo snaps to a new location.
  45754. * * snapDistance is the the change in distance
  45755. */
  45756. onSnapObservable: Observable<{
  45757. snapDistance: number;
  45758. }>;
  45759. private _isEnabled;
  45760. private _parent;
  45761. /**
  45762. * Creates a PlaneRotationGizmo
  45763. * @param gizmoLayer The utility layer the gizmo will be added to
  45764. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45765. * @param color The color of the gizmo
  45766. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45767. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45768. */
  45769. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45770. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45771. /**
  45772. * If the gizmo is enabled
  45773. */
  45774. isEnabled: boolean;
  45775. /**
  45776. * Disposes of the gizmo
  45777. */
  45778. dispose(): void;
  45779. }
  45780. }
  45781. declare module BABYLON {
  45782. /**
  45783. * Gizmo that enables rotating a mesh along 3 axis
  45784. */
  45785. export class RotationGizmo extends Gizmo {
  45786. /**
  45787. * Internal gizmo used for interactions on the x axis
  45788. */
  45789. xGizmo: PlaneRotationGizmo;
  45790. /**
  45791. * Internal gizmo used for interactions on the y axis
  45792. */
  45793. yGizmo: PlaneRotationGizmo;
  45794. /**
  45795. * Internal gizmo used for interactions on the z axis
  45796. */
  45797. zGizmo: PlaneRotationGizmo;
  45798. /** Fires an event when any of it's sub gizmos are dragged */
  45799. onDragStartObservable: Observable<unknown>;
  45800. /** Fires an event when any of it's sub gizmos are released from dragging */
  45801. onDragEndObservable: Observable<unknown>;
  45802. private _meshAttached;
  45803. attachedMesh: Nullable<AbstractMesh>;
  45804. /**
  45805. * Creates a RotationGizmo
  45806. * @param gizmoLayer The utility layer the gizmo will be added to
  45807. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45808. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45809. */
  45810. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45811. updateGizmoRotationToMatchAttachedMesh: boolean;
  45812. /**
  45813. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45814. */
  45815. snapDistance: number;
  45816. /**
  45817. * Ratio for the scale of the gizmo (Default: 1)
  45818. */
  45819. scaleRatio: number;
  45820. /**
  45821. * Disposes of the gizmo
  45822. */
  45823. dispose(): void;
  45824. /**
  45825. * CustomMeshes are not supported by this gizmo
  45826. * @param mesh The mesh to replace the default mesh of the gizmo
  45827. */
  45828. setCustomMesh(mesh: Mesh): void;
  45829. }
  45830. }
  45831. declare module BABYLON {
  45832. /**
  45833. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45834. */
  45835. export class GizmoManager implements IDisposable {
  45836. private scene;
  45837. /**
  45838. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45839. */
  45840. gizmos: {
  45841. positionGizmo: Nullable<PositionGizmo>;
  45842. rotationGizmo: Nullable<RotationGizmo>;
  45843. scaleGizmo: Nullable<ScaleGizmo>;
  45844. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45845. };
  45846. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45847. clearGizmoOnEmptyPointerEvent: boolean;
  45848. /** Fires an event when the manager is attached to a mesh */
  45849. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45850. private _gizmosEnabled;
  45851. private _pointerObserver;
  45852. private _attachedMesh;
  45853. private _boundingBoxColor;
  45854. private _defaultUtilityLayer;
  45855. private _defaultKeepDepthUtilityLayer;
  45856. /**
  45857. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45858. */
  45859. boundingBoxDragBehavior: SixDofDragBehavior;
  45860. /**
  45861. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45862. */
  45863. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45864. /**
  45865. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45866. */
  45867. usePointerToAttachGizmos: boolean;
  45868. /**
  45869. * Utility layer that the bounding box gizmo belongs to
  45870. */
  45871. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45872. /**
  45873. * Utility layer that all gizmos besides bounding box belong to
  45874. */
  45875. readonly utilityLayer: UtilityLayerRenderer;
  45876. /**
  45877. * Instatiates a gizmo manager
  45878. * @param scene the scene to overlay the gizmos on top of
  45879. */
  45880. constructor(scene: Scene);
  45881. /**
  45882. * Attaches a set of gizmos to the specified mesh
  45883. * @param mesh The mesh the gizmo's should be attached to
  45884. */
  45885. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45886. /**
  45887. * If the position gizmo is enabled
  45888. */
  45889. positionGizmoEnabled: boolean;
  45890. /**
  45891. * If the rotation gizmo is enabled
  45892. */
  45893. rotationGizmoEnabled: boolean;
  45894. /**
  45895. * If the scale gizmo is enabled
  45896. */
  45897. scaleGizmoEnabled: boolean;
  45898. /**
  45899. * If the boundingBox gizmo is enabled
  45900. */
  45901. boundingBoxGizmoEnabled: boolean;
  45902. /**
  45903. * Disposes of the gizmo manager
  45904. */
  45905. dispose(): void;
  45906. }
  45907. }
  45908. declare module BABYLON {
  45909. /**
  45910. * A directional light is defined by a direction (what a surprise!).
  45911. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45912. * 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.
  45913. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45914. */
  45915. export class DirectionalLight extends ShadowLight {
  45916. private _shadowFrustumSize;
  45917. /**
  45918. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45919. */
  45920. /**
  45921. * Specifies a fix frustum size for the shadow generation.
  45922. */
  45923. shadowFrustumSize: number;
  45924. private _shadowOrthoScale;
  45925. /**
  45926. * Gets the shadow projection scale against the optimal computed one.
  45927. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45928. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45929. */
  45930. /**
  45931. * Sets the shadow projection scale against the optimal computed one.
  45932. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45933. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45934. */
  45935. shadowOrthoScale: number;
  45936. /**
  45937. * Automatically compute the projection matrix to best fit (including all the casters)
  45938. * on each frame.
  45939. */
  45940. autoUpdateExtends: boolean;
  45941. private _orthoLeft;
  45942. private _orthoRight;
  45943. private _orthoTop;
  45944. private _orthoBottom;
  45945. /**
  45946. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45947. * The directional light is emitted from everywhere in the given direction.
  45948. * It can cast shadows.
  45949. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45950. * @param name The friendly name of the light
  45951. * @param direction The direction of the light
  45952. * @param scene The scene the light belongs to
  45953. */
  45954. constructor(name: string, direction: Vector3, scene: Scene);
  45955. /**
  45956. * Returns the string "DirectionalLight".
  45957. * @return The class name
  45958. */
  45959. getClassName(): string;
  45960. /**
  45961. * Returns the integer 1.
  45962. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45963. */
  45964. getTypeID(): number;
  45965. /**
  45966. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45967. * Returns the DirectionalLight Shadow projection matrix.
  45968. */
  45969. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45970. /**
  45971. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45972. * Returns the DirectionalLight Shadow projection matrix.
  45973. */
  45974. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45975. /**
  45976. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45977. * Returns the DirectionalLight Shadow projection matrix.
  45978. */
  45979. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45980. protected _buildUniformLayout(): void;
  45981. /**
  45982. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45983. * @param effect The effect to update
  45984. * @param lightIndex The index of the light in the effect to update
  45985. * @returns The directional light
  45986. */
  45987. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45988. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45989. /**
  45990. * Gets the minZ used for shadow according to both the scene and the light.
  45991. *
  45992. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45993. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45994. * @param activeCamera The camera we are returning the min for
  45995. * @returns the depth min z
  45996. */
  45997. getDepthMinZ(activeCamera: Camera): number;
  45998. /**
  45999. * Gets the maxZ used for shadow according to both the scene and the light.
  46000. *
  46001. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46002. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46003. * @param activeCamera The camera we are returning the max for
  46004. * @returns the depth max z
  46005. */
  46006. getDepthMaxZ(activeCamera: Camera): number;
  46007. /**
  46008. * Prepares the list of defines specific to the light type.
  46009. * @param defines the list of defines
  46010. * @param lightIndex defines the index of the light for the effect
  46011. */
  46012. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46013. }
  46014. }
  46015. declare module BABYLON {
  46016. /**
  46017. * Class containing static functions to help procedurally build meshes
  46018. */
  46019. export class HemisphereBuilder {
  46020. /**
  46021. * Creates a hemisphere mesh
  46022. * @param name defines the name of the mesh
  46023. * @param options defines the options used to create the mesh
  46024. * @param scene defines the hosting scene
  46025. * @returns the hemisphere mesh
  46026. */
  46027. static CreateHemisphere(name: string, options: {
  46028. segments?: number;
  46029. diameter?: number;
  46030. sideOrientation?: number;
  46031. }, scene: any): Mesh;
  46032. }
  46033. }
  46034. declare module BABYLON {
  46035. /**
  46036. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46037. * These values define a cone of light starting from the position, emitting toward the direction.
  46038. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46039. * and the exponent defines the speed of the decay of the light with distance (reach).
  46040. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46041. */
  46042. export class SpotLight extends ShadowLight {
  46043. private _angle;
  46044. private _innerAngle;
  46045. private _cosHalfAngle;
  46046. private _lightAngleScale;
  46047. private _lightAngleOffset;
  46048. /**
  46049. * Gets the cone angle of the spot light in Radians.
  46050. */
  46051. /**
  46052. * Sets the cone angle of the spot light in Radians.
  46053. */
  46054. angle: number;
  46055. /**
  46056. * Only used in gltf falloff mode, this defines the angle where
  46057. * the directional falloff will start before cutting at angle which could be seen
  46058. * as outer angle.
  46059. */
  46060. /**
  46061. * Only used in gltf falloff mode, this defines the angle where
  46062. * the directional falloff will start before cutting at angle which could be seen
  46063. * as outer angle.
  46064. */
  46065. innerAngle: number;
  46066. private _shadowAngleScale;
  46067. /**
  46068. * Allows scaling the angle of the light for shadow generation only.
  46069. */
  46070. /**
  46071. * Allows scaling the angle of the light for shadow generation only.
  46072. */
  46073. shadowAngleScale: number;
  46074. /**
  46075. * The light decay speed with the distance from the emission spot.
  46076. */
  46077. exponent: number;
  46078. private _projectionTextureMatrix;
  46079. /**
  46080. * Allows reading the projecton texture
  46081. */
  46082. readonly projectionTextureMatrix: Matrix;
  46083. protected _projectionTextureLightNear: number;
  46084. /**
  46085. * Gets the near clip of the Spotlight for texture projection.
  46086. */
  46087. /**
  46088. * Sets the near clip of the Spotlight for texture projection.
  46089. */
  46090. projectionTextureLightNear: number;
  46091. protected _projectionTextureLightFar: number;
  46092. /**
  46093. * Gets the far clip of the Spotlight for texture projection.
  46094. */
  46095. /**
  46096. * Sets the far clip of the Spotlight for texture projection.
  46097. */
  46098. projectionTextureLightFar: number;
  46099. protected _projectionTextureUpDirection: Vector3;
  46100. /**
  46101. * Gets the Up vector of the Spotlight for texture projection.
  46102. */
  46103. /**
  46104. * Sets the Up vector of the Spotlight for texture projection.
  46105. */
  46106. projectionTextureUpDirection: Vector3;
  46107. private _projectionTexture;
  46108. /**
  46109. * Gets the projection texture of the light.
  46110. */
  46111. /**
  46112. * Sets the projection texture of the light.
  46113. */
  46114. projectionTexture: Nullable<BaseTexture>;
  46115. private _projectionTextureViewLightDirty;
  46116. private _projectionTextureProjectionLightDirty;
  46117. private _projectionTextureDirty;
  46118. private _projectionTextureViewTargetVector;
  46119. private _projectionTextureViewLightMatrix;
  46120. private _projectionTextureProjectionLightMatrix;
  46121. private _projectionTextureScalingMatrix;
  46122. /**
  46123. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46124. * It can cast shadows.
  46125. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46126. * @param name The light friendly name
  46127. * @param position The position of the spot light in the scene
  46128. * @param direction The direction of the light in the scene
  46129. * @param angle The cone angle of the light in Radians
  46130. * @param exponent The light decay speed with the distance from the emission spot
  46131. * @param scene The scene the lights belongs to
  46132. */
  46133. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46134. /**
  46135. * Returns the string "SpotLight".
  46136. * @returns the class name
  46137. */
  46138. getClassName(): string;
  46139. /**
  46140. * Returns the integer 2.
  46141. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46142. */
  46143. getTypeID(): number;
  46144. /**
  46145. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46146. */
  46147. protected _setDirection(value: Vector3): void;
  46148. /**
  46149. * Overrides the position setter to recompute the projection texture view light Matrix.
  46150. */
  46151. protected _setPosition(value: Vector3): void;
  46152. /**
  46153. * 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.
  46154. * Returns the SpotLight.
  46155. */
  46156. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46157. protected _computeProjectionTextureViewLightMatrix(): void;
  46158. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46159. /**
  46160. * Main function for light texture projection matrix computing.
  46161. */
  46162. protected _computeProjectionTextureMatrix(): void;
  46163. protected _buildUniformLayout(): void;
  46164. private _computeAngleValues;
  46165. /**
  46166. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46167. * @param effect The effect to update
  46168. * @param lightIndex The index of the light in the effect to update
  46169. * @returns The spot light
  46170. */
  46171. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46172. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46173. /**
  46174. * Disposes the light and the associated resources.
  46175. */
  46176. dispose(): void;
  46177. /**
  46178. * Prepares the list of defines specific to the light type.
  46179. * @param defines the list of defines
  46180. * @param lightIndex defines the index of the light for the effect
  46181. */
  46182. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46183. }
  46184. }
  46185. declare module BABYLON {
  46186. /**
  46187. * Gizmo that enables viewing a light
  46188. */
  46189. export class LightGizmo extends Gizmo {
  46190. private _lightMesh;
  46191. private _material;
  46192. private cachedPosition;
  46193. private cachedForward;
  46194. /**
  46195. * Creates a LightGizmo
  46196. * @param gizmoLayer The utility layer the gizmo will be added to
  46197. */
  46198. constructor(gizmoLayer?: UtilityLayerRenderer);
  46199. private _light;
  46200. /**
  46201. * The light that the gizmo is attached to
  46202. */
  46203. light: Nullable<Light>;
  46204. /**
  46205. * Gets the material used to render the light gizmo
  46206. */
  46207. readonly material: StandardMaterial;
  46208. /**
  46209. * @hidden
  46210. * Updates the gizmo to match the attached mesh's position/rotation
  46211. */
  46212. protected _update(): void;
  46213. private static _Scale;
  46214. /**
  46215. * Creates the lines for a light mesh
  46216. */
  46217. private static _createLightLines;
  46218. /**
  46219. * Disposes of the light gizmo
  46220. */
  46221. dispose(): void;
  46222. private static _CreateHemisphericLightMesh;
  46223. private static _CreatePointLightMesh;
  46224. private static _CreateSpotLightMesh;
  46225. private static _CreateDirectionalLightMesh;
  46226. }
  46227. }
  46228. declare module BABYLON {
  46229. /** @hidden */
  46230. export var backgroundFragmentDeclaration: {
  46231. name: string;
  46232. shader: string;
  46233. };
  46234. }
  46235. declare module BABYLON {
  46236. /** @hidden */
  46237. export var backgroundUboDeclaration: {
  46238. name: string;
  46239. shader: string;
  46240. };
  46241. }
  46242. declare module BABYLON {
  46243. /** @hidden */
  46244. export var backgroundPixelShader: {
  46245. name: string;
  46246. shader: string;
  46247. };
  46248. }
  46249. declare module BABYLON {
  46250. /** @hidden */
  46251. export var backgroundVertexDeclaration: {
  46252. name: string;
  46253. shader: string;
  46254. };
  46255. }
  46256. declare module BABYLON {
  46257. /** @hidden */
  46258. export var backgroundVertexShader: {
  46259. name: string;
  46260. shader: string;
  46261. };
  46262. }
  46263. declare module BABYLON {
  46264. /**
  46265. * Background material used to create an efficient environement around your scene.
  46266. */
  46267. export class BackgroundMaterial extends PushMaterial {
  46268. /**
  46269. * Standard reflectance value at parallel view angle.
  46270. */
  46271. static StandardReflectance0: number;
  46272. /**
  46273. * Standard reflectance value at grazing angle.
  46274. */
  46275. static StandardReflectance90: number;
  46276. protected _primaryColor: Color3;
  46277. /**
  46278. * Key light Color (multiply against the environement texture)
  46279. */
  46280. primaryColor: Color3;
  46281. protected __perceptualColor: Nullable<Color3>;
  46282. /**
  46283. * Experimental Internal Use Only.
  46284. *
  46285. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46286. * This acts as a helper to set the primary color to a more "human friendly" value.
  46287. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46288. * output color as close as possible from the chosen value.
  46289. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46290. * part of lighting setup.)
  46291. */
  46292. _perceptualColor: Nullable<Color3>;
  46293. protected _primaryColorShadowLevel: float;
  46294. /**
  46295. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46296. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46297. */
  46298. primaryColorShadowLevel: float;
  46299. protected _primaryColorHighlightLevel: float;
  46300. /**
  46301. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46302. * The primary color is used at the level chosen to define what the white area would look.
  46303. */
  46304. primaryColorHighlightLevel: float;
  46305. protected _reflectionTexture: Nullable<BaseTexture>;
  46306. /**
  46307. * Reflection Texture used in the material.
  46308. * Should be author in a specific way for the best result (refer to the documentation).
  46309. */
  46310. reflectionTexture: Nullable<BaseTexture>;
  46311. protected _reflectionBlur: float;
  46312. /**
  46313. * Reflection Texture level of blur.
  46314. *
  46315. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46316. * texture twice.
  46317. */
  46318. reflectionBlur: float;
  46319. protected _diffuseTexture: Nullable<BaseTexture>;
  46320. /**
  46321. * Diffuse Texture used in the material.
  46322. * Should be author in a specific way for the best result (refer to the documentation).
  46323. */
  46324. diffuseTexture: Nullable<BaseTexture>;
  46325. protected _shadowLights: Nullable<IShadowLight[]>;
  46326. /**
  46327. * Specify the list of lights casting shadow on the material.
  46328. * All scene shadow lights will be included if null.
  46329. */
  46330. shadowLights: Nullable<IShadowLight[]>;
  46331. protected _shadowLevel: float;
  46332. /**
  46333. * Helps adjusting the shadow to a softer level if required.
  46334. * 0 means black shadows and 1 means no shadows.
  46335. */
  46336. shadowLevel: float;
  46337. protected _sceneCenter: Vector3;
  46338. /**
  46339. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46340. * It is usually zero but might be interesting to modify according to your setup.
  46341. */
  46342. sceneCenter: Vector3;
  46343. protected _opacityFresnel: boolean;
  46344. /**
  46345. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46346. * This helps ensuring a nice transition when the camera goes under the ground.
  46347. */
  46348. opacityFresnel: boolean;
  46349. protected _reflectionFresnel: boolean;
  46350. /**
  46351. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46352. * This helps adding a mirror texture on the ground.
  46353. */
  46354. reflectionFresnel: boolean;
  46355. protected _reflectionFalloffDistance: number;
  46356. /**
  46357. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46358. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46359. */
  46360. reflectionFalloffDistance: number;
  46361. protected _reflectionAmount: number;
  46362. /**
  46363. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46364. */
  46365. reflectionAmount: number;
  46366. protected _reflectionReflectance0: number;
  46367. /**
  46368. * This specifies the weight of the reflection at grazing angle.
  46369. */
  46370. reflectionReflectance0: number;
  46371. protected _reflectionReflectance90: number;
  46372. /**
  46373. * This specifies the weight of the reflection at a perpendicular point of view.
  46374. */
  46375. reflectionReflectance90: number;
  46376. /**
  46377. * Sets the reflection reflectance fresnel values according to the default standard
  46378. * empirically know to work well :-)
  46379. */
  46380. reflectionStandardFresnelWeight: number;
  46381. protected _useRGBColor: boolean;
  46382. /**
  46383. * Helps to directly use the maps channels instead of their level.
  46384. */
  46385. useRGBColor: boolean;
  46386. protected _enableNoise: boolean;
  46387. /**
  46388. * This helps reducing the banding effect that could occur on the background.
  46389. */
  46390. enableNoise: boolean;
  46391. /**
  46392. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46393. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46394. * Recommended to be keep at 1.0 except for special cases.
  46395. */
  46396. fovMultiplier: number;
  46397. private _fovMultiplier;
  46398. /**
  46399. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46400. */
  46401. useEquirectangularFOV: boolean;
  46402. private _maxSimultaneousLights;
  46403. /**
  46404. * Number of Simultaneous lights allowed on the material.
  46405. */
  46406. maxSimultaneousLights: int;
  46407. /**
  46408. * Default configuration related to image processing available in the Background Material.
  46409. */
  46410. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46411. /**
  46412. * Keep track of the image processing observer to allow dispose and replace.
  46413. */
  46414. private _imageProcessingObserver;
  46415. /**
  46416. * Attaches a new image processing configuration to the PBR Material.
  46417. * @param configuration (if null the scene configuration will be use)
  46418. */
  46419. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46420. /**
  46421. * Gets the image processing configuration used either in this material.
  46422. */
  46423. /**
  46424. * Sets the Default image processing configuration used either in the this material.
  46425. *
  46426. * If sets to null, the scene one is in use.
  46427. */
  46428. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46429. /**
  46430. * Gets wether the color curves effect is enabled.
  46431. */
  46432. /**
  46433. * Sets wether the color curves effect is enabled.
  46434. */
  46435. cameraColorCurvesEnabled: boolean;
  46436. /**
  46437. * Gets wether the color grading effect is enabled.
  46438. */
  46439. /**
  46440. * Gets wether the color grading effect is enabled.
  46441. */
  46442. cameraColorGradingEnabled: boolean;
  46443. /**
  46444. * Gets wether tonemapping is enabled or not.
  46445. */
  46446. /**
  46447. * Sets wether tonemapping is enabled or not
  46448. */
  46449. cameraToneMappingEnabled: boolean;
  46450. /**
  46451. * The camera exposure used on this material.
  46452. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46453. * This corresponds to a photographic exposure.
  46454. */
  46455. /**
  46456. * The camera exposure used on this material.
  46457. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46458. * This corresponds to a photographic exposure.
  46459. */
  46460. cameraExposure: float;
  46461. /**
  46462. * Gets The camera contrast used on this material.
  46463. */
  46464. /**
  46465. * Sets The camera contrast used on this material.
  46466. */
  46467. cameraContrast: float;
  46468. /**
  46469. * Gets the Color Grading 2D Lookup Texture.
  46470. */
  46471. /**
  46472. * Sets the Color Grading 2D Lookup Texture.
  46473. */
  46474. cameraColorGradingTexture: Nullable<BaseTexture>;
  46475. /**
  46476. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46477. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46478. * 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;
  46479. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46480. */
  46481. /**
  46482. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46483. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46484. * 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;
  46485. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46486. */
  46487. cameraColorCurves: Nullable<ColorCurves>;
  46488. /**
  46489. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46490. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46491. */
  46492. switchToBGR: boolean;
  46493. private _renderTargets;
  46494. private _reflectionControls;
  46495. private _white;
  46496. private _primaryShadowColor;
  46497. private _primaryHighlightColor;
  46498. /**
  46499. * Instantiates a Background Material in the given scene
  46500. * @param name The friendly name of the material
  46501. * @param scene The scene to add the material to
  46502. */
  46503. constructor(name: string, scene: Scene);
  46504. /**
  46505. * Gets a boolean indicating that current material needs to register RTT
  46506. */
  46507. readonly hasRenderTargetTextures: boolean;
  46508. /**
  46509. * The entire material has been created in order to prevent overdraw.
  46510. * @returns false
  46511. */
  46512. needAlphaTesting(): boolean;
  46513. /**
  46514. * The entire material has been created in order to prevent overdraw.
  46515. * @returns true if blending is enable
  46516. */
  46517. needAlphaBlending(): boolean;
  46518. /**
  46519. * Checks wether the material is ready to be rendered for a given mesh.
  46520. * @param mesh The mesh to render
  46521. * @param subMesh The submesh to check against
  46522. * @param useInstances Specify wether or not the material is used with instances
  46523. * @returns true if all the dependencies are ready (Textures, Effects...)
  46524. */
  46525. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46526. /**
  46527. * Compute the primary color according to the chosen perceptual color.
  46528. */
  46529. private _computePrimaryColorFromPerceptualColor;
  46530. /**
  46531. * Compute the highlights and shadow colors according to their chosen levels.
  46532. */
  46533. private _computePrimaryColors;
  46534. /**
  46535. * Build the uniform buffer used in the material.
  46536. */
  46537. buildUniformLayout(): void;
  46538. /**
  46539. * Unbind the material.
  46540. */
  46541. unbind(): void;
  46542. /**
  46543. * Bind only the world matrix to the material.
  46544. * @param world The world matrix to bind.
  46545. */
  46546. bindOnlyWorldMatrix(world: Matrix): void;
  46547. /**
  46548. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46549. * @param world The world matrix to bind.
  46550. * @param subMesh The submesh to bind for.
  46551. */
  46552. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46553. /**
  46554. * Checks to see if a texture is used in the material.
  46555. * @param texture - Base texture to use.
  46556. * @returns - Boolean specifying if a texture is used in the material.
  46557. */
  46558. hasTexture(texture: BaseTexture): boolean;
  46559. /**
  46560. * Dispose the material.
  46561. * @param forceDisposeEffect Force disposal of the associated effect.
  46562. * @param forceDisposeTextures Force disposal of the associated textures.
  46563. */
  46564. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46565. /**
  46566. * Clones the material.
  46567. * @param name The cloned name.
  46568. * @returns The cloned material.
  46569. */
  46570. clone(name: string): BackgroundMaterial;
  46571. /**
  46572. * Serializes the current material to its JSON representation.
  46573. * @returns The JSON representation.
  46574. */
  46575. serialize(): any;
  46576. /**
  46577. * Gets the class name of the material
  46578. * @returns "BackgroundMaterial"
  46579. */
  46580. getClassName(): string;
  46581. /**
  46582. * Parse a JSON input to create back a background material.
  46583. * @param source The JSON data to parse
  46584. * @param scene The scene to create the parsed material in
  46585. * @param rootUrl The root url of the assets the material depends upon
  46586. * @returns the instantiated BackgroundMaterial.
  46587. */
  46588. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46589. }
  46590. }
  46591. declare module BABYLON {
  46592. /**
  46593. * Represents the different options available during the creation of
  46594. * a Environment helper.
  46595. *
  46596. * This can control the default ground, skybox and image processing setup of your scene.
  46597. */
  46598. export interface IEnvironmentHelperOptions {
  46599. /**
  46600. * Specifies wether or not to create a ground.
  46601. * True by default.
  46602. */
  46603. createGround: boolean;
  46604. /**
  46605. * Specifies the ground size.
  46606. * 15 by default.
  46607. */
  46608. groundSize: number;
  46609. /**
  46610. * The texture used on the ground for the main color.
  46611. * Comes from the BabylonJS CDN by default.
  46612. *
  46613. * Remarks: Can be either a texture or a url.
  46614. */
  46615. groundTexture: string | BaseTexture;
  46616. /**
  46617. * The color mixed in the ground texture by default.
  46618. * BabylonJS clearColor by default.
  46619. */
  46620. groundColor: Color3;
  46621. /**
  46622. * Specifies the ground opacity.
  46623. * 1 by default.
  46624. */
  46625. groundOpacity: number;
  46626. /**
  46627. * Enables the ground to receive shadows.
  46628. * True by default.
  46629. */
  46630. enableGroundShadow: boolean;
  46631. /**
  46632. * Helps preventing the shadow to be fully black on the ground.
  46633. * 0.5 by default.
  46634. */
  46635. groundShadowLevel: number;
  46636. /**
  46637. * Creates a mirror texture attach to the ground.
  46638. * false by default.
  46639. */
  46640. enableGroundMirror: boolean;
  46641. /**
  46642. * Specifies the ground mirror size ratio.
  46643. * 0.3 by default as the default kernel is 64.
  46644. */
  46645. groundMirrorSizeRatio: number;
  46646. /**
  46647. * Specifies the ground mirror blur kernel size.
  46648. * 64 by default.
  46649. */
  46650. groundMirrorBlurKernel: number;
  46651. /**
  46652. * Specifies the ground mirror visibility amount.
  46653. * 1 by default
  46654. */
  46655. groundMirrorAmount: number;
  46656. /**
  46657. * Specifies the ground mirror reflectance weight.
  46658. * This uses the standard weight of the background material to setup the fresnel effect
  46659. * of the mirror.
  46660. * 1 by default.
  46661. */
  46662. groundMirrorFresnelWeight: number;
  46663. /**
  46664. * Specifies the ground mirror Falloff distance.
  46665. * This can helps reducing the size of the reflection.
  46666. * 0 by Default.
  46667. */
  46668. groundMirrorFallOffDistance: number;
  46669. /**
  46670. * Specifies the ground mirror texture type.
  46671. * Unsigned Int by Default.
  46672. */
  46673. groundMirrorTextureType: number;
  46674. /**
  46675. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46676. * the shown objects.
  46677. */
  46678. groundYBias: number;
  46679. /**
  46680. * Specifies wether or not to create a skybox.
  46681. * True by default.
  46682. */
  46683. createSkybox: boolean;
  46684. /**
  46685. * Specifies the skybox size.
  46686. * 20 by default.
  46687. */
  46688. skyboxSize: number;
  46689. /**
  46690. * The texture used on the skybox for the main color.
  46691. * Comes from the BabylonJS CDN by default.
  46692. *
  46693. * Remarks: Can be either a texture or a url.
  46694. */
  46695. skyboxTexture: string | BaseTexture;
  46696. /**
  46697. * The color mixed in the skybox texture by default.
  46698. * BabylonJS clearColor by default.
  46699. */
  46700. skyboxColor: Color3;
  46701. /**
  46702. * The background rotation around the Y axis of the scene.
  46703. * This helps aligning the key lights of your scene with the background.
  46704. * 0 by default.
  46705. */
  46706. backgroundYRotation: number;
  46707. /**
  46708. * Compute automatically the size of the elements to best fit with the scene.
  46709. */
  46710. sizeAuto: boolean;
  46711. /**
  46712. * Default position of the rootMesh if autoSize is not true.
  46713. */
  46714. rootPosition: Vector3;
  46715. /**
  46716. * Sets up the image processing in the scene.
  46717. * true by default.
  46718. */
  46719. setupImageProcessing: boolean;
  46720. /**
  46721. * The texture used as your environment texture in the scene.
  46722. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46723. *
  46724. * Remarks: Can be either a texture or a url.
  46725. */
  46726. environmentTexture: string | BaseTexture;
  46727. /**
  46728. * The value of the exposure to apply to the scene.
  46729. * 0.6 by default if setupImageProcessing is true.
  46730. */
  46731. cameraExposure: number;
  46732. /**
  46733. * The value of the contrast to apply to the scene.
  46734. * 1.6 by default if setupImageProcessing is true.
  46735. */
  46736. cameraContrast: number;
  46737. /**
  46738. * Specifies wether or not tonemapping should be enabled in the scene.
  46739. * true by default if setupImageProcessing is true.
  46740. */
  46741. toneMappingEnabled: boolean;
  46742. }
  46743. /**
  46744. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46745. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46746. * It also helps with the default setup of your imageProcessing configuration.
  46747. */
  46748. export class EnvironmentHelper {
  46749. /**
  46750. * Default ground texture URL.
  46751. */
  46752. private static _groundTextureCDNUrl;
  46753. /**
  46754. * Default skybox texture URL.
  46755. */
  46756. private static _skyboxTextureCDNUrl;
  46757. /**
  46758. * Default environment texture URL.
  46759. */
  46760. private static _environmentTextureCDNUrl;
  46761. /**
  46762. * Creates the default options for the helper.
  46763. */
  46764. private static _getDefaultOptions;
  46765. private _rootMesh;
  46766. /**
  46767. * Gets the root mesh created by the helper.
  46768. */
  46769. readonly rootMesh: Mesh;
  46770. private _skybox;
  46771. /**
  46772. * Gets the skybox created by the helper.
  46773. */
  46774. readonly skybox: Nullable<Mesh>;
  46775. private _skyboxTexture;
  46776. /**
  46777. * Gets the skybox texture created by the helper.
  46778. */
  46779. readonly skyboxTexture: Nullable<BaseTexture>;
  46780. private _skyboxMaterial;
  46781. /**
  46782. * Gets the skybox material created by the helper.
  46783. */
  46784. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46785. private _ground;
  46786. /**
  46787. * Gets the ground mesh created by the helper.
  46788. */
  46789. readonly ground: Nullable<Mesh>;
  46790. private _groundTexture;
  46791. /**
  46792. * Gets the ground texture created by the helper.
  46793. */
  46794. readonly groundTexture: Nullable<BaseTexture>;
  46795. private _groundMirror;
  46796. /**
  46797. * Gets the ground mirror created by the helper.
  46798. */
  46799. readonly groundMirror: Nullable<MirrorTexture>;
  46800. /**
  46801. * Gets the ground mirror render list to helps pushing the meshes
  46802. * you wish in the ground reflection.
  46803. */
  46804. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46805. private _groundMaterial;
  46806. /**
  46807. * Gets the ground material created by the helper.
  46808. */
  46809. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46810. /**
  46811. * Stores the creation options.
  46812. */
  46813. private readonly _scene;
  46814. private _options;
  46815. /**
  46816. * This observable will be notified with any error during the creation of the environment,
  46817. * mainly texture creation errors.
  46818. */
  46819. onErrorObservable: Observable<{
  46820. message?: string;
  46821. exception?: any;
  46822. }>;
  46823. /**
  46824. * constructor
  46825. * @param options Defines the options we want to customize the helper
  46826. * @param scene The scene to add the material to
  46827. */
  46828. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46829. /**
  46830. * Updates the background according to the new options
  46831. * @param options
  46832. */
  46833. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46834. /**
  46835. * Sets the primary color of all the available elements.
  46836. * @param color the main color to affect to the ground and the background
  46837. */
  46838. setMainColor(color: Color3): void;
  46839. /**
  46840. * Setup the image processing according to the specified options.
  46841. */
  46842. private _setupImageProcessing;
  46843. /**
  46844. * Setup the environment texture according to the specified options.
  46845. */
  46846. private _setupEnvironmentTexture;
  46847. /**
  46848. * Setup the background according to the specified options.
  46849. */
  46850. private _setupBackground;
  46851. /**
  46852. * Get the scene sizes according to the setup.
  46853. */
  46854. private _getSceneSize;
  46855. /**
  46856. * Setup the ground according to the specified options.
  46857. */
  46858. private _setupGround;
  46859. /**
  46860. * Setup the ground material according to the specified options.
  46861. */
  46862. private _setupGroundMaterial;
  46863. /**
  46864. * Setup the ground diffuse texture according to the specified options.
  46865. */
  46866. private _setupGroundDiffuseTexture;
  46867. /**
  46868. * Setup the ground mirror texture according to the specified options.
  46869. */
  46870. private _setupGroundMirrorTexture;
  46871. /**
  46872. * Setup the ground to receive the mirror texture.
  46873. */
  46874. private _setupMirrorInGroundMaterial;
  46875. /**
  46876. * Setup the skybox according to the specified options.
  46877. */
  46878. private _setupSkybox;
  46879. /**
  46880. * Setup the skybox material according to the specified options.
  46881. */
  46882. private _setupSkyboxMaterial;
  46883. /**
  46884. * Setup the skybox reflection texture according to the specified options.
  46885. */
  46886. private _setupSkyboxReflectionTexture;
  46887. private _errorHandler;
  46888. /**
  46889. * Dispose all the elements created by the Helper.
  46890. */
  46891. dispose(): void;
  46892. }
  46893. }
  46894. declare module BABYLON {
  46895. /**
  46896. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46897. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46898. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46899. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46900. */
  46901. export class PhotoDome extends TransformNode {
  46902. /**
  46903. * Define the image as a Monoscopic panoramic 360 image.
  46904. */
  46905. static readonly MODE_MONOSCOPIC: number;
  46906. /**
  46907. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46908. */
  46909. static readonly MODE_TOPBOTTOM: number;
  46910. /**
  46911. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46912. */
  46913. static readonly MODE_SIDEBYSIDE: number;
  46914. private _useDirectMapping;
  46915. /**
  46916. * The texture being displayed on the sphere
  46917. */
  46918. protected _photoTexture: Texture;
  46919. /**
  46920. * Gets or sets the texture being displayed on the sphere
  46921. */
  46922. photoTexture: Texture;
  46923. /**
  46924. * Observable raised when an error occured while loading the 360 image
  46925. */
  46926. onLoadErrorObservable: Observable<string>;
  46927. /**
  46928. * The skybox material
  46929. */
  46930. protected _material: BackgroundMaterial;
  46931. /**
  46932. * The surface used for the skybox
  46933. */
  46934. protected _mesh: Mesh;
  46935. /**
  46936. * Gets the mesh used for the skybox.
  46937. */
  46938. readonly mesh: Mesh;
  46939. /**
  46940. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46941. * Also see the options.resolution property.
  46942. */
  46943. fovMultiplier: number;
  46944. private _imageMode;
  46945. /**
  46946. * Gets or set the current video mode for the video. It can be:
  46947. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46948. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46949. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46950. */
  46951. imageMode: number;
  46952. /**
  46953. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46954. * @param name Element's name, child elements will append suffixes for their own names.
  46955. * @param urlsOfPhoto defines the url of the photo to display
  46956. * @param options defines an object containing optional or exposed sub element properties
  46957. * @param onError defines a callback called when an error occured while loading the texture
  46958. */
  46959. constructor(name: string, urlOfPhoto: string, options: {
  46960. resolution?: number;
  46961. size?: number;
  46962. useDirectMapping?: boolean;
  46963. faceForward?: boolean;
  46964. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46965. private _onBeforeCameraRenderObserver;
  46966. private _changeImageMode;
  46967. /**
  46968. * Releases resources associated with this node.
  46969. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46970. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46971. */
  46972. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46973. }
  46974. }
  46975. declare module BABYLON {
  46976. /**
  46977. * Class used to host RGBD texture specific utilities
  46978. */
  46979. export class RGBDTextureTools {
  46980. /**
  46981. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46982. * @param texture the texture to expand.
  46983. */
  46984. static ExpandRGBDTexture(texture: Texture): void;
  46985. }
  46986. }
  46987. declare module BABYLON {
  46988. /**
  46989. * Class used to host texture specific utilities
  46990. */
  46991. export class BRDFTextureTools {
  46992. /**
  46993. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46994. * @param scene defines the hosting scene
  46995. * @returns the environment BRDF texture
  46996. */
  46997. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46998. private static _environmentBRDFBase64Texture;
  46999. }
  47000. }
  47001. declare module BABYLON {
  47002. /**
  47003. * @hidden
  47004. */
  47005. export interface IMaterialClearCoatDefines {
  47006. CLEARCOAT: boolean;
  47007. CLEARCOAT_DEFAULTIOR: boolean;
  47008. CLEARCOAT_TEXTURE: boolean;
  47009. CLEARCOAT_TEXTUREDIRECTUV: number;
  47010. CLEARCOAT_BUMP: boolean;
  47011. CLEARCOAT_BUMPDIRECTUV: number;
  47012. CLEARCOAT_TINT: boolean;
  47013. CLEARCOAT_TINT_TEXTURE: boolean;
  47014. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47015. /** @hidden */
  47016. _areTexturesDirty: boolean;
  47017. }
  47018. /**
  47019. * Define the code related to the clear coat parameters of the pbr material.
  47020. */
  47021. export class PBRClearCoatConfiguration {
  47022. /**
  47023. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47024. * The default fits with a polyurethane material.
  47025. */
  47026. private static readonly _DefaultIndexOfRefraction;
  47027. private _isEnabled;
  47028. /**
  47029. * Defines if the clear coat is enabled in the material.
  47030. */
  47031. isEnabled: boolean;
  47032. /**
  47033. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47034. */
  47035. intensity: number;
  47036. /**
  47037. * Defines the clear coat layer roughness.
  47038. */
  47039. roughness: number;
  47040. private _indexOfRefraction;
  47041. /**
  47042. * Defines the index of refraction of the clear coat.
  47043. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47044. * The default fits with a polyurethane material.
  47045. * Changing the default value is more performance intensive.
  47046. */
  47047. indexOfRefraction: number;
  47048. private _texture;
  47049. /**
  47050. * Stores the clear coat values in a texture.
  47051. */
  47052. texture: Nullable<BaseTexture>;
  47053. private _bumpTexture;
  47054. /**
  47055. * Define the clear coat specific bump texture.
  47056. */
  47057. bumpTexture: Nullable<BaseTexture>;
  47058. private _isTintEnabled;
  47059. /**
  47060. * Defines if the clear coat tint is enabled in the material.
  47061. */
  47062. isTintEnabled: boolean;
  47063. /**
  47064. * Defines the clear coat tint of the material.
  47065. * This is only use if tint is enabled
  47066. */
  47067. tintColor: Color3;
  47068. /**
  47069. * Defines the distance at which the tint color should be found in the
  47070. * clear coat media.
  47071. * This is only use if tint is enabled
  47072. */
  47073. tintColorAtDistance: number;
  47074. /**
  47075. * Defines the clear coat layer thickness.
  47076. * This is only use if tint is enabled
  47077. */
  47078. tintThickness: number;
  47079. private _tintTexture;
  47080. /**
  47081. * Stores the clear tint values in a texture.
  47082. * rgb is tint
  47083. * a is a thickness factor
  47084. */
  47085. tintTexture: Nullable<BaseTexture>;
  47086. /** @hidden */
  47087. private _internalMarkAllSubMeshesAsTexturesDirty;
  47088. /** @hidden */
  47089. _markAllSubMeshesAsTexturesDirty(): void;
  47090. /**
  47091. * Instantiate a new istance of clear coat configuration.
  47092. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47093. */
  47094. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47095. /**
  47096. * Gets wehter the submesh is ready to be used or not.
  47097. * @param defines the list of "defines" to update.
  47098. * @param scene defines the scene the material belongs to.
  47099. * @param engine defines the engine the material belongs to.
  47100. * @param disableBumpMap defines wether the material disables bump or not.
  47101. * @returns - boolean indicating that the submesh is ready or not.
  47102. */
  47103. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47104. /**
  47105. * Checks to see if a texture is used in the material.
  47106. * @param defines the list of "defines" to update.
  47107. * @param scene defines the scene to the material belongs to.
  47108. */
  47109. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47110. /**
  47111. * Binds the material data.
  47112. * @param uniformBuffer defines the Uniform buffer to fill in.
  47113. * @param scene defines the scene the material belongs to.
  47114. * @param engine defines the engine the material belongs to.
  47115. * @param disableBumpMap defines wether the material disables bump or not.
  47116. * @param isFrozen defines wether the material is frozen or not.
  47117. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47118. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47119. */
  47120. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47121. /**
  47122. * Checks to see if a texture is used in the material.
  47123. * @param texture - Base texture to use.
  47124. * @returns - Boolean specifying if a texture is used in the material.
  47125. */
  47126. hasTexture(texture: BaseTexture): boolean;
  47127. /**
  47128. * Returns an array of the actively used textures.
  47129. * @param activeTextures Array of BaseTextures
  47130. */
  47131. getActiveTextures(activeTextures: BaseTexture[]): void;
  47132. /**
  47133. * Returns the animatable textures.
  47134. * @param animatables Array of animatable textures.
  47135. */
  47136. getAnimatables(animatables: IAnimatable[]): void;
  47137. /**
  47138. * Disposes the resources of the material.
  47139. * @param forceDisposeTextures - Forces the disposal of all textures.
  47140. */
  47141. dispose(forceDisposeTextures?: boolean): void;
  47142. /**
  47143. * Get the current class name of the texture useful for serialization or dynamic coding.
  47144. * @returns "PBRClearCoatConfiguration"
  47145. */
  47146. getClassName(): string;
  47147. /**
  47148. * Add fallbacks to the effect fallbacks list.
  47149. * @param defines defines the Base texture to use.
  47150. * @param fallbacks defines the current fallback list.
  47151. * @param currentRank defines the current fallback rank.
  47152. * @returns the new fallback rank.
  47153. */
  47154. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47155. /**
  47156. * Add the required uniforms to the current list.
  47157. * @param uniforms defines the current uniform list.
  47158. */
  47159. static AddUniforms(uniforms: string[]): void;
  47160. /**
  47161. * Add the required samplers to the current list.
  47162. * @param samplers defines the current sampler list.
  47163. */
  47164. static AddSamplers(samplers: string[]): void;
  47165. /**
  47166. * Add the required uniforms to the current buffer.
  47167. * @param uniformBuffer defines the current uniform buffer.
  47168. */
  47169. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47170. /**
  47171. * Makes a duplicate of the current configuration into another one.
  47172. * @param clearCoatConfiguration define the config where to copy the info
  47173. */
  47174. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47175. /**
  47176. * Serializes this clear coat configuration.
  47177. * @returns - An object with the serialized config.
  47178. */
  47179. serialize(): any;
  47180. /**
  47181. * Parses a anisotropy Configuration from a serialized object.
  47182. * @param source - Serialized object.
  47183. * @param scene Defines the scene we are parsing for
  47184. * @param rootUrl Defines the rootUrl to load from
  47185. */
  47186. parse(source: any, scene: Scene, rootUrl: string): void;
  47187. }
  47188. }
  47189. declare module BABYLON {
  47190. /**
  47191. * @hidden
  47192. */
  47193. export interface IMaterialAnisotropicDefines {
  47194. ANISOTROPIC: boolean;
  47195. ANISOTROPIC_TEXTURE: boolean;
  47196. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47197. MAINUV1: boolean;
  47198. _areTexturesDirty: boolean;
  47199. _needUVs: boolean;
  47200. }
  47201. /**
  47202. * Define the code related to the anisotropic parameters of the pbr material.
  47203. */
  47204. export class PBRAnisotropicConfiguration {
  47205. private _isEnabled;
  47206. /**
  47207. * Defines if the anisotropy is enabled in the material.
  47208. */
  47209. isEnabled: boolean;
  47210. /**
  47211. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47212. */
  47213. intensity: number;
  47214. /**
  47215. * Defines if the effect is along the tangents, bitangents or in between.
  47216. * By default, the effect is "strectching" the highlights along the tangents.
  47217. */
  47218. direction: Vector2;
  47219. private _texture;
  47220. /**
  47221. * Stores the anisotropy values in a texture.
  47222. * rg is direction (like normal from -1 to 1)
  47223. * b is a intensity
  47224. */
  47225. texture: Nullable<BaseTexture>;
  47226. /** @hidden */
  47227. private _internalMarkAllSubMeshesAsTexturesDirty;
  47228. /** @hidden */
  47229. _markAllSubMeshesAsTexturesDirty(): void;
  47230. /**
  47231. * Instantiate a new istance of anisotropy configuration.
  47232. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47233. */
  47234. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47235. /**
  47236. * Specifies that the submesh is ready to be used.
  47237. * @param defines the list of "defines" to update.
  47238. * @param scene defines the scene the material belongs to.
  47239. * @returns - boolean indicating that the submesh is ready or not.
  47240. */
  47241. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47242. /**
  47243. * Checks to see if a texture is used in the material.
  47244. * @param defines the list of "defines" to update.
  47245. * @param mesh the mesh we are preparing the defines for.
  47246. * @param scene defines the scene the material belongs to.
  47247. */
  47248. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47249. /**
  47250. * Binds the material data.
  47251. * @param uniformBuffer defines the Uniform buffer to fill in.
  47252. * @param scene defines the scene the material belongs to.
  47253. * @param isFrozen defines wether the material is frozen or not.
  47254. */
  47255. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47256. /**
  47257. * Checks to see if a texture is used in the material.
  47258. * @param texture - Base texture to use.
  47259. * @returns - Boolean specifying if a texture is used in the material.
  47260. */
  47261. hasTexture(texture: BaseTexture): boolean;
  47262. /**
  47263. * Returns an array of the actively used textures.
  47264. * @param activeTextures Array of BaseTextures
  47265. */
  47266. getActiveTextures(activeTextures: BaseTexture[]): void;
  47267. /**
  47268. * Returns the animatable textures.
  47269. * @param animatables Array of animatable textures.
  47270. */
  47271. getAnimatables(animatables: IAnimatable[]): void;
  47272. /**
  47273. * Disposes the resources of the material.
  47274. * @param forceDisposeTextures - Forces the disposal of all textures.
  47275. */
  47276. dispose(forceDisposeTextures?: boolean): void;
  47277. /**
  47278. * Get the current class name of the texture useful for serialization or dynamic coding.
  47279. * @returns "PBRAnisotropicConfiguration"
  47280. */
  47281. getClassName(): string;
  47282. /**
  47283. * Add fallbacks to the effect fallbacks list.
  47284. * @param defines defines the Base texture to use.
  47285. * @param fallbacks defines the current fallback list.
  47286. * @param currentRank defines the current fallback rank.
  47287. * @returns the new fallback rank.
  47288. */
  47289. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47290. /**
  47291. * Add the required uniforms to the current list.
  47292. * @param uniforms defines the current uniform list.
  47293. */
  47294. static AddUniforms(uniforms: string[]): void;
  47295. /**
  47296. * Add the required uniforms to the current buffer.
  47297. * @param uniformBuffer defines the current uniform buffer.
  47298. */
  47299. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47300. /**
  47301. * Add the required samplers to the current list.
  47302. * @param samplers defines the current sampler list.
  47303. */
  47304. static AddSamplers(samplers: string[]): void;
  47305. /**
  47306. * Makes a duplicate of the current configuration into another one.
  47307. * @param anisotropicConfiguration define the config where to copy the info
  47308. */
  47309. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47310. /**
  47311. * Serializes this anisotropy configuration.
  47312. * @returns - An object with the serialized config.
  47313. */
  47314. serialize(): any;
  47315. /**
  47316. * Parses a anisotropy Configuration from a serialized object.
  47317. * @param source - Serialized object.
  47318. * @param scene Defines the scene we are parsing for
  47319. * @param rootUrl Defines the rootUrl to load from
  47320. */
  47321. parse(source: any, scene: Scene, rootUrl: string): void;
  47322. }
  47323. }
  47324. declare module BABYLON {
  47325. /**
  47326. * @hidden
  47327. */
  47328. export interface IMaterialBRDFDefines {
  47329. BRDF_V_HEIGHT_CORRELATED: boolean;
  47330. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47331. SPHERICAL_HARMONICS: boolean;
  47332. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47333. /** @hidden */
  47334. _areMiscDirty: boolean;
  47335. }
  47336. /**
  47337. * Define the code related to the BRDF parameters of the pbr material.
  47338. */
  47339. export class PBRBRDFConfiguration {
  47340. /**
  47341. * Default value used for the energy conservation.
  47342. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47343. */
  47344. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47345. /**
  47346. * Default value used for the Smith Visibility Height Correlated mode.
  47347. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47348. */
  47349. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47350. /**
  47351. * Default value used for the IBL diffuse part.
  47352. * This can help switching back to the polynomials mode globally which is a tiny bit
  47353. * less GPU intensive at the drawback of a lower quality.
  47354. */
  47355. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47356. /**
  47357. * Default value used for activating energy conservation for the specular workflow.
  47358. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47359. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47360. */
  47361. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  47362. private _useEnergyConservation;
  47363. /**
  47364. * Defines if the material uses energy conservation.
  47365. */
  47366. useEnergyConservation: boolean;
  47367. private _useSmithVisibilityHeightCorrelated;
  47368. /**
  47369. * LEGACY Mode set to false
  47370. * Defines if the material uses height smith correlated visibility term.
  47371. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47372. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47373. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47374. * Not relying on height correlated will also disable energy conservation.
  47375. */
  47376. useSmithVisibilityHeightCorrelated: boolean;
  47377. private _useSphericalHarmonics;
  47378. /**
  47379. * LEGACY Mode set to false
  47380. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47381. * diffuse part of the IBL.
  47382. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47383. * to the ground truth.
  47384. */
  47385. useSphericalHarmonics: boolean;
  47386. private _useSpecularGlossinessInputEnergyConservation;
  47387. /**
  47388. * Defines if the material uses energy conservation, when the specular workflow is active.
  47389. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47390. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47391. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  47392. */
  47393. useSpecularGlossinessInputEnergyConservation: boolean;
  47394. /** @hidden */
  47395. private _internalMarkAllSubMeshesAsMiscDirty;
  47396. /** @hidden */
  47397. _markAllSubMeshesAsMiscDirty(): void;
  47398. /**
  47399. * Instantiate a new istance of clear coat configuration.
  47400. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47401. */
  47402. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47403. /**
  47404. * Checks to see if a texture is used in the material.
  47405. * @param defines the list of "defines" to update.
  47406. */
  47407. prepareDefines(defines: IMaterialBRDFDefines): void;
  47408. /**
  47409. * Get the current class name of the texture useful for serialization or dynamic coding.
  47410. * @returns "PBRClearCoatConfiguration"
  47411. */
  47412. getClassName(): string;
  47413. /**
  47414. * Makes a duplicate of the current configuration into another one.
  47415. * @param brdfConfiguration define the config where to copy the info
  47416. */
  47417. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47418. /**
  47419. * Serializes this BRDF configuration.
  47420. * @returns - An object with the serialized config.
  47421. */
  47422. serialize(): any;
  47423. /**
  47424. * Parses a anisotropy Configuration from a serialized object.
  47425. * @param source - Serialized object.
  47426. * @param scene Defines the scene we are parsing for
  47427. * @param rootUrl Defines the rootUrl to load from
  47428. */
  47429. parse(source: any, scene: Scene, rootUrl: string): void;
  47430. }
  47431. }
  47432. declare module BABYLON {
  47433. /**
  47434. * @hidden
  47435. */
  47436. export interface IMaterialSheenDefines {
  47437. SHEEN: boolean;
  47438. SHEEN_TEXTURE: boolean;
  47439. SHEEN_TEXTUREDIRECTUV: number;
  47440. SHEEN_LINKWITHALBEDO: boolean;
  47441. /** @hidden */
  47442. _areTexturesDirty: boolean;
  47443. }
  47444. /**
  47445. * Define the code related to the Sheen parameters of the pbr material.
  47446. */
  47447. export class PBRSheenConfiguration {
  47448. private _isEnabled;
  47449. /**
  47450. * Defines if the material uses sheen.
  47451. */
  47452. isEnabled: boolean;
  47453. private _linkSheenWithAlbedo;
  47454. /**
  47455. * Defines if the sheen is linked to the sheen color.
  47456. */
  47457. linkSheenWithAlbedo: boolean;
  47458. /**
  47459. * Defines the sheen intensity.
  47460. */
  47461. intensity: number;
  47462. /**
  47463. * Defines the sheen color.
  47464. */
  47465. color: Color3;
  47466. private _texture;
  47467. /**
  47468. * Stores the sheen tint values in a texture.
  47469. * rgb is tint
  47470. * a is a intensity
  47471. */
  47472. texture: Nullable<BaseTexture>;
  47473. /** @hidden */
  47474. private _internalMarkAllSubMeshesAsTexturesDirty;
  47475. /** @hidden */
  47476. _markAllSubMeshesAsTexturesDirty(): void;
  47477. /**
  47478. * Instantiate a new istance of clear coat configuration.
  47479. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47480. */
  47481. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47482. /**
  47483. * Specifies that the submesh is ready to be used.
  47484. * @param defines the list of "defines" to update.
  47485. * @param scene defines the scene the material belongs to.
  47486. * @returns - boolean indicating that the submesh is ready or not.
  47487. */
  47488. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47489. /**
  47490. * Checks to see if a texture is used in the material.
  47491. * @param defines the list of "defines" to update.
  47492. * @param scene defines the scene the material belongs to.
  47493. */
  47494. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47495. /**
  47496. * Binds the material data.
  47497. * @param uniformBuffer defines the Uniform buffer to fill in.
  47498. * @param scene defines the scene the material belongs to.
  47499. * @param isFrozen defines wether the material is frozen or not.
  47500. */
  47501. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47502. /**
  47503. * Checks to see if a texture is used in the material.
  47504. * @param texture - Base texture to use.
  47505. * @returns - Boolean specifying if a texture is used in the material.
  47506. */
  47507. hasTexture(texture: BaseTexture): boolean;
  47508. /**
  47509. * Returns an array of the actively used textures.
  47510. * @param activeTextures Array of BaseTextures
  47511. */
  47512. getActiveTextures(activeTextures: BaseTexture[]): void;
  47513. /**
  47514. * Returns the animatable textures.
  47515. * @param animatables Array of animatable textures.
  47516. */
  47517. getAnimatables(animatables: IAnimatable[]): void;
  47518. /**
  47519. * Disposes the resources of the material.
  47520. * @param forceDisposeTextures - Forces the disposal of all textures.
  47521. */
  47522. dispose(forceDisposeTextures?: boolean): void;
  47523. /**
  47524. * Get the current class name of the texture useful for serialization or dynamic coding.
  47525. * @returns "PBRSheenConfiguration"
  47526. */
  47527. getClassName(): string;
  47528. /**
  47529. * Add fallbacks to the effect fallbacks list.
  47530. * @param defines defines the Base texture to use.
  47531. * @param fallbacks defines the current fallback list.
  47532. * @param currentRank defines the current fallback rank.
  47533. * @returns the new fallback rank.
  47534. */
  47535. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47536. /**
  47537. * Add the required uniforms to the current list.
  47538. * @param uniforms defines the current uniform list.
  47539. */
  47540. static AddUniforms(uniforms: string[]): void;
  47541. /**
  47542. * Add the required uniforms to the current buffer.
  47543. * @param uniformBuffer defines the current uniform buffer.
  47544. */
  47545. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47546. /**
  47547. * Add the required samplers to the current list.
  47548. * @param samplers defines the current sampler list.
  47549. */
  47550. static AddSamplers(samplers: string[]): void;
  47551. /**
  47552. * Makes a duplicate of the current configuration into another one.
  47553. * @param sheenConfiguration define the config where to copy the info
  47554. */
  47555. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47556. /**
  47557. * Serializes this BRDF configuration.
  47558. * @returns - An object with the serialized config.
  47559. */
  47560. serialize(): any;
  47561. /**
  47562. * Parses a anisotropy Configuration from a serialized object.
  47563. * @param source - Serialized object.
  47564. * @param scene Defines the scene we are parsing for
  47565. * @param rootUrl Defines the rootUrl to load from
  47566. */
  47567. parse(source: any, scene: Scene, rootUrl: string): void;
  47568. }
  47569. }
  47570. declare module BABYLON {
  47571. /**
  47572. * @hidden
  47573. */
  47574. export interface IMaterialSubSurfaceDefines {
  47575. SUBSURFACE: boolean;
  47576. SS_REFRACTION: boolean;
  47577. SS_TRANSLUCENCY: boolean;
  47578. SS_SCATERRING: boolean;
  47579. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47580. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47581. SS_REFRACTIONMAP_3D: boolean;
  47582. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47583. SS_LODINREFRACTIONALPHA: boolean;
  47584. SS_GAMMAREFRACTION: boolean;
  47585. SS_RGBDREFRACTION: boolean;
  47586. SS_LINEARSPECULARREFRACTION: boolean;
  47587. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47588. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47589. /** @hidden */
  47590. _areTexturesDirty: boolean;
  47591. }
  47592. /**
  47593. * Define the code related to the sub surface parameters of the pbr material.
  47594. */
  47595. export class PBRSubSurfaceConfiguration {
  47596. private _isRefractionEnabled;
  47597. /**
  47598. * Defines if the refraction is enabled in the material.
  47599. */
  47600. isRefractionEnabled: boolean;
  47601. private _isTranslucencyEnabled;
  47602. /**
  47603. * Defines if the translucency is enabled in the material.
  47604. */
  47605. isTranslucencyEnabled: boolean;
  47606. private _isScatteringEnabled;
  47607. /**
  47608. * Defines the refraction intensity of the material.
  47609. * The refraction when enabled replaces the Diffuse part of the material.
  47610. * The intensity helps transitionning between diffuse and refraction.
  47611. */
  47612. refractionIntensity: number;
  47613. /**
  47614. * Defines the translucency intensity of the material.
  47615. * When translucency has been enabled, this defines how much of the "translucency"
  47616. * is addded to the diffuse part of the material.
  47617. */
  47618. translucencyIntensity: number;
  47619. /**
  47620. * Defines the scattering intensity of the material.
  47621. * When scattering has been enabled, this defines how much of the "scattered light"
  47622. * is addded to the diffuse part of the material.
  47623. */
  47624. scatteringIntensity: number;
  47625. private _thicknessTexture;
  47626. /**
  47627. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47628. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47629. * 0 would mean minimumThickness
  47630. * 1 would mean maximumThickness
  47631. * The other channels might be use as a mask to vary the different effects intensity.
  47632. */
  47633. thicknessTexture: Nullable<BaseTexture>;
  47634. private _refractionTexture;
  47635. /**
  47636. * Defines the texture to use for refraction.
  47637. */
  47638. refractionTexture: Nullable<BaseTexture>;
  47639. private _indexOfRefraction;
  47640. /**
  47641. * Defines the index of refraction used in the material.
  47642. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47643. */
  47644. indexOfRefraction: number;
  47645. private _invertRefractionY;
  47646. /**
  47647. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47648. */
  47649. invertRefractionY: boolean;
  47650. private _linkRefractionWithTransparency;
  47651. /**
  47652. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47653. * Materials half opaque for instance using refraction could benefit from this control.
  47654. */
  47655. linkRefractionWithTransparency: boolean;
  47656. /**
  47657. * Defines the minimum thickness stored in the thickness map.
  47658. * If no thickness map is defined, this value will be used to simulate thickness.
  47659. */
  47660. minimumThickness: number;
  47661. /**
  47662. * Defines the maximum thickness stored in the thickness map.
  47663. */
  47664. maximumThickness: number;
  47665. /**
  47666. * Defines the volume tint of the material.
  47667. * This is used for both translucency and scattering.
  47668. */
  47669. tintColor: Color3;
  47670. /**
  47671. * Defines the distance at which the tint color should be found in the media.
  47672. * This is used for refraction only.
  47673. */
  47674. tintColorAtDistance: number;
  47675. /**
  47676. * Defines how far each channel transmit through the media.
  47677. * It is defined as a color to simplify it selection.
  47678. */
  47679. diffusionDistance: Color3;
  47680. private _useMaskFromThicknessTexture;
  47681. /**
  47682. * Stores the intensity of the different subsurface effects in the thickness texture.
  47683. * * the green channel is the translucency intensity.
  47684. * * the blue channel is the scattering intensity.
  47685. * * the alpha channel is the refraction intensity.
  47686. */
  47687. useMaskFromThicknessTexture: boolean;
  47688. /** @hidden */
  47689. private _internalMarkAllSubMeshesAsTexturesDirty;
  47690. /** @hidden */
  47691. _markAllSubMeshesAsTexturesDirty(): void;
  47692. /**
  47693. * Instantiate a new istance of sub surface configuration.
  47694. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47695. */
  47696. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47697. /**
  47698. * Gets wehter the submesh is ready to be used or not.
  47699. * @param defines the list of "defines" to update.
  47700. * @param scene defines the scene the material belongs to.
  47701. * @returns - boolean indicating that the submesh is ready or not.
  47702. */
  47703. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47704. /**
  47705. * Checks to see if a texture is used in the material.
  47706. * @param defines the list of "defines" to update.
  47707. * @param scene defines the scene to the material belongs to.
  47708. */
  47709. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47710. /**
  47711. * Binds the material data.
  47712. * @param uniformBuffer defines the Uniform buffer to fill in.
  47713. * @param scene defines the scene the material belongs to.
  47714. * @param engine defines the engine the material belongs to.
  47715. * @param isFrozen defines wether the material is frozen or not.
  47716. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47717. */
  47718. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47719. /**
  47720. * Unbinds the material from the mesh.
  47721. * @param activeEffect defines the effect that should be unbound from.
  47722. * @returns true if unbound, otherwise false
  47723. */
  47724. unbind(activeEffect: Effect): boolean;
  47725. /**
  47726. * Returns the texture used for refraction or null if none is used.
  47727. * @param scene defines the scene the material belongs to.
  47728. * @returns - Refraction texture if present. If no refraction texture and refraction
  47729. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47730. */
  47731. private _getRefractionTexture;
  47732. /**
  47733. * Returns true if alpha blending should be disabled.
  47734. */
  47735. readonly disableAlphaBlending: boolean;
  47736. /**
  47737. * Fills the list of render target textures.
  47738. * @param renderTargets the list of render targets to update
  47739. */
  47740. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47741. /**
  47742. * Checks to see if a texture is used in the material.
  47743. * @param texture - Base texture to use.
  47744. * @returns - Boolean specifying if a texture is used in the material.
  47745. */
  47746. hasTexture(texture: BaseTexture): boolean;
  47747. /**
  47748. * Gets a boolean indicating that current material needs to register RTT
  47749. * @returns true if this uses a render target otherwise false.
  47750. */
  47751. hasRenderTargetTextures(): boolean;
  47752. /**
  47753. * Returns an array of the actively used textures.
  47754. * @param activeTextures Array of BaseTextures
  47755. */
  47756. getActiveTextures(activeTextures: BaseTexture[]): void;
  47757. /**
  47758. * Returns the animatable textures.
  47759. * @param animatables Array of animatable textures.
  47760. */
  47761. getAnimatables(animatables: IAnimatable[]): void;
  47762. /**
  47763. * Disposes the resources of the material.
  47764. * @param forceDisposeTextures - Forces the disposal of all textures.
  47765. */
  47766. dispose(forceDisposeTextures?: boolean): void;
  47767. /**
  47768. * Get the current class name of the texture useful for serialization or dynamic coding.
  47769. * @returns "PBRSubSurfaceConfiguration"
  47770. */
  47771. getClassName(): string;
  47772. /**
  47773. * Add fallbacks to the effect fallbacks list.
  47774. * @param defines defines the Base texture to use.
  47775. * @param fallbacks defines the current fallback list.
  47776. * @param currentRank defines the current fallback rank.
  47777. * @returns the new fallback rank.
  47778. */
  47779. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47780. /**
  47781. * Add the required uniforms to the current list.
  47782. * @param uniforms defines the current uniform list.
  47783. */
  47784. static AddUniforms(uniforms: string[]): void;
  47785. /**
  47786. * Add the required samplers to the current list.
  47787. * @param samplers defines the current sampler list.
  47788. */
  47789. static AddSamplers(samplers: string[]): void;
  47790. /**
  47791. * Add the required uniforms to the current buffer.
  47792. * @param uniformBuffer defines the current uniform buffer.
  47793. */
  47794. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47795. /**
  47796. * Makes a duplicate of the current configuration into another one.
  47797. * @param configuration define the config where to copy the info
  47798. */
  47799. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47800. /**
  47801. * Serializes this Sub Surface configuration.
  47802. * @returns - An object with the serialized config.
  47803. */
  47804. serialize(): any;
  47805. /**
  47806. * Parses a anisotropy Configuration from a serialized object.
  47807. * @param source - Serialized object.
  47808. * @param scene Defines the scene we are parsing for
  47809. * @param rootUrl Defines the rootUrl to load from
  47810. */
  47811. parse(source: any, scene: Scene, rootUrl: string): void;
  47812. }
  47813. }
  47814. declare module BABYLON {
  47815. /** @hidden */
  47816. export var pbrFragmentDeclaration: {
  47817. name: string;
  47818. shader: string;
  47819. };
  47820. }
  47821. declare module BABYLON {
  47822. /** @hidden */
  47823. export var pbrUboDeclaration: {
  47824. name: string;
  47825. shader: string;
  47826. };
  47827. }
  47828. declare module BABYLON {
  47829. /** @hidden */
  47830. export var pbrFragmentExtraDeclaration: {
  47831. name: string;
  47832. shader: string;
  47833. };
  47834. }
  47835. declare module BABYLON {
  47836. /** @hidden */
  47837. export var pbrFragmentSamplersDeclaration: {
  47838. name: string;
  47839. shader: string;
  47840. };
  47841. }
  47842. declare module BABYLON {
  47843. /** @hidden */
  47844. export var pbrHelperFunctions: {
  47845. name: string;
  47846. shader: string;
  47847. };
  47848. }
  47849. declare module BABYLON {
  47850. /** @hidden */
  47851. export var harmonicsFunctions: {
  47852. name: string;
  47853. shader: string;
  47854. };
  47855. }
  47856. declare module BABYLON {
  47857. /** @hidden */
  47858. export var pbrDirectLightingSetupFunctions: {
  47859. name: string;
  47860. shader: string;
  47861. };
  47862. }
  47863. declare module BABYLON {
  47864. /** @hidden */
  47865. export var pbrDirectLightingFalloffFunctions: {
  47866. name: string;
  47867. shader: string;
  47868. };
  47869. }
  47870. declare module BABYLON {
  47871. /** @hidden */
  47872. export var pbrBRDFFunctions: {
  47873. name: string;
  47874. shader: string;
  47875. };
  47876. }
  47877. declare module BABYLON {
  47878. /** @hidden */
  47879. export var pbrDirectLightingFunctions: {
  47880. name: string;
  47881. shader: string;
  47882. };
  47883. }
  47884. declare module BABYLON {
  47885. /** @hidden */
  47886. export var pbrIBLFunctions: {
  47887. name: string;
  47888. shader: string;
  47889. };
  47890. }
  47891. declare module BABYLON {
  47892. /** @hidden */
  47893. export var pbrDebug: {
  47894. name: string;
  47895. shader: string;
  47896. };
  47897. }
  47898. declare module BABYLON {
  47899. /** @hidden */
  47900. export var pbrPixelShader: {
  47901. name: string;
  47902. shader: string;
  47903. };
  47904. }
  47905. declare module BABYLON {
  47906. /** @hidden */
  47907. export var pbrVertexDeclaration: {
  47908. name: string;
  47909. shader: string;
  47910. };
  47911. }
  47912. declare module BABYLON {
  47913. /** @hidden */
  47914. export var pbrVertexShader: {
  47915. name: string;
  47916. shader: string;
  47917. };
  47918. }
  47919. declare module BABYLON {
  47920. /**
  47921. * Manages the defines for the PBR Material.
  47922. * @hidden
  47923. */
  47924. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47925. PBR: boolean;
  47926. MAINUV1: boolean;
  47927. MAINUV2: boolean;
  47928. UV1: boolean;
  47929. UV2: boolean;
  47930. ALBEDO: boolean;
  47931. ALBEDODIRECTUV: number;
  47932. VERTEXCOLOR: boolean;
  47933. AMBIENT: boolean;
  47934. AMBIENTDIRECTUV: number;
  47935. AMBIENTINGRAYSCALE: boolean;
  47936. OPACITY: boolean;
  47937. VERTEXALPHA: boolean;
  47938. OPACITYDIRECTUV: number;
  47939. OPACITYRGB: boolean;
  47940. ALPHATEST: boolean;
  47941. DEPTHPREPASS: boolean;
  47942. ALPHABLEND: boolean;
  47943. ALPHAFROMALBEDO: boolean;
  47944. ALPHATESTVALUE: string;
  47945. SPECULAROVERALPHA: boolean;
  47946. RADIANCEOVERALPHA: boolean;
  47947. ALPHAFRESNEL: boolean;
  47948. LINEARALPHAFRESNEL: boolean;
  47949. PREMULTIPLYALPHA: boolean;
  47950. EMISSIVE: boolean;
  47951. EMISSIVEDIRECTUV: number;
  47952. REFLECTIVITY: boolean;
  47953. REFLECTIVITYDIRECTUV: number;
  47954. SPECULARTERM: boolean;
  47955. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47956. MICROSURFACEAUTOMATIC: boolean;
  47957. LODBASEDMICROSFURACE: boolean;
  47958. MICROSURFACEMAP: boolean;
  47959. MICROSURFACEMAPDIRECTUV: number;
  47960. METALLICWORKFLOW: boolean;
  47961. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47962. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47963. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47964. AOSTOREINMETALMAPRED: boolean;
  47965. METALLICF0FACTORFROMMETALLICMAP: boolean;
  47966. ENVIRONMENTBRDF: boolean;
  47967. ENVIRONMENTBRDF_RGBD: boolean;
  47968. NORMAL: boolean;
  47969. TANGENT: boolean;
  47970. BUMP: boolean;
  47971. BUMPDIRECTUV: number;
  47972. OBJECTSPACE_NORMALMAP: boolean;
  47973. PARALLAX: boolean;
  47974. PARALLAXOCCLUSION: boolean;
  47975. NORMALXYSCALE: boolean;
  47976. LIGHTMAP: boolean;
  47977. LIGHTMAPDIRECTUV: number;
  47978. USELIGHTMAPASSHADOWMAP: boolean;
  47979. GAMMALIGHTMAP: boolean;
  47980. RGBDLIGHTMAP: boolean;
  47981. REFLECTION: boolean;
  47982. REFLECTIONMAP_3D: boolean;
  47983. REFLECTIONMAP_SPHERICAL: boolean;
  47984. REFLECTIONMAP_PLANAR: boolean;
  47985. REFLECTIONMAP_CUBIC: boolean;
  47986. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47987. REFLECTIONMAP_PROJECTION: boolean;
  47988. REFLECTIONMAP_SKYBOX: boolean;
  47989. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47990. REFLECTIONMAP_EXPLICIT: boolean;
  47991. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47992. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47993. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47994. INVERTCUBICMAP: boolean;
  47995. USESPHERICALFROMREFLECTIONMAP: boolean;
  47996. USEIRRADIANCEMAP: boolean;
  47997. SPHERICAL_HARMONICS: boolean;
  47998. USESPHERICALINVERTEX: boolean;
  47999. REFLECTIONMAP_OPPOSITEZ: boolean;
  48000. LODINREFLECTIONALPHA: boolean;
  48001. GAMMAREFLECTION: boolean;
  48002. RGBDREFLECTION: boolean;
  48003. LINEARSPECULARREFLECTION: boolean;
  48004. RADIANCEOCCLUSION: boolean;
  48005. HORIZONOCCLUSION: boolean;
  48006. INSTANCES: boolean;
  48007. NUM_BONE_INFLUENCERS: number;
  48008. BonesPerMesh: number;
  48009. BONETEXTURE: boolean;
  48010. NONUNIFORMSCALING: boolean;
  48011. MORPHTARGETS: boolean;
  48012. MORPHTARGETS_NORMAL: boolean;
  48013. MORPHTARGETS_TANGENT: boolean;
  48014. MORPHTARGETS_UV: boolean;
  48015. NUM_MORPH_INFLUENCERS: number;
  48016. IMAGEPROCESSING: boolean;
  48017. VIGNETTE: boolean;
  48018. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48019. VIGNETTEBLENDMODEOPAQUE: boolean;
  48020. TONEMAPPING: boolean;
  48021. TONEMAPPING_ACES: boolean;
  48022. CONTRAST: boolean;
  48023. COLORCURVES: boolean;
  48024. COLORGRADING: boolean;
  48025. COLORGRADING3D: boolean;
  48026. SAMPLER3DGREENDEPTH: boolean;
  48027. SAMPLER3DBGRMAP: boolean;
  48028. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48029. EXPOSURE: boolean;
  48030. MULTIVIEW: boolean;
  48031. USEPHYSICALLIGHTFALLOFF: boolean;
  48032. USEGLTFLIGHTFALLOFF: boolean;
  48033. TWOSIDEDLIGHTING: boolean;
  48034. SHADOWFLOAT: boolean;
  48035. CLIPPLANE: boolean;
  48036. CLIPPLANE2: boolean;
  48037. CLIPPLANE3: boolean;
  48038. CLIPPLANE4: boolean;
  48039. POINTSIZE: boolean;
  48040. FOG: boolean;
  48041. LOGARITHMICDEPTH: boolean;
  48042. FORCENORMALFORWARD: boolean;
  48043. SPECULARAA: boolean;
  48044. CLEARCOAT: boolean;
  48045. CLEARCOAT_DEFAULTIOR: boolean;
  48046. CLEARCOAT_TEXTURE: boolean;
  48047. CLEARCOAT_TEXTUREDIRECTUV: number;
  48048. CLEARCOAT_BUMP: boolean;
  48049. CLEARCOAT_BUMPDIRECTUV: number;
  48050. CLEARCOAT_TINT: boolean;
  48051. CLEARCOAT_TINT_TEXTURE: boolean;
  48052. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48053. ANISOTROPIC: boolean;
  48054. ANISOTROPIC_TEXTURE: boolean;
  48055. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48056. BRDF_V_HEIGHT_CORRELATED: boolean;
  48057. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48058. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48059. SHEEN: boolean;
  48060. SHEEN_TEXTURE: boolean;
  48061. SHEEN_TEXTUREDIRECTUV: number;
  48062. SHEEN_LINKWITHALBEDO: boolean;
  48063. SUBSURFACE: boolean;
  48064. SS_REFRACTION: boolean;
  48065. SS_TRANSLUCENCY: boolean;
  48066. SS_SCATERRING: boolean;
  48067. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48068. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48069. SS_REFRACTIONMAP_3D: boolean;
  48070. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48071. SS_LODINREFRACTIONALPHA: boolean;
  48072. SS_GAMMAREFRACTION: boolean;
  48073. SS_RGBDREFRACTION: boolean;
  48074. SS_LINEARSPECULARREFRACTION: boolean;
  48075. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48076. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48077. UNLIT: boolean;
  48078. DEBUGMODE: number;
  48079. /**
  48080. * Initializes the PBR Material defines.
  48081. */
  48082. constructor();
  48083. /**
  48084. * Resets the PBR Material defines.
  48085. */
  48086. reset(): void;
  48087. }
  48088. /**
  48089. * The Physically based material base class of BJS.
  48090. *
  48091. * This offers the main features of a standard PBR material.
  48092. * For more information, please refer to the documentation :
  48093. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48094. */
  48095. export abstract class PBRBaseMaterial extends PushMaterial {
  48096. /**
  48097. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48098. */
  48099. static readonly PBRMATERIAL_OPAQUE: number;
  48100. /**
  48101. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48102. */
  48103. static readonly PBRMATERIAL_ALPHATEST: number;
  48104. /**
  48105. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48106. */
  48107. static readonly PBRMATERIAL_ALPHABLEND: number;
  48108. /**
  48109. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48110. * They are also discarded below the alpha cutoff threshold to improve performances.
  48111. */
  48112. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48113. /**
  48114. * Defines the default value of how much AO map is occluding the analytical lights
  48115. * (point spot...).
  48116. */
  48117. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48118. /**
  48119. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48120. */
  48121. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48122. /**
  48123. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48124. * to enhance interoperability with other engines.
  48125. */
  48126. static readonly LIGHTFALLOFF_GLTF: number;
  48127. /**
  48128. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48129. * to enhance interoperability with other materials.
  48130. */
  48131. static readonly LIGHTFALLOFF_STANDARD: number;
  48132. /**
  48133. * Intensity of the direct lights e.g. the four lights available in your scene.
  48134. * This impacts both the direct diffuse and specular highlights.
  48135. */
  48136. protected _directIntensity: number;
  48137. /**
  48138. * Intensity of the emissive part of the material.
  48139. * This helps controlling the emissive effect without modifying the emissive color.
  48140. */
  48141. protected _emissiveIntensity: number;
  48142. /**
  48143. * Intensity of the environment e.g. how much the environment will light the object
  48144. * either through harmonics for rough material or through the refelction for shiny ones.
  48145. */
  48146. protected _environmentIntensity: number;
  48147. /**
  48148. * This is a special control allowing the reduction of the specular highlights coming from the
  48149. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48150. */
  48151. protected _specularIntensity: number;
  48152. /**
  48153. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48154. */
  48155. private _lightingInfos;
  48156. /**
  48157. * Debug Control allowing disabling the bump map on this material.
  48158. */
  48159. protected _disableBumpMap: boolean;
  48160. /**
  48161. * AKA Diffuse Texture in standard nomenclature.
  48162. */
  48163. protected _albedoTexture: Nullable<BaseTexture>;
  48164. /**
  48165. * AKA Occlusion Texture in other nomenclature.
  48166. */
  48167. protected _ambientTexture: Nullable<BaseTexture>;
  48168. /**
  48169. * AKA Occlusion Texture Intensity in other nomenclature.
  48170. */
  48171. protected _ambientTextureStrength: number;
  48172. /**
  48173. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48174. * 1 means it completely occludes it
  48175. * 0 mean it has no impact
  48176. */
  48177. protected _ambientTextureImpactOnAnalyticalLights: number;
  48178. /**
  48179. * Stores the alpha values in a texture.
  48180. */
  48181. protected _opacityTexture: Nullable<BaseTexture>;
  48182. /**
  48183. * Stores the reflection values in a texture.
  48184. */
  48185. protected _reflectionTexture: Nullable<BaseTexture>;
  48186. /**
  48187. * Stores the emissive values in a texture.
  48188. */
  48189. protected _emissiveTexture: Nullable<BaseTexture>;
  48190. /**
  48191. * AKA Specular texture in other nomenclature.
  48192. */
  48193. protected _reflectivityTexture: Nullable<BaseTexture>;
  48194. /**
  48195. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48196. */
  48197. protected _metallicTexture: Nullable<BaseTexture>;
  48198. /**
  48199. * Specifies the metallic scalar of the metallic/roughness workflow.
  48200. * Can also be used to scale the metalness values of the metallic texture.
  48201. */
  48202. protected _metallic: Nullable<number>;
  48203. /**
  48204. * Specifies the roughness scalar of the metallic/roughness workflow.
  48205. * Can also be used to scale the roughness values of the metallic texture.
  48206. */
  48207. protected _roughness: Nullable<number>;
  48208. /**
  48209. * Specifies the an F0 factor to help configuring the material F0.
  48210. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  48211. * to 0.5 the previously hard coded value stays the same.
  48212. * Can also be used to scale the F0 values of the metallic texture.
  48213. */
  48214. protected _metallicF0Factor: number;
  48215. /**
  48216. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  48217. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  48218. * your expectation as it multiplies with the texture data.
  48219. */
  48220. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  48221. /**
  48222. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48223. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48224. */
  48225. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48226. /**
  48227. * Stores surface normal data used to displace a mesh in a texture.
  48228. */
  48229. protected _bumpTexture: Nullable<BaseTexture>;
  48230. /**
  48231. * Stores the pre-calculated light information of a mesh in a texture.
  48232. */
  48233. protected _lightmapTexture: Nullable<BaseTexture>;
  48234. /**
  48235. * The color of a material in ambient lighting.
  48236. */
  48237. protected _ambientColor: Color3;
  48238. /**
  48239. * AKA Diffuse Color in other nomenclature.
  48240. */
  48241. protected _albedoColor: Color3;
  48242. /**
  48243. * AKA Specular Color in other nomenclature.
  48244. */
  48245. protected _reflectivityColor: Color3;
  48246. /**
  48247. * The color applied when light is reflected from a material.
  48248. */
  48249. protected _reflectionColor: Color3;
  48250. /**
  48251. * The color applied when light is emitted from a material.
  48252. */
  48253. protected _emissiveColor: Color3;
  48254. /**
  48255. * AKA Glossiness in other nomenclature.
  48256. */
  48257. protected _microSurface: number;
  48258. /**
  48259. * Specifies that the material will use the light map as a show map.
  48260. */
  48261. protected _useLightmapAsShadowmap: boolean;
  48262. /**
  48263. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48264. * makes the reflect vector face the model (under horizon).
  48265. */
  48266. protected _useHorizonOcclusion: boolean;
  48267. /**
  48268. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48269. * too much the area relying on ambient texture to define their ambient occlusion.
  48270. */
  48271. protected _useRadianceOcclusion: boolean;
  48272. /**
  48273. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48274. */
  48275. protected _useAlphaFromAlbedoTexture: boolean;
  48276. /**
  48277. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48278. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48279. */
  48280. protected _useSpecularOverAlpha: boolean;
  48281. /**
  48282. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48283. */
  48284. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48285. /**
  48286. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48287. */
  48288. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48289. /**
  48290. * Specifies if the metallic texture contains the roughness information in its green channel.
  48291. */
  48292. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48293. /**
  48294. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48295. */
  48296. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48297. /**
  48298. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48299. */
  48300. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48301. /**
  48302. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48303. */
  48304. protected _useAmbientInGrayScale: boolean;
  48305. /**
  48306. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48307. * The material will try to infer what glossiness each pixel should be.
  48308. */
  48309. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48310. /**
  48311. * Defines the falloff type used in this material.
  48312. * It by default is Physical.
  48313. */
  48314. protected _lightFalloff: number;
  48315. /**
  48316. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48317. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48318. */
  48319. protected _useRadianceOverAlpha: boolean;
  48320. /**
  48321. * Allows using an object space normal map (instead of tangent space).
  48322. */
  48323. protected _useObjectSpaceNormalMap: boolean;
  48324. /**
  48325. * Allows using the bump map in parallax mode.
  48326. */
  48327. protected _useParallax: boolean;
  48328. /**
  48329. * Allows using the bump map in parallax occlusion mode.
  48330. */
  48331. protected _useParallaxOcclusion: boolean;
  48332. /**
  48333. * Controls the scale bias of the parallax mode.
  48334. */
  48335. protected _parallaxScaleBias: number;
  48336. /**
  48337. * If sets to true, disables all the lights affecting the material.
  48338. */
  48339. protected _disableLighting: boolean;
  48340. /**
  48341. * Number of Simultaneous lights allowed on the material.
  48342. */
  48343. protected _maxSimultaneousLights: number;
  48344. /**
  48345. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48346. */
  48347. protected _invertNormalMapX: boolean;
  48348. /**
  48349. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48350. */
  48351. protected _invertNormalMapY: boolean;
  48352. /**
  48353. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48354. */
  48355. protected _twoSidedLighting: boolean;
  48356. /**
  48357. * Defines the alpha limits in alpha test mode.
  48358. */
  48359. protected _alphaCutOff: number;
  48360. /**
  48361. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48362. */
  48363. protected _forceAlphaTest: boolean;
  48364. /**
  48365. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48366. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48367. */
  48368. protected _useAlphaFresnel: boolean;
  48369. /**
  48370. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48371. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48372. */
  48373. protected _useLinearAlphaFresnel: boolean;
  48374. /**
  48375. * The transparency mode of the material.
  48376. */
  48377. protected _transparencyMode: Nullable<number>;
  48378. /**
  48379. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48380. * from cos thetav and roughness:
  48381. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48382. */
  48383. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48384. /**
  48385. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48386. */
  48387. protected _forceIrradianceInFragment: boolean;
  48388. /**
  48389. * Force normal to face away from face.
  48390. */
  48391. protected _forceNormalForward: boolean;
  48392. /**
  48393. * Enables specular anti aliasing in the PBR shader.
  48394. * It will both interacts on the Geometry for analytical and IBL lighting.
  48395. * It also prefilter the roughness map based on the bump values.
  48396. */
  48397. protected _enableSpecularAntiAliasing: boolean;
  48398. /**
  48399. * Default configuration related to image processing available in the PBR Material.
  48400. */
  48401. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48402. /**
  48403. * Keep track of the image processing observer to allow dispose and replace.
  48404. */
  48405. private _imageProcessingObserver;
  48406. /**
  48407. * Attaches a new image processing configuration to the PBR Material.
  48408. * @param configuration
  48409. */
  48410. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48411. /**
  48412. * Stores the available render targets.
  48413. */
  48414. private _renderTargets;
  48415. /**
  48416. * Sets the global ambient color for the material used in lighting calculations.
  48417. */
  48418. private _globalAmbientColor;
  48419. /**
  48420. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48421. */
  48422. private _useLogarithmicDepth;
  48423. /**
  48424. * If set to true, no lighting calculations will be applied.
  48425. */
  48426. private _unlit;
  48427. private _debugMode;
  48428. /**
  48429. * @hidden
  48430. * This is reserved for the inspector.
  48431. * Defines the material debug mode.
  48432. * It helps seeing only some components of the material while troubleshooting.
  48433. */
  48434. debugMode: number;
  48435. /**
  48436. * @hidden
  48437. * This is reserved for the inspector.
  48438. * Specify from where on screen the debug mode should start.
  48439. * The value goes from -1 (full screen) to 1 (not visible)
  48440. * It helps with side by side comparison against the final render
  48441. * This defaults to -1
  48442. */
  48443. private debugLimit;
  48444. /**
  48445. * @hidden
  48446. * This is reserved for the inspector.
  48447. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48448. * You can use the factor to better multiply the final value.
  48449. */
  48450. private debugFactor;
  48451. /**
  48452. * Defines the clear coat layer parameters for the material.
  48453. */
  48454. readonly clearCoat: PBRClearCoatConfiguration;
  48455. /**
  48456. * Defines the anisotropic parameters for the material.
  48457. */
  48458. readonly anisotropy: PBRAnisotropicConfiguration;
  48459. /**
  48460. * Defines the BRDF parameters for the material.
  48461. */
  48462. readonly brdf: PBRBRDFConfiguration;
  48463. /**
  48464. * Defines the Sheen parameters for the material.
  48465. */
  48466. readonly sheen: PBRSheenConfiguration;
  48467. /**
  48468. * Defines the SubSurface parameters for the material.
  48469. */
  48470. readonly subSurface: PBRSubSurfaceConfiguration;
  48471. /**
  48472. * Custom callback helping to override the default shader used in the material.
  48473. */
  48474. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48475. protected _rebuildInParallel: boolean;
  48476. /**
  48477. * Instantiates a new PBRMaterial instance.
  48478. *
  48479. * @param name The material name
  48480. * @param scene The scene the material will be use in.
  48481. */
  48482. constructor(name: string, scene: Scene);
  48483. /**
  48484. * Gets a boolean indicating that current material needs to register RTT
  48485. */
  48486. readonly hasRenderTargetTextures: boolean;
  48487. /**
  48488. * Gets the name of the material class.
  48489. */
  48490. getClassName(): string;
  48491. /**
  48492. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48493. */
  48494. /**
  48495. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48496. */
  48497. useLogarithmicDepth: boolean;
  48498. /**
  48499. * Gets the current transparency mode.
  48500. */
  48501. /**
  48502. * Sets the transparency mode of the material.
  48503. *
  48504. * | Value | Type | Description |
  48505. * | ----- | ----------------------------------- | ----------- |
  48506. * | 0 | OPAQUE | |
  48507. * | 1 | ALPHATEST | |
  48508. * | 2 | ALPHABLEND | |
  48509. * | 3 | ALPHATESTANDBLEND | |
  48510. *
  48511. */
  48512. transparencyMode: Nullable<number>;
  48513. /**
  48514. * Returns true if alpha blending should be disabled.
  48515. */
  48516. private readonly _disableAlphaBlending;
  48517. /**
  48518. * Specifies whether or not this material should be rendered in alpha blend mode.
  48519. */
  48520. needAlphaBlending(): boolean;
  48521. /**
  48522. * Specifies if the mesh will require alpha blending.
  48523. * @param mesh - BJS mesh.
  48524. */
  48525. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48526. /**
  48527. * Specifies whether or not this material should be rendered in alpha test mode.
  48528. */
  48529. needAlphaTesting(): boolean;
  48530. /**
  48531. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48532. */
  48533. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48534. /**
  48535. * Gets the texture used for the alpha test.
  48536. */
  48537. getAlphaTestTexture(): Nullable<BaseTexture>;
  48538. /**
  48539. * Specifies that the submesh is ready to be used.
  48540. * @param mesh - BJS mesh.
  48541. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48542. * @param useInstances - Specifies that instances should be used.
  48543. * @returns - boolean indicating that the submesh is ready or not.
  48544. */
  48545. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48546. /**
  48547. * Specifies if the material uses metallic roughness workflow.
  48548. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48549. */
  48550. isMetallicWorkflow(): boolean;
  48551. private _prepareEffect;
  48552. private _prepareDefines;
  48553. /**
  48554. * Force shader compilation
  48555. */
  48556. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  48557. /**
  48558. * Initializes the uniform buffer layout for the shader.
  48559. */
  48560. buildUniformLayout(): void;
  48561. /**
  48562. * Unbinds the material from the mesh
  48563. */
  48564. unbind(): void;
  48565. /**
  48566. * Binds the submesh data.
  48567. * @param world - The world matrix.
  48568. * @param mesh - The BJS mesh.
  48569. * @param subMesh - A submesh of the BJS mesh.
  48570. */
  48571. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48572. /**
  48573. * Returns the animatable textures.
  48574. * @returns - Array of animatable textures.
  48575. */
  48576. getAnimatables(): IAnimatable[];
  48577. /**
  48578. * Returns the texture used for reflections.
  48579. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48580. */
  48581. private _getReflectionTexture;
  48582. /**
  48583. * Returns an array of the actively used textures.
  48584. * @returns - Array of BaseTextures
  48585. */
  48586. getActiveTextures(): BaseTexture[];
  48587. /**
  48588. * Checks to see if a texture is used in the material.
  48589. * @param texture - Base texture to use.
  48590. * @returns - Boolean specifying if a texture is used in the material.
  48591. */
  48592. hasTexture(texture: BaseTexture): boolean;
  48593. /**
  48594. * Disposes the resources of the material.
  48595. * @param forceDisposeEffect - Forces the disposal of effects.
  48596. * @param forceDisposeTextures - Forces the disposal of all textures.
  48597. */
  48598. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48599. }
  48600. }
  48601. declare module BABYLON {
  48602. /**
  48603. * The Physically based material of BJS.
  48604. *
  48605. * This offers the main features of a standard PBR material.
  48606. * For more information, please refer to the documentation :
  48607. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48608. */
  48609. export class PBRMaterial extends PBRBaseMaterial {
  48610. /**
  48611. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48612. */
  48613. static readonly PBRMATERIAL_OPAQUE: number;
  48614. /**
  48615. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48616. */
  48617. static readonly PBRMATERIAL_ALPHATEST: number;
  48618. /**
  48619. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48620. */
  48621. static readonly PBRMATERIAL_ALPHABLEND: number;
  48622. /**
  48623. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48624. * They are also discarded below the alpha cutoff threshold to improve performances.
  48625. */
  48626. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48627. /**
  48628. * Defines the default value of how much AO map is occluding the analytical lights
  48629. * (point spot...).
  48630. */
  48631. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48632. /**
  48633. * Intensity of the direct lights e.g. the four lights available in your scene.
  48634. * This impacts both the direct diffuse and specular highlights.
  48635. */
  48636. directIntensity: number;
  48637. /**
  48638. * Intensity of the emissive part of the material.
  48639. * This helps controlling the emissive effect without modifying the emissive color.
  48640. */
  48641. emissiveIntensity: number;
  48642. /**
  48643. * Intensity of the environment e.g. how much the environment will light the object
  48644. * either through harmonics for rough material or through the refelction for shiny ones.
  48645. */
  48646. environmentIntensity: number;
  48647. /**
  48648. * This is a special control allowing the reduction of the specular highlights coming from the
  48649. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48650. */
  48651. specularIntensity: number;
  48652. /**
  48653. * Debug Control allowing disabling the bump map on this material.
  48654. */
  48655. disableBumpMap: boolean;
  48656. /**
  48657. * AKA Diffuse Texture in standard nomenclature.
  48658. */
  48659. albedoTexture: BaseTexture;
  48660. /**
  48661. * AKA Occlusion Texture in other nomenclature.
  48662. */
  48663. ambientTexture: BaseTexture;
  48664. /**
  48665. * AKA Occlusion Texture Intensity in other nomenclature.
  48666. */
  48667. ambientTextureStrength: number;
  48668. /**
  48669. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48670. * 1 means it completely occludes it
  48671. * 0 mean it has no impact
  48672. */
  48673. ambientTextureImpactOnAnalyticalLights: number;
  48674. /**
  48675. * Stores the alpha values in a texture.
  48676. */
  48677. opacityTexture: BaseTexture;
  48678. /**
  48679. * Stores the reflection values in a texture.
  48680. */
  48681. reflectionTexture: Nullable<BaseTexture>;
  48682. /**
  48683. * Stores the emissive values in a texture.
  48684. */
  48685. emissiveTexture: BaseTexture;
  48686. /**
  48687. * AKA Specular texture in other nomenclature.
  48688. */
  48689. reflectivityTexture: BaseTexture;
  48690. /**
  48691. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48692. */
  48693. metallicTexture: BaseTexture;
  48694. /**
  48695. * Specifies the metallic scalar of the metallic/roughness workflow.
  48696. * Can also be used to scale the metalness values of the metallic texture.
  48697. */
  48698. metallic: Nullable<number>;
  48699. /**
  48700. * Specifies the roughness scalar of the metallic/roughness workflow.
  48701. * Can also be used to scale the roughness values of the metallic texture.
  48702. */
  48703. roughness: Nullable<number>;
  48704. /**
  48705. * Specifies the an F0 factor to help configuring the material F0.
  48706. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  48707. * to 0.5 the previously hard coded value stays the same.
  48708. * Can also be used to scale the F0 values of the metallic texture.
  48709. */
  48710. metallicF0Factor: number;
  48711. /**
  48712. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  48713. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  48714. * your expectation as it multiplies with the texture data.
  48715. */
  48716. useMetallicF0FactorFromMetallicTexture: boolean;
  48717. /**
  48718. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48719. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48720. */
  48721. microSurfaceTexture: BaseTexture;
  48722. /**
  48723. * Stores surface normal data used to displace a mesh in a texture.
  48724. */
  48725. bumpTexture: BaseTexture;
  48726. /**
  48727. * Stores the pre-calculated light information of a mesh in a texture.
  48728. */
  48729. lightmapTexture: BaseTexture;
  48730. /**
  48731. * Stores the refracted light information in a texture.
  48732. */
  48733. refractionTexture: Nullable<BaseTexture>;
  48734. /**
  48735. * The color of a material in ambient lighting.
  48736. */
  48737. ambientColor: Color3;
  48738. /**
  48739. * AKA Diffuse Color in other nomenclature.
  48740. */
  48741. albedoColor: Color3;
  48742. /**
  48743. * AKA Specular Color in other nomenclature.
  48744. */
  48745. reflectivityColor: Color3;
  48746. /**
  48747. * The color reflected from the material.
  48748. */
  48749. reflectionColor: Color3;
  48750. /**
  48751. * The color emitted from the material.
  48752. */
  48753. emissiveColor: Color3;
  48754. /**
  48755. * AKA Glossiness in other nomenclature.
  48756. */
  48757. microSurface: number;
  48758. /**
  48759. * source material index of refraction (IOR)' / 'destination material IOR.
  48760. */
  48761. indexOfRefraction: number;
  48762. /**
  48763. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48764. */
  48765. invertRefractionY: boolean;
  48766. /**
  48767. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48768. * Materials half opaque for instance using refraction could benefit from this control.
  48769. */
  48770. linkRefractionWithTransparency: boolean;
  48771. /**
  48772. * If true, the light map contains occlusion information instead of lighting info.
  48773. */
  48774. useLightmapAsShadowmap: boolean;
  48775. /**
  48776. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48777. */
  48778. useAlphaFromAlbedoTexture: boolean;
  48779. /**
  48780. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48781. */
  48782. forceAlphaTest: boolean;
  48783. /**
  48784. * Defines the alpha limits in alpha test mode.
  48785. */
  48786. alphaCutOff: number;
  48787. /**
  48788. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48789. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48790. */
  48791. useSpecularOverAlpha: boolean;
  48792. /**
  48793. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48794. */
  48795. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48796. /**
  48797. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48798. */
  48799. useRoughnessFromMetallicTextureAlpha: boolean;
  48800. /**
  48801. * Specifies if the metallic texture contains the roughness information in its green channel.
  48802. */
  48803. useRoughnessFromMetallicTextureGreen: boolean;
  48804. /**
  48805. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48806. */
  48807. useMetallnessFromMetallicTextureBlue: boolean;
  48808. /**
  48809. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48810. */
  48811. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48812. /**
  48813. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48814. */
  48815. useAmbientInGrayScale: boolean;
  48816. /**
  48817. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48818. * The material will try to infer what glossiness each pixel should be.
  48819. */
  48820. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48821. /**
  48822. * BJS is using an harcoded light falloff based on a manually sets up range.
  48823. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48824. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48825. */
  48826. /**
  48827. * BJS is using an harcoded light falloff based on a manually sets up range.
  48828. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48829. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48830. */
  48831. usePhysicalLightFalloff: boolean;
  48832. /**
  48833. * In order to support the falloff compatibility with gltf, a special mode has been added
  48834. * to reproduce the gltf light falloff.
  48835. */
  48836. /**
  48837. * In order to support the falloff compatibility with gltf, a special mode has been added
  48838. * to reproduce the gltf light falloff.
  48839. */
  48840. useGLTFLightFalloff: boolean;
  48841. /**
  48842. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48843. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48844. */
  48845. useRadianceOverAlpha: boolean;
  48846. /**
  48847. * Allows using an object space normal map (instead of tangent space).
  48848. */
  48849. useObjectSpaceNormalMap: boolean;
  48850. /**
  48851. * Allows using the bump map in parallax mode.
  48852. */
  48853. useParallax: boolean;
  48854. /**
  48855. * Allows using the bump map in parallax occlusion mode.
  48856. */
  48857. useParallaxOcclusion: boolean;
  48858. /**
  48859. * Controls the scale bias of the parallax mode.
  48860. */
  48861. parallaxScaleBias: number;
  48862. /**
  48863. * If sets to true, disables all the lights affecting the material.
  48864. */
  48865. disableLighting: boolean;
  48866. /**
  48867. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48868. */
  48869. forceIrradianceInFragment: boolean;
  48870. /**
  48871. * Number of Simultaneous lights allowed on the material.
  48872. */
  48873. maxSimultaneousLights: number;
  48874. /**
  48875. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48876. */
  48877. invertNormalMapX: boolean;
  48878. /**
  48879. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48880. */
  48881. invertNormalMapY: boolean;
  48882. /**
  48883. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48884. */
  48885. twoSidedLighting: boolean;
  48886. /**
  48887. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48888. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48889. */
  48890. useAlphaFresnel: boolean;
  48891. /**
  48892. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48893. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48894. */
  48895. useLinearAlphaFresnel: boolean;
  48896. /**
  48897. * Let user defines the brdf lookup texture used for IBL.
  48898. * A default 8bit version is embedded but you could point at :
  48899. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48900. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48901. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48902. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48903. */
  48904. environmentBRDFTexture: Nullable<BaseTexture>;
  48905. /**
  48906. * Force normal to face away from face.
  48907. */
  48908. forceNormalForward: boolean;
  48909. /**
  48910. * Enables specular anti aliasing in the PBR shader.
  48911. * It will both interacts on the Geometry for analytical and IBL lighting.
  48912. * It also prefilter the roughness map based on the bump values.
  48913. */
  48914. enableSpecularAntiAliasing: boolean;
  48915. /**
  48916. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48917. * makes the reflect vector face the model (under horizon).
  48918. */
  48919. useHorizonOcclusion: boolean;
  48920. /**
  48921. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48922. * too much the area relying on ambient texture to define their ambient occlusion.
  48923. */
  48924. useRadianceOcclusion: boolean;
  48925. /**
  48926. * If set to true, no lighting calculations will be applied.
  48927. */
  48928. unlit: boolean;
  48929. /**
  48930. * Gets the image processing configuration used either in this material.
  48931. */
  48932. /**
  48933. * Sets the Default image processing configuration used either in the this material.
  48934. *
  48935. * If sets to null, the scene one is in use.
  48936. */
  48937. imageProcessingConfiguration: ImageProcessingConfiguration;
  48938. /**
  48939. * Gets wether the color curves effect is enabled.
  48940. */
  48941. /**
  48942. * Sets wether the color curves effect is enabled.
  48943. */
  48944. cameraColorCurvesEnabled: boolean;
  48945. /**
  48946. * Gets wether the color grading effect is enabled.
  48947. */
  48948. /**
  48949. * Gets wether the color grading effect is enabled.
  48950. */
  48951. cameraColorGradingEnabled: boolean;
  48952. /**
  48953. * Gets wether tonemapping is enabled or not.
  48954. */
  48955. /**
  48956. * Sets wether tonemapping is enabled or not
  48957. */
  48958. cameraToneMappingEnabled: boolean;
  48959. /**
  48960. * The camera exposure used on this material.
  48961. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48962. * This corresponds to a photographic exposure.
  48963. */
  48964. /**
  48965. * The camera exposure used on this material.
  48966. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48967. * This corresponds to a photographic exposure.
  48968. */
  48969. cameraExposure: number;
  48970. /**
  48971. * Gets The camera contrast used on this material.
  48972. */
  48973. /**
  48974. * Sets The camera contrast used on this material.
  48975. */
  48976. cameraContrast: number;
  48977. /**
  48978. * Gets the Color Grading 2D Lookup Texture.
  48979. */
  48980. /**
  48981. * Sets the Color Grading 2D Lookup Texture.
  48982. */
  48983. cameraColorGradingTexture: Nullable<BaseTexture>;
  48984. /**
  48985. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48986. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48987. * 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;
  48988. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48989. */
  48990. /**
  48991. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48992. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48993. * 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;
  48994. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48995. */
  48996. cameraColorCurves: Nullable<ColorCurves>;
  48997. /**
  48998. * Instantiates a new PBRMaterial instance.
  48999. *
  49000. * @param name The material name
  49001. * @param scene The scene the material will be use in.
  49002. */
  49003. constructor(name: string, scene: Scene);
  49004. /**
  49005. * Returns the name of this material class.
  49006. */
  49007. getClassName(): string;
  49008. /**
  49009. * Makes a duplicate of the current material.
  49010. * @param name - name to use for the new material.
  49011. */
  49012. clone(name: string): PBRMaterial;
  49013. /**
  49014. * Serializes this PBR Material.
  49015. * @returns - An object with the serialized material.
  49016. */
  49017. serialize(): any;
  49018. /**
  49019. * Parses a PBR Material from a serialized object.
  49020. * @param source - Serialized object.
  49021. * @param scene - BJS scene instance.
  49022. * @param rootUrl - url for the scene object
  49023. * @returns - PBRMaterial
  49024. */
  49025. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49026. }
  49027. }
  49028. declare module BABYLON {
  49029. /**
  49030. * Direct draw surface info
  49031. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49032. */
  49033. export interface DDSInfo {
  49034. /**
  49035. * Width of the texture
  49036. */
  49037. width: number;
  49038. /**
  49039. * Width of the texture
  49040. */
  49041. height: number;
  49042. /**
  49043. * Number of Mipmaps for the texture
  49044. * @see https://en.wikipedia.org/wiki/Mipmap
  49045. */
  49046. mipmapCount: number;
  49047. /**
  49048. * If the textures format is a known fourCC format
  49049. * @see https://www.fourcc.org/
  49050. */
  49051. isFourCC: boolean;
  49052. /**
  49053. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49054. */
  49055. isRGB: boolean;
  49056. /**
  49057. * If the texture is a lumincance format
  49058. */
  49059. isLuminance: boolean;
  49060. /**
  49061. * If this is a cube texture
  49062. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49063. */
  49064. isCube: boolean;
  49065. /**
  49066. * If the texture is a compressed format eg. FOURCC_DXT1
  49067. */
  49068. isCompressed: boolean;
  49069. /**
  49070. * The dxgiFormat of the texture
  49071. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49072. */
  49073. dxgiFormat: number;
  49074. /**
  49075. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49076. */
  49077. textureType: number;
  49078. /**
  49079. * Sphericle polynomial created for the dds texture
  49080. */
  49081. sphericalPolynomial?: SphericalPolynomial;
  49082. }
  49083. /**
  49084. * Class used to provide DDS decompression tools
  49085. */
  49086. export class DDSTools {
  49087. /**
  49088. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49089. */
  49090. static StoreLODInAlphaChannel: boolean;
  49091. /**
  49092. * Gets DDS information from an array buffer
  49093. * @param arrayBuffer defines the array buffer to read data from
  49094. * @returns the DDS information
  49095. */
  49096. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49097. private static _FloatView;
  49098. private static _Int32View;
  49099. private static _ToHalfFloat;
  49100. private static _FromHalfFloat;
  49101. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49102. private static _GetHalfFloatRGBAArrayBuffer;
  49103. private static _GetFloatRGBAArrayBuffer;
  49104. private static _GetFloatAsUIntRGBAArrayBuffer;
  49105. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49106. private static _GetRGBAArrayBuffer;
  49107. private static _ExtractLongWordOrder;
  49108. private static _GetRGBArrayBuffer;
  49109. private static _GetLuminanceArrayBuffer;
  49110. /**
  49111. * Uploads DDS Levels to a Babylon Texture
  49112. * @hidden
  49113. */
  49114. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49115. }
  49116. interface ThinEngine {
  49117. /**
  49118. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49119. * @param rootUrl defines the url where the file to load is located
  49120. * @param scene defines the current scene
  49121. * @param lodScale defines scale to apply to the mip map selection
  49122. * @param lodOffset defines offset to apply to the mip map selection
  49123. * @param onLoad defines an optional callback raised when the texture is loaded
  49124. * @param onError defines an optional callback raised if there is an issue to load the texture
  49125. * @param format defines the format of the data
  49126. * @param forcedExtension defines the extension to use to pick the right loader
  49127. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49128. * @returns the cube texture as an InternalTexture
  49129. */
  49130. 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;
  49131. }
  49132. }
  49133. declare module BABYLON {
  49134. /**
  49135. * Implementation of the DDS Texture Loader.
  49136. * @hidden
  49137. */
  49138. export class _DDSTextureLoader implements IInternalTextureLoader {
  49139. /**
  49140. * Defines wether the loader supports cascade loading the different faces.
  49141. */
  49142. readonly supportCascades: boolean;
  49143. /**
  49144. * This returns if the loader support the current file information.
  49145. * @param extension defines the file extension of the file being loaded
  49146. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49147. * @param fallback defines the fallback internal texture if any
  49148. * @param isBase64 defines whether the texture is encoded as a base64
  49149. * @param isBuffer defines whether the texture data are stored as a buffer
  49150. * @returns true if the loader can load the specified file
  49151. */
  49152. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49153. /**
  49154. * Transform the url before loading if required.
  49155. * @param rootUrl the url of the texture
  49156. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49157. * @returns the transformed texture
  49158. */
  49159. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49160. /**
  49161. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49162. * @param rootUrl the url of the texture
  49163. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49164. * @returns the fallback texture
  49165. */
  49166. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49167. /**
  49168. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49169. * @param data contains the texture data
  49170. * @param texture defines the BabylonJS internal texture
  49171. * @param createPolynomials will be true if polynomials have been requested
  49172. * @param onLoad defines the callback to trigger once the texture is ready
  49173. * @param onError defines the callback to trigger in case of error
  49174. */
  49175. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49176. /**
  49177. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49178. * @param data contains the texture data
  49179. * @param texture defines the BabylonJS internal texture
  49180. * @param callback defines the method to call once ready to upload
  49181. */
  49182. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49183. }
  49184. }
  49185. declare module BABYLON {
  49186. /**
  49187. * Implementation of the ENV Texture Loader.
  49188. * @hidden
  49189. */
  49190. export class _ENVTextureLoader implements IInternalTextureLoader {
  49191. /**
  49192. * Defines wether the loader supports cascade loading the different faces.
  49193. */
  49194. readonly supportCascades: boolean;
  49195. /**
  49196. * This returns if the loader support the current file information.
  49197. * @param extension defines the file extension of the file being loaded
  49198. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49199. * @param fallback defines the fallback internal texture if any
  49200. * @param isBase64 defines whether the texture is encoded as a base64
  49201. * @param isBuffer defines whether the texture data are stored as a buffer
  49202. * @returns true if the loader can load the specified file
  49203. */
  49204. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49205. /**
  49206. * Transform the url before loading if required.
  49207. * @param rootUrl the url of the texture
  49208. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49209. * @returns the transformed texture
  49210. */
  49211. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49212. /**
  49213. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49214. * @param rootUrl the url of the texture
  49215. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49216. * @returns the fallback texture
  49217. */
  49218. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49219. /**
  49220. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49221. * @param data contains the texture data
  49222. * @param texture defines the BabylonJS internal texture
  49223. * @param createPolynomials will be true if polynomials have been requested
  49224. * @param onLoad defines the callback to trigger once the texture is ready
  49225. * @param onError defines the callback to trigger in case of error
  49226. */
  49227. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49228. /**
  49229. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49230. * @param data contains the texture data
  49231. * @param texture defines the BabylonJS internal texture
  49232. * @param callback defines the method to call once ready to upload
  49233. */
  49234. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49235. }
  49236. }
  49237. declare module BABYLON {
  49238. /**
  49239. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49240. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49241. */
  49242. export class KhronosTextureContainer {
  49243. /** contents of the KTX container file */
  49244. arrayBuffer: any;
  49245. private static HEADER_LEN;
  49246. private static COMPRESSED_2D;
  49247. private static COMPRESSED_3D;
  49248. private static TEX_2D;
  49249. private static TEX_3D;
  49250. /**
  49251. * Gets the openGL type
  49252. */
  49253. glType: number;
  49254. /**
  49255. * Gets the openGL type size
  49256. */
  49257. glTypeSize: number;
  49258. /**
  49259. * Gets the openGL format
  49260. */
  49261. glFormat: number;
  49262. /**
  49263. * Gets the openGL internal format
  49264. */
  49265. glInternalFormat: number;
  49266. /**
  49267. * Gets the base internal format
  49268. */
  49269. glBaseInternalFormat: number;
  49270. /**
  49271. * Gets image width in pixel
  49272. */
  49273. pixelWidth: number;
  49274. /**
  49275. * Gets image height in pixel
  49276. */
  49277. pixelHeight: number;
  49278. /**
  49279. * Gets image depth in pixels
  49280. */
  49281. pixelDepth: number;
  49282. /**
  49283. * Gets the number of array elements
  49284. */
  49285. numberOfArrayElements: number;
  49286. /**
  49287. * Gets the number of faces
  49288. */
  49289. numberOfFaces: number;
  49290. /**
  49291. * Gets the number of mipmap levels
  49292. */
  49293. numberOfMipmapLevels: number;
  49294. /**
  49295. * Gets the bytes of key value data
  49296. */
  49297. bytesOfKeyValueData: number;
  49298. /**
  49299. * Gets the load type
  49300. */
  49301. loadType: number;
  49302. /**
  49303. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49304. */
  49305. isInvalid: boolean;
  49306. /**
  49307. * Creates a new KhronosTextureContainer
  49308. * @param arrayBuffer contents of the KTX container file
  49309. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49310. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49311. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49312. */
  49313. constructor(
  49314. /** contents of the KTX container file */
  49315. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49316. /**
  49317. * Uploads KTX content to a Babylon Texture.
  49318. * It is assumed that the texture has already been created & is currently bound
  49319. * @hidden
  49320. */
  49321. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49322. private _upload2DCompressedLevels;
  49323. }
  49324. }
  49325. declare module BABYLON {
  49326. /**
  49327. * Implementation of the KTX Texture Loader.
  49328. * @hidden
  49329. */
  49330. export class _KTXTextureLoader implements IInternalTextureLoader {
  49331. /**
  49332. * Defines wether the loader supports cascade loading the different faces.
  49333. */
  49334. readonly supportCascades: boolean;
  49335. /**
  49336. * This returns if the loader support the current file information.
  49337. * @param extension defines the file extension of the file being loaded
  49338. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49339. * @param fallback defines the fallback internal texture if any
  49340. * @param isBase64 defines whether the texture is encoded as a base64
  49341. * @param isBuffer defines whether the texture data are stored as a buffer
  49342. * @returns true if the loader can load the specified file
  49343. */
  49344. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49345. /**
  49346. * Transform the url before loading if required.
  49347. * @param rootUrl the url of the texture
  49348. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49349. * @returns the transformed texture
  49350. */
  49351. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49352. /**
  49353. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49354. * @param rootUrl the url of the texture
  49355. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49356. * @returns the fallback texture
  49357. */
  49358. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49359. /**
  49360. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49361. * @param data contains the texture data
  49362. * @param texture defines the BabylonJS internal texture
  49363. * @param createPolynomials will be true if polynomials have been requested
  49364. * @param onLoad defines the callback to trigger once the texture is ready
  49365. * @param onError defines the callback to trigger in case of error
  49366. */
  49367. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49368. /**
  49369. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49370. * @param data contains the texture data
  49371. * @param texture defines the BabylonJS internal texture
  49372. * @param callback defines the method to call once ready to upload
  49373. */
  49374. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49375. }
  49376. }
  49377. declare module BABYLON {
  49378. /**
  49379. * Options for the default xr helper
  49380. */
  49381. export class WebXRDefaultExperienceOptions {
  49382. /**
  49383. * Floor meshes that should be used for teleporting
  49384. */
  49385. floorMeshes: Array<AbstractMesh>;
  49386. /**
  49387. * Enable or disable default UI to enter XR
  49388. */
  49389. disableDefaultUI: boolean;
  49390. }
  49391. /**
  49392. * Default experience which provides a similar setup to the previous webVRExperience
  49393. */
  49394. export class WebXRDefaultExperience {
  49395. /**
  49396. * Base experience
  49397. */
  49398. baseExperience: WebXRExperienceHelper;
  49399. /**
  49400. * Input experience extension
  49401. */
  49402. input: WebXRInput;
  49403. /**
  49404. * Loads the controller models
  49405. */
  49406. controllerModelLoader: WebXRControllerModelLoader;
  49407. /**
  49408. * Enables laser pointer and selection
  49409. */
  49410. pointerSelection: WebXRControllerPointerSelection;
  49411. /**
  49412. * Enables teleportation
  49413. */
  49414. teleportation: WebXRControllerTeleportation;
  49415. /**
  49416. * Enables ui for enetering/exiting xr
  49417. */
  49418. enterExitUI: WebXREnterExitUI;
  49419. /**
  49420. * Default target xr should render to
  49421. */
  49422. renderTarget: WebXRRenderTarget;
  49423. /**
  49424. * Creates the default xr experience
  49425. * @param scene scene
  49426. * @param options options for basic configuration
  49427. * @returns resulting WebXRDefaultExperience
  49428. */
  49429. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49430. private constructor();
  49431. /**
  49432. * DIsposes of the experience helper
  49433. */
  49434. dispose(): void;
  49435. }
  49436. }
  49437. declare module BABYLON {
  49438. /** @hidden */
  49439. export var _forceSceneHelpersToBundle: boolean;
  49440. interface Scene {
  49441. /**
  49442. * Creates a default light for the scene.
  49443. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49444. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49445. */
  49446. createDefaultLight(replace?: boolean): void;
  49447. /**
  49448. * Creates a default camera for the scene.
  49449. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49450. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49451. * @param replace has default false, when true replaces the active camera in the scene
  49452. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49453. */
  49454. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49455. /**
  49456. * Creates a default camera and a default light.
  49457. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49458. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49459. * @param replace has the default false, when true replaces the active camera/light in the scene
  49460. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49461. */
  49462. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49463. /**
  49464. * Creates a new sky box
  49465. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49466. * @param environmentTexture defines the texture to use as environment texture
  49467. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49468. * @param scale defines the overall scale of the skybox
  49469. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49470. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49471. * @returns a new mesh holding the sky box
  49472. */
  49473. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49474. /**
  49475. * Creates a new environment
  49476. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49477. * @param options defines the options you can use to configure the environment
  49478. * @returns the new EnvironmentHelper
  49479. */
  49480. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49481. /**
  49482. * Creates a new VREXperienceHelper
  49483. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49484. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49485. * @returns a new VREXperienceHelper
  49486. */
  49487. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49488. /**
  49489. * Creates a new WebXRDefaultExperience
  49490. * @see http://doc.babylonjs.com/how_to/webxr
  49491. * @param options experience options
  49492. * @returns a promise for a new WebXRDefaultExperience
  49493. */
  49494. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49495. }
  49496. }
  49497. declare module BABYLON {
  49498. /**
  49499. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49500. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49501. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49502. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49503. */
  49504. export class VideoDome extends TransformNode {
  49505. /**
  49506. * Define the video source as a Monoscopic panoramic 360 video.
  49507. */
  49508. static readonly MODE_MONOSCOPIC: number;
  49509. /**
  49510. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49511. */
  49512. static readonly MODE_TOPBOTTOM: number;
  49513. /**
  49514. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49515. */
  49516. static readonly MODE_SIDEBYSIDE: number;
  49517. private _halfDome;
  49518. private _useDirectMapping;
  49519. /**
  49520. * The video texture being displayed on the sphere
  49521. */
  49522. protected _videoTexture: VideoTexture;
  49523. /**
  49524. * Gets the video texture being displayed on the sphere
  49525. */
  49526. readonly videoTexture: VideoTexture;
  49527. /**
  49528. * The skybox material
  49529. */
  49530. protected _material: BackgroundMaterial;
  49531. /**
  49532. * The surface used for the skybox
  49533. */
  49534. protected _mesh: Mesh;
  49535. /**
  49536. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  49537. */
  49538. private _halfDomeMask;
  49539. /**
  49540. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49541. * Also see the options.resolution property.
  49542. */
  49543. fovMultiplier: number;
  49544. private _videoMode;
  49545. /**
  49546. * Gets or set the current video mode for the video. It can be:
  49547. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49548. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49549. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49550. */
  49551. videoMode: number;
  49552. /**
  49553. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  49554. *
  49555. */
  49556. /**
  49557. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  49558. */
  49559. halfDome: boolean;
  49560. /**
  49561. * Oberserver used in Stereoscopic VR Mode.
  49562. */
  49563. private _onBeforeCameraRenderObserver;
  49564. /**
  49565. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49566. * @param name Element's name, child elements will append suffixes for their own names.
  49567. * @param urlsOrVideo defines the url(s) or the video element to use
  49568. * @param options An object containing optional or exposed sub element properties
  49569. */
  49570. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49571. resolution?: number;
  49572. clickToPlay?: boolean;
  49573. autoPlay?: boolean;
  49574. loop?: boolean;
  49575. size?: number;
  49576. poster?: string;
  49577. faceForward?: boolean;
  49578. useDirectMapping?: boolean;
  49579. halfDomeMode?: boolean;
  49580. }, scene: Scene);
  49581. private _changeVideoMode;
  49582. /**
  49583. * Releases resources associated with this node.
  49584. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49585. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49586. */
  49587. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49588. }
  49589. }
  49590. declare module BABYLON {
  49591. /**
  49592. * This class can be used to get instrumentation data from a Babylon engine
  49593. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49594. */
  49595. export class EngineInstrumentation implements IDisposable {
  49596. /**
  49597. * Define the instrumented engine.
  49598. */
  49599. engine: Engine;
  49600. private _captureGPUFrameTime;
  49601. private _gpuFrameTimeToken;
  49602. private _gpuFrameTime;
  49603. private _captureShaderCompilationTime;
  49604. private _shaderCompilationTime;
  49605. private _onBeginFrameObserver;
  49606. private _onEndFrameObserver;
  49607. private _onBeforeShaderCompilationObserver;
  49608. private _onAfterShaderCompilationObserver;
  49609. /**
  49610. * Gets the perf counter used for GPU frame time
  49611. */
  49612. readonly gpuFrameTimeCounter: PerfCounter;
  49613. /**
  49614. * Gets the GPU frame time capture status
  49615. */
  49616. /**
  49617. * Enable or disable the GPU frame time capture
  49618. */
  49619. captureGPUFrameTime: boolean;
  49620. /**
  49621. * Gets the perf counter used for shader compilation time
  49622. */
  49623. readonly shaderCompilationTimeCounter: PerfCounter;
  49624. /**
  49625. * Gets the shader compilation time capture status
  49626. */
  49627. /**
  49628. * Enable or disable the shader compilation time capture
  49629. */
  49630. captureShaderCompilationTime: boolean;
  49631. /**
  49632. * Instantiates a new engine instrumentation.
  49633. * This class can be used to get instrumentation data from a Babylon engine
  49634. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49635. * @param engine Defines the engine to instrument
  49636. */
  49637. constructor(
  49638. /**
  49639. * Define the instrumented engine.
  49640. */
  49641. engine: Engine);
  49642. /**
  49643. * Dispose and release associated resources.
  49644. */
  49645. dispose(): void;
  49646. }
  49647. }
  49648. declare module BABYLON {
  49649. /**
  49650. * This class can be used to get instrumentation data from a Babylon engine
  49651. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49652. */
  49653. export class SceneInstrumentation implements IDisposable {
  49654. /**
  49655. * Defines the scene to instrument
  49656. */
  49657. scene: Scene;
  49658. private _captureActiveMeshesEvaluationTime;
  49659. private _activeMeshesEvaluationTime;
  49660. private _captureRenderTargetsRenderTime;
  49661. private _renderTargetsRenderTime;
  49662. private _captureFrameTime;
  49663. private _frameTime;
  49664. private _captureRenderTime;
  49665. private _renderTime;
  49666. private _captureInterFrameTime;
  49667. private _interFrameTime;
  49668. private _captureParticlesRenderTime;
  49669. private _particlesRenderTime;
  49670. private _captureSpritesRenderTime;
  49671. private _spritesRenderTime;
  49672. private _capturePhysicsTime;
  49673. private _physicsTime;
  49674. private _captureAnimationsTime;
  49675. private _animationsTime;
  49676. private _captureCameraRenderTime;
  49677. private _cameraRenderTime;
  49678. private _onBeforeActiveMeshesEvaluationObserver;
  49679. private _onAfterActiveMeshesEvaluationObserver;
  49680. private _onBeforeRenderTargetsRenderObserver;
  49681. private _onAfterRenderTargetsRenderObserver;
  49682. private _onAfterRenderObserver;
  49683. private _onBeforeDrawPhaseObserver;
  49684. private _onAfterDrawPhaseObserver;
  49685. private _onBeforeAnimationsObserver;
  49686. private _onBeforeParticlesRenderingObserver;
  49687. private _onAfterParticlesRenderingObserver;
  49688. private _onBeforeSpritesRenderingObserver;
  49689. private _onAfterSpritesRenderingObserver;
  49690. private _onBeforePhysicsObserver;
  49691. private _onAfterPhysicsObserver;
  49692. private _onAfterAnimationsObserver;
  49693. private _onBeforeCameraRenderObserver;
  49694. private _onAfterCameraRenderObserver;
  49695. /**
  49696. * Gets the perf counter used for active meshes evaluation time
  49697. */
  49698. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49699. /**
  49700. * Gets the active meshes evaluation time capture status
  49701. */
  49702. /**
  49703. * Enable or disable the active meshes evaluation time capture
  49704. */
  49705. captureActiveMeshesEvaluationTime: boolean;
  49706. /**
  49707. * Gets the perf counter used for render targets render time
  49708. */
  49709. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49710. /**
  49711. * Gets the render targets render time capture status
  49712. */
  49713. /**
  49714. * Enable or disable the render targets render time capture
  49715. */
  49716. captureRenderTargetsRenderTime: boolean;
  49717. /**
  49718. * Gets the perf counter used for particles render time
  49719. */
  49720. readonly particlesRenderTimeCounter: PerfCounter;
  49721. /**
  49722. * Gets the particles render time capture status
  49723. */
  49724. /**
  49725. * Enable or disable the particles render time capture
  49726. */
  49727. captureParticlesRenderTime: boolean;
  49728. /**
  49729. * Gets the perf counter used for sprites render time
  49730. */
  49731. readonly spritesRenderTimeCounter: PerfCounter;
  49732. /**
  49733. * Gets the sprites render time capture status
  49734. */
  49735. /**
  49736. * Enable or disable the sprites render time capture
  49737. */
  49738. captureSpritesRenderTime: boolean;
  49739. /**
  49740. * Gets the perf counter used for physics time
  49741. */
  49742. readonly physicsTimeCounter: PerfCounter;
  49743. /**
  49744. * Gets the physics time capture status
  49745. */
  49746. /**
  49747. * Enable or disable the physics time capture
  49748. */
  49749. capturePhysicsTime: boolean;
  49750. /**
  49751. * Gets the perf counter used for animations time
  49752. */
  49753. readonly animationsTimeCounter: PerfCounter;
  49754. /**
  49755. * Gets the animations time capture status
  49756. */
  49757. /**
  49758. * Enable or disable the animations time capture
  49759. */
  49760. captureAnimationsTime: boolean;
  49761. /**
  49762. * Gets the perf counter used for frame time capture
  49763. */
  49764. readonly frameTimeCounter: PerfCounter;
  49765. /**
  49766. * Gets the frame time capture status
  49767. */
  49768. /**
  49769. * Enable or disable the frame time capture
  49770. */
  49771. captureFrameTime: boolean;
  49772. /**
  49773. * Gets the perf counter used for inter-frames time capture
  49774. */
  49775. readonly interFrameTimeCounter: PerfCounter;
  49776. /**
  49777. * Gets the inter-frames time capture status
  49778. */
  49779. /**
  49780. * Enable or disable the inter-frames time capture
  49781. */
  49782. captureInterFrameTime: boolean;
  49783. /**
  49784. * Gets the perf counter used for render time capture
  49785. */
  49786. readonly renderTimeCounter: PerfCounter;
  49787. /**
  49788. * Gets the render time capture status
  49789. */
  49790. /**
  49791. * Enable or disable the render time capture
  49792. */
  49793. captureRenderTime: boolean;
  49794. /**
  49795. * Gets the perf counter used for camera render time capture
  49796. */
  49797. readonly cameraRenderTimeCounter: PerfCounter;
  49798. /**
  49799. * Gets the camera render time capture status
  49800. */
  49801. /**
  49802. * Enable or disable the camera render time capture
  49803. */
  49804. captureCameraRenderTime: boolean;
  49805. /**
  49806. * Gets the perf counter used for draw calls
  49807. */
  49808. readonly drawCallsCounter: PerfCounter;
  49809. /**
  49810. * Instantiates a new scene instrumentation.
  49811. * This class can be used to get instrumentation data from a Babylon engine
  49812. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49813. * @param scene Defines the scene to instrument
  49814. */
  49815. constructor(
  49816. /**
  49817. * Defines the scene to instrument
  49818. */
  49819. scene: Scene);
  49820. /**
  49821. * Dispose and release associated resources.
  49822. */
  49823. dispose(): void;
  49824. }
  49825. }
  49826. declare module BABYLON {
  49827. /** @hidden */
  49828. export var glowMapGenerationPixelShader: {
  49829. name: string;
  49830. shader: string;
  49831. };
  49832. }
  49833. declare module BABYLON {
  49834. /** @hidden */
  49835. export var glowMapGenerationVertexShader: {
  49836. name: string;
  49837. shader: string;
  49838. };
  49839. }
  49840. declare module BABYLON {
  49841. /**
  49842. * Effect layer options. This helps customizing the behaviour
  49843. * of the effect layer.
  49844. */
  49845. export interface IEffectLayerOptions {
  49846. /**
  49847. * Multiplication factor apply to the canvas size to compute the render target size
  49848. * used to generated the objects (the smaller the faster).
  49849. */
  49850. mainTextureRatio: number;
  49851. /**
  49852. * Enforces a fixed size texture to ensure effect stability across devices.
  49853. */
  49854. mainTextureFixedSize?: number;
  49855. /**
  49856. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49857. */
  49858. alphaBlendingMode: number;
  49859. /**
  49860. * The camera attached to the layer.
  49861. */
  49862. camera: Nullable<Camera>;
  49863. /**
  49864. * The rendering group to draw the layer in.
  49865. */
  49866. renderingGroupId: number;
  49867. }
  49868. /**
  49869. * The effect layer Helps adding post process effect blended with the main pass.
  49870. *
  49871. * This can be for instance use to generate glow or higlight effects on the scene.
  49872. *
  49873. * The effect layer class can not be used directly and is intented to inherited from to be
  49874. * customized per effects.
  49875. */
  49876. export abstract class EffectLayer {
  49877. private _vertexBuffers;
  49878. private _indexBuffer;
  49879. private _cachedDefines;
  49880. private _effectLayerMapGenerationEffect;
  49881. private _effectLayerOptions;
  49882. private _mergeEffect;
  49883. protected _scene: Scene;
  49884. protected _engine: Engine;
  49885. protected _maxSize: number;
  49886. protected _mainTextureDesiredSize: ISize;
  49887. protected _mainTexture: RenderTargetTexture;
  49888. protected _shouldRender: boolean;
  49889. protected _postProcesses: PostProcess[];
  49890. protected _textures: BaseTexture[];
  49891. protected _emissiveTextureAndColor: {
  49892. texture: Nullable<BaseTexture>;
  49893. color: Color4;
  49894. };
  49895. /**
  49896. * The name of the layer
  49897. */
  49898. name: string;
  49899. /**
  49900. * The clear color of the texture used to generate the glow map.
  49901. */
  49902. neutralColor: Color4;
  49903. /**
  49904. * Specifies wether the highlight layer is enabled or not.
  49905. */
  49906. isEnabled: boolean;
  49907. /**
  49908. * Gets the camera attached to the layer.
  49909. */
  49910. readonly camera: Nullable<Camera>;
  49911. /**
  49912. * Gets the rendering group id the layer should render in.
  49913. */
  49914. renderingGroupId: number;
  49915. /**
  49916. * An event triggered when the effect layer has been disposed.
  49917. */
  49918. onDisposeObservable: Observable<EffectLayer>;
  49919. /**
  49920. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49921. */
  49922. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49923. /**
  49924. * An event triggered when the generated texture is being merged in the scene.
  49925. */
  49926. onBeforeComposeObservable: Observable<EffectLayer>;
  49927. /**
  49928. * An event triggered when the mesh is rendered into the effect render target.
  49929. */
  49930. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  49931. /**
  49932. * An event triggered after the mesh has been rendered into the effect render target.
  49933. */
  49934. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  49935. /**
  49936. * An event triggered when the generated texture has been merged in the scene.
  49937. */
  49938. onAfterComposeObservable: Observable<EffectLayer>;
  49939. /**
  49940. * An event triggered when the efffect layer changes its size.
  49941. */
  49942. onSizeChangedObservable: Observable<EffectLayer>;
  49943. /** @hidden */
  49944. static _SceneComponentInitialization: (scene: Scene) => void;
  49945. /**
  49946. * Instantiates a new effect Layer and references it in the scene.
  49947. * @param name The name of the layer
  49948. * @param scene The scene to use the layer in
  49949. */
  49950. constructor(
  49951. /** The Friendly of the effect in the scene */
  49952. name: string, scene: Scene);
  49953. /**
  49954. * Get the effect name of the layer.
  49955. * @return The effect name
  49956. */
  49957. abstract getEffectName(): string;
  49958. /**
  49959. * Checks for the readiness of the element composing the layer.
  49960. * @param subMesh the mesh to check for
  49961. * @param useInstances specify wether or not to use instances to render the mesh
  49962. * @return true if ready otherwise, false
  49963. */
  49964. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49965. /**
  49966. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49967. * @returns true if the effect requires stencil during the main canvas render pass.
  49968. */
  49969. abstract needStencil(): boolean;
  49970. /**
  49971. * Create the merge effect. This is the shader use to blit the information back
  49972. * to the main canvas at the end of the scene rendering.
  49973. * @returns The effect containing the shader used to merge the effect on the main canvas
  49974. */
  49975. protected abstract _createMergeEffect(): Effect;
  49976. /**
  49977. * Creates the render target textures and post processes used in the effect layer.
  49978. */
  49979. protected abstract _createTextureAndPostProcesses(): void;
  49980. /**
  49981. * Implementation specific of rendering the generating effect on the main canvas.
  49982. * @param effect The effect used to render through
  49983. */
  49984. protected abstract _internalRender(effect: Effect): void;
  49985. /**
  49986. * Sets the required values for both the emissive texture and and the main color.
  49987. */
  49988. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49989. /**
  49990. * Free any resources and references associated to a mesh.
  49991. * Internal use
  49992. * @param mesh The mesh to free.
  49993. */
  49994. abstract _disposeMesh(mesh: Mesh): void;
  49995. /**
  49996. * Serializes this layer (Glow or Highlight for example)
  49997. * @returns a serialized layer object
  49998. */
  49999. abstract serialize?(): any;
  50000. /**
  50001. * Initializes the effect layer with the required options.
  50002. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50003. */
  50004. protected _init(options: Partial<IEffectLayerOptions>): void;
  50005. /**
  50006. * Generates the index buffer of the full screen quad blending to the main canvas.
  50007. */
  50008. private _generateIndexBuffer;
  50009. /**
  50010. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50011. */
  50012. private _generateVertexBuffer;
  50013. /**
  50014. * Sets the main texture desired size which is the closest power of two
  50015. * of the engine canvas size.
  50016. */
  50017. private _setMainTextureSize;
  50018. /**
  50019. * Creates the main texture for the effect layer.
  50020. */
  50021. protected _createMainTexture(): void;
  50022. /**
  50023. * Adds specific effects defines.
  50024. * @param defines The defines to add specifics to.
  50025. */
  50026. protected _addCustomEffectDefines(defines: string[]): void;
  50027. /**
  50028. * Checks for the readiness of the element composing the layer.
  50029. * @param subMesh the mesh to check for
  50030. * @param useInstances specify wether or not to use instances to render the mesh
  50031. * @param emissiveTexture the associated emissive texture used to generate the glow
  50032. * @return true if ready otherwise, false
  50033. */
  50034. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50035. /**
  50036. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50037. */
  50038. render(): void;
  50039. /**
  50040. * Determine if a given mesh will be used in the current effect.
  50041. * @param mesh mesh to test
  50042. * @returns true if the mesh will be used
  50043. */
  50044. hasMesh(mesh: AbstractMesh): boolean;
  50045. /**
  50046. * Returns true if the layer contains information to display, otherwise false.
  50047. * @returns true if the glow layer should be rendered
  50048. */
  50049. shouldRender(): boolean;
  50050. /**
  50051. * Returns true if the mesh should render, otherwise false.
  50052. * @param mesh The mesh to render
  50053. * @returns true if it should render otherwise false
  50054. */
  50055. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50056. /**
  50057. * Returns true if the mesh can be rendered, otherwise false.
  50058. * @param mesh The mesh to render
  50059. * @param material The material used on the mesh
  50060. * @returns true if it can be rendered otherwise false
  50061. */
  50062. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50063. /**
  50064. * Returns true if the mesh should render, otherwise false.
  50065. * @param mesh The mesh to render
  50066. * @returns true if it should render otherwise false
  50067. */
  50068. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50069. /**
  50070. * Renders the submesh passed in parameter to the generation map.
  50071. */
  50072. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50073. /**
  50074. * Defines wether the current material of the mesh should be use to render the effect.
  50075. * @param mesh defines the current mesh to render
  50076. */
  50077. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  50078. /**
  50079. * Rebuild the required buffers.
  50080. * @hidden Internal use only.
  50081. */
  50082. _rebuild(): void;
  50083. /**
  50084. * Dispose only the render target textures and post process.
  50085. */
  50086. private _disposeTextureAndPostProcesses;
  50087. /**
  50088. * Dispose the highlight layer and free resources.
  50089. */
  50090. dispose(): void;
  50091. /**
  50092. * Gets the class name of the effect layer
  50093. * @returns the string with the class name of the effect layer
  50094. */
  50095. getClassName(): string;
  50096. /**
  50097. * Creates an effect layer from parsed effect layer data
  50098. * @param parsedEffectLayer defines effect layer data
  50099. * @param scene defines the current scene
  50100. * @param rootUrl defines the root URL containing the effect layer information
  50101. * @returns a parsed effect Layer
  50102. */
  50103. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50104. }
  50105. }
  50106. declare module BABYLON {
  50107. interface AbstractScene {
  50108. /**
  50109. * The list of effect layers (highlights/glow) added to the scene
  50110. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50111. * @see http://doc.babylonjs.com/how_to/glow_layer
  50112. */
  50113. effectLayers: Array<EffectLayer>;
  50114. /**
  50115. * Removes the given effect layer from this scene.
  50116. * @param toRemove defines the effect layer to remove
  50117. * @returns the index of the removed effect layer
  50118. */
  50119. removeEffectLayer(toRemove: EffectLayer): number;
  50120. /**
  50121. * Adds the given effect layer to this scene
  50122. * @param newEffectLayer defines the effect layer to add
  50123. */
  50124. addEffectLayer(newEffectLayer: EffectLayer): void;
  50125. }
  50126. /**
  50127. * Defines the layer scene component responsible to manage any effect layers
  50128. * in a given scene.
  50129. */
  50130. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50131. /**
  50132. * The component name helpfull to identify the component in the list of scene components.
  50133. */
  50134. readonly name: string;
  50135. /**
  50136. * The scene the component belongs to.
  50137. */
  50138. scene: Scene;
  50139. private _engine;
  50140. private _renderEffects;
  50141. private _needStencil;
  50142. private _previousStencilState;
  50143. /**
  50144. * Creates a new instance of the component for the given scene
  50145. * @param scene Defines the scene to register the component in
  50146. */
  50147. constructor(scene: Scene);
  50148. /**
  50149. * Registers the component in a given scene
  50150. */
  50151. register(): void;
  50152. /**
  50153. * Rebuilds the elements related to this component in case of
  50154. * context lost for instance.
  50155. */
  50156. rebuild(): void;
  50157. /**
  50158. * Serializes the component data to the specified json object
  50159. * @param serializationObject The object to serialize to
  50160. */
  50161. serialize(serializationObject: any): void;
  50162. /**
  50163. * Adds all the elements from the container to the scene
  50164. * @param container the container holding the elements
  50165. */
  50166. addFromContainer(container: AbstractScene): void;
  50167. /**
  50168. * Removes all the elements in the container from the scene
  50169. * @param container contains the elements to remove
  50170. * @param dispose if the removed element should be disposed (default: false)
  50171. */
  50172. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50173. /**
  50174. * Disposes the component and the associated ressources.
  50175. */
  50176. dispose(): void;
  50177. private _isReadyForMesh;
  50178. private _renderMainTexture;
  50179. private _setStencil;
  50180. private _setStencilBack;
  50181. private _draw;
  50182. private _drawCamera;
  50183. private _drawRenderingGroup;
  50184. }
  50185. }
  50186. declare module BABYLON {
  50187. /** @hidden */
  50188. export var glowMapMergePixelShader: {
  50189. name: string;
  50190. shader: string;
  50191. };
  50192. }
  50193. declare module BABYLON {
  50194. /** @hidden */
  50195. export var glowMapMergeVertexShader: {
  50196. name: string;
  50197. shader: string;
  50198. };
  50199. }
  50200. declare module BABYLON {
  50201. interface AbstractScene {
  50202. /**
  50203. * Return a the first highlight layer of the scene with a given name.
  50204. * @param name The name of the highlight layer to look for.
  50205. * @return The highlight layer if found otherwise null.
  50206. */
  50207. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50208. }
  50209. /**
  50210. * Glow layer options. This helps customizing the behaviour
  50211. * of the glow layer.
  50212. */
  50213. export interface IGlowLayerOptions {
  50214. /**
  50215. * Multiplication factor apply to the canvas size to compute the render target size
  50216. * used to generated the glowing objects (the smaller the faster).
  50217. */
  50218. mainTextureRatio: number;
  50219. /**
  50220. * Enforces a fixed size texture to ensure resize independant blur.
  50221. */
  50222. mainTextureFixedSize?: number;
  50223. /**
  50224. * How big is the kernel of the blur texture.
  50225. */
  50226. blurKernelSize: number;
  50227. /**
  50228. * The camera attached to the layer.
  50229. */
  50230. camera: Nullable<Camera>;
  50231. /**
  50232. * Enable MSAA by chosing the number of samples.
  50233. */
  50234. mainTextureSamples?: number;
  50235. /**
  50236. * The rendering group to draw the layer in.
  50237. */
  50238. renderingGroupId: number;
  50239. }
  50240. /**
  50241. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50242. *
  50243. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  50244. *
  50245. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50246. */
  50247. export class GlowLayer extends EffectLayer {
  50248. /**
  50249. * Effect Name of the layer.
  50250. */
  50251. static readonly EffectName: string;
  50252. /**
  50253. * The default blur kernel size used for the glow.
  50254. */
  50255. static DefaultBlurKernelSize: number;
  50256. /**
  50257. * The default texture size ratio used for the glow.
  50258. */
  50259. static DefaultTextureRatio: number;
  50260. /**
  50261. * Sets the kernel size of the blur.
  50262. */
  50263. /**
  50264. * Gets the kernel size of the blur.
  50265. */
  50266. blurKernelSize: number;
  50267. /**
  50268. * Sets the glow intensity.
  50269. */
  50270. /**
  50271. * Gets the glow intensity.
  50272. */
  50273. intensity: number;
  50274. private _options;
  50275. private _intensity;
  50276. private _horizontalBlurPostprocess1;
  50277. private _verticalBlurPostprocess1;
  50278. private _horizontalBlurPostprocess2;
  50279. private _verticalBlurPostprocess2;
  50280. private _blurTexture1;
  50281. private _blurTexture2;
  50282. private _postProcesses1;
  50283. private _postProcesses2;
  50284. private _includedOnlyMeshes;
  50285. private _excludedMeshes;
  50286. private _meshesUsingTheirOwnMaterials;
  50287. /**
  50288. * Callback used to let the user override the color selection on a per mesh basis
  50289. */
  50290. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50291. /**
  50292. * Callback used to let the user override the texture selection on a per mesh basis
  50293. */
  50294. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50295. /**
  50296. * Instantiates a new glow Layer and references it to the scene.
  50297. * @param name The name of the layer
  50298. * @param scene The scene to use the layer in
  50299. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50300. */
  50301. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50302. /**
  50303. * Get the effect name of the layer.
  50304. * @return The effect name
  50305. */
  50306. getEffectName(): string;
  50307. /**
  50308. * Create the merge effect. This is the shader use to blit the information back
  50309. * to the main canvas at the end of the scene rendering.
  50310. */
  50311. protected _createMergeEffect(): Effect;
  50312. /**
  50313. * Creates the render target textures and post processes used in the glow layer.
  50314. */
  50315. protected _createTextureAndPostProcesses(): void;
  50316. /**
  50317. * Checks for the readiness of the element composing the layer.
  50318. * @param subMesh the mesh to check for
  50319. * @param useInstances specify wether or not to use instances to render the mesh
  50320. * @param emissiveTexture the associated emissive texture used to generate the glow
  50321. * @return true if ready otherwise, false
  50322. */
  50323. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50324. /**
  50325. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50326. */
  50327. needStencil(): boolean;
  50328. /**
  50329. * Returns true if the mesh can be rendered, otherwise false.
  50330. * @param mesh The mesh to render
  50331. * @param material The material used on the mesh
  50332. * @returns true if it can be rendered otherwise false
  50333. */
  50334. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50335. /**
  50336. * Implementation specific of rendering the generating effect on the main canvas.
  50337. * @param effect The effect used to render through
  50338. */
  50339. protected _internalRender(effect: Effect): void;
  50340. /**
  50341. * Sets the required values for both the emissive texture and and the main color.
  50342. */
  50343. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50344. /**
  50345. * Returns true if the mesh should render, otherwise false.
  50346. * @param mesh The mesh to render
  50347. * @returns true if it should render otherwise false
  50348. */
  50349. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50350. /**
  50351. * Adds specific effects defines.
  50352. * @param defines The defines to add specifics to.
  50353. */
  50354. protected _addCustomEffectDefines(defines: string[]): void;
  50355. /**
  50356. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50357. * @param mesh The mesh to exclude from the glow layer
  50358. */
  50359. addExcludedMesh(mesh: Mesh): void;
  50360. /**
  50361. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50362. * @param mesh The mesh to remove
  50363. */
  50364. removeExcludedMesh(mesh: Mesh): void;
  50365. /**
  50366. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50367. * @param mesh The mesh to include in the glow layer
  50368. */
  50369. addIncludedOnlyMesh(mesh: Mesh): void;
  50370. /**
  50371. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50372. * @param mesh The mesh to remove
  50373. */
  50374. removeIncludedOnlyMesh(mesh: Mesh): void;
  50375. /**
  50376. * Determine if a given mesh will be used in the glow layer
  50377. * @param mesh The mesh to test
  50378. * @returns true if the mesh will be highlighted by the current glow layer
  50379. */
  50380. hasMesh(mesh: AbstractMesh): boolean;
  50381. /**
  50382. * Defines wether the current material of the mesh should be use to render the effect.
  50383. * @param mesh defines the current mesh to render
  50384. */
  50385. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  50386. /**
  50387. * Add a mesh to be rendered through its own material and not with emissive only.
  50388. * @param mesh The mesh for which we need to use its material
  50389. */
  50390. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  50391. /**
  50392. * Remove a mesh from being rendered through its own material and not with emissive only.
  50393. * @param mesh The mesh for which we need to not use its material
  50394. */
  50395. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  50396. /**
  50397. * Free any resources and references associated to a mesh.
  50398. * Internal use
  50399. * @param mesh The mesh to free.
  50400. * @hidden
  50401. */
  50402. _disposeMesh(mesh: Mesh): void;
  50403. /**
  50404. * Gets the class name of the effect layer
  50405. * @returns the string with the class name of the effect layer
  50406. */
  50407. getClassName(): string;
  50408. /**
  50409. * Serializes this glow layer
  50410. * @returns a serialized glow layer object
  50411. */
  50412. serialize(): any;
  50413. /**
  50414. * Creates a Glow Layer from parsed glow layer data
  50415. * @param parsedGlowLayer defines glow layer data
  50416. * @param scene defines the current scene
  50417. * @param rootUrl defines the root URL containing the glow layer information
  50418. * @returns a parsed Glow Layer
  50419. */
  50420. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50421. }
  50422. }
  50423. declare module BABYLON {
  50424. /** @hidden */
  50425. export var glowBlurPostProcessPixelShader: {
  50426. name: string;
  50427. shader: string;
  50428. };
  50429. }
  50430. declare module BABYLON {
  50431. interface AbstractScene {
  50432. /**
  50433. * Return a the first highlight layer of the scene with a given name.
  50434. * @param name The name of the highlight layer to look for.
  50435. * @return The highlight layer if found otherwise null.
  50436. */
  50437. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50438. }
  50439. /**
  50440. * Highlight layer options. This helps customizing the behaviour
  50441. * of the highlight layer.
  50442. */
  50443. export interface IHighlightLayerOptions {
  50444. /**
  50445. * Multiplication factor apply to the canvas size to compute the render target size
  50446. * used to generated the glowing objects (the smaller the faster).
  50447. */
  50448. mainTextureRatio: number;
  50449. /**
  50450. * Enforces a fixed size texture to ensure resize independant blur.
  50451. */
  50452. mainTextureFixedSize?: number;
  50453. /**
  50454. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50455. * of the picture to blur (the smaller the faster).
  50456. */
  50457. blurTextureSizeRatio: number;
  50458. /**
  50459. * How big in texel of the blur texture is the vertical blur.
  50460. */
  50461. blurVerticalSize: number;
  50462. /**
  50463. * How big in texel of the blur texture is the horizontal blur.
  50464. */
  50465. blurHorizontalSize: number;
  50466. /**
  50467. * Alpha blending mode used to apply the blur. Default is combine.
  50468. */
  50469. alphaBlendingMode: number;
  50470. /**
  50471. * The camera attached to the layer.
  50472. */
  50473. camera: Nullable<Camera>;
  50474. /**
  50475. * Should we display highlight as a solid stroke?
  50476. */
  50477. isStroke?: boolean;
  50478. /**
  50479. * The rendering group to draw the layer in.
  50480. */
  50481. renderingGroupId: number;
  50482. }
  50483. /**
  50484. * The highlight layer Helps adding a glow effect around a mesh.
  50485. *
  50486. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  50487. * glowy meshes to your scene.
  50488. *
  50489. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50490. */
  50491. export class HighlightLayer extends EffectLayer {
  50492. name: string;
  50493. /**
  50494. * Effect Name of the highlight layer.
  50495. */
  50496. static readonly EffectName: string;
  50497. /**
  50498. * The neutral color used during the preparation of the glow effect.
  50499. * This is black by default as the blend operation is a blend operation.
  50500. */
  50501. static NeutralColor: Color4;
  50502. /**
  50503. * Stencil value used for glowing meshes.
  50504. */
  50505. static GlowingMeshStencilReference: number;
  50506. /**
  50507. * Stencil value used for the other meshes in the scene.
  50508. */
  50509. static NormalMeshStencilReference: number;
  50510. /**
  50511. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50512. */
  50513. innerGlow: boolean;
  50514. /**
  50515. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50516. */
  50517. outerGlow: boolean;
  50518. /**
  50519. * Specifies the horizontal size of the blur.
  50520. */
  50521. /**
  50522. * Gets the horizontal size of the blur.
  50523. */
  50524. blurHorizontalSize: number;
  50525. /**
  50526. * Specifies the vertical size of the blur.
  50527. */
  50528. /**
  50529. * Gets the vertical size of the blur.
  50530. */
  50531. blurVerticalSize: number;
  50532. /**
  50533. * An event triggered when the highlight layer is being blurred.
  50534. */
  50535. onBeforeBlurObservable: Observable<HighlightLayer>;
  50536. /**
  50537. * An event triggered when the highlight layer has been blurred.
  50538. */
  50539. onAfterBlurObservable: Observable<HighlightLayer>;
  50540. private _instanceGlowingMeshStencilReference;
  50541. private _options;
  50542. private _downSamplePostprocess;
  50543. private _horizontalBlurPostprocess;
  50544. private _verticalBlurPostprocess;
  50545. private _blurTexture;
  50546. private _meshes;
  50547. private _excludedMeshes;
  50548. /**
  50549. * Instantiates a new highlight Layer and references it to the scene..
  50550. * @param name The name of the layer
  50551. * @param scene The scene to use the layer in
  50552. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50553. */
  50554. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50555. /**
  50556. * Get the effect name of the layer.
  50557. * @return The effect name
  50558. */
  50559. getEffectName(): string;
  50560. /**
  50561. * Create the merge effect. This is the shader use to blit the information back
  50562. * to the main canvas at the end of the scene rendering.
  50563. */
  50564. protected _createMergeEffect(): Effect;
  50565. /**
  50566. * Creates the render target textures and post processes used in the highlight layer.
  50567. */
  50568. protected _createTextureAndPostProcesses(): void;
  50569. /**
  50570. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50571. */
  50572. needStencil(): boolean;
  50573. /**
  50574. * Checks for the readiness of the element composing the layer.
  50575. * @param subMesh the mesh to check for
  50576. * @param useInstances specify wether or not to use instances to render the mesh
  50577. * @param emissiveTexture the associated emissive texture used to generate the glow
  50578. * @return true if ready otherwise, false
  50579. */
  50580. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50581. /**
  50582. * Implementation specific of rendering the generating effect on the main canvas.
  50583. * @param effect The effect used to render through
  50584. */
  50585. protected _internalRender(effect: Effect): void;
  50586. /**
  50587. * Returns true if the layer contains information to display, otherwise false.
  50588. */
  50589. shouldRender(): boolean;
  50590. /**
  50591. * Returns true if the mesh should render, otherwise false.
  50592. * @param mesh The mesh to render
  50593. * @returns true if it should render otherwise false
  50594. */
  50595. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50596. /**
  50597. * Sets the required values for both the emissive texture and and the main color.
  50598. */
  50599. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50600. /**
  50601. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50602. * @param mesh The mesh to exclude from the highlight layer
  50603. */
  50604. addExcludedMesh(mesh: Mesh): void;
  50605. /**
  50606. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50607. * @param mesh The mesh to highlight
  50608. */
  50609. removeExcludedMesh(mesh: Mesh): void;
  50610. /**
  50611. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50612. * @param mesh mesh to test
  50613. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50614. */
  50615. hasMesh(mesh: AbstractMesh): boolean;
  50616. /**
  50617. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50618. * @param mesh The mesh to highlight
  50619. * @param color The color of the highlight
  50620. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50621. */
  50622. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50623. /**
  50624. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50625. * @param mesh The mesh to highlight
  50626. */
  50627. removeMesh(mesh: Mesh): void;
  50628. /**
  50629. * Force the stencil to the normal expected value for none glowing parts
  50630. */
  50631. private _defaultStencilReference;
  50632. /**
  50633. * Free any resources and references associated to a mesh.
  50634. * Internal use
  50635. * @param mesh The mesh to free.
  50636. * @hidden
  50637. */
  50638. _disposeMesh(mesh: Mesh): void;
  50639. /**
  50640. * Dispose the highlight layer and free resources.
  50641. */
  50642. dispose(): void;
  50643. /**
  50644. * Gets the class name of the effect layer
  50645. * @returns the string with the class name of the effect layer
  50646. */
  50647. getClassName(): string;
  50648. /**
  50649. * Serializes this Highlight layer
  50650. * @returns a serialized Highlight layer object
  50651. */
  50652. serialize(): any;
  50653. /**
  50654. * Creates a Highlight layer from parsed Highlight layer data
  50655. * @param parsedHightlightLayer defines the Highlight layer data
  50656. * @param scene defines the current scene
  50657. * @param rootUrl defines the root URL containing the Highlight layer information
  50658. * @returns a parsed Highlight layer
  50659. */
  50660. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50661. }
  50662. }
  50663. declare module BABYLON {
  50664. interface AbstractScene {
  50665. /**
  50666. * The list of layers (background and foreground) of the scene
  50667. */
  50668. layers: Array<Layer>;
  50669. }
  50670. /**
  50671. * Defines the layer scene component responsible to manage any layers
  50672. * in a given scene.
  50673. */
  50674. export class LayerSceneComponent implements ISceneComponent {
  50675. /**
  50676. * The component name helpfull to identify the component in the list of scene components.
  50677. */
  50678. readonly name: string;
  50679. /**
  50680. * The scene the component belongs to.
  50681. */
  50682. scene: Scene;
  50683. private _engine;
  50684. /**
  50685. * Creates a new instance of the component for the given scene
  50686. * @param scene Defines the scene to register the component in
  50687. */
  50688. constructor(scene: Scene);
  50689. /**
  50690. * Registers the component in a given scene
  50691. */
  50692. register(): void;
  50693. /**
  50694. * Rebuilds the elements related to this component in case of
  50695. * context lost for instance.
  50696. */
  50697. rebuild(): void;
  50698. /**
  50699. * Disposes the component and the associated ressources.
  50700. */
  50701. dispose(): void;
  50702. private _draw;
  50703. private _drawCameraPredicate;
  50704. private _drawCameraBackground;
  50705. private _drawCameraForeground;
  50706. private _drawRenderTargetPredicate;
  50707. private _drawRenderTargetBackground;
  50708. private _drawRenderTargetForeground;
  50709. /**
  50710. * Adds all the elements from the container to the scene
  50711. * @param container the container holding the elements
  50712. */
  50713. addFromContainer(container: AbstractScene): void;
  50714. /**
  50715. * Removes all the elements in the container from the scene
  50716. * @param container contains the elements to remove
  50717. * @param dispose if the removed element should be disposed (default: false)
  50718. */
  50719. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50720. }
  50721. }
  50722. declare module BABYLON {
  50723. /** @hidden */
  50724. export var layerPixelShader: {
  50725. name: string;
  50726. shader: string;
  50727. };
  50728. }
  50729. declare module BABYLON {
  50730. /** @hidden */
  50731. export var layerVertexShader: {
  50732. name: string;
  50733. shader: string;
  50734. };
  50735. }
  50736. declare module BABYLON {
  50737. /**
  50738. * This represents a full screen 2d layer.
  50739. * This can be useful to display a picture in the background of your scene for instance.
  50740. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50741. */
  50742. export class Layer {
  50743. /**
  50744. * Define the name of the layer.
  50745. */
  50746. name: string;
  50747. /**
  50748. * Define the texture the layer should display.
  50749. */
  50750. texture: Nullable<Texture>;
  50751. /**
  50752. * Is the layer in background or foreground.
  50753. */
  50754. isBackground: boolean;
  50755. /**
  50756. * Define the color of the layer (instead of texture).
  50757. */
  50758. color: Color4;
  50759. /**
  50760. * Define the scale of the layer in order to zoom in out of the texture.
  50761. */
  50762. scale: Vector2;
  50763. /**
  50764. * Define an offset for the layer in order to shift the texture.
  50765. */
  50766. offset: Vector2;
  50767. /**
  50768. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50769. */
  50770. alphaBlendingMode: number;
  50771. /**
  50772. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50773. * Alpha test will not mix with the background color in case of transparency.
  50774. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50775. */
  50776. alphaTest: boolean;
  50777. /**
  50778. * Define a mask to restrict the layer to only some of the scene cameras.
  50779. */
  50780. layerMask: number;
  50781. /**
  50782. * Define the list of render target the layer is visible into.
  50783. */
  50784. renderTargetTextures: RenderTargetTexture[];
  50785. /**
  50786. * Define if the layer is only used in renderTarget or if it also
  50787. * renders in the main frame buffer of the canvas.
  50788. */
  50789. renderOnlyInRenderTargetTextures: boolean;
  50790. private _scene;
  50791. private _vertexBuffers;
  50792. private _indexBuffer;
  50793. private _effect;
  50794. private _alphaTestEffect;
  50795. /**
  50796. * An event triggered when the layer is disposed.
  50797. */
  50798. onDisposeObservable: Observable<Layer>;
  50799. private _onDisposeObserver;
  50800. /**
  50801. * Back compatibility with callback before the onDisposeObservable existed.
  50802. * The set callback will be triggered when the layer has been disposed.
  50803. */
  50804. onDispose: () => void;
  50805. /**
  50806. * An event triggered before rendering the scene
  50807. */
  50808. onBeforeRenderObservable: Observable<Layer>;
  50809. private _onBeforeRenderObserver;
  50810. /**
  50811. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50812. * The set callback will be triggered just before rendering the layer.
  50813. */
  50814. onBeforeRender: () => void;
  50815. /**
  50816. * An event triggered after rendering the scene
  50817. */
  50818. onAfterRenderObservable: Observable<Layer>;
  50819. private _onAfterRenderObserver;
  50820. /**
  50821. * Back compatibility with callback before the onAfterRenderObservable existed.
  50822. * The set callback will be triggered just after rendering the layer.
  50823. */
  50824. onAfterRender: () => void;
  50825. /**
  50826. * Instantiates a new layer.
  50827. * This represents a full screen 2d layer.
  50828. * This can be useful to display a picture in the background of your scene for instance.
  50829. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50830. * @param name Define the name of the layer in the scene
  50831. * @param imgUrl Define the url of the texture to display in the layer
  50832. * @param scene Define the scene the layer belongs to
  50833. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50834. * @param color Defines a color for the layer
  50835. */
  50836. constructor(
  50837. /**
  50838. * Define the name of the layer.
  50839. */
  50840. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50841. private _createIndexBuffer;
  50842. /** @hidden */
  50843. _rebuild(): void;
  50844. /**
  50845. * Renders the layer in the scene.
  50846. */
  50847. render(): void;
  50848. /**
  50849. * Disposes and releases the associated ressources.
  50850. */
  50851. dispose(): void;
  50852. }
  50853. }
  50854. declare module BABYLON {
  50855. /** @hidden */
  50856. export var lensFlarePixelShader: {
  50857. name: string;
  50858. shader: string;
  50859. };
  50860. }
  50861. declare module BABYLON {
  50862. /** @hidden */
  50863. export var lensFlareVertexShader: {
  50864. name: string;
  50865. shader: string;
  50866. };
  50867. }
  50868. declare module BABYLON {
  50869. /**
  50870. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50871. * It is usually composed of several `lensFlare`.
  50872. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50873. */
  50874. export class LensFlareSystem {
  50875. /**
  50876. * Define the name of the lens flare system
  50877. */
  50878. name: string;
  50879. /**
  50880. * List of lens flares used in this system.
  50881. */
  50882. lensFlares: LensFlare[];
  50883. /**
  50884. * Define a limit from the border the lens flare can be visible.
  50885. */
  50886. borderLimit: number;
  50887. /**
  50888. * Define a viewport border we do not want to see the lens flare in.
  50889. */
  50890. viewportBorder: number;
  50891. /**
  50892. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50893. */
  50894. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50895. /**
  50896. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50897. */
  50898. layerMask: number;
  50899. /**
  50900. * Define the id of the lens flare system in the scene.
  50901. * (equal to name by default)
  50902. */
  50903. id: string;
  50904. private _scene;
  50905. private _emitter;
  50906. private _vertexBuffers;
  50907. private _indexBuffer;
  50908. private _effect;
  50909. private _positionX;
  50910. private _positionY;
  50911. private _isEnabled;
  50912. /** @hidden */
  50913. static _SceneComponentInitialization: (scene: Scene) => void;
  50914. /**
  50915. * Instantiates a lens flare system.
  50916. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50917. * It is usually composed of several `lensFlare`.
  50918. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50919. * @param name Define the name of the lens flare system in the scene
  50920. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50921. * @param scene Define the scene the lens flare system belongs to
  50922. */
  50923. constructor(
  50924. /**
  50925. * Define the name of the lens flare system
  50926. */
  50927. name: string, emitter: any, scene: Scene);
  50928. /**
  50929. * Define if the lens flare system is enabled.
  50930. */
  50931. isEnabled: boolean;
  50932. /**
  50933. * Get the scene the effects belongs to.
  50934. * @returns the scene holding the lens flare system
  50935. */
  50936. getScene(): Scene;
  50937. /**
  50938. * Get the emitter of the lens flare system.
  50939. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50940. * @returns the emitter of the lens flare system
  50941. */
  50942. getEmitter(): any;
  50943. /**
  50944. * Set the emitter of the lens flare system.
  50945. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50946. * @param newEmitter Define the new emitter of the system
  50947. */
  50948. setEmitter(newEmitter: any): void;
  50949. /**
  50950. * Get the lens flare system emitter position.
  50951. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50952. * @returns the position
  50953. */
  50954. getEmitterPosition(): Vector3;
  50955. /**
  50956. * @hidden
  50957. */
  50958. computeEffectivePosition(globalViewport: Viewport): boolean;
  50959. /** @hidden */
  50960. _isVisible(): boolean;
  50961. /**
  50962. * @hidden
  50963. */
  50964. render(): boolean;
  50965. /**
  50966. * Dispose and release the lens flare with its associated resources.
  50967. */
  50968. dispose(): void;
  50969. /**
  50970. * Parse a lens flare system from a JSON repressentation
  50971. * @param parsedLensFlareSystem Define the JSON to parse
  50972. * @param scene Define the scene the parsed system should be instantiated in
  50973. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50974. * @returns the parsed system
  50975. */
  50976. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50977. /**
  50978. * Serialize the current Lens Flare System into a JSON representation.
  50979. * @returns the serialized JSON
  50980. */
  50981. serialize(): any;
  50982. }
  50983. }
  50984. declare module BABYLON {
  50985. /**
  50986. * This represents one of the lens effect in a `lensFlareSystem`.
  50987. * It controls one of the indiviual texture used in the effect.
  50988. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50989. */
  50990. export class LensFlare {
  50991. /**
  50992. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50993. */
  50994. size: number;
  50995. /**
  50996. * 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.
  50997. */
  50998. position: number;
  50999. /**
  51000. * Define the lens color.
  51001. */
  51002. color: Color3;
  51003. /**
  51004. * Define the lens texture.
  51005. */
  51006. texture: Nullable<Texture>;
  51007. /**
  51008. * Define the alpha mode to render this particular lens.
  51009. */
  51010. alphaMode: number;
  51011. private _system;
  51012. /**
  51013. * Creates a new Lens Flare.
  51014. * This represents one of the lens effect in a `lensFlareSystem`.
  51015. * It controls one of the indiviual texture used in the effect.
  51016. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51017. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51018. * @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.
  51019. * @param color Define the lens color
  51020. * @param imgUrl Define the lens texture url
  51021. * @param system Define the `lensFlareSystem` this flare is part of
  51022. * @returns The newly created Lens Flare
  51023. */
  51024. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51025. /**
  51026. * Instantiates a new Lens Flare.
  51027. * This represents one of the lens effect in a `lensFlareSystem`.
  51028. * It controls one of the indiviual texture used in the effect.
  51029. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51030. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51031. * @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.
  51032. * @param color Define the lens color
  51033. * @param imgUrl Define the lens texture url
  51034. * @param system Define the `lensFlareSystem` this flare is part of
  51035. */
  51036. constructor(
  51037. /**
  51038. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51039. */
  51040. size: number,
  51041. /**
  51042. * 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.
  51043. */
  51044. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51045. /**
  51046. * Dispose and release the lens flare with its associated resources.
  51047. */
  51048. dispose(): void;
  51049. }
  51050. }
  51051. declare module BABYLON {
  51052. interface AbstractScene {
  51053. /**
  51054. * The list of lens flare system added to the scene
  51055. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51056. */
  51057. lensFlareSystems: Array<LensFlareSystem>;
  51058. /**
  51059. * Removes the given lens flare system from this scene.
  51060. * @param toRemove The lens flare system to remove
  51061. * @returns The index of the removed lens flare system
  51062. */
  51063. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51064. /**
  51065. * Adds the given lens flare system to this scene
  51066. * @param newLensFlareSystem The lens flare system to add
  51067. */
  51068. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51069. /**
  51070. * Gets a lens flare system using its name
  51071. * @param name defines the name to look for
  51072. * @returns the lens flare system or null if not found
  51073. */
  51074. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51075. /**
  51076. * Gets a lens flare system using its id
  51077. * @param id defines the id to look for
  51078. * @returns the lens flare system or null if not found
  51079. */
  51080. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51081. }
  51082. /**
  51083. * Defines the lens flare scene component responsible to manage any lens flares
  51084. * in a given scene.
  51085. */
  51086. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51087. /**
  51088. * The component name helpfull to identify the component in the list of scene components.
  51089. */
  51090. readonly name: string;
  51091. /**
  51092. * The scene the component belongs to.
  51093. */
  51094. scene: Scene;
  51095. /**
  51096. * Creates a new instance of the component for the given scene
  51097. * @param scene Defines the scene to register the component in
  51098. */
  51099. constructor(scene: Scene);
  51100. /**
  51101. * Registers the component in a given scene
  51102. */
  51103. register(): void;
  51104. /**
  51105. * Rebuilds the elements related to this component in case of
  51106. * context lost for instance.
  51107. */
  51108. rebuild(): void;
  51109. /**
  51110. * Adds all the elements from the container to the scene
  51111. * @param container the container holding the elements
  51112. */
  51113. addFromContainer(container: AbstractScene): void;
  51114. /**
  51115. * Removes all the elements in the container from the scene
  51116. * @param container contains the elements to remove
  51117. * @param dispose if the removed element should be disposed (default: false)
  51118. */
  51119. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51120. /**
  51121. * Serializes the component data to the specified json object
  51122. * @param serializationObject The object to serialize to
  51123. */
  51124. serialize(serializationObject: any): void;
  51125. /**
  51126. * Disposes the component and the associated ressources.
  51127. */
  51128. dispose(): void;
  51129. private _draw;
  51130. }
  51131. }
  51132. declare module BABYLON {
  51133. /**
  51134. * Defines the shadow generator component responsible to manage any shadow generators
  51135. * in a given scene.
  51136. */
  51137. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51138. /**
  51139. * The component name helpfull to identify the component in the list of scene components.
  51140. */
  51141. readonly name: string;
  51142. /**
  51143. * The scene the component belongs to.
  51144. */
  51145. scene: Scene;
  51146. /**
  51147. * Creates a new instance of the component for the given scene
  51148. * @param scene Defines the scene to register the component in
  51149. */
  51150. constructor(scene: Scene);
  51151. /**
  51152. * Registers the component in a given scene
  51153. */
  51154. register(): void;
  51155. /**
  51156. * Rebuilds the elements related to this component in case of
  51157. * context lost for instance.
  51158. */
  51159. rebuild(): void;
  51160. /**
  51161. * Serializes the component data to the specified json object
  51162. * @param serializationObject The object to serialize to
  51163. */
  51164. serialize(serializationObject: any): void;
  51165. /**
  51166. * Adds all the elements from the container to the scene
  51167. * @param container the container holding the elements
  51168. */
  51169. addFromContainer(container: AbstractScene): void;
  51170. /**
  51171. * Removes all the elements in the container from the scene
  51172. * @param container contains the elements to remove
  51173. * @param dispose if the removed element should be disposed (default: false)
  51174. */
  51175. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51176. /**
  51177. * Rebuilds the elements related to this component in case of
  51178. * context lost for instance.
  51179. */
  51180. dispose(): void;
  51181. private _gatherRenderTargets;
  51182. }
  51183. }
  51184. declare module BABYLON {
  51185. /**
  51186. * A point light is a light defined by an unique point in world space.
  51187. * The light is emitted in every direction from this point.
  51188. * A good example of a point light is a standard light bulb.
  51189. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51190. */
  51191. export class PointLight extends ShadowLight {
  51192. private _shadowAngle;
  51193. /**
  51194. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51195. * This specifies what angle the shadow will use to be created.
  51196. *
  51197. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51198. */
  51199. /**
  51200. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51201. * This specifies what angle the shadow will use to be created.
  51202. *
  51203. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51204. */
  51205. shadowAngle: number;
  51206. /**
  51207. * Gets the direction if it has been set.
  51208. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51209. */
  51210. /**
  51211. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51212. */
  51213. direction: Vector3;
  51214. /**
  51215. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51216. * A PointLight emits the light in every direction.
  51217. * It can cast shadows.
  51218. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51219. * ```javascript
  51220. * var pointLight = new PointLight("pl", camera.position, scene);
  51221. * ```
  51222. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51223. * @param name The light friendly name
  51224. * @param position The position of the point light in the scene
  51225. * @param scene The scene the lights belongs to
  51226. */
  51227. constructor(name: string, position: Vector3, scene: Scene);
  51228. /**
  51229. * Returns the string "PointLight"
  51230. * @returns the class name
  51231. */
  51232. getClassName(): string;
  51233. /**
  51234. * Returns the integer 0.
  51235. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51236. */
  51237. getTypeID(): number;
  51238. /**
  51239. * Specifies wether or not the shadowmap should be a cube texture.
  51240. * @returns true if the shadowmap needs to be a cube texture.
  51241. */
  51242. needCube(): boolean;
  51243. /**
  51244. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51245. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51246. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51247. */
  51248. getShadowDirection(faceIndex?: number): Vector3;
  51249. /**
  51250. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51251. * - fov = PI / 2
  51252. * - aspect ratio : 1.0
  51253. * - z-near and far equal to the active camera minZ and maxZ.
  51254. * Returns the PointLight.
  51255. */
  51256. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51257. protected _buildUniformLayout(): void;
  51258. /**
  51259. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51260. * @param effect The effect to update
  51261. * @param lightIndex The index of the light in the effect to update
  51262. * @returns The point light
  51263. */
  51264. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51265. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51266. /**
  51267. * Prepares the list of defines specific to the light type.
  51268. * @param defines the list of defines
  51269. * @param lightIndex defines the index of the light for the effect
  51270. */
  51271. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51272. }
  51273. }
  51274. declare module BABYLON {
  51275. /**
  51276. * Header information of HDR texture files.
  51277. */
  51278. export interface HDRInfo {
  51279. /**
  51280. * The height of the texture in pixels.
  51281. */
  51282. height: number;
  51283. /**
  51284. * The width of the texture in pixels.
  51285. */
  51286. width: number;
  51287. /**
  51288. * The index of the beginning of the data in the binary file.
  51289. */
  51290. dataPosition: number;
  51291. }
  51292. /**
  51293. * This groups tools to convert HDR texture to native colors array.
  51294. */
  51295. export class HDRTools {
  51296. private static Ldexp;
  51297. private static Rgbe2float;
  51298. private static readStringLine;
  51299. /**
  51300. * Reads header information from an RGBE texture stored in a native array.
  51301. * More information on this format are available here:
  51302. * https://en.wikipedia.org/wiki/RGBE_image_format
  51303. *
  51304. * @param uint8array The binary file stored in native array.
  51305. * @return The header information.
  51306. */
  51307. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51308. /**
  51309. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51310. * This RGBE texture needs to store the information as a panorama.
  51311. *
  51312. * More information on this format are available here:
  51313. * https://en.wikipedia.org/wiki/RGBE_image_format
  51314. *
  51315. * @param buffer The binary file stored in an array buffer.
  51316. * @param size The expected size of the extracted cubemap.
  51317. * @return The Cube Map information.
  51318. */
  51319. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51320. /**
  51321. * Returns the pixels data extracted from an RGBE texture.
  51322. * This pixels will be stored left to right up to down in the R G B order in one array.
  51323. *
  51324. * More information on this format are available here:
  51325. * https://en.wikipedia.org/wiki/RGBE_image_format
  51326. *
  51327. * @param uint8array The binary file stored in an array buffer.
  51328. * @param hdrInfo The header information of the file.
  51329. * @return The pixels data in RGB right to left up to down order.
  51330. */
  51331. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51332. private static RGBE_ReadPixels_RLE;
  51333. }
  51334. }
  51335. declare module BABYLON {
  51336. /**
  51337. * This represents a texture coming from an HDR input.
  51338. *
  51339. * The only supported format is currently panorama picture stored in RGBE format.
  51340. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51341. */
  51342. export class HDRCubeTexture extends BaseTexture {
  51343. private static _facesMapping;
  51344. private _generateHarmonics;
  51345. private _noMipmap;
  51346. private _textureMatrix;
  51347. private _size;
  51348. private _onLoad;
  51349. private _onError;
  51350. /**
  51351. * The texture URL.
  51352. */
  51353. url: string;
  51354. /**
  51355. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51356. */
  51357. coordinatesMode: number;
  51358. protected _isBlocking: boolean;
  51359. /**
  51360. * Sets wether or not the texture is blocking during loading.
  51361. */
  51362. /**
  51363. * Gets wether or not the texture is blocking during loading.
  51364. */
  51365. isBlocking: boolean;
  51366. protected _rotationY: number;
  51367. /**
  51368. * Sets texture matrix rotation angle around Y axis in radians.
  51369. */
  51370. /**
  51371. * Gets texture matrix rotation angle around Y axis radians.
  51372. */
  51373. rotationY: number;
  51374. /**
  51375. * Gets or sets the center of the bounding box associated with the cube texture
  51376. * It must define where the camera used to render the texture was set
  51377. */
  51378. boundingBoxPosition: Vector3;
  51379. private _boundingBoxSize;
  51380. /**
  51381. * Gets or sets the size of the bounding box associated with the cube texture
  51382. * When defined, the cubemap will switch to local mode
  51383. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51384. * @example https://www.babylonjs-playground.com/#RNASML
  51385. */
  51386. boundingBoxSize: Vector3;
  51387. /**
  51388. * Instantiates an HDRTexture from the following parameters.
  51389. *
  51390. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51391. * @param scene The scene the texture will be used in
  51392. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51393. * @param noMipmap Forces to not generate the mipmap if true
  51394. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51395. * @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)
  51396. * @param reserved Reserved flag for internal use.
  51397. */
  51398. 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>);
  51399. /**
  51400. * Get the current class name of the texture useful for serialization or dynamic coding.
  51401. * @returns "HDRCubeTexture"
  51402. */
  51403. getClassName(): string;
  51404. /**
  51405. * Occurs when the file is raw .hdr file.
  51406. */
  51407. private loadTexture;
  51408. clone(): HDRCubeTexture;
  51409. delayLoad(): void;
  51410. /**
  51411. * Get the texture reflection matrix used to rotate/transform the reflection.
  51412. * @returns the reflection matrix
  51413. */
  51414. getReflectionTextureMatrix(): Matrix;
  51415. /**
  51416. * Set the texture reflection matrix used to rotate/transform the reflection.
  51417. * @param value Define the reflection matrix to set
  51418. */
  51419. setReflectionTextureMatrix(value: Matrix): void;
  51420. /**
  51421. * Parses a JSON representation of an HDR Texture in order to create the texture
  51422. * @param parsedTexture Define the JSON representation
  51423. * @param scene Define the scene the texture should be created in
  51424. * @param rootUrl Define the root url in case we need to load relative dependencies
  51425. * @returns the newly created texture after parsing
  51426. */
  51427. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51428. serialize(): any;
  51429. }
  51430. }
  51431. declare module BABYLON {
  51432. /**
  51433. * Class used to control physics engine
  51434. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51435. */
  51436. export class PhysicsEngine implements IPhysicsEngine {
  51437. private _physicsPlugin;
  51438. /**
  51439. * Global value used to control the smallest number supported by the simulation
  51440. */
  51441. static Epsilon: number;
  51442. private _impostors;
  51443. private _joints;
  51444. /**
  51445. * Gets the gravity vector used by the simulation
  51446. */
  51447. gravity: Vector3;
  51448. /**
  51449. * Factory used to create the default physics plugin.
  51450. * @returns The default physics plugin
  51451. */
  51452. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51453. /**
  51454. * Creates a new Physics Engine
  51455. * @param gravity defines the gravity vector used by the simulation
  51456. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51457. */
  51458. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51459. /**
  51460. * Sets the gravity vector used by the simulation
  51461. * @param gravity defines the gravity vector to use
  51462. */
  51463. setGravity(gravity: Vector3): void;
  51464. /**
  51465. * Set the time step of the physics engine.
  51466. * Default is 1/60.
  51467. * To slow it down, enter 1/600 for example.
  51468. * To speed it up, 1/30
  51469. * @param newTimeStep defines the new timestep to apply to this world.
  51470. */
  51471. setTimeStep(newTimeStep?: number): void;
  51472. /**
  51473. * Get the time step of the physics engine.
  51474. * @returns the current time step
  51475. */
  51476. getTimeStep(): number;
  51477. /**
  51478. * Release all resources
  51479. */
  51480. dispose(): void;
  51481. /**
  51482. * Gets the name of the current physics plugin
  51483. * @returns the name of the plugin
  51484. */
  51485. getPhysicsPluginName(): string;
  51486. /**
  51487. * Adding a new impostor for the impostor tracking.
  51488. * This will be done by the impostor itself.
  51489. * @param impostor the impostor to add
  51490. */
  51491. addImpostor(impostor: PhysicsImpostor): void;
  51492. /**
  51493. * Remove an impostor from the engine.
  51494. * This impostor and its mesh will not longer be updated by the physics engine.
  51495. * @param impostor the impostor to remove
  51496. */
  51497. removeImpostor(impostor: PhysicsImpostor): void;
  51498. /**
  51499. * Add a joint to the physics engine
  51500. * @param mainImpostor defines the main impostor to which the joint is added.
  51501. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51502. * @param joint defines the joint that will connect both impostors.
  51503. */
  51504. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51505. /**
  51506. * Removes a joint from the simulation
  51507. * @param mainImpostor defines the impostor used with the joint
  51508. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51509. * @param joint defines the joint to remove
  51510. */
  51511. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51512. /**
  51513. * Called by the scene. No need to call it.
  51514. * @param delta defines the timespam between frames
  51515. */
  51516. _step(delta: number): void;
  51517. /**
  51518. * Gets the current plugin used to run the simulation
  51519. * @returns current plugin
  51520. */
  51521. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51522. /**
  51523. * Gets the list of physic impostors
  51524. * @returns an array of PhysicsImpostor
  51525. */
  51526. getImpostors(): Array<PhysicsImpostor>;
  51527. /**
  51528. * Gets the impostor for a physics enabled object
  51529. * @param object defines the object impersonated by the impostor
  51530. * @returns the PhysicsImpostor or null if not found
  51531. */
  51532. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51533. /**
  51534. * Gets the impostor for a physics body object
  51535. * @param body defines physics body used by the impostor
  51536. * @returns the PhysicsImpostor or null if not found
  51537. */
  51538. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51539. /**
  51540. * Does a raycast in the physics world
  51541. * @param from when should the ray start?
  51542. * @param to when should the ray end?
  51543. * @returns PhysicsRaycastResult
  51544. */
  51545. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51546. }
  51547. }
  51548. declare module BABYLON {
  51549. /** @hidden */
  51550. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51551. private _useDeltaForWorldStep;
  51552. world: any;
  51553. name: string;
  51554. private _physicsMaterials;
  51555. private _fixedTimeStep;
  51556. private _cannonRaycastResult;
  51557. private _raycastResult;
  51558. private _physicsBodysToRemoveAfterStep;
  51559. BJSCANNON: any;
  51560. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51561. setGravity(gravity: Vector3): void;
  51562. setTimeStep(timeStep: number): void;
  51563. getTimeStep(): number;
  51564. executeStep(delta: number): void;
  51565. private _removeMarkedPhysicsBodiesFromWorld;
  51566. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51567. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51568. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51569. private _processChildMeshes;
  51570. removePhysicsBody(impostor: PhysicsImpostor): void;
  51571. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51572. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51573. private _addMaterial;
  51574. private _checkWithEpsilon;
  51575. private _createShape;
  51576. private _createHeightmap;
  51577. private _minus90X;
  51578. private _plus90X;
  51579. private _tmpPosition;
  51580. private _tmpDeltaPosition;
  51581. private _tmpUnityRotation;
  51582. private _updatePhysicsBodyTransformation;
  51583. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51584. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51585. isSupported(): boolean;
  51586. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51587. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51588. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51589. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51590. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51591. getBodyMass(impostor: PhysicsImpostor): number;
  51592. getBodyFriction(impostor: PhysicsImpostor): number;
  51593. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51594. getBodyRestitution(impostor: PhysicsImpostor): number;
  51595. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51596. sleepBody(impostor: PhysicsImpostor): void;
  51597. wakeUpBody(impostor: PhysicsImpostor): void;
  51598. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51599. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51600. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51601. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51602. getRadius(impostor: PhysicsImpostor): number;
  51603. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51604. dispose(): void;
  51605. private _extendNamespace;
  51606. /**
  51607. * Does a raycast in the physics world
  51608. * @param from when should the ray start?
  51609. * @param to when should the ray end?
  51610. * @returns PhysicsRaycastResult
  51611. */
  51612. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51613. }
  51614. }
  51615. declare module BABYLON {
  51616. /** @hidden */
  51617. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51618. world: any;
  51619. name: string;
  51620. BJSOIMO: any;
  51621. private _raycastResult;
  51622. constructor(iterations?: number, oimoInjection?: any);
  51623. setGravity(gravity: Vector3): void;
  51624. setTimeStep(timeStep: number): void;
  51625. getTimeStep(): number;
  51626. private _tmpImpostorsArray;
  51627. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51628. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51629. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51630. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51631. private _tmpPositionVector;
  51632. removePhysicsBody(impostor: PhysicsImpostor): void;
  51633. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51634. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51635. isSupported(): boolean;
  51636. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51637. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51638. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51639. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51640. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51641. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51642. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51643. getBodyMass(impostor: PhysicsImpostor): number;
  51644. getBodyFriction(impostor: PhysicsImpostor): number;
  51645. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51646. getBodyRestitution(impostor: PhysicsImpostor): number;
  51647. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51648. sleepBody(impostor: PhysicsImpostor): void;
  51649. wakeUpBody(impostor: PhysicsImpostor): void;
  51650. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51651. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51652. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51653. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51654. getRadius(impostor: PhysicsImpostor): number;
  51655. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51656. dispose(): void;
  51657. /**
  51658. * Does a raycast in the physics world
  51659. * @param from when should the ray start?
  51660. * @param to when should the ray end?
  51661. * @returns PhysicsRaycastResult
  51662. */
  51663. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51664. }
  51665. }
  51666. declare module BABYLON {
  51667. /**
  51668. * Class containing static functions to help procedurally build meshes
  51669. */
  51670. export class RibbonBuilder {
  51671. /**
  51672. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51673. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51674. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51675. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51676. * * 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
  51677. * * 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
  51678. * * 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
  51679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51680. * * 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
  51681. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51682. * * 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
  51683. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51684. * * 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
  51685. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51687. * @param name defines the name of the mesh
  51688. * @param options defines the options used to create the mesh
  51689. * @param scene defines the hosting scene
  51690. * @returns the ribbon mesh
  51691. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51692. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51693. */
  51694. static CreateRibbon(name: string, options: {
  51695. pathArray: Vector3[][];
  51696. closeArray?: boolean;
  51697. closePath?: boolean;
  51698. offset?: number;
  51699. updatable?: boolean;
  51700. sideOrientation?: number;
  51701. frontUVs?: Vector4;
  51702. backUVs?: Vector4;
  51703. instance?: Mesh;
  51704. invertUV?: boolean;
  51705. uvs?: Vector2[];
  51706. colors?: Color4[];
  51707. }, scene?: Nullable<Scene>): Mesh;
  51708. }
  51709. }
  51710. declare module BABYLON {
  51711. /**
  51712. * Class containing static functions to help procedurally build meshes
  51713. */
  51714. export class ShapeBuilder {
  51715. /**
  51716. * 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.
  51717. * * 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.
  51718. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51719. * * 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.
  51720. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51721. * * 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
  51722. * * 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
  51723. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51725. * * 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
  51726. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51728. * @param name defines the name of the mesh
  51729. * @param options defines the options used to create the mesh
  51730. * @param scene defines the hosting scene
  51731. * @returns the extruded shape mesh
  51732. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51734. */
  51735. static ExtrudeShape(name: string, options: {
  51736. shape: Vector3[];
  51737. path: Vector3[];
  51738. scale?: number;
  51739. rotation?: number;
  51740. cap?: number;
  51741. updatable?: boolean;
  51742. sideOrientation?: number;
  51743. frontUVs?: Vector4;
  51744. backUVs?: Vector4;
  51745. instance?: Mesh;
  51746. invertUV?: boolean;
  51747. }, scene?: Nullable<Scene>): Mesh;
  51748. /**
  51749. * Creates an custom extruded shape mesh.
  51750. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51751. * * 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.
  51752. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51753. * * 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
  51754. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51755. * * 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
  51756. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51757. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51758. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51759. * * 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
  51760. * * 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
  51761. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51763. * * 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
  51764. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51766. * @param name defines the name of the mesh
  51767. * @param options defines the options used to create the mesh
  51768. * @param scene defines the hosting scene
  51769. * @returns the custom extruded shape mesh
  51770. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51771. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51772. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51773. */
  51774. static ExtrudeShapeCustom(name: string, options: {
  51775. shape: Vector3[];
  51776. path: Vector3[];
  51777. scaleFunction?: any;
  51778. rotationFunction?: any;
  51779. ribbonCloseArray?: boolean;
  51780. ribbonClosePath?: boolean;
  51781. cap?: number;
  51782. updatable?: boolean;
  51783. sideOrientation?: number;
  51784. frontUVs?: Vector4;
  51785. backUVs?: Vector4;
  51786. instance?: Mesh;
  51787. invertUV?: boolean;
  51788. }, scene?: Nullable<Scene>): Mesh;
  51789. private static _ExtrudeShapeGeneric;
  51790. }
  51791. }
  51792. declare module BABYLON {
  51793. /**
  51794. * AmmoJS Physics plugin
  51795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51796. * @see https://github.com/kripken/ammo.js/
  51797. */
  51798. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51799. private _useDeltaForWorldStep;
  51800. /**
  51801. * Reference to the Ammo library
  51802. */
  51803. bjsAMMO: any;
  51804. /**
  51805. * Created ammoJS world which physics bodies are added to
  51806. */
  51807. world: any;
  51808. /**
  51809. * Name of the plugin
  51810. */
  51811. name: string;
  51812. private _timeStep;
  51813. private _fixedTimeStep;
  51814. private _maxSteps;
  51815. private _tmpQuaternion;
  51816. private _tmpAmmoTransform;
  51817. private _tmpAmmoQuaternion;
  51818. private _tmpAmmoConcreteContactResultCallback;
  51819. private _collisionConfiguration;
  51820. private _dispatcher;
  51821. private _overlappingPairCache;
  51822. private _solver;
  51823. private _softBodySolver;
  51824. private _tmpAmmoVectorA;
  51825. private _tmpAmmoVectorB;
  51826. private _tmpAmmoVectorC;
  51827. private _tmpAmmoVectorD;
  51828. private _tmpContactCallbackResult;
  51829. private _tmpAmmoVectorRCA;
  51830. private _tmpAmmoVectorRCB;
  51831. private _raycastResult;
  51832. private static readonly DISABLE_COLLISION_FLAG;
  51833. private static readonly KINEMATIC_FLAG;
  51834. private static readonly DISABLE_DEACTIVATION_FLAG;
  51835. /**
  51836. * Initializes the ammoJS plugin
  51837. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51838. * @param ammoInjection can be used to inject your own ammo reference
  51839. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51840. */
  51841. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51842. /**
  51843. * Sets the gravity of the physics world (m/(s^2))
  51844. * @param gravity Gravity to set
  51845. */
  51846. setGravity(gravity: Vector3): void;
  51847. /**
  51848. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51849. * @param timeStep timestep to use in seconds
  51850. */
  51851. setTimeStep(timeStep: number): void;
  51852. /**
  51853. * 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)
  51854. * @param fixedTimeStep fixedTimeStep to use in seconds
  51855. */
  51856. setFixedTimeStep(fixedTimeStep: number): void;
  51857. /**
  51858. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51859. * @param maxSteps the maximum number of steps by the physics engine per frame
  51860. */
  51861. setMaxSteps(maxSteps: number): void;
  51862. /**
  51863. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51864. * @returns the current timestep in seconds
  51865. */
  51866. getTimeStep(): number;
  51867. private _isImpostorInContact;
  51868. private _isImpostorPairInContact;
  51869. private _stepSimulation;
  51870. /**
  51871. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51872. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51873. * After the step the babylon meshes are set to the position of the physics imposters
  51874. * @param delta amount of time to step forward
  51875. * @param impostors array of imposters to update before/after the step
  51876. */
  51877. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51878. /**
  51879. * Update babylon mesh to match physics world object
  51880. * @param impostor imposter to match
  51881. */
  51882. private _afterSoftStep;
  51883. /**
  51884. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51885. * @param impostor imposter to match
  51886. */
  51887. private _ropeStep;
  51888. /**
  51889. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51890. * @param impostor imposter to match
  51891. */
  51892. private _softbodyOrClothStep;
  51893. private _tmpVector;
  51894. private _tmpMatrix;
  51895. /**
  51896. * Applies an impulse on the imposter
  51897. * @param impostor imposter to apply impulse to
  51898. * @param force amount of force to be applied to the imposter
  51899. * @param contactPoint the location to apply the impulse on the imposter
  51900. */
  51901. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51902. /**
  51903. * Applies a force on the imposter
  51904. * @param impostor imposter to apply force
  51905. * @param force amount of force to be applied to the imposter
  51906. * @param contactPoint the location to apply the force on the imposter
  51907. */
  51908. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51909. /**
  51910. * Creates a physics body using the plugin
  51911. * @param impostor the imposter to create the physics body on
  51912. */
  51913. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51914. /**
  51915. * Removes the physics body from the imposter and disposes of the body's memory
  51916. * @param impostor imposter to remove the physics body from
  51917. */
  51918. removePhysicsBody(impostor: PhysicsImpostor): void;
  51919. /**
  51920. * Generates a joint
  51921. * @param impostorJoint the imposter joint to create the joint with
  51922. */
  51923. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51924. /**
  51925. * Removes a joint
  51926. * @param impostorJoint the imposter joint to remove the joint from
  51927. */
  51928. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51929. private _addMeshVerts;
  51930. /**
  51931. * Initialise the soft body vertices to match its object's (mesh) vertices
  51932. * Softbody vertices (nodes) are in world space and to match this
  51933. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51934. * @param impostor to create the softbody for
  51935. */
  51936. private _softVertexData;
  51937. /**
  51938. * Create an impostor's soft body
  51939. * @param impostor to create the softbody for
  51940. */
  51941. private _createSoftbody;
  51942. /**
  51943. * Create cloth for an impostor
  51944. * @param impostor to create the softbody for
  51945. */
  51946. private _createCloth;
  51947. /**
  51948. * Create rope for an impostor
  51949. * @param impostor to create the softbody for
  51950. */
  51951. private _createRope;
  51952. private _addHullVerts;
  51953. private _createShape;
  51954. /**
  51955. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51956. * @param impostor imposter containing the physics body and babylon object
  51957. */
  51958. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51959. /**
  51960. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51961. * @param impostor imposter containing the physics body and babylon object
  51962. * @param newPosition new position
  51963. * @param newRotation new rotation
  51964. */
  51965. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51966. /**
  51967. * If this plugin is supported
  51968. * @returns true if its supported
  51969. */
  51970. isSupported(): boolean;
  51971. /**
  51972. * Sets the linear velocity of the physics body
  51973. * @param impostor imposter to set the velocity on
  51974. * @param velocity velocity to set
  51975. */
  51976. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51977. /**
  51978. * Sets the angular velocity of the physics body
  51979. * @param impostor imposter to set the velocity on
  51980. * @param velocity velocity to set
  51981. */
  51982. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51983. /**
  51984. * gets the linear velocity
  51985. * @param impostor imposter to get linear velocity from
  51986. * @returns linear velocity
  51987. */
  51988. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51989. /**
  51990. * gets the angular velocity
  51991. * @param impostor imposter to get angular velocity from
  51992. * @returns angular velocity
  51993. */
  51994. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51995. /**
  51996. * Sets the mass of physics body
  51997. * @param impostor imposter to set the mass on
  51998. * @param mass mass to set
  51999. */
  52000. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52001. /**
  52002. * Gets the mass of the physics body
  52003. * @param impostor imposter to get the mass from
  52004. * @returns mass
  52005. */
  52006. getBodyMass(impostor: PhysicsImpostor): number;
  52007. /**
  52008. * Gets friction of the impostor
  52009. * @param impostor impostor to get friction from
  52010. * @returns friction value
  52011. */
  52012. getBodyFriction(impostor: PhysicsImpostor): number;
  52013. /**
  52014. * Sets friction of the impostor
  52015. * @param impostor impostor to set friction on
  52016. * @param friction friction value
  52017. */
  52018. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52019. /**
  52020. * Gets restitution of the impostor
  52021. * @param impostor impostor to get restitution from
  52022. * @returns restitution value
  52023. */
  52024. getBodyRestitution(impostor: PhysicsImpostor): number;
  52025. /**
  52026. * Sets resitution of the impostor
  52027. * @param impostor impostor to set resitution on
  52028. * @param restitution resitution value
  52029. */
  52030. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52031. /**
  52032. * Gets pressure inside the impostor
  52033. * @param impostor impostor to get pressure from
  52034. * @returns pressure value
  52035. */
  52036. getBodyPressure(impostor: PhysicsImpostor): number;
  52037. /**
  52038. * Sets pressure inside a soft body impostor
  52039. * Cloth and rope must remain 0 pressure
  52040. * @param impostor impostor to set pressure on
  52041. * @param pressure pressure value
  52042. */
  52043. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52044. /**
  52045. * Gets stiffness of the impostor
  52046. * @param impostor impostor to get stiffness from
  52047. * @returns pressure value
  52048. */
  52049. getBodyStiffness(impostor: PhysicsImpostor): number;
  52050. /**
  52051. * Sets stiffness of the impostor
  52052. * @param impostor impostor to set stiffness on
  52053. * @param stiffness stiffness value from 0 to 1
  52054. */
  52055. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52056. /**
  52057. * Gets velocityIterations of the impostor
  52058. * @param impostor impostor to get velocity iterations from
  52059. * @returns velocityIterations value
  52060. */
  52061. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52062. /**
  52063. * Sets velocityIterations of the impostor
  52064. * @param impostor impostor to set velocity iterations on
  52065. * @param velocityIterations velocityIterations value
  52066. */
  52067. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52068. /**
  52069. * Gets positionIterations of the impostor
  52070. * @param impostor impostor to get position iterations from
  52071. * @returns positionIterations value
  52072. */
  52073. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52074. /**
  52075. * Sets positionIterations of the impostor
  52076. * @param impostor impostor to set position on
  52077. * @param positionIterations positionIterations value
  52078. */
  52079. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52080. /**
  52081. * Append an anchor to a cloth object
  52082. * @param impostor is the cloth impostor to add anchor to
  52083. * @param otherImpostor is the rigid impostor to anchor to
  52084. * @param width ratio across width from 0 to 1
  52085. * @param height ratio up height from 0 to 1
  52086. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52087. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52088. */
  52089. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52090. /**
  52091. * Append an hook to a rope object
  52092. * @param impostor is the rope impostor to add hook to
  52093. * @param otherImpostor is the rigid impostor to hook to
  52094. * @param length ratio along the rope from 0 to 1
  52095. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52096. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52097. */
  52098. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52099. /**
  52100. * Sleeps the physics body and stops it from being active
  52101. * @param impostor impostor to sleep
  52102. */
  52103. sleepBody(impostor: PhysicsImpostor): void;
  52104. /**
  52105. * Activates the physics body
  52106. * @param impostor impostor to activate
  52107. */
  52108. wakeUpBody(impostor: PhysicsImpostor): void;
  52109. /**
  52110. * Updates the distance parameters of the joint
  52111. * @param joint joint to update
  52112. * @param maxDistance maximum distance of the joint
  52113. * @param minDistance minimum distance of the joint
  52114. */
  52115. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52116. /**
  52117. * Sets a motor on the joint
  52118. * @param joint joint to set motor on
  52119. * @param speed speed of the motor
  52120. * @param maxForce maximum force of the motor
  52121. * @param motorIndex index of the motor
  52122. */
  52123. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52124. /**
  52125. * Sets the motors limit
  52126. * @param joint joint to set limit on
  52127. * @param upperLimit upper limit
  52128. * @param lowerLimit lower limit
  52129. */
  52130. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52131. /**
  52132. * Syncs the position and rotation of a mesh with the impostor
  52133. * @param mesh mesh to sync
  52134. * @param impostor impostor to update the mesh with
  52135. */
  52136. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52137. /**
  52138. * Gets the radius of the impostor
  52139. * @param impostor impostor to get radius from
  52140. * @returns the radius
  52141. */
  52142. getRadius(impostor: PhysicsImpostor): number;
  52143. /**
  52144. * Gets the box size of the impostor
  52145. * @param impostor impostor to get box size from
  52146. * @param result the resulting box size
  52147. */
  52148. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52149. /**
  52150. * Disposes of the impostor
  52151. */
  52152. dispose(): void;
  52153. /**
  52154. * Does a raycast in the physics world
  52155. * @param from when should the ray start?
  52156. * @param to when should the ray end?
  52157. * @returns PhysicsRaycastResult
  52158. */
  52159. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52160. }
  52161. }
  52162. declare module BABYLON {
  52163. interface AbstractScene {
  52164. /**
  52165. * The list of reflection probes added to the scene
  52166. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52167. */
  52168. reflectionProbes: Array<ReflectionProbe>;
  52169. /**
  52170. * Removes the given reflection probe from this scene.
  52171. * @param toRemove The reflection probe to remove
  52172. * @returns The index of the removed reflection probe
  52173. */
  52174. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52175. /**
  52176. * Adds the given reflection probe to this scene.
  52177. * @param newReflectionProbe The reflection probe to add
  52178. */
  52179. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52180. }
  52181. /**
  52182. * Class used to generate realtime reflection / refraction cube textures
  52183. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52184. */
  52185. export class ReflectionProbe {
  52186. /** defines the name of the probe */
  52187. name: string;
  52188. private _scene;
  52189. private _renderTargetTexture;
  52190. private _projectionMatrix;
  52191. private _viewMatrix;
  52192. private _target;
  52193. private _add;
  52194. private _attachedMesh;
  52195. private _invertYAxis;
  52196. /** Gets or sets probe position (center of the cube map) */
  52197. position: Vector3;
  52198. /**
  52199. * Creates a new reflection probe
  52200. * @param name defines the name of the probe
  52201. * @param size defines the texture resolution (for each face)
  52202. * @param scene defines the hosting scene
  52203. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52204. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52205. */
  52206. constructor(
  52207. /** defines the name of the probe */
  52208. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52209. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52210. samples: number;
  52211. /** Gets or sets the refresh rate to use (on every frame by default) */
  52212. refreshRate: number;
  52213. /**
  52214. * Gets the hosting scene
  52215. * @returns a Scene
  52216. */
  52217. getScene(): Scene;
  52218. /** Gets the internal CubeTexture used to render to */
  52219. readonly cubeTexture: RenderTargetTexture;
  52220. /** Gets the list of meshes to render */
  52221. readonly renderList: Nullable<AbstractMesh[]>;
  52222. /**
  52223. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52224. * @param mesh defines the mesh to attach to
  52225. */
  52226. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52227. /**
  52228. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52229. * @param renderingGroupId The rendering group id corresponding to its index
  52230. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52231. */
  52232. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52233. /**
  52234. * Clean all associated resources
  52235. */
  52236. dispose(): void;
  52237. /**
  52238. * Converts the reflection probe information to a readable string for debug purpose.
  52239. * @param fullDetails Supports for multiple levels of logging within scene loading
  52240. * @returns the human readable reflection probe info
  52241. */
  52242. toString(fullDetails?: boolean): string;
  52243. /**
  52244. * Get the class name of the relfection probe.
  52245. * @returns "ReflectionProbe"
  52246. */
  52247. getClassName(): string;
  52248. /**
  52249. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52250. * @returns The JSON representation of the texture
  52251. */
  52252. serialize(): any;
  52253. /**
  52254. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52255. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52256. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52257. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52258. * @returns The parsed reflection probe if successful
  52259. */
  52260. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52261. }
  52262. }
  52263. declare module BABYLON {
  52264. /** @hidden */
  52265. export var _BabylonLoaderRegistered: boolean;
  52266. /**
  52267. * Helps setting up some configuration for the babylon file loader.
  52268. */
  52269. export class BabylonFileLoaderConfiguration {
  52270. /**
  52271. * The loader does not allow injecting custom physix engine into the plugins.
  52272. * Unfortunately in ES6, we need to manually inject them into the plugin.
  52273. * So you could set this variable to your engine import to make it work.
  52274. */
  52275. static LoaderInjectedPhysicsEngine: any;
  52276. }
  52277. }
  52278. declare module BABYLON {
  52279. /**
  52280. * The Physically based simple base material of BJS.
  52281. *
  52282. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52283. * It is used as the base class for both the specGloss and metalRough conventions.
  52284. */
  52285. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52286. /**
  52287. * Number of Simultaneous lights allowed on the material.
  52288. */
  52289. maxSimultaneousLights: number;
  52290. /**
  52291. * If sets to true, disables all the lights affecting the material.
  52292. */
  52293. disableLighting: boolean;
  52294. /**
  52295. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52296. */
  52297. environmentTexture: BaseTexture;
  52298. /**
  52299. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52300. */
  52301. invertNormalMapX: boolean;
  52302. /**
  52303. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52304. */
  52305. invertNormalMapY: boolean;
  52306. /**
  52307. * Normal map used in the model.
  52308. */
  52309. normalTexture: BaseTexture;
  52310. /**
  52311. * Emissivie color used to self-illuminate the model.
  52312. */
  52313. emissiveColor: Color3;
  52314. /**
  52315. * Emissivie texture used to self-illuminate the model.
  52316. */
  52317. emissiveTexture: BaseTexture;
  52318. /**
  52319. * Occlusion Channel Strenght.
  52320. */
  52321. occlusionStrength: number;
  52322. /**
  52323. * Occlusion Texture of the material (adding extra occlusion effects).
  52324. */
  52325. occlusionTexture: BaseTexture;
  52326. /**
  52327. * Defines the alpha limits in alpha test mode.
  52328. */
  52329. alphaCutOff: number;
  52330. /**
  52331. * Gets the current double sided mode.
  52332. */
  52333. /**
  52334. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52335. */
  52336. doubleSided: boolean;
  52337. /**
  52338. * Stores the pre-calculated light information of a mesh in a texture.
  52339. */
  52340. lightmapTexture: BaseTexture;
  52341. /**
  52342. * If true, the light map contains occlusion information instead of lighting info.
  52343. */
  52344. useLightmapAsShadowmap: boolean;
  52345. /**
  52346. * Instantiates a new PBRMaterial instance.
  52347. *
  52348. * @param name The material name
  52349. * @param scene The scene the material will be use in.
  52350. */
  52351. constructor(name: string, scene: Scene);
  52352. getClassName(): string;
  52353. }
  52354. }
  52355. declare module BABYLON {
  52356. /**
  52357. * The PBR material of BJS following the metal roughness convention.
  52358. *
  52359. * This fits to the PBR convention in the GLTF definition:
  52360. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52361. */
  52362. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52363. /**
  52364. * The base color has two different interpretations depending on the value of metalness.
  52365. * When the material is a metal, the base color is the specific measured reflectance value
  52366. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52367. * of the material.
  52368. */
  52369. baseColor: Color3;
  52370. /**
  52371. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52372. * well as opacity information in the alpha channel.
  52373. */
  52374. baseTexture: BaseTexture;
  52375. /**
  52376. * Specifies the metallic scalar value of the material.
  52377. * Can also be used to scale the metalness values of the metallic texture.
  52378. */
  52379. metallic: number;
  52380. /**
  52381. * Specifies the roughness scalar value of the material.
  52382. * Can also be used to scale the roughness values of the metallic texture.
  52383. */
  52384. roughness: number;
  52385. /**
  52386. * Texture containing both the metallic value in the B channel and the
  52387. * roughness value in the G channel to keep better precision.
  52388. */
  52389. metallicRoughnessTexture: BaseTexture;
  52390. /**
  52391. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52392. *
  52393. * @param name The material name
  52394. * @param scene The scene the material will be use in.
  52395. */
  52396. constructor(name: string, scene: Scene);
  52397. /**
  52398. * Return the currrent class name of the material.
  52399. */
  52400. getClassName(): string;
  52401. /**
  52402. * Makes a duplicate of the current material.
  52403. * @param name - name to use for the new material.
  52404. */
  52405. clone(name: string): PBRMetallicRoughnessMaterial;
  52406. /**
  52407. * Serialize the material to a parsable JSON object.
  52408. */
  52409. serialize(): any;
  52410. /**
  52411. * Parses a JSON object correponding to the serialize function.
  52412. */
  52413. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52414. }
  52415. }
  52416. declare module BABYLON {
  52417. /**
  52418. * The PBR material of BJS following the specular glossiness convention.
  52419. *
  52420. * This fits to the PBR convention in the GLTF definition:
  52421. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52422. */
  52423. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52424. /**
  52425. * Specifies the diffuse color of the material.
  52426. */
  52427. diffuseColor: Color3;
  52428. /**
  52429. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52430. * channel.
  52431. */
  52432. diffuseTexture: BaseTexture;
  52433. /**
  52434. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52435. */
  52436. specularColor: Color3;
  52437. /**
  52438. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52439. */
  52440. glossiness: number;
  52441. /**
  52442. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52443. */
  52444. specularGlossinessTexture: BaseTexture;
  52445. /**
  52446. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52447. *
  52448. * @param name The material name
  52449. * @param scene The scene the material will be use in.
  52450. */
  52451. constructor(name: string, scene: Scene);
  52452. /**
  52453. * Return the currrent class name of the material.
  52454. */
  52455. getClassName(): string;
  52456. /**
  52457. * Makes a duplicate of the current material.
  52458. * @param name - name to use for the new material.
  52459. */
  52460. clone(name: string): PBRSpecularGlossinessMaterial;
  52461. /**
  52462. * Serialize the material to a parsable JSON object.
  52463. */
  52464. serialize(): any;
  52465. /**
  52466. * Parses a JSON object correponding to the serialize function.
  52467. */
  52468. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52469. }
  52470. }
  52471. declare module BABYLON {
  52472. /**
  52473. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52474. * It can help converting any input color in a desired output one. This can then be used to create effects
  52475. * from sepia, black and white to sixties or futuristic rendering...
  52476. *
  52477. * The only supported format is currently 3dl.
  52478. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52479. */
  52480. export class ColorGradingTexture extends BaseTexture {
  52481. /**
  52482. * The current texture matrix. (will always be identity in color grading texture)
  52483. */
  52484. private _textureMatrix;
  52485. /**
  52486. * The texture URL.
  52487. */
  52488. url: string;
  52489. /**
  52490. * Empty line regex stored for GC.
  52491. */
  52492. private static _noneEmptyLineRegex;
  52493. private _engine;
  52494. /**
  52495. * Instantiates a ColorGradingTexture from the following parameters.
  52496. *
  52497. * @param url The location of the color gradind data (currently only supporting 3dl)
  52498. * @param scene The scene the texture will be used in
  52499. */
  52500. constructor(url: string, scene: Scene);
  52501. /**
  52502. * Returns the texture matrix used in most of the material.
  52503. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52504. */
  52505. getTextureMatrix(): Matrix;
  52506. /**
  52507. * Occurs when the file being loaded is a .3dl LUT file.
  52508. */
  52509. private load3dlTexture;
  52510. /**
  52511. * Starts the loading process of the texture.
  52512. */
  52513. private loadTexture;
  52514. /**
  52515. * Clones the color gradind texture.
  52516. */
  52517. clone(): ColorGradingTexture;
  52518. /**
  52519. * Called during delayed load for textures.
  52520. */
  52521. delayLoad(): void;
  52522. /**
  52523. * Parses a color grading texture serialized by Babylon.
  52524. * @param parsedTexture The texture information being parsedTexture
  52525. * @param scene The scene to load the texture in
  52526. * @param rootUrl The root url of the data assets to load
  52527. * @return A color gradind texture
  52528. */
  52529. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52530. /**
  52531. * Serializes the LUT texture to json format.
  52532. */
  52533. serialize(): any;
  52534. }
  52535. }
  52536. declare module BABYLON {
  52537. /**
  52538. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52539. */
  52540. export class EquiRectangularCubeTexture extends BaseTexture {
  52541. /** The six faces of the cube. */
  52542. private static _FacesMapping;
  52543. private _noMipmap;
  52544. private _onLoad;
  52545. private _onError;
  52546. /** The size of the cubemap. */
  52547. private _size;
  52548. /** The buffer of the image. */
  52549. private _buffer;
  52550. /** The width of the input image. */
  52551. private _width;
  52552. /** The height of the input image. */
  52553. private _height;
  52554. /** The URL to the image. */
  52555. url: string;
  52556. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52557. coordinatesMode: number;
  52558. /**
  52559. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52560. * @param url The location of the image
  52561. * @param scene The scene the texture will be used in
  52562. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52563. * @param noMipmap Forces to not generate the mipmap if true
  52564. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52565. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52566. * @param onLoad — defines a callback called when texture is loaded
  52567. * @param onError — defines a callback called if there is an error
  52568. */
  52569. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52570. /**
  52571. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52572. */
  52573. private loadImage;
  52574. /**
  52575. * Convert the image buffer into a cubemap and create a CubeTexture.
  52576. */
  52577. private loadTexture;
  52578. /**
  52579. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52580. * @param buffer The ArrayBuffer that should be converted.
  52581. * @returns The buffer as Float32Array.
  52582. */
  52583. private getFloat32ArrayFromArrayBuffer;
  52584. /**
  52585. * Get the current class name of the texture useful for serialization or dynamic coding.
  52586. * @returns "EquiRectangularCubeTexture"
  52587. */
  52588. getClassName(): string;
  52589. /**
  52590. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52591. * @returns A clone of the current EquiRectangularCubeTexture.
  52592. */
  52593. clone(): EquiRectangularCubeTexture;
  52594. }
  52595. }
  52596. declare module BABYLON {
  52597. /**
  52598. * Based on jsTGALoader - Javascript loader for TGA file
  52599. * By Vincent Thibault
  52600. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52601. */
  52602. export class TGATools {
  52603. private static _TYPE_INDEXED;
  52604. private static _TYPE_RGB;
  52605. private static _TYPE_GREY;
  52606. private static _TYPE_RLE_INDEXED;
  52607. private static _TYPE_RLE_RGB;
  52608. private static _TYPE_RLE_GREY;
  52609. private static _ORIGIN_MASK;
  52610. private static _ORIGIN_SHIFT;
  52611. private static _ORIGIN_BL;
  52612. private static _ORIGIN_BR;
  52613. private static _ORIGIN_UL;
  52614. private static _ORIGIN_UR;
  52615. /**
  52616. * Gets the header of a TGA file
  52617. * @param data defines the TGA data
  52618. * @returns the header
  52619. */
  52620. static GetTGAHeader(data: Uint8Array): any;
  52621. /**
  52622. * Uploads TGA content to a Babylon Texture
  52623. * @hidden
  52624. */
  52625. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52626. /** @hidden */
  52627. 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;
  52628. /** @hidden */
  52629. 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;
  52630. /** @hidden */
  52631. 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;
  52632. /** @hidden */
  52633. 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;
  52634. /** @hidden */
  52635. 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;
  52636. /** @hidden */
  52637. 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;
  52638. }
  52639. }
  52640. declare module BABYLON {
  52641. /**
  52642. * Implementation of the TGA Texture Loader.
  52643. * @hidden
  52644. */
  52645. export class _TGATextureLoader implements IInternalTextureLoader {
  52646. /**
  52647. * Defines wether the loader supports cascade loading the different faces.
  52648. */
  52649. readonly supportCascades: boolean;
  52650. /**
  52651. * This returns if the loader support the current file information.
  52652. * @param extension defines the file extension of the file being loaded
  52653. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52654. * @param fallback defines the fallback internal texture if any
  52655. * @param isBase64 defines whether the texture is encoded as a base64
  52656. * @param isBuffer defines whether the texture data are stored as a buffer
  52657. * @returns true if the loader can load the specified file
  52658. */
  52659. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52660. /**
  52661. * Transform the url before loading if required.
  52662. * @param rootUrl the url of the texture
  52663. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52664. * @returns the transformed texture
  52665. */
  52666. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52667. /**
  52668. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52669. * @param rootUrl the url of the texture
  52670. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52671. * @returns the fallback texture
  52672. */
  52673. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52674. /**
  52675. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52676. * @param data contains the texture data
  52677. * @param texture defines the BabylonJS internal texture
  52678. * @param createPolynomials will be true if polynomials have been requested
  52679. * @param onLoad defines the callback to trigger once the texture is ready
  52680. * @param onError defines the callback to trigger in case of error
  52681. */
  52682. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52683. /**
  52684. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52685. * @param data contains the texture data
  52686. * @param texture defines the BabylonJS internal texture
  52687. * @param callback defines the method to call once ready to upload
  52688. */
  52689. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52690. }
  52691. }
  52692. declare module BABYLON {
  52693. /**
  52694. * Info about the .basis files
  52695. */
  52696. class BasisFileInfo {
  52697. /**
  52698. * If the file has alpha
  52699. */
  52700. hasAlpha: boolean;
  52701. /**
  52702. * Info about each image of the basis file
  52703. */
  52704. images: Array<{
  52705. levels: Array<{
  52706. width: number;
  52707. height: number;
  52708. transcodedPixels: ArrayBufferView;
  52709. }>;
  52710. }>;
  52711. }
  52712. /**
  52713. * Result of transcoding a basis file
  52714. */
  52715. class TranscodeResult {
  52716. /**
  52717. * Info about the .basis file
  52718. */
  52719. fileInfo: BasisFileInfo;
  52720. /**
  52721. * Format to use when loading the file
  52722. */
  52723. format: number;
  52724. }
  52725. /**
  52726. * Configuration options for the Basis transcoder
  52727. */
  52728. export class BasisTranscodeConfiguration {
  52729. /**
  52730. * Supported compression formats used to determine the supported output format of the transcoder
  52731. */
  52732. supportedCompressionFormats?: {
  52733. /**
  52734. * etc1 compression format
  52735. */
  52736. etc1?: boolean;
  52737. /**
  52738. * s3tc compression format
  52739. */
  52740. s3tc?: boolean;
  52741. /**
  52742. * pvrtc compression format
  52743. */
  52744. pvrtc?: boolean;
  52745. /**
  52746. * etc2 compression format
  52747. */
  52748. etc2?: boolean;
  52749. };
  52750. /**
  52751. * If mipmap levels should be loaded for transcoded images (Default: true)
  52752. */
  52753. loadMipmapLevels?: boolean;
  52754. /**
  52755. * Index of a single image to load (Default: all images)
  52756. */
  52757. loadSingleImage?: number;
  52758. }
  52759. /**
  52760. * Used to load .Basis files
  52761. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52762. */
  52763. export class BasisTools {
  52764. private static _IgnoreSupportedFormats;
  52765. /**
  52766. * URL to use when loading the basis transcoder
  52767. */
  52768. static JSModuleURL: string;
  52769. /**
  52770. * URL to use when loading the wasm module for the transcoder
  52771. */
  52772. static WasmModuleURL: string;
  52773. /**
  52774. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52775. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52776. * @returns internal format corresponding to the Basis format
  52777. */
  52778. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52779. private static _WorkerPromise;
  52780. private static _Worker;
  52781. private static _actionId;
  52782. private static _CreateWorkerAsync;
  52783. /**
  52784. * Transcodes a loaded image file to compressed pixel data
  52785. * @param imageData image data to transcode
  52786. * @param config configuration options for the transcoding
  52787. * @returns a promise resulting in the transcoded image
  52788. */
  52789. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52790. /**
  52791. * Loads a texture from the transcode result
  52792. * @param texture texture load to
  52793. * @param transcodeResult the result of transcoding the basis file to load from
  52794. */
  52795. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52796. }
  52797. }
  52798. declare module BABYLON {
  52799. /**
  52800. * Loader for .basis file format
  52801. */
  52802. export class _BasisTextureLoader implements IInternalTextureLoader {
  52803. /**
  52804. * Defines whether the loader supports cascade loading the different faces.
  52805. */
  52806. readonly supportCascades: boolean;
  52807. /**
  52808. * This returns if the loader support the current file information.
  52809. * @param extension defines the file extension of the file being loaded
  52810. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52811. * @param fallback defines the fallback internal texture if any
  52812. * @param isBase64 defines whether the texture is encoded as a base64
  52813. * @param isBuffer defines whether the texture data are stored as a buffer
  52814. * @returns true if the loader can load the specified file
  52815. */
  52816. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52817. /**
  52818. * Transform the url before loading if required.
  52819. * @param rootUrl the url of the texture
  52820. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52821. * @returns the transformed texture
  52822. */
  52823. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52824. /**
  52825. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52826. * @param rootUrl the url of the texture
  52827. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52828. * @returns the fallback texture
  52829. */
  52830. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52831. /**
  52832. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52833. * @param data contains the texture data
  52834. * @param texture defines the BabylonJS internal texture
  52835. * @param createPolynomials will be true if polynomials have been requested
  52836. * @param onLoad defines the callback to trigger once the texture is ready
  52837. * @param onError defines the callback to trigger in case of error
  52838. */
  52839. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52840. /**
  52841. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52842. * @param data contains the texture data
  52843. * @param texture defines the BabylonJS internal texture
  52844. * @param callback defines the method to call once ready to upload
  52845. */
  52846. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52847. }
  52848. }
  52849. declare module BABYLON {
  52850. /**
  52851. * 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.
  52852. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52853. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52854. */
  52855. export class CustomProceduralTexture extends ProceduralTexture {
  52856. private _animate;
  52857. private _time;
  52858. private _config;
  52859. private _texturePath;
  52860. /**
  52861. * Instantiates a new Custom Procedural Texture.
  52862. * 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.
  52863. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52864. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52865. * @param name Define the name of the texture
  52866. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52867. * @param size Define the size of the texture to create
  52868. * @param scene Define the scene the texture belongs to
  52869. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52870. * @param generateMipMaps Define if the texture should creates mip maps or not
  52871. */
  52872. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52873. private _loadJson;
  52874. /**
  52875. * Is the texture ready to be used ? (rendered at least once)
  52876. * @returns true if ready, otherwise, false.
  52877. */
  52878. isReady(): boolean;
  52879. /**
  52880. * Render the texture to its associated render target.
  52881. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52882. */
  52883. render(useCameraPostProcess?: boolean): void;
  52884. /**
  52885. * Update the list of dependant textures samplers in the shader.
  52886. */
  52887. updateTextures(): void;
  52888. /**
  52889. * Update the uniform values of the procedural texture in the shader.
  52890. */
  52891. updateShaderUniforms(): void;
  52892. /**
  52893. * Define if the texture animates or not.
  52894. */
  52895. animate: boolean;
  52896. }
  52897. }
  52898. declare module BABYLON {
  52899. /** @hidden */
  52900. export var noisePixelShader: {
  52901. name: string;
  52902. shader: string;
  52903. };
  52904. }
  52905. declare module BABYLON {
  52906. /**
  52907. * Class used to generate noise procedural textures
  52908. */
  52909. export class NoiseProceduralTexture extends ProceduralTexture {
  52910. private _time;
  52911. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52912. brightness: number;
  52913. /** Defines the number of octaves to process */
  52914. octaves: number;
  52915. /** Defines the level of persistence (0.8 by default) */
  52916. persistence: number;
  52917. /** Gets or sets animation speed factor (default is 1) */
  52918. animationSpeedFactor: number;
  52919. /**
  52920. * Creates a new NoiseProceduralTexture
  52921. * @param name defines the name fo the texture
  52922. * @param size defines the size of the texture (default is 256)
  52923. * @param scene defines the hosting scene
  52924. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52925. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52926. */
  52927. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52928. private _updateShaderUniforms;
  52929. protected _getDefines(): string;
  52930. /** Generate the current state of the procedural texture */
  52931. render(useCameraPostProcess?: boolean): void;
  52932. /**
  52933. * Serializes this noise procedural texture
  52934. * @returns a serialized noise procedural texture object
  52935. */
  52936. serialize(): any;
  52937. /**
  52938. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52939. * @param parsedTexture defines parsed texture data
  52940. * @param scene defines the current scene
  52941. * @param rootUrl defines the root URL containing noise procedural texture information
  52942. * @returns a parsed NoiseProceduralTexture
  52943. */
  52944. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52945. }
  52946. }
  52947. declare module BABYLON {
  52948. /**
  52949. * Raw cube texture where the raw buffers are passed in
  52950. */
  52951. export class RawCubeTexture extends CubeTexture {
  52952. /**
  52953. * Creates a cube texture where the raw buffers are passed in.
  52954. * @param scene defines the scene the texture is attached to
  52955. * @param data defines the array of data to use to create each face
  52956. * @param size defines the size of the textures
  52957. * @param format defines the format of the data
  52958. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52959. * @param generateMipMaps defines if the engine should generate the mip levels
  52960. * @param invertY defines if data must be stored with Y axis inverted
  52961. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52962. * @param compression defines the compression used (null by default)
  52963. */
  52964. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52965. /**
  52966. * Updates the raw cube texture.
  52967. * @param data defines the data to store
  52968. * @param format defines the data format
  52969. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52970. * @param invertY defines if data must be stored with Y axis inverted
  52971. * @param compression defines the compression used (null by default)
  52972. * @param level defines which level of the texture to update
  52973. */
  52974. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52975. /**
  52976. * Updates a raw cube texture with RGBD encoded data.
  52977. * @param data defines the array of data [mipmap][face] to use to create each face
  52978. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52979. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52980. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52981. * @returns a promsie that resolves when the operation is complete
  52982. */
  52983. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52984. /**
  52985. * Clones the raw cube texture.
  52986. * @return a new cube texture
  52987. */
  52988. clone(): CubeTexture;
  52989. /** @hidden */
  52990. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52991. }
  52992. }
  52993. declare module BABYLON {
  52994. /**
  52995. * Class used to store 3D textures containing user data
  52996. */
  52997. export class RawTexture3D extends Texture {
  52998. /** Gets or sets the texture format to use */
  52999. format: number;
  53000. private _engine;
  53001. /**
  53002. * Create a new RawTexture3D
  53003. * @param data defines the data of the texture
  53004. * @param width defines the width of the texture
  53005. * @param height defines the height of the texture
  53006. * @param depth defines the depth of the texture
  53007. * @param format defines the texture format to use
  53008. * @param scene defines the hosting scene
  53009. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53010. * @param invertY defines if texture must be stored with Y axis inverted
  53011. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53012. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53013. */
  53014. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53015. /** Gets or sets the texture format to use */
  53016. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53017. /**
  53018. * Update the texture with new data
  53019. * @param data defines the data to store in the texture
  53020. */
  53021. update(data: ArrayBufferView): void;
  53022. }
  53023. }
  53024. declare module BABYLON {
  53025. /**
  53026. * Class used to store 2D array textures containing user data
  53027. */
  53028. export class RawTexture2DArray extends Texture {
  53029. /** Gets or sets the texture format to use */
  53030. format: number;
  53031. private _engine;
  53032. /**
  53033. * Create a new RawTexture2DArray
  53034. * @param data defines the data of the texture
  53035. * @param width defines the width of the texture
  53036. * @param height defines the height of the texture
  53037. * @param depth defines the number of layers of the texture
  53038. * @param format defines the texture format to use
  53039. * @param scene defines the hosting scene
  53040. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53041. * @param invertY defines if texture must be stored with Y axis inverted
  53042. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53043. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53044. */
  53045. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53046. /** Gets or sets the texture format to use */
  53047. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53048. /**
  53049. * Update the texture with new data
  53050. * @param data defines the data to store in the texture
  53051. */
  53052. update(data: ArrayBufferView): void;
  53053. }
  53054. }
  53055. declare module BABYLON {
  53056. /**
  53057. * Creates a refraction texture used by refraction channel of the standard material.
  53058. * It is like a mirror but to see through a material.
  53059. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53060. */
  53061. export class RefractionTexture extends RenderTargetTexture {
  53062. /**
  53063. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53064. * 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.
  53065. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53066. */
  53067. refractionPlane: Plane;
  53068. /**
  53069. * Define how deep under the surface we should see.
  53070. */
  53071. depth: number;
  53072. /**
  53073. * Creates a refraction texture used by refraction channel of the standard material.
  53074. * It is like a mirror but to see through a material.
  53075. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53076. * @param name Define the texture name
  53077. * @param size Define the size of the underlying texture
  53078. * @param scene Define the scene the refraction belongs to
  53079. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53080. */
  53081. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53082. /**
  53083. * Clone the refraction texture.
  53084. * @returns the cloned texture
  53085. */
  53086. clone(): RefractionTexture;
  53087. /**
  53088. * Serialize the texture to a JSON representation you could use in Parse later on
  53089. * @returns the serialized JSON representation
  53090. */
  53091. serialize(): any;
  53092. }
  53093. }
  53094. declare module BABYLON {
  53095. /**
  53096. * Defines the options related to the creation of an HtmlElementTexture
  53097. */
  53098. export interface IHtmlElementTextureOptions {
  53099. /**
  53100. * Defines wether mip maps should be created or not.
  53101. */
  53102. generateMipMaps?: boolean;
  53103. /**
  53104. * Defines the sampling mode of the texture.
  53105. */
  53106. samplingMode?: number;
  53107. /**
  53108. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53109. */
  53110. engine: Nullable<ThinEngine>;
  53111. /**
  53112. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53113. */
  53114. scene: Nullable<Scene>;
  53115. }
  53116. /**
  53117. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53118. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53119. * is automatically managed.
  53120. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53121. * in your application.
  53122. *
  53123. * As the update is not automatic, you need to call them manually.
  53124. */
  53125. export class HtmlElementTexture extends BaseTexture {
  53126. /**
  53127. * The texture URL.
  53128. */
  53129. element: HTMLVideoElement | HTMLCanvasElement;
  53130. private static readonly DefaultOptions;
  53131. private _textureMatrix;
  53132. private _engine;
  53133. private _isVideo;
  53134. private _generateMipMaps;
  53135. private _samplingMode;
  53136. /**
  53137. * Instantiates a HtmlElementTexture from the following parameters.
  53138. *
  53139. * @param name Defines the name of the texture
  53140. * @param element Defines the video or canvas the texture is filled with
  53141. * @param options Defines the other none mandatory texture creation options
  53142. */
  53143. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53144. private _createInternalTexture;
  53145. /**
  53146. * Returns the texture matrix used in most of the material.
  53147. */
  53148. getTextureMatrix(): Matrix;
  53149. /**
  53150. * Updates the content of the texture.
  53151. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53152. */
  53153. update(invertY?: Nullable<boolean>): void;
  53154. }
  53155. }
  53156. declare module BABYLON {
  53157. /**
  53158. * Enum used to define the target of a block
  53159. */
  53160. export enum NodeMaterialBlockTargets {
  53161. /** Vertex shader */
  53162. Vertex = 1,
  53163. /** Fragment shader */
  53164. Fragment = 2,
  53165. /** Neutral */
  53166. Neutral = 4,
  53167. /** Vertex and Fragment */
  53168. VertexAndFragment = 3
  53169. }
  53170. }
  53171. declare module BABYLON {
  53172. /**
  53173. * Defines the kind of connection point for node based material
  53174. */
  53175. export enum NodeMaterialBlockConnectionPointTypes {
  53176. /** Float */
  53177. Float = 1,
  53178. /** Int */
  53179. Int = 2,
  53180. /** Vector2 */
  53181. Vector2 = 4,
  53182. /** Vector3 */
  53183. Vector3 = 8,
  53184. /** Vector4 */
  53185. Vector4 = 16,
  53186. /** Color3 */
  53187. Color3 = 32,
  53188. /** Color4 */
  53189. Color4 = 64,
  53190. /** Matrix */
  53191. Matrix = 128,
  53192. /** Detect type based on connection */
  53193. AutoDetect = 1024,
  53194. /** Output type that will be defined by input type */
  53195. BasedOnInput = 2048
  53196. }
  53197. }
  53198. declare module BABYLON {
  53199. /**
  53200. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53201. */
  53202. export enum NodeMaterialBlockConnectionPointMode {
  53203. /** Value is an uniform */
  53204. Uniform = 0,
  53205. /** Value is a mesh attribute */
  53206. Attribute = 1,
  53207. /** Value is a varying between vertex and fragment shaders */
  53208. Varying = 2,
  53209. /** Mode is undefined */
  53210. Undefined = 3
  53211. }
  53212. }
  53213. declare module BABYLON {
  53214. /**
  53215. * Enum used to define system values e.g. values automatically provided by the system
  53216. */
  53217. export enum NodeMaterialSystemValues {
  53218. /** World */
  53219. World = 1,
  53220. /** View */
  53221. View = 2,
  53222. /** Projection */
  53223. Projection = 3,
  53224. /** ViewProjection */
  53225. ViewProjection = 4,
  53226. /** WorldView */
  53227. WorldView = 5,
  53228. /** WorldViewProjection */
  53229. WorldViewProjection = 6,
  53230. /** CameraPosition */
  53231. CameraPosition = 7,
  53232. /** Fog Color */
  53233. FogColor = 8,
  53234. /** Delta time */
  53235. DeltaTime = 9
  53236. }
  53237. }
  53238. declare module BABYLON {
  53239. /**
  53240. * Root class for all node material optimizers
  53241. */
  53242. export class NodeMaterialOptimizer {
  53243. /**
  53244. * Function used to optimize a NodeMaterial graph
  53245. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53246. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53247. */
  53248. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53249. }
  53250. }
  53251. declare module BABYLON {
  53252. /**
  53253. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53254. */
  53255. export class TransformBlock extends NodeMaterialBlock {
  53256. /**
  53257. * Defines the value to use to complement W value to transform it to a Vector4
  53258. */
  53259. complementW: number;
  53260. /**
  53261. * Defines the value to use to complement z value to transform it to a Vector4
  53262. */
  53263. complementZ: number;
  53264. /**
  53265. * Creates a new TransformBlock
  53266. * @param name defines the block name
  53267. */
  53268. constructor(name: string);
  53269. /**
  53270. * Gets the current class name
  53271. * @returns the class name
  53272. */
  53273. getClassName(): string;
  53274. /**
  53275. * Gets the vector input
  53276. */
  53277. readonly vector: NodeMaterialConnectionPoint;
  53278. /**
  53279. * Gets the output component
  53280. */
  53281. readonly output: NodeMaterialConnectionPoint;
  53282. /**
  53283. * Gets the matrix transform input
  53284. */
  53285. readonly transform: NodeMaterialConnectionPoint;
  53286. protected _buildBlock(state: NodeMaterialBuildState): this;
  53287. serialize(): any;
  53288. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53289. protected _dumpPropertiesCode(): string;
  53290. }
  53291. }
  53292. declare module BABYLON {
  53293. /**
  53294. * Block used to output the vertex position
  53295. */
  53296. export class VertexOutputBlock extends NodeMaterialBlock {
  53297. /**
  53298. * Creates a new VertexOutputBlock
  53299. * @param name defines the block name
  53300. */
  53301. constructor(name: string);
  53302. /**
  53303. * Gets the current class name
  53304. * @returns the class name
  53305. */
  53306. getClassName(): string;
  53307. /**
  53308. * Gets the vector input component
  53309. */
  53310. readonly vector: NodeMaterialConnectionPoint;
  53311. protected _buildBlock(state: NodeMaterialBuildState): this;
  53312. }
  53313. }
  53314. declare module BABYLON {
  53315. /**
  53316. * Block used to output the final color
  53317. */
  53318. export class FragmentOutputBlock extends NodeMaterialBlock {
  53319. /**
  53320. * Create a new FragmentOutputBlock
  53321. * @param name defines the block name
  53322. */
  53323. constructor(name: string);
  53324. /**
  53325. * Gets the current class name
  53326. * @returns the class name
  53327. */
  53328. getClassName(): string;
  53329. /**
  53330. * Gets the rgba input component
  53331. */
  53332. readonly rgba: NodeMaterialConnectionPoint;
  53333. /**
  53334. * Gets the rgb input component
  53335. */
  53336. readonly rgb: NodeMaterialConnectionPoint;
  53337. /**
  53338. * Gets the a input component
  53339. */
  53340. readonly a: NodeMaterialConnectionPoint;
  53341. protected _buildBlock(state: NodeMaterialBuildState): this;
  53342. }
  53343. }
  53344. declare module BABYLON {
  53345. /**
  53346. * Block used to read a reflection texture from a sampler
  53347. */
  53348. export class ReflectionTextureBlock extends NodeMaterialBlock {
  53349. private _define3DName;
  53350. private _defineCubicName;
  53351. private _defineExplicitName;
  53352. private _defineProjectionName;
  53353. private _defineLocalCubicName;
  53354. private _defineSphericalName;
  53355. private _definePlanarName;
  53356. private _defineEquirectangularName;
  53357. private _defineMirroredEquirectangularFixedName;
  53358. private _defineEquirectangularFixedName;
  53359. private _defineSkyboxName;
  53360. private _cubeSamplerName;
  53361. private _2DSamplerName;
  53362. private _positionUVWName;
  53363. private _directionWName;
  53364. private _reflectionCoordsName;
  53365. private _reflection2DCoordsName;
  53366. private _reflectionColorName;
  53367. private _reflectionMatrixName;
  53368. /**
  53369. * Gets or sets the texture associated with the node
  53370. */
  53371. texture: Nullable<BaseTexture>;
  53372. /**
  53373. * Create a new TextureBlock
  53374. * @param name defines the block name
  53375. */
  53376. constructor(name: string);
  53377. /**
  53378. * Gets the current class name
  53379. * @returns the class name
  53380. */
  53381. getClassName(): string;
  53382. /**
  53383. * Gets the world position input component
  53384. */
  53385. readonly position: NodeMaterialConnectionPoint;
  53386. /**
  53387. * Gets the world position input component
  53388. */
  53389. readonly worldPosition: NodeMaterialConnectionPoint;
  53390. /**
  53391. * Gets the world normal input component
  53392. */
  53393. readonly worldNormal: NodeMaterialConnectionPoint;
  53394. /**
  53395. * Gets the world input component
  53396. */
  53397. readonly world: NodeMaterialConnectionPoint;
  53398. /**
  53399. * Gets the camera (or eye) position component
  53400. */
  53401. readonly cameraPosition: NodeMaterialConnectionPoint;
  53402. /**
  53403. * Gets the view input component
  53404. */
  53405. readonly view: NodeMaterialConnectionPoint;
  53406. /**
  53407. * Gets the rgb output component
  53408. */
  53409. readonly rgb: NodeMaterialConnectionPoint;
  53410. /**
  53411. * Gets the r output component
  53412. */
  53413. readonly r: NodeMaterialConnectionPoint;
  53414. /**
  53415. * Gets the g output component
  53416. */
  53417. readonly g: NodeMaterialConnectionPoint;
  53418. /**
  53419. * Gets the b output component
  53420. */
  53421. readonly b: NodeMaterialConnectionPoint;
  53422. autoConfigure(material: NodeMaterial): void;
  53423. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53424. isReady(): boolean;
  53425. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53426. private _injectVertexCode;
  53427. private _writeOutput;
  53428. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53429. protected _dumpPropertiesCode(): string;
  53430. serialize(): any;
  53431. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53432. }
  53433. }
  53434. declare module BABYLON {
  53435. /**
  53436. * Interface used to configure the node material editor
  53437. */
  53438. export interface INodeMaterialEditorOptions {
  53439. /** Define the URl to load node editor script */
  53440. editorURL?: string;
  53441. }
  53442. /** @hidden */
  53443. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53444. /** BONES */
  53445. NUM_BONE_INFLUENCERS: number;
  53446. BonesPerMesh: number;
  53447. BONETEXTURE: boolean;
  53448. /** MORPH TARGETS */
  53449. MORPHTARGETS: boolean;
  53450. MORPHTARGETS_NORMAL: boolean;
  53451. MORPHTARGETS_TANGENT: boolean;
  53452. MORPHTARGETS_UV: boolean;
  53453. NUM_MORPH_INFLUENCERS: number;
  53454. /** IMAGE PROCESSING */
  53455. IMAGEPROCESSING: boolean;
  53456. VIGNETTE: boolean;
  53457. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53458. VIGNETTEBLENDMODEOPAQUE: boolean;
  53459. TONEMAPPING: boolean;
  53460. TONEMAPPING_ACES: boolean;
  53461. CONTRAST: boolean;
  53462. EXPOSURE: boolean;
  53463. COLORCURVES: boolean;
  53464. COLORGRADING: boolean;
  53465. COLORGRADING3D: boolean;
  53466. SAMPLER3DGREENDEPTH: boolean;
  53467. SAMPLER3DBGRMAP: boolean;
  53468. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53469. /** MISC. */
  53470. BUMPDIRECTUV: number;
  53471. constructor();
  53472. setValue(name: string, value: boolean): void;
  53473. }
  53474. /**
  53475. * Class used to configure NodeMaterial
  53476. */
  53477. export interface INodeMaterialOptions {
  53478. /**
  53479. * Defines if blocks should emit comments
  53480. */
  53481. emitComments: boolean;
  53482. }
  53483. /**
  53484. * Class used to create a node based material built by assembling shader blocks
  53485. */
  53486. export class NodeMaterial extends PushMaterial {
  53487. private static _BuildIdGenerator;
  53488. private _options;
  53489. private _vertexCompilationState;
  53490. private _fragmentCompilationState;
  53491. private _sharedData;
  53492. private _buildId;
  53493. private _buildWasSuccessful;
  53494. private _cachedWorldViewMatrix;
  53495. private _cachedWorldViewProjectionMatrix;
  53496. private _optimizers;
  53497. private _animationFrame;
  53498. /** Define the URl to load node editor script */
  53499. static EditorURL: string;
  53500. private BJSNODEMATERIALEDITOR;
  53501. /** Get the inspector from bundle or global */
  53502. private _getGlobalNodeMaterialEditor;
  53503. /**
  53504. * 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)
  53505. */
  53506. ignoreAlpha: boolean;
  53507. /**
  53508. * Defines the maximum number of lights that can be used in the material
  53509. */
  53510. maxSimultaneousLights: number;
  53511. /**
  53512. * Observable raised when the material is built
  53513. */
  53514. onBuildObservable: Observable<NodeMaterial>;
  53515. /**
  53516. * Gets or sets the root nodes of the material vertex shader
  53517. */
  53518. _vertexOutputNodes: NodeMaterialBlock[];
  53519. /**
  53520. * Gets or sets the root nodes of the material fragment (pixel) shader
  53521. */
  53522. _fragmentOutputNodes: NodeMaterialBlock[];
  53523. /** Gets or sets options to control the node material overall behavior */
  53524. options: INodeMaterialOptions;
  53525. /**
  53526. * Default configuration related to image processing available in the standard Material.
  53527. */
  53528. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53529. /**
  53530. * Gets the image processing configuration used either in this material.
  53531. */
  53532. /**
  53533. * Sets the Default image processing configuration used either in the this material.
  53534. *
  53535. * If sets to null, the scene one is in use.
  53536. */
  53537. imageProcessingConfiguration: ImageProcessingConfiguration;
  53538. /**
  53539. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  53540. */
  53541. attachedBlocks: NodeMaterialBlock[];
  53542. /**
  53543. * Create a new node based material
  53544. * @param name defines the material name
  53545. * @param scene defines the hosting scene
  53546. * @param options defines creation option
  53547. */
  53548. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53549. /**
  53550. * Gets the current class name of the material e.g. "NodeMaterial"
  53551. * @returns the class name
  53552. */
  53553. getClassName(): string;
  53554. /**
  53555. * Keep track of the image processing observer to allow dispose and replace.
  53556. */
  53557. private _imageProcessingObserver;
  53558. /**
  53559. * Attaches a new image processing configuration to the Standard Material.
  53560. * @param configuration
  53561. */
  53562. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53563. /**
  53564. * Get a block by its name
  53565. * @param name defines the name of the block to retrieve
  53566. * @returns the required block or null if not found
  53567. */
  53568. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  53569. /**
  53570. * Get a block by its name
  53571. * @param predicate defines the predicate used to find the good candidate
  53572. * @returns the required block or null if not found
  53573. */
  53574. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  53575. /**
  53576. * Get an input block by its name
  53577. * @param predicate defines the predicate used to find the good candidate
  53578. * @returns the required input block or null if not found
  53579. */
  53580. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  53581. /**
  53582. * Gets the list of input blocks attached to this material
  53583. * @returns an array of InputBlocks
  53584. */
  53585. getInputBlocks(): InputBlock[];
  53586. /**
  53587. * Adds a new optimizer to the list of optimizers
  53588. * @param optimizer defines the optimizers to add
  53589. * @returns the current material
  53590. */
  53591. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53592. /**
  53593. * Remove an optimizer from the list of optimizers
  53594. * @param optimizer defines the optimizers to remove
  53595. * @returns the current material
  53596. */
  53597. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53598. /**
  53599. * Add a new block to the list of output nodes
  53600. * @param node defines the node to add
  53601. * @returns the current material
  53602. */
  53603. addOutputNode(node: NodeMaterialBlock): this;
  53604. /**
  53605. * Remove a block from the list of root nodes
  53606. * @param node defines the node to remove
  53607. * @returns the current material
  53608. */
  53609. removeOutputNode(node: NodeMaterialBlock): this;
  53610. private _addVertexOutputNode;
  53611. private _removeVertexOutputNode;
  53612. private _addFragmentOutputNode;
  53613. private _removeFragmentOutputNode;
  53614. /**
  53615. * Specifies if the material will require alpha blending
  53616. * @returns a boolean specifying if alpha blending is needed
  53617. */
  53618. needAlphaBlending(): boolean;
  53619. /**
  53620. * Specifies if this material should be rendered in alpha test mode
  53621. * @returns a boolean specifying if an alpha test is needed.
  53622. */
  53623. needAlphaTesting(): boolean;
  53624. private _initializeBlock;
  53625. private _resetDualBlocks;
  53626. /**
  53627. * Build the material and generates the inner effect
  53628. * @param verbose defines if the build should log activity
  53629. */
  53630. build(verbose?: boolean): void;
  53631. /**
  53632. * Runs an otpimization phase to try to improve the shader code
  53633. */
  53634. optimize(): void;
  53635. private _prepareDefinesForAttributes;
  53636. /**
  53637. * Get if the submesh is ready to be used and all its information available.
  53638. * Child classes can use it to update shaders
  53639. * @param mesh defines the mesh to check
  53640. * @param subMesh defines which submesh to check
  53641. * @param useInstances specifies that instances should be used
  53642. * @returns a boolean indicating that the submesh is ready or not
  53643. */
  53644. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53645. /**
  53646. * Get a string representing the shaders built by the current node graph
  53647. */
  53648. readonly compiledShaders: string;
  53649. /**
  53650. * Binds the world matrix to the material
  53651. * @param world defines the world transformation matrix
  53652. */
  53653. bindOnlyWorldMatrix(world: Matrix): void;
  53654. /**
  53655. * Binds the submesh to this material by preparing the effect and shader to draw
  53656. * @param world defines the world transformation matrix
  53657. * @param mesh defines the mesh containing the submesh
  53658. * @param subMesh defines the submesh to bind the material to
  53659. */
  53660. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53661. /**
  53662. * Gets the active textures from the material
  53663. * @returns an array of textures
  53664. */
  53665. getActiveTextures(): BaseTexture[];
  53666. /**
  53667. * Gets the list of texture blocks
  53668. * @returns an array of texture blocks
  53669. */
  53670. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  53671. /**
  53672. * Specifies if the material uses a texture
  53673. * @param texture defines the texture to check against the material
  53674. * @returns a boolean specifying if the material uses the texture
  53675. */
  53676. hasTexture(texture: BaseTexture): boolean;
  53677. /**
  53678. * Disposes the material
  53679. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53680. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53681. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53682. */
  53683. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53684. /** Creates the node editor window. */
  53685. private _createNodeEditor;
  53686. /**
  53687. * Launch the node material editor
  53688. * @param config Define the configuration of the editor
  53689. * @return a promise fulfilled when the node editor is visible
  53690. */
  53691. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53692. /**
  53693. * Clear the current material
  53694. */
  53695. clear(): void;
  53696. /**
  53697. * Clear the current material and set it to a default state
  53698. */
  53699. setToDefault(): void;
  53700. /**
  53701. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  53702. * @param url defines the url to load from
  53703. * @returns a promise that will fullfil when the material is fully loaded
  53704. */
  53705. loadAsync(url: string): Promise<void>;
  53706. private _gatherBlocks;
  53707. /**
  53708. * Generate a string containing the code declaration required to create an equivalent of this material
  53709. * @returns a string
  53710. */
  53711. generateCode(): string;
  53712. /**
  53713. * Serializes this material in a JSON representation
  53714. * @returns the serialized material object
  53715. */
  53716. serialize(): any;
  53717. private _restoreConnections;
  53718. /**
  53719. * Clear the current graph and load a new one from a serialization object
  53720. * @param source defines the JSON representation of the material
  53721. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53722. */
  53723. loadFromSerialization(source: any, rootUrl?: string): void;
  53724. /**
  53725. * Creates a node material from parsed material data
  53726. * @param source defines the JSON representation of the material
  53727. * @param scene defines the hosting scene
  53728. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53729. * @returns a new node material
  53730. */
  53731. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53732. /**
  53733. * Creates a new node material set to default basic configuration
  53734. * @param name defines the name of the material
  53735. * @param scene defines the hosting scene
  53736. * @returns a new NodeMaterial
  53737. */
  53738. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53739. }
  53740. }
  53741. declare module BABYLON {
  53742. /**
  53743. * Block used to read a texture from a sampler
  53744. */
  53745. export class TextureBlock extends NodeMaterialBlock {
  53746. private _defineName;
  53747. private _linearDefineName;
  53748. private _samplerName;
  53749. private _transformedUVName;
  53750. private _textureTransformName;
  53751. private _textureInfoName;
  53752. private _mainUVName;
  53753. private _mainUVDefineName;
  53754. /**
  53755. * Gets or sets the texture associated with the node
  53756. */
  53757. texture: Nullable<Texture>;
  53758. /**
  53759. * Create a new TextureBlock
  53760. * @param name defines the block name
  53761. */
  53762. constructor(name: string);
  53763. /**
  53764. * Gets the current class name
  53765. * @returns the class name
  53766. */
  53767. getClassName(): string;
  53768. /**
  53769. * Gets the uv input component
  53770. */
  53771. readonly uv: NodeMaterialConnectionPoint;
  53772. /**
  53773. * Gets the rgba output component
  53774. */
  53775. readonly rgba: NodeMaterialConnectionPoint;
  53776. /**
  53777. * Gets the rgb output component
  53778. */
  53779. readonly rgb: NodeMaterialConnectionPoint;
  53780. /**
  53781. * Gets the r output component
  53782. */
  53783. readonly r: NodeMaterialConnectionPoint;
  53784. /**
  53785. * Gets the g output component
  53786. */
  53787. readonly g: NodeMaterialConnectionPoint;
  53788. /**
  53789. * Gets the b output component
  53790. */
  53791. readonly b: NodeMaterialConnectionPoint;
  53792. /**
  53793. * Gets the a output component
  53794. */
  53795. readonly a: NodeMaterialConnectionPoint;
  53796. readonly target: NodeMaterialBlockTargets;
  53797. autoConfigure(material: NodeMaterial): void;
  53798. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53799. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53800. isReady(): boolean;
  53801. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53802. private readonly _isMixed;
  53803. private _injectVertexCode;
  53804. private _writeOutput;
  53805. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53806. protected _dumpPropertiesCode(): string;
  53807. serialize(): any;
  53808. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53809. }
  53810. }
  53811. declare module BABYLON {
  53812. /**
  53813. * Class used to store shared data between 2 NodeMaterialBuildState
  53814. */
  53815. export class NodeMaterialBuildStateSharedData {
  53816. /**
  53817. * Gets the list of emitted varyings
  53818. */
  53819. temps: string[];
  53820. /**
  53821. * Gets the list of emitted varyings
  53822. */
  53823. varyings: string[];
  53824. /**
  53825. * Gets the varying declaration string
  53826. */
  53827. varyingDeclaration: string;
  53828. /**
  53829. * Input blocks
  53830. */
  53831. inputBlocks: InputBlock[];
  53832. /**
  53833. * Input blocks
  53834. */
  53835. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53836. /**
  53837. * Bindable blocks (Blocks that need to set data to the effect)
  53838. */
  53839. bindableBlocks: NodeMaterialBlock[];
  53840. /**
  53841. * List of blocks that can provide a compilation fallback
  53842. */
  53843. blocksWithFallbacks: NodeMaterialBlock[];
  53844. /**
  53845. * List of blocks that can provide a define update
  53846. */
  53847. blocksWithDefines: NodeMaterialBlock[];
  53848. /**
  53849. * List of blocks that can provide a repeatable content
  53850. */
  53851. repeatableContentBlocks: NodeMaterialBlock[];
  53852. /**
  53853. * List of blocks that can provide a dynamic list of uniforms
  53854. */
  53855. dynamicUniformBlocks: NodeMaterialBlock[];
  53856. /**
  53857. * List of blocks that can block the isReady function for the material
  53858. */
  53859. blockingBlocks: NodeMaterialBlock[];
  53860. /**
  53861. * Gets the list of animated inputs
  53862. */
  53863. animatedInputs: InputBlock[];
  53864. /**
  53865. * Build Id used to avoid multiple recompilations
  53866. */
  53867. buildId: number;
  53868. /** List of emitted variables */
  53869. variableNames: {
  53870. [key: string]: number;
  53871. };
  53872. /** List of emitted defines */
  53873. defineNames: {
  53874. [key: string]: number;
  53875. };
  53876. /** Should emit comments? */
  53877. emitComments: boolean;
  53878. /** Emit build activity */
  53879. verbose: boolean;
  53880. /** Gets or sets the hosting scene */
  53881. scene: Scene;
  53882. /**
  53883. * Gets the compilation hints emitted at compilation time
  53884. */
  53885. hints: {
  53886. needWorldViewMatrix: boolean;
  53887. needWorldViewProjectionMatrix: boolean;
  53888. needAlphaBlending: boolean;
  53889. needAlphaTesting: boolean;
  53890. };
  53891. /**
  53892. * List of compilation checks
  53893. */
  53894. checks: {
  53895. emitVertex: boolean;
  53896. emitFragment: boolean;
  53897. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53898. };
  53899. /** Creates a new shared data */
  53900. constructor();
  53901. /**
  53902. * Emits console errors and exceptions if there is a failing check
  53903. */
  53904. emitErrors(): void;
  53905. }
  53906. }
  53907. declare module BABYLON {
  53908. /**
  53909. * Class used to store node based material build state
  53910. */
  53911. export class NodeMaterialBuildState {
  53912. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53913. supportUniformBuffers: boolean;
  53914. /**
  53915. * Gets the list of emitted attributes
  53916. */
  53917. attributes: string[];
  53918. /**
  53919. * Gets the list of emitted uniforms
  53920. */
  53921. uniforms: string[];
  53922. /**
  53923. * Gets the list of emitted constants
  53924. */
  53925. constants: string[];
  53926. /**
  53927. * Gets the list of emitted samplers
  53928. */
  53929. samplers: string[];
  53930. /**
  53931. * Gets the list of emitted functions
  53932. */
  53933. functions: {
  53934. [key: string]: string;
  53935. };
  53936. /**
  53937. * Gets the list of emitted extensions
  53938. */
  53939. extensions: {
  53940. [key: string]: string;
  53941. };
  53942. /**
  53943. * Gets the target of the compilation state
  53944. */
  53945. target: NodeMaterialBlockTargets;
  53946. /**
  53947. * Gets the list of emitted counters
  53948. */
  53949. counters: {
  53950. [key: string]: number;
  53951. };
  53952. /**
  53953. * Shared data between multiple NodeMaterialBuildState instances
  53954. */
  53955. sharedData: NodeMaterialBuildStateSharedData;
  53956. /** @hidden */
  53957. _vertexState: NodeMaterialBuildState;
  53958. /** @hidden */
  53959. _attributeDeclaration: string;
  53960. /** @hidden */
  53961. _uniformDeclaration: string;
  53962. /** @hidden */
  53963. _constantDeclaration: string;
  53964. /** @hidden */
  53965. _samplerDeclaration: string;
  53966. /** @hidden */
  53967. _varyingTransfer: string;
  53968. private _repeatableContentAnchorIndex;
  53969. /** @hidden */
  53970. _builtCompilationString: string;
  53971. /**
  53972. * Gets the emitted compilation strings
  53973. */
  53974. compilationString: string;
  53975. /**
  53976. * Finalize the compilation strings
  53977. * @param state defines the current compilation state
  53978. */
  53979. finalize(state: NodeMaterialBuildState): void;
  53980. /** @hidden */
  53981. readonly _repeatableContentAnchor: string;
  53982. /** @hidden */
  53983. _getFreeVariableName(prefix: string): string;
  53984. /** @hidden */
  53985. _getFreeDefineName(prefix: string): string;
  53986. /** @hidden */
  53987. _excludeVariableName(name: string): void;
  53988. /** @hidden */
  53989. _emit2DSampler(name: string): void;
  53990. /** @hidden */
  53991. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53992. /** @hidden */
  53993. _emitExtension(name: string, extension: string): void;
  53994. /** @hidden */
  53995. _emitFunction(name: string, code: string, comments: string): void;
  53996. /** @hidden */
  53997. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53998. replaceStrings?: {
  53999. search: RegExp;
  54000. replace: string;
  54001. }[];
  54002. repeatKey?: string;
  54003. }): string;
  54004. /** @hidden */
  54005. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54006. repeatKey?: string;
  54007. removeAttributes?: boolean;
  54008. removeUniforms?: boolean;
  54009. removeVaryings?: boolean;
  54010. removeIfDef?: boolean;
  54011. replaceStrings?: {
  54012. search: RegExp;
  54013. replace: string;
  54014. }[];
  54015. }, storeKey?: string): void;
  54016. /** @hidden */
  54017. _registerTempVariable(name: string): boolean;
  54018. /** @hidden */
  54019. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  54020. /** @hidden */
  54021. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54022. /** @hidden */
  54023. _emitFloat(value: number): string;
  54024. }
  54025. }
  54026. declare module BABYLON {
  54027. /**
  54028. * Defines a block that can be used inside a node based material
  54029. */
  54030. export class NodeMaterialBlock {
  54031. private _buildId;
  54032. private _buildTarget;
  54033. private _target;
  54034. private _isFinalMerger;
  54035. private _isInput;
  54036. protected _isUnique: boolean;
  54037. /** @hidden */
  54038. _codeVariableName: string;
  54039. /** @hidden */
  54040. _inputs: NodeMaterialConnectionPoint[];
  54041. /** @hidden */
  54042. _outputs: NodeMaterialConnectionPoint[];
  54043. /** @hidden */
  54044. _preparationId: number;
  54045. /**
  54046. * Gets or sets the name of the block
  54047. */
  54048. name: string;
  54049. /**
  54050. * Gets or sets the unique id of the node
  54051. */
  54052. uniqueId: number;
  54053. /**
  54054. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  54055. */
  54056. readonly isUnique: boolean;
  54057. /**
  54058. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54059. */
  54060. readonly isFinalMerger: boolean;
  54061. /**
  54062. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54063. */
  54064. readonly isInput: boolean;
  54065. /**
  54066. * Gets or sets the build Id
  54067. */
  54068. buildId: number;
  54069. /**
  54070. * Gets or sets the target of the block
  54071. */
  54072. target: NodeMaterialBlockTargets;
  54073. /**
  54074. * Gets the list of input points
  54075. */
  54076. readonly inputs: NodeMaterialConnectionPoint[];
  54077. /** Gets the list of output points */
  54078. readonly outputs: NodeMaterialConnectionPoint[];
  54079. /**
  54080. * Find an input by its name
  54081. * @param name defines the name of the input to look for
  54082. * @returns the input or null if not found
  54083. */
  54084. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54085. /**
  54086. * Find an output by its name
  54087. * @param name defines the name of the outputto look for
  54088. * @returns the output or null if not found
  54089. */
  54090. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54091. /**
  54092. * Creates a new NodeMaterialBlock
  54093. * @param name defines the block name
  54094. * @param target defines the target of that block (Vertex by default)
  54095. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54096. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54097. */
  54098. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54099. /**
  54100. * Initialize the block and prepare the context for build
  54101. * @param state defines the state that will be used for the build
  54102. */
  54103. initialize(state: NodeMaterialBuildState): void;
  54104. /**
  54105. * Bind data to effect. Will only be called for blocks with isBindable === true
  54106. * @param effect defines the effect to bind data to
  54107. * @param nodeMaterial defines the hosting NodeMaterial
  54108. * @param mesh defines the mesh that will be rendered
  54109. */
  54110. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54111. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54112. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54113. protected _writeFloat(value: number): string;
  54114. /**
  54115. * Gets the current class name e.g. "NodeMaterialBlock"
  54116. * @returns the class name
  54117. */
  54118. getClassName(): string;
  54119. /**
  54120. * Register a new input. Must be called inside a block constructor
  54121. * @param name defines the connection point name
  54122. * @param type defines the connection point type
  54123. * @param isOptional defines a boolean indicating that this input can be omitted
  54124. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  54125. * @returns the current block
  54126. */
  54127. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54128. /**
  54129. * Register a new output. Must be called inside a block constructor
  54130. * @param name defines the connection point name
  54131. * @param type defines the connection point type
  54132. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  54133. * @returns the current block
  54134. */
  54135. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54136. /**
  54137. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54138. * @param forOutput defines an optional connection point to check compatibility with
  54139. * @returns the first available input or null
  54140. */
  54141. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54142. /**
  54143. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54144. * @param forBlock defines an optional block to check compatibility with
  54145. * @returns the first available input or null
  54146. */
  54147. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54148. /**
  54149. * Gets the sibling of the given output
  54150. * @param current defines the current output
  54151. * @returns the next output in the list or null
  54152. */
  54153. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  54154. /**
  54155. * Connect current block with another block
  54156. * @param other defines the block to connect with
  54157. * @param options define the various options to help pick the right connections
  54158. * @returns the current block
  54159. */
  54160. connectTo(other: NodeMaterialBlock, options?: {
  54161. input?: string;
  54162. output?: string;
  54163. outputSwizzle?: string;
  54164. }): this | undefined;
  54165. protected _buildBlock(state: NodeMaterialBuildState): void;
  54166. /**
  54167. * Add uniforms, samplers and uniform buffers at compilation time
  54168. * @param state defines the state to update
  54169. * @param nodeMaterial defines the node material requesting the update
  54170. * @param defines defines the material defines to update
  54171. * @param uniformBuffers defines the list of uniform buffer names
  54172. */
  54173. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54174. /**
  54175. * Add potential fallbacks if shader compilation fails
  54176. * @param mesh defines the mesh to be rendered
  54177. * @param fallbacks defines the current prioritized list of fallbacks
  54178. */
  54179. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54180. /**
  54181. * Initialize defines for shader compilation
  54182. * @param mesh defines the mesh to be rendered
  54183. * @param nodeMaterial defines the node material requesting the update
  54184. * @param defines defines the material defines to update
  54185. * @param useInstances specifies that instances should be used
  54186. */
  54187. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54188. /**
  54189. * Update defines for shader compilation
  54190. * @param mesh defines the mesh to be rendered
  54191. * @param nodeMaterial defines the node material requesting the update
  54192. * @param defines defines the material defines to update
  54193. * @param useInstances specifies that instances should be used
  54194. */
  54195. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54196. /**
  54197. * Lets the block try to connect some inputs automatically
  54198. * @param material defines the hosting NodeMaterial
  54199. */
  54200. autoConfigure(material: NodeMaterial): void;
  54201. /**
  54202. * Function called when a block is declared as repeatable content generator
  54203. * @param vertexShaderState defines the current compilation state for the vertex shader
  54204. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54205. * @param mesh defines the mesh to be rendered
  54206. * @param defines defines the material defines to update
  54207. */
  54208. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54209. /**
  54210. * Checks if the block is ready
  54211. * @param mesh defines the mesh to be rendered
  54212. * @param nodeMaterial defines the node material requesting the update
  54213. * @param defines defines the material defines to update
  54214. * @param useInstances specifies that instances should be used
  54215. * @returns true if the block is ready
  54216. */
  54217. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54218. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  54219. private _processBuild;
  54220. /**
  54221. * Compile the current node and generate the shader code
  54222. * @param state defines the current compilation state (uniforms, samplers, current string)
  54223. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  54224. * @returns true if already built
  54225. */
  54226. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  54227. protected _inputRename(name: string): string;
  54228. protected _outputRename(name: string): string;
  54229. protected _dumpPropertiesCode(): string;
  54230. /** @hidden */
  54231. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  54232. /** @hidden */
  54233. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  54234. /**
  54235. * Clone the current block to a new identical block
  54236. * @param scene defines the hosting scene
  54237. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54238. * @returns a copy of the current block
  54239. */
  54240. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  54241. /**
  54242. * Serializes this block in a JSON representation
  54243. * @returns the serialized block object
  54244. */
  54245. serialize(): any;
  54246. /** @hidden */
  54247. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54248. /**
  54249. * Release resources
  54250. */
  54251. dispose(): void;
  54252. }
  54253. }
  54254. declare module BABYLON {
  54255. /**
  54256. * Enum defining the type of animations supported by InputBlock
  54257. */
  54258. export enum AnimatedInputBlockTypes {
  54259. /** No animation */
  54260. None = 0,
  54261. /** Time based animation. Will only work for floats */
  54262. Time = 1
  54263. }
  54264. }
  54265. declare module BABYLON {
  54266. /**
  54267. * Block used to expose an input value
  54268. */
  54269. export class InputBlock extends NodeMaterialBlock {
  54270. private _mode;
  54271. private _associatedVariableName;
  54272. private _storedValue;
  54273. private _valueCallback;
  54274. private _type;
  54275. private _animationType;
  54276. /** Gets or set a value used to limit the range of float values */
  54277. min: number;
  54278. /** Gets or set a value used to limit the range of float values */
  54279. max: number;
  54280. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  54281. matrixMode: number;
  54282. /** @hidden */
  54283. _systemValue: Nullable<NodeMaterialSystemValues>;
  54284. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  54285. visibleInInspector: boolean;
  54286. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  54287. isConstant: boolean;
  54288. /**
  54289. * Gets or sets the connection point type (default is float)
  54290. */
  54291. readonly type: NodeMaterialBlockConnectionPointTypes;
  54292. /**
  54293. * Creates a new InputBlock
  54294. * @param name defines the block name
  54295. * @param target defines the target of that block (Vertex by default)
  54296. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54297. */
  54298. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54299. /**
  54300. * Gets the output component
  54301. */
  54302. readonly output: NodeMaterialConnectionPoint;
  54303. /**
  54304. * Set the source of this connection point to a vertex attribute
  54305. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54306. * @returns the current connection point
  54307. */
  54308. setAsAttribute(attributeName?: string): InputBlock;
  54309. /**
  54310. * Set the source of this connection point to a system value
  54311. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  54312. * @returns the current connection point
  54313. */
  54314. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  54315. /**
  54316. * Gets or sets the value of that point.
  54317. * Please note that this value will be ignored if valueCallback is defined
  54318. */
  54319. value: any;
  54320. /**
  54321. * Gets or sets a callback used to get the value of that point.
  54322. * Please note that setting this value will force the connection point to ignore the value property
  54323. */
  54324. valueCallback: () => any;
  54325. /**
  54326. * Gets or sets the associated variable name in the shader
  54327. */
  54328. associatedVariableName: string;
  54329. /** Gets or sets the type of animation applied to the input */
  54330. animationType: AnimatedInputBlockTypes;
  54331. /**
  54332. * Gets a boolean indicating that this connection point not defined yet
  54333. */
  54334. readonly isUndefined: boolean;
  54335. /**
  54336. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54337. * In this case the connection point name must be the name of the uniform to use.
  54338. * Can only be set on inputs
  54339. */
  54340. isUniform: boolean;
  54341. /**
  54342. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54343. * In this case the connection point name must be the name of the attribute to use
  54344. * Can only be set on inputs
  54345. */
  54346. isAttribute: boolean;
  54347. /**
  54348. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54349. * Can only be set on exit points
  54350. */
  54351. isVarying: boolean;
  54352. /**
  54353. * Gets a boolean indicating that the current connection point is a system value
  54354. */
  54355. readonly isSystemValue: boolean;
  54356. /**
  54357. * Gets or sets the current well known value or null if not defined as a system value
  54358. */
  54359. systemValue: Nullable<NodeMaterialSystemValues>;
  54360. /**
  54361. * Gets the current class name
  54362. * @returns the class name
  54363. */
  54364. getClassName(): string;
  54365. /**
  54366. * Animate the input if animationType !== None
  54367. * @param scene defines the rendering scene
  54368. */
  54369. animate(scene: Scene): void;
  54370. private _emitDefine;
  54371. initialize(state: NodeMaterialBuildState): void;
  54372. /**
  54373. * Set the input block to its default value (based on its type)
  54374. */
  54375. setDefaultValue(): void;
  54376. private _emitConstant;
  54377. private _emit;
  54378. /** @hidden */
  54379. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54380. /** @hidden */
  54381. _transmit(effect: Effect, scene: Scene): void;
  54382. protected _buildBlock(state: NodeMaterialBuildState): void;
  54383. protected _dumpPropertiesCode(): string;
  54384. serialize(): any;
  54385. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54386. }
  54387. }
  54388. declare module BABYLON {
  54389. /**
  54390. * Enum used to define the compatibility state between two connection points
  54391. */
  54392. export enum NodeMaterialConnectionPointCompatibilityStates {
  54393. /** Points are compatibles */
  54394. Compatible = 0,
  54395. /** Points are incompatible because of their types */
  54396. TypeIncompatible = 1,
  54397. /** Points are incompatible because of their targets (vertex vs fragment) */
  54398. TargetIncompatible = 2
  54399. }
  54400. /**
  54401. * Defines a connection point for a block
  54402. */
  54403. export class NodeMaterialConnectionPoint {
  54404. /** @hidden */
  54405. _ownerBlock: NodeMaterialBlock;
  54406. /** @hidden */
  54407. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54408. private _endpoints;
  54409. private _associatedVariableName;
  54410. /** @hidden */
  54411. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54412. /** @hidden */
  54413. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54414. private _type;
  54415. /** @hidden */
  54416. _enforceAssociatedVariableName: boolean;
  54417. /**
  54418. * Gets or sets the additional types supported by this connection point
  54419. */
  54420. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54421. /**
  54422. * Gets or sets the additional types excluded by this connection point
  54423. */
  54424. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54425. /**
  54426. * Observable triggered when this point is connected
  54427. */
  54428. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  54429. /**
  54430. * Gets or sets the associated variable name in the shader
  54431. */
  54432. associatedVariableName: string;
  54433. /**
  54434. * Gets or sets the connection point type (default is float)
  54435. */
  54436. type: NodeMaterialBlockConnectionPointTypes;
  54437. /**
  54438. * Gets or sets the connection point name
  54439. */
  54440. name: string;
  54441. /**
  54442. * Gets or sets a boolean indicating that this connection point can be omitted
  54443. */
  54444. isOptional: boolean;
  54445. /**
  54446. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54447. */
  54448. define: string;
  54449. /** @hidden */
  54450. _prioritizeVertex: boolean;
  54451. private _target;
  54452. /** Gets or sets the target of that connection point */
  54453. target: NodeMaterialBlockTargets;
  54454. /**
  54455. * Gets a boolean indicating that the current point is connected
  54456. */
  54457. readonly isConnected: boolean;
  54458. /**
  54459. * Gets a boolean indicating that the current point is connected to an input block
  54460. */
  54461. readonly isConnectedToInputBlock: boolean;
  54462. /**
  54463. * Gets a the connected input block (if any)
  54464. */
  54465. readonly connectInputBlock: Nullable<InputBlock>;
  54466. /** Get the other side of the connection (if any) */
  54467. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54468. /** Get the block that owns this connection point */
  54469. readonly ownerBlock: NodeMaterialBlock;
  54470. /** Get the block connected on the other side of this connection (if any) */
  54471. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54472. /** Get the block connected on the endpoints of this connection (if any) */
  54473. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54474. /** Gets the list of connected endpoints */
  54475. readonly endpoints: NodeMaterialConnectionPoint[];
  54476. /** Gets a boolean indicating if that output point is connected to at least one input */
  54477. readonly hasEndpoints: boolean;
  54478. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  54479. readonly isConnectedInVertexShader: boolean;
  54480. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  54481. readonly isConnectedInFragmentShader: boolean;
  54482. /**
  54483. * Creates a new connection point
  54484. * @param name defines the connection point name
  54485. * @param ownerBlock defines the block hosting this connection point
  54486. */
  54487. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54488. /**
  54489. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54490. * @returns the class name
  54491. */
  54492. getClassName(): string;
  54493. /**
  54494. * Gets a boolean indicating if the current point can be connected to another point
  54495. * @param connectionPoint defines the other connection point
  54496. * @returns a boolean
  54497. */
  54498. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54499. /**
  54500. * Gets a number indicating if the current point can be connected to another point
  54501. * @param connectionPoint defines the other connection point
  54502. * @returns a number defining the compatibility state
  54503. */
  54504. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  54505. /**
  54506. * Connect this point to another connection point
  54507. * @param connectionPoint defines the other connection point
  54508. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  54509. * @returns the current connection point
  54510. */
  54511. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  54512. /**
  54513. * Disconnect this point from one of his endpoint
  54514. * @param endpoint defines the other connection point
  54515. * @returns the current connection point
  54516. */
  54517. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54518. /**
  54519. * Serializes this point in a JSON representation
  54520. * @returns the serialized point object
  54521. */
  54522. serialize(): any;
  54523. /**
  54524. * Release resources
  54525. */
  54526. dispose(): void;
  54527. }
  54528. }
  54529. declare module BABYLON {
  54530. /**
  54531. * Block used to add support for vertex skinning (bones)
  54532. */
  54533. export class BonesBlock extends NodeMaterialBlock {
  54534. /**
  54535. * Creates a new BonesBlock
  54536. * @param name defines the block name
  54537. */
  54538. constructor(name: string);
  54539. /**
  54540. * Initialize the block and prepare the context for build
  54541. * @param state defines the state that will be used for the build
  54542. */
  54543. initialize(state: NodeMaterialBuildState): void;
  54544. /**
  54545. * Gets the current class name
  54546. * @returns the class name
  54547. */
  54548. getClassName(): string;
  54549. /**
  54550. * Gets the matrix indices input component
  54551. */
  54552. readonly matricesIndices: NodeMaterialConnectionPoint;
  54553. /**
  54554. * Gets the matrix weights input component
  54555. */
  54556. readonly matricesWeights: NodeMaterialConnectionPoint;
  54557. /**
  54558. * Gets the extra matrix indices input component
  54559. */
  54560. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54561. /**
  54562. * Gets the extra matrix weights input component
  54563. */
  54564. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54565. /**
  54566. * Gets the world input component
  54567. */
  54568. readonly world: NodeMaterialConnectionPoint;
  54569. /**
  54570. * Gets the output component
  54571. */
  54572. readonly output: NodeMaterialConnectionPoint;
  54573. autoConfigure(material: NodeMaterial): void;
  54574. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54575. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54576. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54577. protected _buildBlock(state: NodeMaterialBuildState): this;
  54578. }
  54579. }
  54580. declare module BABYLON {
  54581. /**
  54582. * Block used to add support for instances
  54583. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54584. */
  54585. export class InstancesBlock extends NodeMaterialBlock {
  54586. /**
  54587. * Creates a new InstancesBlock
  54588. * @param name defines the block name
  54589. */
  54590. constructor(name: string);
  54591. /**
  54592. * Gets the current class name
  54593. * @returns the class name
  54594. */
  54595. getClassName(): string;
  54596. /**
  54597. * Gets the first world row input component
  54598. */
  54599. readonly world0: NodeMaterialConnectionPoint;
  54600. /**
  54601. * Gets the second world row input component
  54602. */
  54603. readonly world1: NodeMaterialConnectionPoint;
  54604. /**
  54605. * Gets the third world row input component
  54606. */
  54607. readonly world2: NodeMaterialConnectionPoint;
  54608. /**
  54609. * Gets the forth world row input component
  54610. */
  54611. readonly world3: NodeMaterialConnectionPoint;
  54612. /**
  54613. * Gets the world input component
  54614. */
  54615. readonly world: NodeMaterialConnectionPoint;
  54616. /**
  54617. * Gets the output component
  54618. */
  54619. readonly output: NodeMaterialConnectionPoint;
  54620. autoConfigure(material: NodeMaterial): void;
  54621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54622. protected _buildBlock(state: NodeMaterialBuildState): this;
  54623. }
  54624. }
  54625. declare module BABYLON {
  54626. /**
  54627. * Block used to add morph targets support to vertex shader
  54628. */
  54629. export class MorphTargetsBlock extends NodeMaterialBlock {
  54630. private _repeatableContentAnchor;
  54631. private _repeatebleContentGenerated;
  54632. /**
  54633. * Create a new MorphTargetsBlock
  54634. * @param name defines the block name
  54635. */
  54636. constructor(name: string);
  54637. /**
  54638. * Gets the current class name
  54639. * @returns the class name
  54640. */
  54641. getClassName(): string;
  54642. /**
  54643. * Gets the position input component
  54644. */
  54645. readonly position: NodeMaterialConnectionPoint;
  54646. /**
  54647. * Gets the normal input component
  54648. */
  54649. readonly normal: NodeMaterialConnectionPoint;
  54650. /**
  54651. * Gets the tangent input component
  54652. */
  54653. readonly tangent: NodeMaterialConnectionPoint;
  54654. /**
  54655. * Gets the tangent input component
  54656. */
  54657. readonly uv: NodeMaterialConnectionPoint;
  54658. /**
  54659. * Gets the position output component
  54660. */
  54661. readonly positionOutput: NodeMaterialConnectionPoint;
  54662. /**
  54663. * Gets the normal output component
  54664. */
  54665. readonly normalOutput: NodeMaterialConnectionPoint;
  54666. /**
  54667. * Gets the tangent output component
  54668. */
  54669. readonly tangentOutput: NodeMaterialConnectionPoint;
  54670. /**
  54671. * Gets the tangent output component
  54672. */
  54673. readonly uvOutput: NodeMaterialConnectionPoint;
  54674. initialize(state: NodeMaterialBuildState): void;
  54675. autoConfigure(material: NodeMaterial): void;
  54676. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54677. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54678. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54679. protected _buildBlock(state: NodeMaterialBuildState): this;
  54680. }
  54681. }
  54682. declare module BABYLON {
  54683. /**
  54684. * Block used to get data information from a light
  54685. */
  54686. export class LightInformationBlock extends NodeMaterialBlock {
  54687. private _lightDataUniformName;
  54688. private _lightColorUniformName;
  54689. private _lightTypeDefineName;
  54690. /**
  54691. * Gets or sets the light associated with this block
  54692. */
  54693. light: Nullable<Light>;
  54694. /**
  54695. * Creates a new LightInformationBlock
  54696. * @param name defines the block name
  54697. */
  54698. constructor(name: string);
  54699. /**
  54700. * Gets the current class name
  54701. * @returns the class name
  54702. */
  54703. getClassName(): string;
  54704. /**
  54705. * Gets the world position input component
  54706. */
  54707. readonly worldPosition: NodeMaterialConnectionPoint;
  54708. /**
  54709. * Gets the direction output component
  54710. */
  54711. readonly direction: NodeMaterialConnectionPoint;
  54712. /**
  54713. * Gets the direction output component
  54714. */
  54715. readonly color: NodeMaterialConnectionPoint;
  54716. /**
  54717. * Gets the direction output component
  54718. */
  54719. readonly intensity: NodeMaterialConnectionPoint;
  54720. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54721. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54722. protected _buildBlock(state: NodeMaterialBuildState): this;
  54723. serialize(): any;
  54724. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54725. }
  54726. }
  54727. declare module BABYLON {
  54728. /**
  54729. * Block used to add image processing support to fragment shader
  54730. */
  54731. export class ImageProcessingBlock extends NodeMaterialBlock {
  54732. /**
  54733. * Create a new ImageProcessingBlock
  54734. * @param name defines the block name
  54735. */
  54736. constructor(name: string);
  54737. /**
  54738. * Gets the current class name
  54739. * @returns the class name
  54740. */
  54741. getClassName(): string;
  54742. /**
  54743. * Gets the color input component
  54744. */
  54745. readonly color: NodeMaterialConnectionPoint;
  54746. /**
  54747. * Gets the output component
  54748. */
  54749. readonly output: NodeMaterialConnectionPoint;
  54750. /**
  54751. * Initialize the block and prepare the context for build
  54752. * @param state defines the state that will be used for the build
  54753. */
  54754. initialize(state: NodeMaterialBuildState): void;
  54755. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54756. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54757. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54758. protected _buildBlock(state: NodeMaterialBuildState): this;
  54759. }
  54760. }
  54761. declare module BABYLON {
  54762. /**
  54763. * Block used to pertub normals based on a normal map
  54764. */
  54765. export class PerturbNormalBlock extends NodeMaterialBlock {
  54766. private _tangentSpaceParameterName;
  54767. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54768. invertX: boolean;
  54769. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54770. invertY: boolean;
  54771. /**
  54772. * Create a new PerturbNormalBlock
  54773. * @param name defines the block name
  54774. */
  54775. constructor(name: string);
  54776. /**
  54777. * Gets the current class name
  54778. * @returns the class name
  54779. */
  54780. getClassName(): string;
  54781. /**
  54782. * Gets the world position input component
  54783. */
  54784. readonly worldPosition: NodeMaterialConnectionPoint;
  54785. /**
  54786. * Gets the world normal input component
  54787. */
  54788. readonly worldNormal: NodeMaterialConnectionPoint;
  54789. /**
  54790. * Gets the uv input component
  54791. */
  54792. readonly uv: NodeMaterialConnectionPoint;
  54793. /**
  54794. * Gets the normal map color input component
  54795. */
  54796. readonly normalMapColor: NodeMaterialConnectionPoint;
  54797. /**
  54798. * Gets the strength input component
  54799. */
  54800. readonly strength: NodeMaterialConnectionPoint;
  54801. /**
  54802. * Gets the output component
  54803. */
  54804. readonly output: NodeMaterialConnectionPoint;
  54805. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54806. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54807. autoConfigure(material: NodeMaterial): void;
  54808. protected _buildBlock(state: NodeMaterialBuildState): this;
  54809. protected _dumpPropertiesCode(): string;
  54810. serialize(): any;
  54811. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54812. }
  54813. }
  54814. declare module BABYLON {
  54815. /**
  54816. * Block used to discard a pixel if a value is smaller than a cutoff
  54817. */
  54818. export class DiscardBlock extends NodeMaterialBlock {
  54819. /**
  54820. * Create a new DiscardBlock
  54821. * @param name defines the block name
  54822. */
  54823. constructor(name: string);
  54824. /**
  54825. * Gets the current class name
  54826. * @returns the class name
  54827. */
  54828. getClassName(): string;
  54829. /**
  54830. * Gets the color input component
  54831. */
  54832. readonly value: NodeMaterialConnectionPoint;
  54833. /**
  54834. * Gets the cutoff input component
  54835. */
  54836. readonly cutoff: NodeMaterialConnectionPoint;
  54837. protected _buildBlock(state: NodeMaterialBuildState): this;
  54838. }
  54839. }
  54840. declare module BABYLON {
  54841. /**
  54842. * Block used to test if the fragment shader is front facing
  54843. */
  54844. export class FrontFacingBlock extends NodeMaterialBlock {
  54845. /**
  54846. * Creates a new FrontFacingBlock
  54847. * @param name defines the block name
  54848. */
  54849. constructor(name: string);
  54850. /**
  54851. * Gets the current class name
  54852. * @returns the class name
  54853. */
  54854. getClassName(): string;
  54855. /**
  54856. * Gets the output component
  54857. */
  54858. readonly output: NodeMaterialConnectionPoint;
  54859. protected _buildBlock(state: NodeMaterialBuildState): this;
  54860. }
  54861. }
  54862. declare module BABYLON {
  54863. /**
  54864. * Block used to add support for scene fog
  54865. */
  54866. export class FogBlock extends NodeMaterialBlock {
  54867. private _fogDistanceName;
  54868. private _fogParameters;
  54869. /**
  54870. * Create a new FogBlock
  54871. * @param name defines the block name
  54872. */
  54873. constructor(name: string);
  54874. /**
  54875. * Gets the current class name
  54876. * @returns the class name
  54877. */
  54878. getClassName(): string;
  54879. /**
  54880. * Gets the world position input component
  54881. */
  54882. readonly worldPosition: NodeMaterialConnectionPoint;
  54883. /**
  54884. * Gets the view input component
  54885. */
  54886. readonly view: NodeMaterialConnectionPoint;
  54887. /**
  54888. * Gets the color input component
  54889. */
  54890. readonly input: NodeMaterialConnectionPoint;
  54891. /**
  54892. * Gets the fog color input component
  54893. */
  54894. readonly fogColor: NodeMaterialConnectionPoint;
  54895. /**
  54896. * Gets the output component
  54897. */
  54898. readonly output: NodeMaterialConnectionPoint;
  54899. autoConfigure(material: NodeMaterial): void;
  54900. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54901. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54902. protected _buildBlock(state: NodeMaterialBuildState): this;
  54903. }
  54904. }
  54905. declare module BABYLON {
  54906. /**
  54907. * Block used to add light in the fragment shader
  54908. */
  54909. export class LightBlock extends NodeMaterialBlock {
  54910. private _lightId;
  54911. /**
  54912. * Gets or sets the light associated with this block
  54913. */
  54914. light: Nullable<Light>;
  54915. /**
  54916. * Create a new LightBlock
  54917. * @param name defines the block name
  54918. */
  54919. constructor(name: string);
  54920. /**
  54921. * Gets the current class name
  54922. * @returns the class name
  54923. */
  54924. getClassName(): string;
  54925. /**
  54926. * Gets the world position input component
  54927. */
  54928. readonly worldPosition: NodeMaterialConnectionPoint;
  54929. /**
  54930. * Gets the world normal input component
  54931. */
  54932. readonly worldNormal: NodeMaterialConnectionPoint;
  54933. /**
  54934. * Gets the camera (or eye) position component
  54935. */
  54936. readonly cameraPosition: NodeMaterialConnectionPoint;
  54937. /**
  54938. * Gets the glossiness component
  54939. */
  54940. readonly glossiness: NodeMaterialConnectionPoint;
  54941. /**
  54942. * Gets the glossinness power component
  54943. */
  54944. readonly glossPower: NodeMaterialConnectionPoint;
  54945. /**
  54946. * Gets the diffuse color component
  54947. */
  54948. readonly diffuseColor: NodeMaterialConnectionPoint;
  54949. /**
  54950. * Gets the specular color component
  54951. */
  54952. readonly specularColor: NodeMaterialConnectionPoint;
  54953. /**
  54954. * Gets the diffuse output component
  54955. */
  54956. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54957. /**
  54958. * Gets the specular output component
  54959. */
  54960. readonly specularOutput: NodeMaterialConnectionPoint;
  54961. autoConfigure(material: NodeMaterial): void;
  54962. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54963. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54964. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54965. private _injectVertexCode;
  54966. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54967. serialize(): any;
  54968. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54969. }
  54970. }
  54971. declare module BABYLON {
  54972. /**
  54973. * Block used to multiply 2 values
  54974. */
  54975. export class MultiplyBlock extends NodeMaterialBlock {
  54976. /**
  54977. * Creates a new MultiplyBlock
  54978. * @param name defines the block name
  54979. */
  54980. constructor(name: string);
  54981. /**
  54982. * Gets the current class name
  54983. * @returns the class name
  54984. */
  54985. getClassName(): string;
  54986. /**
  54987. * Gets the left operand input component
  54988. */
  54989. readonly left: NodeMaterialConnectionPoint;
  54990. /**
  54991. * Gets the right operand input component
  54992. */
  54993. readonly right: NodeMaterialConnectionPoint;
  54994. /**
  54995. * Gets the output component
  54996. */
  54997. readonly output: NodeMaterialConnectionPoint;
  54998. protected _buildBlock(state: NodeMaterialBuildState): this;
  54999. }
  55000. }
  55001. declare module BABYLON {
  55002. /**
  55003. * Block used to add 2 vectors
  55004. */
  55005. export class AddBlock extends NodeMaterialBlock {
  55006. /**
  55007. * Creates a new AddBlock
  55008. * @param name defines the block name
  55009. */
  55010. constructor(name: string);
  55011. /**
  55012. * Gets the current class name
  55013. * @returns the class name
  55014. */
  55015. getClassName(): string;
  55016. /**
  55017. * Gets the left operand input component
  55018. */
  55019. readonly left: NodeMaterialConnectionPoint;
  55020. /**
  55021. * Gets the right operand input component
  55022. */
  55023. readonly right: NodeMaterialConnectionPoint;
  55024. /**
  55025. * Gets the output component
  55026. */
  55027. readonly output: NodeMaterialConnectionPoint;
  55028. protected _buildBlock(state: NodeMaterialBuildState): this;
  55029. }
  55030. }
  55031. declare module BABYLON {
  55032. /**
  55033. * Block used to scale a vector by a float
  55034. */
  55035. export class ScaleBlock extends NodeMaterialBlock {
  55036. /**
  55037. * Creates a new ScaleBlock
  55038. * @param name defines the block name
  55039. */
  55040. constructor(name: string);
  55041. /**
  55042. * Gets the current class name
  55043. * @returns the class name
  55044. */
  55045. getClassName(): string;
  55046. /**
  55047. * Gets the input component
  55048. */
  55049. readonly input: NodeMaterialConnectionPoint;
  55050. /**
  55051. * Gets the factor input component
  55052. */
  55053. readonly factor: NodeMaterialConnectionPoint;
  55054. /**
  55055. * Gets the output component
  55056. */
  55057. readonly output: NodeMaterialConnectionPoint;
  55058. protected _buildBlock(state: NodeMaterialBuildState): this;
  55059. }
  55060. }
  55061. declare module BABYLON {
  55062. /**
  55063. * Block used to clamp a float
  55064. */
  55065. export class ClampBlock extends NodeMaterialBlock {
  55066. /** Gets or sets the minimum range */
  55067. minimum: number;
  55068. /** Gets or sets the maximum range */
  55069. maximum: number;
  55070. /**
  55071. * Creates a new ClampBlock
  55072. * @param name defines the block name
  55073. */
  55074. constructor(name: string);
  55075. /**
  55076. * Gets the current class name
  55077. * @returns the class name
  55078. */
  55079. getClassName(): string;
  55080. /**
  55081. * Gets the value input component
  55082. */
  55083. readonly value: NodeMaterialConnectionPoint;
  55084. /**
  55085. * Gets the output component
  55086. */
  55087. readonly output: NodeMaterialConnectionPoint;
  55088. protected _buildBlock(state: NodeMaterialBuildState): this;
  55089. protected _dumpPropertiesCode(): string;
  55090. serialize(): any;
  55091. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55092. }
  55093. }
  55094. declare module BABYLON {
  55095. /**
  55096. * Block used to apply a cross product between 2 vectors
  55097. */
  55098. export class CrossBlock extends NodeMaterialBlock {
  55099. /**
  55100. * Creates a new CrossBlock
  55101. * @param name defines the block name
  55102. */
  55103. constructor(name: string);
  55104. /**
  55105. * Gets the current class name
  55106. * @returns the class name
  55107. */
  55108. getClassName(): string;
  55109. /**
  55110. * Gets the left operand input component
  55111. */
  55112. readonly left: NodeMaterialConnectionPoint;
  55113. /**
  55114. * Gets the right operand input component
  55115. */
  55116. readonly right: NodeMaterialConnectionPoint;
  55117. /**
  55118. * Gets the output component
  55119. */
  55120. readonly output: NodeMaterialConnectionPoint;
  55121. protected _buildBlock(state: NodeMaterialBuildState): this;
  55122. }
  55123. }
  55124. declare module BABYLON {
  55125. /**
  55126. * Block used to apply a dot product between 2 vectors
  55127. */
  55128. export class DotBlock extends NodeMaterialBlock {
  55129. /**
  55130. * Creates a new DotBlock
  55131. * @param name defines the block name
  55132. */
  55133. constructor(name: string);
  55134. /**
  55135. * Gets the current class name
  55136. * @returns the class name
  55137. */
  55138. getClassName(): string;
  55139. /**
  55140. * Gets the left operand input component
  55141. */
  55142. readonly left: NodeMaterialConnectionPoint;
  55143. /**
  55144. * Gets the right operand input component
  55145. */
  55146. readonly right: NodeMaterialConnectionPoint;
  55147. /**
  55148. * Gets the output component
  55149. */
  55150. readonly output: NodeMaterialConnectionPoint;
  55151. protected _buildBlock(state: NodeMaterialBuildState): this;
  55152. }
  55153. }
  55154. declare module BABYLON {
  55155. /**
  55156. * Block used to remap a float from a range to a new one
  55157. */
  55158. export class RemapBlock extends NodeMaterialBlock {
  55159. /**
  55160. * Gets or sets the source range
  55161. */
  55162. sourceRange: Vector2;
  55163. /**
  55164. * Gets or sets the target range
  55165. */
  55166. targetRange: Vector2;
  55167. /**
  55168. * Creates a new RemapBlock
  55169. * @param name defines the block name
  55170. */
  55171. constructor(name: string);
  55172. /**
  55173. * Gets the current class name
  55174. * @returns the class name
  55175. */
  55176. getClassName(): string;
  55177. /**
  55178. * Gets the input component
  55179. */
  55180. readonly input: NodeMaterialConnectionPoint;
  55181. /**
  55182. * Gets the source min input component
  55183. */
  55184. readonly sourceMin: NodeMaterialConnectionPoint;
  55185. /**
  55186. * Gets the source max input component
  55187. */
  55188. readonly sourceMax: NodeMaterialConnectionPoint;
  55189. /**
  55190. * Gets the target min input component
  55191. */
  55192. readonly targetMin: NodeMaterialConnectionPoint;
  55193. /**
  55194. * Gets the target max input component
  55195. */
  55196. readonly targetMax: NodeMaterialConnectionPoint;
  55197. /**
  55198. * Gets the output component
  55199. */
  55200. readonly output: NodeMaterialConnectionPoint;
  55201. protected _buildBlock(state: NodeMaterialBuildState): this;
  55202. protected _dumpPropertiesCode(): string;
  55203. serialize(): any;
  55204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55205. }
  55206. }
  55207. declare module BABYLON {
  55208. /**
  55209. * Block used to normalize a vector
  55210. */
  55211. export class NormalizeBlock extends NodeMaterialBlock {
  55212. /**
  55213. * Creates a new NormalizeBlock
  55214. * @param name defines the block name
  55215. */
  55216. constructor(name: string);
  55217. /**
  55218. * Gets the current class name
  55219. * @returns the class name
  55220. */
  55221. getClassName(): string;
  55222. /**
  55223. * Gets the input component
  55224. */
  55225. readonly input: NodeMaterialConnectionPoint;
  55226. /**
  55227. * Gets the output component
  55228. */
  55229. readonly output: NodeMaterialConnectionPoint;
  55230. protected _buildBlock(state: NodeMaterialBuildState): this;
  55231. }
  55232. }
  55233. declare module BABYLON {
  55234. /**
  55235. * Operations supported by the Trigonometry block
  55236. */
  55237. export enum TrigonometryBlockOperations {
  55238. /** Cos */
  55239. Cos = 0,
  55240. /** Sin */
  55241. Sin = 1,
  55242. /** Abs */
  55243. Abs = 2,
  55244. /** Exp */
  55245. Exp = 3,
  55246. /** Exp2 */
  55247. Exp2 = 4,
  55248. /** Round */
  55249. Round = 5,
  55250. /** Floor */
  55251. Floor = 6,
  55252. /** Ceiling */
  55253. Ceiling = 7,
  55254. /** Square root */
  55255. Sqrt = 8,
  55256. /** Log */
  55257. Log = 9,
  55258. /** Tangent */
  55259. Tan = 10,
  55260. /** Arc tangent */
  55261. ArcTan = 11,
  55262. /** Arc cosinus */
  55263. ArcCos = 12,
  55264. /** Arc sinus */
  55265. ArcSin = 13,
  55266. /** Fraction */
  55267. Fract = 14,
  55268. /** Sign */
  55269. Sign = 15,
  55270. /** To radians (from degrees) */
  55271. Radians = 16,
  55272. /** To degrees (from radians) */
  55273. Degrees = 17
  55274. }
  55275. /**
  55276. * Block used to apply trigonometry operation to floats
  55277. */
  55278. export class TrigonometryBlock extends NodeMaterialBlock {
  55279. /**
  55280. * Gets or sets the operation applied by the block
  55281. */
  55282. operation: TrigonometryBlockOperations;
  55283. /**
  55284. * Creates a new TrigonometryBlock
  55285. * @param name defines the block name
  55286. */
  55287. constructor(name: string);
  55288. /**
  55289. * Gets the current class name
  55290. * @returns the class name
  55291. */
  55292. getClassName(): string;
  55293. /**
  55294. * Gets the input component
  55295. */
  55296. readonly input: NodeMaterialConnectionPoint;
  55297. /**
  55298. * Gets the output component
  55299. */
  55300. readonly output: NodeMaterialConnectionPoint;
  55301. protected _buildBlock(state: NodeMaterialBuildState): this;
  55302. serialize(): any;
  55303. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55304. }
  55305. }
  55306. declare module BABYLON {
  55307. /**
  55308. * Block used to create a Color3/4 out of individual inputs (one for each component)
  55309. */
  55310. export class ColorMergerBlock extends NodeMaterialBlock {
  55311. /**
  55312. * Create a new ColorMergerBlock
  55313. * @param name defines the block name
  55314. */
  55315. constructor(name: string);
  55316. /**
  55317. * Gets the current class name
  55318. * @returns the class name
  55319. */
  55320. getClassName(): string;
  55321. /**
  55322. * Gets the r component (input)
  55323. */
  55324. readonly r: NodeMaterialConnectionPoint;
  55325. /**
  55326. * Gets the g component (input)
  55327. */
  55328. readonly g: NodeMaterialConnectionPoint;
  55329. /**
  55330. * Gets the b component (input)
  55331. */
  55332. readonly b: NodeMaterialConnectionPoint;
  55333. /**
  55334. * Gets the a component (input)
  55335. */
  55336. readonly a: NodeMaterialConnectionPoint;
  55337. /**
  55338. * Gets the rgba component (output)
  55339. */
  55340. readonly rgba: NodeMaterialConnectionPoint;
  55341. /**
  55342. * Gets the rgb component (output)
  55343. */
  55344. readonly rgb: NodeMaterialConnectionPoint;
  55345. protected _buildBlock(state: NodeMaterialBuildState): this;
  55346. }
  55347. }
  55348. declare module BABYLON {
  55349. /**
  55350. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  55351. */
  55352. export class VectorMergerBlock extends NodeMaterialBlock {
  55353. /**
  55354. * Create a new VectorMergerBlock
  55355. * @param name defines the block name
  55356. */
  55357. constructor(name: string);
  55358. /**
  55359. * Gets the current class name
  55360. * @returns the class name
  55361. */
  55362. getClassName(): string;
  55363. /**
  55364. * Gets the x component (input)
  55365. */
  55366. readonly x: NodeMaterialConnectionPoint;
  55367. /**
  55368. * Gets the y component (input)
  55369. */
  55370. readonly y: NodeMaterialConnectionPoint;
  55371. /**
  55372. * Gets the z component (input)
  55373. */
  55374. readonly z: NodeMaterialConnectionPoint;
  55375. /**
  55376. * Gets the w component (input)
  55377. */
  55378. readonly w: NodeMaterialConnectionPoint;
  55379. /**
  55380. * Gets the xyzw component (output)
  55381. */
  55382. readonly xyzw: NodeMaterialConnectionPoint;
  55383. /**
  55384. * Gets the xyz component (output)
  55385. */
  55386. readonly xyz: NodeMaterialConnectionPoint;
  55387. /**
  55388. * Gets the xy component (output)
  55389. */
  55390. readonly xy: NodeMaterialConnectionPoint;
  55391. protected _buildBlock(state: NodeMaterialBuildState): this;
  55392. }
  55393. }
  55394. declare module BABYLON {
  55395. /**
  55396. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  55397. */
  55398. export class ColorSplitterBlock extends NodeMaterialBlock {
  55399. /**
  55400. * Create a new ColorSplitterBlock
  55401. * @param name defines the block name
  55402. */
  55403. constructor(name: string);
  55404. /**
  55405. * Gets the current class name
  55406. * @returns the class name
  55407. */
  55408. getClassName(): string;
  55409. /**
  55410. * Gets the rgba component (input)
  55411. */
  55412. readonly rgba: NodeMaterialConnectionPoint;
  55413. /**
  55414. * Gets the rgb component (input)
  55415. */
  55416. readonly rgbIn: NodeMaterialConnectionPoint;
  55417. /**
  55418. * Gets the rgb component (output)
  55419. */
  55420. readonly rgbOut: NodeMaterialConnectionPoint;
  55421. /**
  55422. * Gets the r component (output)
  55423. */
  55424. readonly r: NodeMaterialConnectionPoint;
  55425. /**
  55426. * Gets the g component (output)
  55427. */
  55428. readonly g: NodeMaterialConnectionPoint;
  55429. /**
  55430. * Gets the b component (output)
  55431. */
  55432. readonly b: NodeMaterialConnectionPoint;
  55433. /**
  55434. * Gets the a component (output)
  55435. */
  55436. readonly a: NodeMaterialConnectionPoint;
  55437. protected _inputRename(name: string): string;
  55438. protected _outputRename(name: string): string;
  55439. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55440. }
  55441. }
  55442. declare module BABYLON {
  55443. /**
  55444. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  55445. */
  55446. export class VectorSplitterBlock extends NodeMaterialBlock {
  55447. /**
  55448. * Create a new VectorSplitterBlock
  55449. * @param name defines the block name
  55450. */
  55451. constructor(name: string);
  55452. /**
  55453. * Gets the current class name
  55454. * @returns the class name
  55455. */
  55456. getClassName(): string;
  55457. /**
  55458. * Gets the xyzw component (input)
  55459. */
  55460. readonly xyzw: NodeMaterialConnectionPoint;
  55461. /**
  55462. * Gets the xyz component (input)
  55463. */
  55464. readonly xyzIn: NodeMaterialConnectionPoint;
  55465. /**
  55466. * Gets the xy component (input)
  55467. */
  55468. readonly xyIn: NodeMaterialConnectionPoint;
  55469. /**
  55470. * Gets the xyz component (output)
  55471. */
  55472. readonly xyzOut: NodeMaterialConnectionPoint;
  55473. /**
  55474. * Gets the xy component (output)
  55475. */
  55476. readonly xyOut: NodeMaterialConnectionPoint;
  55477. /**
  55478. * Gets the x component (output)
  55479. */
  55480. readonly x: NodeMaterialConnectionPoint;
  55481. /**
  55482. * Gets the y component (output)
  55483. */
  55484. readonly y: NodeMaterialConnectionPoint;
  55485. /**
  55486. * Gets the z component (output)
  55487. */
  55488. readonly z: NodeMaterialConnectionPoint;
  55489. /**
  55490. * Gets the w component (output)
  55491. */
  55492. readonly w: NodeMaterialConnectionPoint;
  55493. protected _inputRename(name: string): string;
  55494. protected _outputRename(name: string): string;
  55495. protected _buildBlock(state: NodeMaterialBuildState): this;
  55496. }
  55497. }
  55498. declare module BABYLON {
  55499. /**
  55500. * Block used to lerp between 2 values
  55501. */
  55502. export class LerpBlock extends NodeMaterialBlock {
  55503. /**
  55504. * Creates a new LerpBlock
  55505. * @param name defines the block name
  55506. */
  55507. constructor(name: string);
  55508. /**
  55509. * Gets the current class name
  55510. * @returns the class name
  55511. */
  55512. getClassName(): string;
  55513. /**
  55514. * Gets the left operand input component
  55515. */
  55516. readonly left: NodeMaterialConnectionPoint;
  55517. /**
  55518. * Gets the right operand input component
  55519. */
  55520. readonly right: NodeMaterialConnectionPoint;
  55521. /**
  55522. * Gets the gradient operand input component
  55523. */
  55524. readonly gradient: NodeMaterialConnectionPoint;
  55525. /**
  55526. * Gets the output component
  55527. */
  55528. readonly output: NodeMaterialConnectionPoint;
  55529. protected _buildBlock(state: NodeMaterialBuildState): this;
  55530. }
  55531. }
  55532. declare module BABYLON {
  55533. /**
  55534. * Block used to divide 2 vectors
  55535. */
  55536. export class DivideBlock extends NodeMaterialBlock {
  55537. /**
  55538. * Creates a new DivideBlock
  55539. * @param name defines the block name
  55540. */
  55541. constructor(name: string);
  55542. /**
  55543. * Gets the current class name
  55544. * @returns the class name
  55545. */
  55546. getClassName(): string;
  55547. /**
  55548. * Gets the left operand input component
  55549. */
  55550. readonly left: NodeMaterialConnectionPoint;
  55551. /**
  55552. * Gets the right operand input component
  55553. */
  55554. readonly right: NodeMaterialConnectionPoint;
  55555. /**
  55556. * Gets the output component
  55557. */
  55558. readonly output: NodeMaterialConnectionPoint;
  55559. protected _buildBlock(state: NodeMaterialBuildState): this;
  55560. }
  55561. }
  55562. declare module BABYLON {
  55563. /**
  55564. * Block used to subtract 2 vectors
  55565. */
  55566. export class SubtractBlock extends NodeMaterialBlock {
  55567. /**
  55568. * Creates a new SubtractBlock
  55569. * @param name defines the block name
  55570. */
  55571. constructor(name: string);
  55572. /**
  55573. * Gets the current class name
  55574. * @returns the class name
  55575. */
  55576. getClassName(): string;
  55577. /**
  55578. * Gets the left operand input component
  55579. */
  55580. readonly left: NodeMaterialConnectionPoint;
  55581. /**
  55582. * Gets the right operand input component
  55583. */
  55584. readonly right: NodeMaterialConnectionPoint;
  55585. /**
  55586. * Gets the output component
  55587. */
  55588. readonly output: NodeMaterialConnectionPoint;
  55589. protected _buildBlock(state: NodeMaterialBuildState): this;
  55590. }
  55591. }
  55592. declare module BABYLON {
  55593. /**
  55594. * Block used to step a value
  55595. */
  55596. export class StepBlock extends NodeMaterialBlock {
  55597. /**
  55598. * Creates a new StepBlock
  55599. * @param name defines the block name
  55600. */
  55601. constructor(name: string);
  55602. /**
  55603. * Gets the current class name
  55604. * @returns the class name
  55605. */
  55606. getClassName(): string;
  55607. /**
  55608. * Gets the value operand input component
  55609. */
  55610. readonly value: NodeMaterialConnectionPoint;
  55611. /**
  55612. * Gets the edge operand input component
  55613. */
  55614. readonly edge: NodeMaterialConnectionPoint;
  55615. /**
  55616. * Gets the output component
  55617. */
  55618. readonly output: NodeMaterialConnectionPoint;
  55619. protected _buildBlock(state: NodeMaterialBuildState): this;
  55620. }
  55621. }
  55622. declare module BABYLON {
  55623. /**
  55624. * Block used to get the opposite (1 - x) of a value
  55625. */
  55626. export class OneMinusBlock extends NodeMaterialBlock {
  55627. /**
  55628. * Creates a new OneMinusBlock
  55629. * @param name defines the block name
  55630. */
  55631. constructor(name: string);
  55632. /**
  55633. * Gets the current class name
  55634. * @returns the class name
  55635. */
  55636. getClassName(): string;
  55637. /**
  55638. * Gets the input component
  55639. */
  55640. readonly input: NodeMaterialConnectionPoint;
  55641. /**
  55642. * Gets the output component
  55643. */
  55644. readonly output: NodeMaterialConnectionPoint;
  55645. protected _buildBlock(state: NodeMaterialBuildState): this;
  55646. }
  55647. }
  55648. declare module BABYLON {
  55649. /**
  55650. * Block used to get the view direction
  55651. */
  55652. export class ViewDirectionBlock extends NodeMaterialBlock {
  55653. /**
  55654. * Creates a new ViewDirectionBlock
  55655. * @param name defines the block name
  55656. */
  55657. constructor(name: string);
  55658. /**
  55659. * Gets the current class name
  55660. * @returns the class name
  55661. */
  55662. getClassName(): string;
  55663. /**
  55664. * Gets the world position component
  55665. */
  55666. readonly worldPosition: NodeMaterialConnectionPoint;
  55667. /**
  55668. * Gets the camera position component
  55669. */
  55670. readonly cameraPosition: NodeMaterialConnectionPoint;
  55671. /**
  55672. * Gets the output component
  55673. */
  55674. readonly output: NodeMaterialConnectionPoint;
  55675. autoConfigure(material: NodeMaterial): void;
  55676. protected _buildBlock(state: NodeMaterialBuildState): this;
  55677. }
  55678. }
  55679. declare module BABYLON {
  55680. /**
  55681. * Block used to compute fresnel value
  55682. */
  55683. export class FresnelBlock extends NodeMaterialBlock {
  55684. /**
  55685. * Create a new FresnelBlock
  55686. * @param name defines the block name
  55687. */
  55688. constructor(name: string);
  55689. /**
  55690. * Gets the current class name
  55691. * @returns the class name
  55692. */
  55693. getClassName(): string;
  55694. /**
  55695. * Gets the world normal input component
  55696. */
  55697. readonly worldNormal: NodeMaterialConnectionPoint;
  55698. /**
  55699. * Gets the view direction input component
  55700. */
  55701. readonly viewDirection: NodeMaterialConnectionPoint;
  55702. /**
  55703. * Gets the bias input component
  55704. */
  55705. readonly bias: NodeMaterialConnectionPoint;
  55706. /**
  55707. * Gets the camera (or eye) position component
  55708. */
  55709. readonly power: NodeMaterialConnectionPoint;
  55710. /**
  55711. * Gets the fresnel output component
  55712. */
  55713. readonly fresnel: NodeMaterialConnectionPoint;
  55714. autoConfigure(material: NodeMaterial): void;
  55715. protected _buildBlock(state: NodeMaterialBuildState): this;
  55716. }
  55717. }
  55718. declare module BABYLON {
  55719. /**
  55720. * Block used to get the max of 2 values
  55721. */
  55722. export class MaxBlock extends NodeMaterialBlock {
  55723. /**
  55724. * Creates a new MaxBlock
  55725. * @param name defines the block name
  55726. */
  55727. constructor(name: string);
  55728. /**
  55729. * Gets the current class name
  55730. * @returns the class name
  55731. */
  55732. getClassName(): string;
  55733. /**
  55734. * Gets the left operand input component
  55735. */
  55736. readonly left: NodeMaterialConnectionPoint;
  55737. /**
  55738. * Gets the right operand input component
  55739. */
  55740. readonly right: NodeMaterialConnectionPoint;
  55741. /**
  55742. * Gets the output component
  55743. */
  55744. readonly output: NodeMaterialConnectionPoint;
  55745. protected _buildBlock(state: NodeMaterialBuildState): this;
  55746. }
  55747. }
  55748. declare module BABYLON {
  55749. /**
  55750. * Block used to get the min of 2 values
  55751. */
  55752. export class MinBlock extends NodeMaterialBlock {
  55753. /**
  55754. * Creates a new MinBlock
  55755. * @param name defines the block name
  55756. */
  55757. constructor(name: string);
  55758. /**
  55759. * Gets the current class name
  55760. * @returns the class name
  55761. */
  55762. getClassName(): string;
  55763. /**
  55764. * Gets the left operand input component
  55765. */
  55766. readonly left: NodeMaterialConnectionPoint;
  55767. /**
  55768. * Gets the right operand input component
  55769. */
  55770. readonly right: NodeMaterialConnectionPoint;
  55771. /**
  55772. * Gets the output component
  55773. */
  55774. readonly output: NodeMaterialConnectionPoint;
  55775. protected _buildBlock(state: NodeMaterialBuildState): this;
  55776. }
  55777. }
  55778. declare module BABYLON {
  55779. /**
  55780. * Block used to get the distance between 2 values
  55781. */
  55782. export class DistanceBlock extends NodeMaterialBlock {
  55783. /**
  55784. * Creates a new DistanceBlock
  55785. * @param name defines the block name
  55786. */
  55787. constructor(name: string);
  55788. /**
  55789. * Gets the current class name
  55790. * @returns the class name
  55791. */
  55792. getClassName(): string;
  55793. /**
  55794. * Gets the left operand input component
  55795. */
  55796. readonly left: NodeMaterialConnectionPoint;
  55797. /**
  55798. * Gets the right operand input component
  55799. */
  55800. readonly right: NodeMaterialConnectionPoint;
  55801. /**
  55802. * Gets the output component
  55803. */
  55804. readonly output: NodeMaterialConnectionPoint;
  55805. protected _buildBlock(state: NodeMaterialBuildState): this;
  55806. }
  55807. }
  55808. declare module BABYLON {
  55809. /**
  55810. * Block used to get the length of a vector
  55811. */
  55812. export class LengthBlock extends NodeMaterialBlock {
  55813. /**
  55814. * Creates a new LengthBlock
  55815. * @param name defines the block name
  55816. */
  55817. constructor(name: string);
  55818. /**
  55819. * Gets the current class name
  55820. * @returns the class name
  55821. */
  55822. getClassName(): string;
  55823. /**
  55824. * Gets the value input component
  55825. */
  55826. readonly value: NodeMaterialConnectionPoint;
  55827. /**
  55828. * Gets the output component
  55829. */
  55830. readonly output: NodeMaterialConnectionPoint;
  55831. protected _buildBlock(state: NodeMaterialBuildState): this;
  55832. }
  55833. }
  55834. declare module BABYLON {
  55835. /**
  55836. * Block used to get negative version of a value (i.e. x * -1)
  55837. */
  55838. export class NegateBlock extends NodeMaterialBlock {
  55839. /**
  55840. * Creates a new NegateBlock
  55841. * @param name defines the block name
  55842. */
  55843. constructor(name: string);
  55844. /**
  55845. * Gets the current class name
  55846. * @returns the class name
  55847. */
  55848. getClassName(): string;
  55849. /**
  55850. * Gets the value input component
  55851. */
  55852. readonly value: NodeMaterialConnectionPoint;
  55853. /**
  55854. * Gets the output component
  55855. */
  55856. readonly output: NodeMaterialConnectionPoint;
  55857. protected _buildBlock(state: NodeMaterialBuildState): this;
  55858. }
  55859. }
  55860. declare module BABYLON {
  55861. /**
  55862. * Block used to get the value of the first parameter raised to the power of the second
  55863. */
  55864. export class PowBlock extends NodeMaterialBlock {
  55865. /**
  55866. * Creates a new PowBlock
  55867. * @param name defines the block name
  55868. */
  55869. constructor(name: string);
  55870. /**
  55871. * Gets the current class name
  55872. * @returns the class name
  55873. */
  55874. getClassName(): string;
  55875. /**
  55876. * Gets the value operand input component
  55877. */
  55878. readonly value: NodeMaterialConnectionPoint;
  55879. /**
  55880. * Gets the power operand input component
  55881. */
  55882. readonly power: NodeMaterialConnectionPoint;
  55883. /**
  55884. * Gets the output component
  55885. */
  55886. readonly output: NodeMaterialConnectionPoint;
  55887. protected _buildBlock(state: NodeMaterialBuildState): this;
  55888. }
  55889. }
  55890. declare module BABYLON {
  55891. /**
  55892. * Block used to get a random number
  55893. */
  55894. export class RandomNumberBlock extends NodeMaterialBlock {
  55895. /**
  55896. * Creates a new RandomNumberBlock
  55897. * @param name defines the block name
  55898. */
  55899. constructor(name: string);
  55900. /**
  55901. * Gets the current class name
  55902. * @returns the class name
  55903. */
  55904. getClassName(): string;
  55905. /**
  55906. * Gets the seed input component
  55907. */
  55908. readonly seed: NodeMaterialConnectionPoint;
  55909. /**
  55910. * Gets the output component
  55911. */
  55912. readonly output: NodeMaterialConnectionPoint;
  55913. protected _buildBlock(state: NodeMaterialBuildState): this;
  55914. }
  55915. }
  55916. declare module BABYLON {
  55917. /**
  55918. * Block used to compute arc tangent of 2 values
  55919. */
  55920. export class ArcTan2Block extends NodeMaterialBlock {
  55921. /**
  55922. * Creates a new ArcTan2Block
  55923. * @param name defines the block name
  55924. */
  55925. constructor(name: string);
  55926. /**
  55927. * Gets the current class name
  55928. * @returns the class name
  55929. */
  55930. getClassName(): string;
  55931. /**
  55932. * Gets the x operand input component
  55933. */
  55934. readonly x: NodeMaterialConnectionPoint;
  55935. /**
  55936. * Gets the y operand input component
  55937. */
  55938. readonly y: NodeMaterialConnectionPoint;
  55939. /**
  55940. * Gets the output component
  55941. */
  55942. readonly output: NodeMaterialConnectionPoint;
  55943. protected _buildBlock(state: NodeMaterialBuildState): this;
  55944. }
  55945. }
  55946. declare module BABYLON {
  55947. /**
  55948. * Block used to smooth step a value
  55949. */
  55950. export class SmoothStepBlock extends NodeMaterialBlock {
  55951. /**
  55952. * Creates a new SmoothStepBlock
  55953. * @param name defines the block name
  55954. */
  55955. constructor(name: string);
  55956. /**
  55957. * Gets the current class name
  55958. * @returns the class name
  55959. */
  55960. getClassName(): string;
  55961. /**
  55962. * Gets the value operand input component
  55963. */
  55964. readonly value: NodeMaterialConnectionPoint;
  55965. /**
  55966. * Gets the first edge operand input component
  55967. */
  55968. readonly edge0: NodeMaterialConnectionPoint;
  55969. /**
  55970. * Gets the second edge operand input component
  55971. */
  55972. readonly edge1: NodeMaterialConnectionPoint;
  55973. /**
  55974. * Gets the output component
  55975. */
  55976. readonly output: NodeMaterialConnectionPoint;
  55977. protected _buildBlock(state: NodeMaterialBuildState): this;
  55978. }
  55979. }
  55980. declare module BABYLON {
  55981. /**
  55982. * Block used to get the reciprocal (1 / x) of a value
  55983. */
  55984. export class ReciprocalBlock extends NodeMaterialBlock {
  55985. /**
  55986. * Creates a new ReciprocalBlock
  55987. * @param name defines the block name
  55988. */
  55989. constructor(name: string);
  55990. /**
  55991. * Gets the current class name
  55992. * @returns the class name
  55993. */
  55994. getClassName(): string;
  55995. /**
  55996. * Gets the input component
  55997. */
  55998. readonly input: NodeMaterialConnectionPoint;
  55999. /**
  56000. * Gets the output component
  56001. */
  56002. readonly output: NodeMaterialConnectionPoint;
  56003. protected _buildBlock(state: NodeMaterialBuildState): this;
  56004. }
  56005. }
  56006. declare module BABYLON {
  56007. /**
  56008. * Block used to replace a color by another one
  56009. */
  56010. export class ReplaceColorBlock extends NodeMaterialBlock {
  56011. /**
  56012. * Creates a new ReplaceColorBlock
  56013. * @param name defines the block name
  56014. */
  56015. constructor(name: string);
  56016. /**
  56017. * Gets the current class name
  56018. * @returns the class name
  56019. */
  56020. getClassName(): string;
  56021. /**
  56022. * Gets the value input component
  56023. */
  56024. readonly value: NodeMaterialConnectionPoint;
  56025. /**
  56026. * Gets the reference input component
  56027. */
  56028. readonly reference: NodeMaterialConnectionPoint;
  56029. /**
  56030. * Gets the distance input component
  56031. */
  56032. readonly distance: NodeMaterialConnectionPoint;
  56033. /**
  56034. * Gets the replacement input component
  56035. */
  56036. readonly replacement: NodeMaterialConnectionPoint;
  56037. /**
  56038. * Gets the output component
  56039. */
  56040. readonly output: NodeMaterialConnectionPoint;
  56041. protected _buildBlock(state: NodeMaterialBuildState): this;
  56042. }
  56043. }
  56044. declare module BABYLON {
  56045. /**
  56046. * Block used to posterize a value
  56047. * @see https://en.wikipedia.org/wiki/Posterization
  56048. */
  56049. export class PosterizeBlock extends NodeMaterialBlock {
  56050. /**
  56051. * Creates a new PosterizeBlock
  56052. * @param name defines the block name
  56053. */
  56054. constructor(name: string);
  56055. /**
  56056. * Gets the current class name
  56057. * @returns the class name
  56058. */
  56059. getClassName(): string;
  56060. /**
  56061. * Gets the value input component
  56062. */
  56063. readonly value: NodeMaterialConnectionPoint;
  56064. /**
  56065. * Gets the steps input component
  56066. */
  56067. readonly steps: NodeMaterialConnectionPoint;
  56068. /**
  56069. * Gets the output component
  56070. */
  56071. readonly output: NodeMaterialConnectionPoint;
  56072. protected _buildBlock(state: NodeMaterialBuildState): this;
  56073. }
  56074. }
  56075. declare module BABYLON {
  56076. /**
  56077. * Operations supported by the Wave block
  56078. */
  56079. export enum WaveBlockKind {
  56080. /** SawTooth */
  56081. SawTooth = 0,
  56082. /** Square */
  56083. Square = 1,
  56084. /** Triangle */
  56085. Triangle = 2
  56086. }
  56087. /**
  56088. * Block used to apply wave operation to floats
  56089. */
  56090. export class WaveBlock extends NodeMaterialBlock {
  56091. /**
  56092. * Gets or sets the kibnd of wave to be applied by the block
  56093. */
  56094. kind: WaveBlockKind;
  56095. /**
  56096. * Creates a new WaveBlock
  56097. * @param name defines the block name
  56098. */
  56099. constructor(name: string);
  56100. /**
  56101. * Gets the current class name
  56102. * @returns the class name
  56103. */
  56104. getClassName(): string;
  56105. /**
  56106. * Gets the input component
  56107. */
  56108. readonly input: NodeMaterialConnectionPoint;
  56109. /**
  56110. * Gets the output component
  56111. */
  56112. readonly output: NodeMaterialConnectionPoint;
  56113. protected _buildBlock(state: NodeMaterialBuildState): this;
  56114. serialize(): any;
  56115. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56116. }
  56117. }
  56118. declare module BABYLON {
  56119. /**
  56120. * Class used to store a color step for the GradientBlock
  56121. */
  56122. export class GradientBlockColorStep {
  56123. /**
  56124. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  56125. */
  56126. step: number;
  56127. /**
  56128. * Gets or sets the color associated with this step
  56129. */
  56130. color: Color3;
  56131. /**
  56132. * Creates a new GradientBlockColorStep
  56133. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  56134. * @param color defines the color associated with this step
  56135. */
  56136. constructor(
  56137. /**
  56138. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  56139. */
  56140. step: number,
  56141. /**
  56142. * Gets or sets the color associated with this step
  56143. */
  56144. color: Color3);
  56145. }
  56146. /**
  56147. * Block used to return a color from a gradient based on an input value between 0 and 1
  56148. */
  56149. export class GradientBlock extends NodeMaterialBlock {
  56150. /**
  56151. * Gets or sets the list of color steps
  56152. */
  56153. colorSteps: GradientBlockColorStep[];
  56154. /**
  56155. * Creates a new GradientBlock
  56156. * @param name defines the block name
  56157. */
  56158. constructor(name: string);
  56159. /**
  56160. * Gets the current class name
  56161. * @returns the class name
  56162. */
  56163. getClassName(): string;
  56164. /**
  56165. * Gets the gradient input component
  56166. */
  56167. readonly gradient: NodeMaterialConnectionPoint;
  56168. /**
  56169. * Gets the output component
  56170. */
  56171. readonly output: NodeMaterialConnectionPoint;
  56172. private _writeColorConstant;
  56173. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56174. serialize(): any;
  56175. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56176. protected _dumpPropertiesCode(): string;
  56177. }
  56178. }
  56179. declare module BABYLON {
  56180. /**
  56181. * Block used to normalize lerp between 2 values
  56182. */
  56183. export class NLerpBlock extends NodeMaterialBlock {
  56184. /**
  56185. * Creates a new NLerpBlock
  56186. * @param name defines the block name
  56187. */
  56188. constructor(name: string);
  56189. /**
  56190. * Gets the current class name
  56191. * @returns the class name
  56192. */
  56193. getClassName(): string;
  56194. /**
  56195. * Gets the left operand input component
  56196. */
  56197. readonly left: NodeMaterialConnectionPoint;
  56198. /**
  56199. * Gets the right operand input component
  56200. */
  56201. readonly right: NodeMaterialConnectionPoint;
  56202. /**
  56203. * Gets the gradient operand input component
  56204. */
  56205. readonly gradient: NodeMaterialConnectionPoint;
  56206. /**
  56207. * Gets the output component
  56208. */
  56209. readonly output: NodeMaterialConnectionPoint;
  56210. protected _buildBlock(state: NodeMaterialBuildState): this;
  56211. }
  56212. }
  56213. declare module BABYLON {
  56214. /**
  56215. * Effect Render Options
  56216. */
  56217. export interface IEffectRendererOptions {
  56218. /**
  56219. * Defines the vertices positions.
  56220. */
  56221. positions?: number[];
  56222. /**
  56223. * Defines the indices.
  56224. */
  56225. indices?: number[];
  56226. }
  56227. /**
  56228. * Helper class to render one or more effects
  56229. */
  56230. export class EffectRenderer {
  56231. private engine;
  56232. private static _DefaultOptions;
  56233. private _vertexBuffers;
  56234. private _indexBuffer;
  56235. private _ringBufferIndex;
  56236. private _ringScreenBuffer;
  56237. private _fullscreenViewport;
  56238. private _getNextFrameBuffer;
  56239. /**
  56240. * Creates an effect renderer
  56241. * @param engine the engine to use for rendering
  56242. * @param options defines the options of the effect renderer
  56243. */
  56244. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  56245. /**
  56246. * Sets the current viewport in normalized coordinates 0-1
  56247. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  56248. */
  56249. setViewport(viewport?: Viewport): void;
  56250. /**
  56251. * Binds the embedded attributes buffer to the effect.
  56252. * @param effect Defines the effect to bind the attributes for
  56253. */
  56254. bindBuffers(effect: Effect): void;
  56255. /**
  56256. * Sets the current effect wrapper to use during draw.
  56257. * The effect needs to be ready before calling this api.
  56258. * This also sets the default full screen position attribute.
  56259. * @param effectWrapper Defines the effect to draw with
  56260. */
  56261. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  56262. /**
  56263. * Draws a full screen quad.
  56264. */
  56265. draw(): void;
  56266. /**
  56267. * renders one or more effects to a specified texture
  56268. * @param effectWrappers list of effects to renderer
  56269. * @param outputTexture texture to draw to, if null it will render to the screen
  56270. */
  56271. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  56272. /**
  56273. * Disposes of the effect renderer
  56274. */
  56275. dispose(): void;
  56276. }
  56277. /**
  56278. * Options to create an EffectWrapper
  56279. */
  56280. interface EffectWrapperCreationOptions {
  56281. /**
  56282. * Engine to use to create the effect
  56283. */
  56284. engine: ThinEngine;
  56285. /**
  56286. * Fragment shader for the effect
  56287. */
  56288. fragmentShader: string;
  56289. /**
  56290. * Vertex shader for the effect
  56291. */
  56292. vertexShader?: string;
  56293. /**
  56294. * Attributes to use in the shader
  56295. */
  56296. attributeNames?: Array<string>;
  56297. /**
  56298. * Uniforms to use in the shader
  56299. */
  56300. uniformNames?: Array<string>;
  56301. /**
  56302. * Texture sampler names to use in the shader
  56303. */
  56304. samplerNames?: Array<string>;
  56305. /**
  56306. * The friendly name of the effect displayed in Spector.
  56307. */
  56308. name?: string;
  56309. }
  56310. /**
  56311. * Wraps an effect to be used for rendering
  56312. */
  56313. export class EffectWrapper {
  56314. /**
  56315. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  56316. */
  56317. onApplyObservable: Observable<{}>;
  56318. /**
  56319. * The underlying effect
  56320. */
  56321. effect: Effect;
  56322. /**
  56323. * Creates an effect to be renderer
  56324. * @param creationOptions options to create the effect
  56325. */
  56326. constructor(creationOptions: EffectWrapperCreationOptions);
  56327. /**
  56328. * Disposes of the effect wrapper
  56329. */
  56330. dispose(): void;
  56331. }
  56332. }
  56333. declare module BABYLON {
  56334. /**
  56335. * Helper class to push actions to a pool of workers.
  56336. */
  56337. export class WorkerPool implements IDisposable {
  56338. private _workerInfos;
  56339. private _pendingActions;
  56340. /**
  56341. * Constructor
  56342. * @param workers Array of workers to use for actions
  56343. */
  56344. constructor(workers: Array<Worker>);
  56345. /**
  56346. * Terminates all workers and clears any pending actions.
  56347. */
  56348. dispose(): void;
  56349. /**
  56350. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56351. * pended until a worker has completed its action.
  56352. * @param action The action to perform. Call onComplete when the action is complete.
  56353. */
  56354. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56355. private _execute;
  56356. }
  56357. }
  56358. declare module BABYLON {
  56359. /**
  56360. * Configuration for Draco compression
  56361. */
  56362. export interface IDracoCompressionConfiguration {
  56363. /**
  56364. * Configuration for the decoder.
  56365. */
  56366. decoder: {
  56367. /**
  56368. * The url to the WebAssembly module.
  56369. */
  56370. wasmUrl?: string;
  56371. /**
  56372. * The url to the WebAssembly binary.
  56373. */
  56374. wasmBinaryUrl?: string;
  56375. /**
  56376. * The url to the fallback JavaScript module.
  56377. */
  56378. fallbackUrl?: string;
  56379. };
  56380. }
  56381. /**
  56382. * Draco compression (https://google.github.io/draco/)
  56383. *
  56384. * This class wraps the Draco module.
  56385. *
  56386. * **Encoder**
  56387. *
  56388. * The encoder is not currently implemented.
  56389. *
  56390. * **Decoder**
  56391. *
  56392. * 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.
  56393. *
  56394. * To update the configuration, use the following code:
  56395. * ```javascript
  56396. * DracoCompression.Configuration = {
  56397. * decoder: {
  56398. * wasmUrl: "<url to the WebAssembly library>",
  56399. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  56400. * fallbackUrl: "<url to the fallback JavaScript library>",
  56401. * }
  56402. * };
  56403. * ```
  56404. *
  56405. * 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.
  56406. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  56407. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  56408. *
  56409. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  56410. * ```javascript
  56411. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  56412. * ```
  56413. *
  56414. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  56415. */
  56416. export class DracoCompression implements IDisposable {
  56417. private _workerPoolPromise?;
  56418. private _decoderModulePromise?;
  56419. /**
  56420. * The configuration. Defaults to the following urls:
  56421. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  56422. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  56423. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  56424. */
  56425. static Configuration: IDracoCompressionConfiguration;
  56426. /**
  56427. * Returns true if the decoder configuration is available.
  56428. */
  56429. static readonly DecoderAvailable: boolean;
  56430. /**
  56431. * Default number of workers to create when creating the draco compression object.
  56432. */
  56433. static DefaultNumWorkers: number;
  56434. private static GetDefaultNumWorkers;
  56435. private static _Default;
  56436. /**
  56437. * Default instance for the draco compression object.
  56438. */
  56439. static readonly Default: DracoCompression;
  56440. /**
  56441. * Constructor
  56442. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  56443. */
  56444. constructor(numWorkers?: number);
  56445. /**
  56446. * Stop all async operations and release resources.
  56447. */
  56448. dispose(): void;
  56449. /**
  56450. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  56451. * @returns a promise that resolves when ready
  56452. */
  56453. whenReadyAsync(): Promise<void>;
  56454. /**
  56455. * Decode Draco compressed mesh data to vertex data.
  56456. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  56457. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  56458. * @returns A promise that resolves with the decoded vertex data
  56459. */
  56460. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  56461. [kind: string]: number;
  56462. }): Promise<VertexData>;
  56463. }
  56464. }
  56465. declare module BABYLON {
  56466. /**
  56467. * Class for building Constructive Solid Geometry
  56468. */
  56469. export class CSG {
  56470. private polygons;
  56471. /**
  56472. * The world matrix
  56473. */
  56474. matrix: Matrix;
  56475. /**
  56476. * Stores the position
  56477. */
  56478. position: Vector3;
  56479. /**
  56480. * Stores the rotation
  56481. */
  56482. rotation: Vector3;
  56483. /**
  56484. * Stores the rotation quaternion
  56485. */
  56486. rotationQuaternion: Nullable<Quaternion>;
  56487. /**
  56488. * Stores the scaling vector
  56489. */
  56490. scaling: Vector3;
  56491. /**
  56492. * Convert the Mesh to CSG
  56493. * @param mesh The Mesh to convert to CSG
  56494. * @returns A new CSG from the Mesh
  56495. */
  56496. static FromMesh(mesh: Mesh): CSG;
  56497. /**
  56498. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  56499. * @param polygons Polygons used to construct a CSG solid
  56500. */
  56501. private static FromPolygons;
  56502. /**
  56503. * Clones, or makes a deep copy, of the CSG
  56504. * @returns A new CSG
  56505. */
  56506. clone(): CSG;
  56507. /**
  56508. * Unions this CSG with another CSG
  56509. * @param csg The CSG to union against this CSG
  56510. * @returns The unioned CSG
  56511. */
  56512. union(csg: CSG): CSG;
  56513. /**
  56514. * Unions this CSG with another CSG in place
  56515. * @param csg The CSG to union against this CSG
  56516. */
  56517. unionInPlace(csg: CSG): void;
  56518. /**
  56519. * Subtracts this CSG with another CSG
  56520. * @param csg The CSG to subtract against this CSG
  56521. * @returns A new CSG
  56522. */
  56523. subtract(csg: CSG): CSG;
  56524. /**
  56525. * Subtracts this CSG with another CSG in place
  56526. * @param csg The CSG to subtact against this CSG
  56527. */
  56528. subtractInPlace(csg: CSG): void;
  56529. /**
  56530. * Intersect this CSG with another CSG
  56531. * @param csg The CSG to intersect against this CSG
  56532. * @returns A new CSG
  56533. */
  56534. intersect(csg: CSG): CSG;
  56535. /**
  56536. * Intersects this CSG with another CSG in place
  56537. * @param csg The CSG to intersect against this CSG
  56538. */
  56539. intersectInPlace(csg: CSG): void;
  56540. /**
  56541. * Return a new CSG solid with solid and empty space switched. This solid is
  56542. * not modified.
  56543. * @returns A new CSG solid with solid and empty space switched
  56544. */
  56545. inverse(): CSG;
  56546. /**
  56547. * Inverses the CSG in place
  56548. */
  56549. inverseInPlace(): void;
  56550. /**
  56551. * This is used to keep meshes transformations so they can be restored
  56552. * when we build back a Babylon Mesh
  56553. * NB : All CSG operations are performed in world coordinates
  56554. * @param csg The CSG to copy the transform attributes from
  56555. * @returns This CSG
  56556. */
  56557. copyTransformAttributes(csg: CSG): CSG;
  56558. /**
  56559. * Build Raw mesh from CSG
  56560. * Coordinates here are in world space
  56561. * @param name The name of the mesh geometry
  56562. * @param scene The Scene
  56563. * @param keepSubMeshes Specifies if the submeshes should be kept
  56564. * @returns A new Mesh
  56565. */
  56566. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56567. /**
  56568. * Build Mesh from CSG taking material and transforms into account
  56569. * @param name The name of the Mesh
  56570. * @param material The material of the Mesh
  56571. * @param scene The Scene
  56572. * @param keepSubMeshes Specifies if submeshes should be kept
  56573. * @returns The new Mesh
  56574. */
  56575. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56576. }
  56577. }
  56578. declare module BABYLON {
  56579. /**
  56580. * Class used to create a trail following a mesh
  56581. */
  56582. export class TrailMesh extends Mesh {
  56583. private _generator;
  56584. private _autoStart;
  56585. private _running;
  56586. private _diameter;
  56587. private _length;
  56588. private _sectionPolygonPointsCount;
  56589. private _sectionVectors;
  56590. private _sectionNormalVectors;
  56591. private _beforeRenderObserver;
  56592. /**
  56593. * @constructor
  56594. * @param name The value used by scene.getMeshByName() to do a lookup.
  56595. * @param generator The mesh to generate a trail.
  56596. * @param scene The scene to add this mesh to.
  56597. * @param diameter Diameter of trailing mesh. Default is 1.
  56598. * @param length Length of trailing mesh. Default is 60.
  56599. * @param autoStart Automatically start trailing mesh. Default true.
  56600. */
  56601. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56602. /**
  56603. * "TrailMesh"
  56604. * @returns "TrailMesh"
  56605. */
  56606. getClassName(): string;
  56607. private _createMesh;
  56608. /**
  56609. * Start trailing mesh.
  56610. */
  56611. start(): void;
  56612. /**
  56613. * Stop trailing mesh.
  56614. */
  56615. stop(): void;
  56616. /**
  56617. * Update trailing mesh geometry.
  56618. */
  56619. update(): void;
  56620. /**
  56621. * Returns a new TrailMesh object.
  56622. * @param name is a string, the name given to the new mesh
  56623. * @param newGenerator use new generator object for cloned trail mesh
  56624. * @returns a new mesh
  56625. */
  56626. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56627. /**
  56628. * Serializes this trail mesh
  56629. * @param serializationObject object to write serialization to
  56630. */
  56631. serialize(serializationObject: any): void;
  56632. /**
  56633. * Parses a serialized trail mesh
  56634. * @param parsedMesh the serialized mesh
  56635. * @param scene the scene to create the trail mesh in
  56636. * @returns the created trail mesh
  56637. */
  56638. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56639. }
  56640. }
  56641. declare module BABYLON {
  56642. /**
  56643. * Class containing static functions to help procedurally build meshes
  56644. */
  56645. export class TiledBoxBuilder {
  56646. /**
  56647. * Creates a box mesh
  56648. * 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)
  56649. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56651. * * 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
  56652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56653. * @param name defines the name of the mesh
  56654. * @param options defines the options used to create the mesh
  56655. * @param scene defines the hosting scene
  56656. * @returns the box mesh
  56657. */
  56658. static CreateTiledBox(name: string, options: {
  56659. pattern?: number;
  56660. width?: number;
  56661. height?: number;
  56662. depth?: number;
  56663. tileSize?: number;
  56664. tileWidth?: number;
  56665. tileHeight?: number;
  56666. alignHorizontal?: number;
  56667. alignVertical?: number;
  56668. faceUV?: Vector4[];
  56669. faceColors?: Color4[];
  56670. sideOrientation?: number;
  56671. updatable?: boolean;
  56672. }, scene?: Nullable<Scene>): Mesh;
  56673. }
  56674. }
  56675. declare module BABYLON {
  56676. /**
  56677. * Class containing static functions to help procedurally build meshes
  56678. */
  56679. export class TorusKnotBuilder {
  56680. /**
  56681. * Creates a torus knot mesh
  56682. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56683. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56684. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56685. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56686. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56687. * * 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
  56688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56689. * @param name defines the name of the mesh
  56690. * @param options defines the options used to create the mesh
  56691. * @param scene defines the hosting scene
  56692. * @returns the torus knot mesh
  56693. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56694. */
  56695. static CreateTorusKnot(name: string, options: {
  56696. radius?: number;
  56697. tube?: number;
  56698. radialSegments?: number;
  56699. tubularSegments?: number;
  56700. p?: number;
  56701. q?: number;
  56702. updatable?: boolean;
  56703. sideOrientation?: number;
  56704. frontUVs?: Vector4;
  56705. backUVs?: Vector4;
  56706. }, scene: any): Mesh;
  56707. }
  56708. }
  56709. declare module BABYLON {
  56710. /**
  56711. * Polygon
  56712. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56713. */
  56714. export class Polygon {
  56715. /**
  56716. * Creates a rectangle
  56717. * @param xmin bottom X coord
  56718. * @param ymin bottom Y coord
  56719. * @param xmax top X coord
  56720. * @param ymax top Y coord
  56721. * @returns points that make the resulting rectation
  56722. */
  56723. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56724. /**
  56725. * Creates a circle
  56726. * @param radius radius of circle
  56727. * @param cx scale in x
  56728. * @param cy scale in y
  56729. * @param numberOfSides number of sides that make up the circle
  56730. * @returns points that make the resulting circle
  56731. */
  56732. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56733. /**
  56734. * Creates a polygon from input string
  56735. * @param input Input polygon data
  56736. * @returns the parsed points
  56737. */
  56738. static Parse(input: string): Vector2[];
  56739. /**
  56740. * Starts building a polygon from x and y coordinates
  56741. * @param x x coordinate
  56742. * @param y y coordinate
  56743. * @returns the started path2
  56744. */
  56745. static StartingAt(x: number, y: number): Path2;
  56746. }
  56747. /**
  56748. * Builds a polygon
  56749. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56750. */
  56751. export class PolygonMeshBuilder {
  56752. private _points;
  56753. private _outlinepoints;
  56754. private _holes;
  56755. private _name;
  56756. private _scene;
  56757. private _epoints;
  56758. private _eholes;
  56759. private _addToepoint;
  56760. /**
  56761. * Babylon reference to the earcut plugin.
  56762. */
  56763. bjsEarcut: any;
  56764. /**
  56765. * Creates a PolygonMeshBuilder
  56766. * @param name name of the builder
  56767. * @param contours Path of the polygon
  56768. * @param scene scene to add to when creating the mesh
  56769. * @param earcutInjection can be used to inject your own earcut reference
  56770. */
  56771. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56772. /**
  56773. * Adds a whole within the polygon
  56774. * @param hole Array of points defining the hole
  56775. * @returns this
  56776. */
  56777. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56778. /**
  56779. * Creates the polygon
  56780. * @param updatable If the mesh should be updatable
  56781. * @param depth The depth of the mesh created
  56782. * @returns the created mesh
  56783. */
  56784. build(updatable?: boolean, depth?: number): Mesh;
  56785. /**
  56786. * Creates the polygon
  56787. * @param depth The depth of the mesh created
  56788. * @returns the created VertexData
  56789. */
  56790. buildVertexData(depth?: number): VertexData;
  56791. /**
  56792. * Adds a side to the polygon
  56793. * @param positions points that make the polygon
  56794. * @param normals normals of the polygon
  56795. * @param uvs uvs of the polygon
  56796. * @param indices indices of the polygon
  56797. * @param bounds bounds of the polygon
  56798. * @param points points of the polygon
  56799. * @param depth depth of the polygon
  56800. * @param flip flip of the polygon
  56801. */
  56802. private addSide;
  56803. }
  56804. }
  56805. declare module BABYLON {
  56806. /**
  56807. * Class containing static functions to help procedurally build meshes
  56808. */
  56809. export class PolygonBuilder {
  56810. /**
  56811. * Creates a polygon mesh
  56812. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56813. * * 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
  56814. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56816. * * 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)
  56817. * * Remember you can only change the shape positions, not their number when updating a polygon
  56818. * @param name defines the name of the mesh
  56819. * @param options defines the options used to create the mesh
  56820. * @param scene defines the hosting scene
  56821. * @param earcutInjection can be used to inject your own earcut reference
  56822. * @returns the polygon mesh
  56823. */
  56824. static CreatePolygon(name: string, options: {
  56825. shape: Vector3[];
  56826. holes?: Vector3[][];
  56827. depth?: number;
  56828. faceUV?: Vector4[];
  56829. faceColors?: Color4[];
  56830. updatable?: boolean;
  56831. sideOrientation?: number;
  56832. frontUVs?: Vector4;
  56833. backUVs?: Vector4;
  56834. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56835. /**
  56836. * Creates an extruded polygon mesh, with depth in the Y direction.
  56837. * * 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)
  56838. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56839. * @param name defines the name of the mesh
  56840. * @param options defines the options used to create the mesh
  56841. * @param scene defines the hosting scene
  56842. * @param earcutInjection can be used to inject your own earcut reference
  56843. * @returns the polygon mesh
  56844. */
  56845. static ExtrudePolygon(name: string, options: {
  56846. shape: Vector3[];
  56847. holes?: Vector3[][];
  56848. depth?: number;
  56849. faceUV?: Vector4[];
  56850. faceColors?: Color4[];
  56851. updatable?: boolean;
  56852. sideOrientation?: number;
  56853. frontUVs?: Vector4;
  56854. backUVs?: Vector4;
  56855. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56856. }
  56857. }
  56858. declare module BABYLON {
  56859. /**
  56860. * Class containing static functions to help procedurally build meshes
  56861. */
  56862. export class LatheBuilder {
  56863. /**
  56864. * Creates lathe mesh.
  56865. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56866. * * 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
  56867. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56868. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56869. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56870. * * 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
  56871. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56872. * * 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
  56873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56874. * * 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
  56875. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56877. * @param name defines the name of the mesh
  56878. * @param options defines the options used to create the mesh
  56879. * @param scene defines the hosting scene
  56880. * @returns the lathe mesh
  56881. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56882. */
  56883. static CreateLathe(name: string, options: {
  56884. shape: Vector3[];
  56885. radius?: number;
  56886. tessellation?: number;
  56887. clip?: number;
  56888. arc?: number;
  56889. closed?: boolean;
  56890. updatable?: boolean;
  56891. sideOrientation?: number;
  56892. frontUVs?: Vector4;
  56893. backUVs?: Vector4;
  56894. cap?: number;
  56895. invertUV?: boolean;
  56896. }, scene?: Nullable<Scene>): Mesh;
  56897. }
  56898. }
  56899. declare module BABYLON {
  56900. /**
  56901. * Class containing static functions to help procedurally build meshes
  56902. */
  56903. export class TiledPlaneBuilder {
  56904. /**
  56905. * Creates a tiled plane mesh
  56906. * * The parameter `pattern` will, depending on value, do nothing or
  56907. * * * flip (reflect about central vertical) alternate tiles across and up
  56908. * * * flip every tile on alternate rows
  56909. * * * rotate (180 degs) alternate tiles across and up
  56910. * * * rotate every tile on alternate rows
  56911. * * * flip and rotate alternate tiles across and up
  56912. * * * flip and rotate every tile on alternate rows
  56913. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56914. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56916. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56917. * * 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)
  56918. * * 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)
  56919. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56920. * @param name defines the name of the mesh
  56921. * @param options defines the options used to create the mesh
  56922. * @param scene defines the hosting scene
  56923. * @returns the box mesh
  56924. */
  56925. static CreateTiledPlane(name: string, options: {
  56926. pattern?: number;
  56927. tileSize?: number;
  56928. tileWidth?: number;
  56929. tileHeight?: number;
  56930. size?: number;
  56931. width?: number;
  56932. height?: number;
  56933. alignHorizontal?: number;
  56934. alignVertical?: number;
  56935. sideOrientation?: number;
  56936. frontUVs?: Vector4;
  56937. backUVs?: Vector4;
  56938. updatable?: boolean;
  56939. }, scene?: Nullable<Scene>): Mesh;
  56940. }
  56941. }
  56942. declare module BABYLON {
  56943. /**
  56944. * Class containing static functions to help procedurally build meshes
  56945. */
  56946. export class TubeBuilder {
  56947. /**
  56948. * Creates a tube mesh.
  56949. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56950. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56951. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56952. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56953. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56954. * * 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)
  56955. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56956. * * 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
  56957. * * 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
  56958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56959. * * 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
  56960. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56962. * @param name defines the name of the mesh
  56963. * @param options defines the options used to create the mesh
  56964. * @param scene defines the hosting scene
  56965. * @returns the tube mesh
  56966. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56967. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56968. */
  56969. static CreateTube(name: string, options: {
  56970. path: Vector3[];
  56971. radius?: number;
  56972. tessellation?: number;
  56973. radiusFunction?: {
  56974. (i: number, distance: number): number;
  56975. };
  56976. cap?: number;
  56977. arc?: number;
  56978. updatable?: boolean;
  56979. sideOrientation?: number;
  56980. frontUVs?: Vector4;
  56981. backUVs?: Vector4;
  56982. instance?: Mesh;
  56983. invertUV?: boolean;
  56984. }, scene?: Nullable<Scene>): Mesh;
  56985. }
  56986. }
  56987. declare module BABYLON {
  56988. /**
  56989. * Class containing static functions to help procedurally build meshes
  56990. */
  56991. export class IcoSphereBuilder {
  56992. /**
  56993. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56994. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56995. * * 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`)
  56996. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56997. * * 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
  56998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56999. * * 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
  57000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57001. * @param name defines the name of the mesh
  57002. * @param options defines the options used to create the mesh
  57003. * @param scene defines the hosting scene
  57004. * @returns the icosahedron mesh
  57005. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57006. */
  57007. static CreateIcoSphere(name: string, options: {
  57008. radius?: number;
  57009. radiusX?: number;
  57010. radiusY?: number;
  57011. radiusZ?: number;
  57012. flat?: boolean;
  57013. subdivisions?: number;
  57014. sideOrientation?: number;
  57015. frontUVs?: Vector4;
  57016. backUVs?: Vector4;
  57017. updatable?: boolean;
  57018. }, scene?: Nullable<Scene>): Mesh;
  57019. }
  57020. }
  57021. declare module BABYLON {
  57022. /**
  57023. * Class containing static functions to help procedurally build meshes
  57024. */
  57025. export class DecalBuilder {
  57026. /**
  57027. * Creates a decal mesh.
  57028. * 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
  57029. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57030. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57031. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57032. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57033. * @param name defines the name of the mesh
  57034. * @param sourceMesh defines the mesh where the decal must be applied
  57035. * @param options defines the options used to create the mesh
  57036. * @param scene defines the hosting scene
  57037. * @returns the decal mesh
  57038. * @see https://doc.babylonjs.com/how_to/decals
  57039. */
  57040. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57041. position?: Vector3;
  57042. normal?: Vector3;
  57043. size?: Vector3;
  57044. angle?: number;
  57045. }): Mesh;
  57046. }
  57047. }
  57048. declare module BABYLON {
  57049. /**
  57050. * Class containing static functions to help procedurally build meshes
  57051. */
  57052. export class MeshBuilder {
  57053. /**
  57054. * Creates a box mesh
  57055. * * The parameter `size` sets the size (float) of each box side (default 1)
  57056. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57057. * * 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)
  57058. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57060. * * 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
  57061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57062. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57063. * @param name defines the name of the mesh
  57064. * @param options defines the options used to create the mesh
  57065. * @param scene defines the hosting scene
  57066. * @returns the box mesh
  57067. */
  57068. static CreateBox(name: string, options: {
  57069. size?: number;
  57070. width?: number;
  57071. height?: number;
  57072. depth?: number;
  57073. faceUV?: Vector4[];
  57074. faceColors?: Color4[];
  57075. sideOrientation?: number;
  57076. frontUVs?: Vector4;
  57077. backUVs?: Vector4;
  57078. updatable?: boolean;
  57079. }, scene?: Nullable<Scene>): Mesh;
  57080. /**
  57081. * Creates a tiled box mesh
  57082. * * faceTiles sets the pattern, tile size and number of tiles for a face
  57083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57084. * @param name defines the name of the mesh
  57085. * @param options defines the options used to create the mesh
  57086. * @param scene defines the hosting scene
  57087. * @returns the tiled box mesh
  57088. */
  57089. static CreateTiledBox(name: string, options: {
  57090. pattern?: number;
  57091. size?: number;
  57092. width?: number;
  57093. height?: number;
  57094. depth: number;
  57095. tileSize?: number;
  57096. tileWidth?: number;
  57097. tileHeight?: number;
  57098. faceUV?: Vector4[];
  57099. faceColors?: Color4[];
  57100. alignHorizontal?: number;
  57101. alignVertical?: number;
  57102. sideOrientation?: number;
  57103. updatable?: boolean;
  57104. }, scene?: Nullable<Scene>): Mesh;
  57105. /**
  57106. * Creates a sphere mesh
  57107. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  57108. * * 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`)
  57109. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  57110. * * 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
  57111. * * 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)
  57112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57113. * * 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
  57114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57115. * @param name defines the name of the mesh
  57116. * @param options defines the options used to create the mesh
  57117. * @param scene defines the hosting scene
  57118. * @returns the sphere mesh
  57119. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  57120. */
  57121. static CreateSphere(name: string, options: {
  57122. segments?: number;
  57123. diameter?: number;
  57124. diameterX?: number;
  57125. diameterY?: number;
  57126. diameterZ?: number;
  57127. arc?: number;
  57128. slice?: number;
  57129. sideOrientation?: number;
  57130. frontUVs?: Vector4;
  57131. backUVs?: Vector4;
  57132. updatable?: boolean;
  57133. }, scene?: Nullable<Scene>): Mesh;
  57134. /**
  57135. * Creates a plane polygonal mesh. By default, this is a disc
  57136. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  57137. * * 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
  57138. * * 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
  57139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57140. * * 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
  57141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57142. * @param name defines the name of the mesh
  57143. * @param options defines the options used to create the mesh
  57144. * @param scene defines the hosting scene
  57145. * @returns the plane polygonal mesh
  57146. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  57147. */
  57148. static CreateDisc(name: string, options: {
  57149. radius?: number;
  57150. tessellation?: number;
  57151. arc?: number;
  57152. updatable?: boolean;
  57153. sideOrientation?: number;
  57154. frontUVs?: Vector4;
  57155. backUVs?: Vector4;
  57156. }, scene?: Nullable<Scene>): Mesh;
  57157. /**
  57158. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57159. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57160. * * 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`)
  57161. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57162. * * 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
  57163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57164. * * 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
  57165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57166. * @param name defines the name of the mesh
  57167. * @param options defines the options used to create the mesh
  57168. * @param scene defines the hosting scene
  57169. * @returns the icosahedron mesh
  57170. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57171. */
  57172. static CreateIcoSphere(name: string, options: {
  57173. radius?: number;
  57174. radiusX?: number;
  57175. radiusY?: number;
  57176. radiusZ?: number;
  57177. flat?: boolean;
  57178. subdivisions?: number;
  57179. sideOrientation?: number;
  57180. frontUVs?: Vector4;
  57181. backUVs?: Vector4;
  57182. updatable?: boolean;
  57183. }, scene?: Nullable<Scene>): Mesh;
  57184. /**
  57185. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57186. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57187. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57188. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57189. * * 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
  57190. * * 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
  57191. * * 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
  57192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57193. * * 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
  57194. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57195. * * 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
  57196. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57197. * * 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
  57198. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57200. * @param name defines the name of the mesh
  57201. * @param options defines the options used to create the mesh
  57202. * @param scene defines the hosting scene
  57203. * @returns the ribbon mesh
  57204. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57205. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57206. */
  57207. static CreateRibbon(name: string, options: {
  57208. pathArray: Vector3[][];
  57209. closeArray?: boolean;
  57210. closePath?: boolean;
  57211. offset?: number;
  57212. updatable?: boolean;
  57213. sideOrientation?: number;
  57214. frontUVs?: Vector4;
  57215. backUVs?: Vector4;
  57216. instance?: Mesh;
  57217. invertUV?: boolean;
  57218. uvs?: Vector2[];
  57219. colors?: Color4[];
  57220. }, scene?: Nullable<Scene>): Mesh;
  57221. /**
  57222. * Creates a cylinder or a cone mesh
  57223. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  57224. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  57225. * * 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.
  57226. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  57227. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  57228. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  57229. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  57230. * * 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).
  57231. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  57232. * * 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).
  57233. * * 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
  57234. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  57235. * * 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
  57236. * * 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.
  57237. * * If `enclose` is false, a ring surface is one element.
  57238. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  57239. * * 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
  57240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57241. * * 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
  57242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57243. * @param name defines the name of the mesh
  57244. * @param options defines the options used to create the mesh
  57245. * @param scene defines the hosting scene
  57246. * @returns the cylinder mesh
  57247. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  57248. */
  57249. static CreateCylinder(name: string, options: {
  57250. height?: number;
  57251. diameterTop?: number;
  57252. diameterBottom?: number;
  57253. diameter?: number;
  57254. tessellation?: number;
  57255. subdivisions?: number;
  57256. arc?: number;
  57257. faceColors?: Color4[];
  57258. faceUV?: Vector4[];
  57259. updatable?: boolean;
  57260. hasRings?: boolean;
  57261. enclose?: boolean;
  57262. cap?: number;
  57263. sideOrientation?: number;
  57264. frontUVs?: Vector4;
  57265. backUVs?: Vector4;
  57266. }, scene?: Nullable<Scene>): Mesh;
  57267. /**
  57268. * Creates a torus mesh
  57269. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  57270. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  57271. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  57272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57273. * * 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
  57274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57275. * @param name defines the name of the mesh
  57276. * @param options defines the options used to create the mesh
  57277. * @param scene defines the hosting scene
  57278. * @returns the torus mesh
  57279. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  57280. */
  57281. static CreateTorus(name: string, options: {
  57282. diameter?: number;
  57283. thickness?: number;
  57284. tessellation?: number;
  57285. updatable?: boolean;
  57286. sideOrientation?: number;
  57287. frontUVs?: Vector4;
  57288. backUVs?: Vector4;
  57289. }, scene?: Nullable<Scene>): Mesh;
  57290. /**
  57291. * Creates a torus knot mesh
  57292. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57293. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57294. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57295. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57297. * * 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
  57298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57299. * @param name defines the name of the mesh
  57300. * @param options defines the options used to create the mesh
  57301. * @param scene defines the hosting scene
  57302. * @returns the torus knot mesh
  57303. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57304. */
  57305. static CreateTorusKnot(name: string, options: {
  57306. radius?: number;
  57307. tube?: number;
  57308. radialSegments?: number;
  57309. tubularSegments?: number;
  57310. p?: number;
  57311. q?: number;
  57312. updatable?: boolean;
  57313. sideOrientation?: number;
  57314. frontUVs?: Vector4;
  57315. backUVs?: Vector4;
  57316. }, scene?: Nullable<Scene>): Mesh;
  57317. /**
  57318. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57319. * * 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
  57320. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57321. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57322. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57323. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57324. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57325. * * 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
  57326. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57328. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57329. * @param name defines the name of the new line system
  57330. * @param options defines the options used to create the line system
  57331. * @param scene defines the hosting scene
  57332. * @returns a new line system mesh
  57333. */
  57334. static CreateLineSystem(name: string, options: {
  57335. lines: Vector3[][];
  57336. updatable?: boolean;
  57337. instance?: Nullable<LinesMesh>;
  57338. colors?: Nullable<Color4[][]>;
  57339. useVertexAlpha?: boolean;
  57340. }, scene: Nullable<Scene>): LinesMesh;
  57341. /**
  57342. * Creates a line mesh
  57343. * 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
  57344. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57345. * * The parameter `points` is an array successive Vector3
  57346. * * 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
  57347. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57348. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57349. * * When updating an instance, remember that only point positions can change, not the number of points
  57350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57352. * @param name defines the name of the new line system
  57353. * @param options defines the options used to create the line system
  57354. * @param scene defines the hosting scene
  57355. * @returns a new line mesh
  57356. */
  57357. static CreateLines(name: string, options: {
  57358. points: Vector3[];
  57359. updatable?: boolean;
  57360. instance?: Nullable<LinesMesh>;
  57361. colors?: Color4[];
  57362. useVertexAlpha?: boolean;
  57363. }, scene?: Nullable<Scene>): LinesMesh;
  57364. /**
  57365. * Creates a dashed line mesh
  57366. * * 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
  57367. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57368. * * The parameter `points` is an array successive Vector3
  57369. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57370. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57371. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57372. * * 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
  57373. * * When updating an instance, remember that only point positions can change, not the number of points
  57374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57375. * @param name defines the name of the mesh
  57376. * @param options defines the options used to create the mesh
  57377. * @param scene defines the hosting scene
  57378. * @returns the dashed line mesh
  57379. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57380. */
  57381. static CreateDashedLines(name: string, options: {
  57382. points: Vector3[];
  57383. dashSize?: number;
  57384. gapSize?: number;
  57385. dashNb?: number;
  57386. updatable?: boolean;
  57387. instance?: LinesMesh;
  57388. }, scene?: Nullable<Scene>): LinesMesh;
  57389. /**
  57390. * 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.
  57391. * * 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.
  57392. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57393. * * 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.
  57394. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57395. * * 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
  57396. * * 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
  57397. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57399. * * 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
  57400. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57402. * @param name defines the name of the mesh
  57403. * @param options defines the options used to create the mesh
  57404. * @param scene defines the hosting scene
  57405. * @returns the extruded shape mesh
  57406. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57407. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57408. */
  57409. static ExtrudeShape(name: string, options: {
  57410. shape: Vector3[];
  57411. path: Vector3[];
  57412. scale?: number;
  57413. rotation?: number;
  57414. cap?: number;
  57415. updatable?: boolean;
  57416. sideOrientation?: number;
  57417. frontUVs?: Vector4;
  57418. backUVs?: Vector4;
  57419. instance?: Mesh;
  57420. invertUV?: boolean;
  57421. }, scene?: Nullable<Scene>): Mesh;
  57422. /**
  57423. * Creates an custom extruded shape mesh.
  57424. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57425. * * 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.
  57426. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57427. * * 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
  57428. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57429. * * 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
  57430. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57431. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57432. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57433. * * 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
  57434. * * 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
  57435. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57437. * * 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
  57438. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57440. * @param name defines the name of the mesh
  57441. * @param options defines the options used to create the mesh
  57442. * @param scene defines the hosting scene
  57443. * @returns the custom extruded shape mesh
  57444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57445. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57447. */
  57448. static ExtrudeShapeCustom(name: string, options: {
  57449. shape: Vector3[];
  57450. path: Vector3[];
  57451. scaleFunction?: any;
  57452. rotationFunction?: any;
  57453. ribbonCloseArray?: boolean;
  57454. ribbonClosePath?: boolean;
  57455. cap?: number;
  57456. updatable?: boolean;
  57457. sideOrientation?: number;
  57458. frontUVs?: Vector4;
  57459. backUVs?: Vector4;
  57460. instance?: Mesh;
  57461. invertUV?: boolean;
  57462. }, scene?: Nullable<Scene>): Mesh;
  57463. /**
  57464. * Creates lathe mesh.
  57465. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57466. * * 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
  57467. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57468. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57469. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57470. * * 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
  57471. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57472. * * 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
  57473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57474. * * 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
  57475. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57477. * @param name defines the name of the mesh
  57478. * @param options defines the options used to create the mesh
  57479. * @param scene defines the hosting scene
  57480. * @returns the lathe mesh
  57481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57482. */
  57483. static CreateLathe(name: string, options: {
  57484. shape: Vector3[];
  57485. radius?: number;
  57486. tessellation?: number;
  57487. clip?: number;
  57488. arc?: number;
  57489. closed?: boolean;
  57490. updatable?: boolean;
  57491. sideOrientation?: number;
  57492. frontUVs?: Vector4;
  57493. backUVs?: Vector4;
  57494. cap?: number;
  57495. invertUV?: boolean;
  57496. }, scene?: Nullable<Scene>): Mesh;
  57497. /**
  57498. * Creates a tiled plane mesh
  57499. * * You can set a limited pattern arrangement with the tiles
  57500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57501. * * 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
  57502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57503. * @param name defines the name of the mesh
  57504. * @param options defines the options used to create the mesh
  57505. * @param scene defines the hosting scene
  57506. * @returns the plane mesh
  57507. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57508. */
  57509. static CreateTiledPlane(name: string, options: {
  57510. pattern?: number;
  57511. tileSize?: number;
  57512. tileWidth?: number;
  57513. tileHeight?: number;
  57514. size?: number;
  57515. width?: number;
  57516. height?: number;
  57517. alignHorizontal?: number;
  57518. alignVertical?: number;
  57519. sideOrientation?: number;
  57520. frontUVs?: Vector4;
  57521. backUVs?: Vector4;
  57522. updatable?: boolean;
  57523. }, scene?: Nullable<Scene>): Mesh;
  57524. /**
  57525. * Creates a plane mesh
  57526. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57527. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57528. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57530. * * 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
  57531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57532. * @param name defines the name of the mesh
  57533. * @param options defines the options used to create the mesh
  57534. * @param scene defines the hosting scene
  57535. * @returns the plane mesh
  57536. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57537. */
  57538. static CreatePlane(name: string, options: {
  57539. size?: number;
  57540. width?: number;
  57541. height?: number;
  57542. sideOrientation?: number;
  57543. frontUVs?: Vector4;
  57544. backUVs?: Vector4;
  57545. updatable?: boolean;
  57546. sourcePlane?: Plane;
  57547. }, scene?: Nullable<Scene>): Mesh;
  57548. /**
  57549. * Creates a ground mesh
  57550. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57551. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57553. * @param name defines the name of the mesh
  57554. * @param options defines the options used to create the mesh
  57555. * @param scene defines the hosting scene
  57556. * @returns the ground mesh
  57557. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57558. */
  57559. static CreateGround(name: string, options: {
  57560. width?: number;
  57561. height?: number;
  57562. subdivisions?: number;
  57563. subdivisionsX?: number;
  57564. subdivisionsY?: number;
  57565. updatable?: boolean;
  57566. }, scene?: Nullable<Scene>): Mesh;
  57567. /**
  57568. * Creates a tiled ground mesh
  57569. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57570. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57571. * * 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
  57572. * * 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
  57573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57574. * @param name defines the name of the mesh
  57575. * @param options defines the options used to create the mesh
  57576. * @param scene defines the hosting scene
  57577. * @returns the tiled ground mesh
  57578. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57579. */
  57580. static CreateTiledGround(name: string, options: {
  57581. xmin: number;
  57582. zmin: number;
  57583. xmax: number;
  57584. zmax: number;
  57585. subdivisions?: {
  57586. w: number;
  57587. h: number;
  57588. };
  57589. precision?: {
  57590. w: number;
  57591. h: number;
  57592. };
  57593. updatable?: boolean;
  57594. }, scene?: Nullable<Scene>): Mesh;
  57595. /**
  57596. * Creates a ground mesh from a height map
  57597. * * The parameter `url` sets the URL of the height map image resource.
  57598. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57599. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57600. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57601. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57602. * * 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.
  57603. * * 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).
  57604. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57606. * @param name defines the name of the mesh
  57607. * @param url defines the url to the height map
  57608. * @param options defines the options used to create the mesh
  57609. * @param scene defines the hosting scene
  57610. * @returns the ground mesh
  57611. * @see https://doc.babylonjs.com/babylon101/height_map
  57612. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57613. */
  57614. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57615. width?: number;
  57616. height?: number;
  57617. subdivisions?: number;
  57618. minHeight?: number;
  57619. maxHeight?: number;
  57620. colorFilter?: Color3;
  57621. alphaFilter?: number;
  57622. updatable?: boolean;
  57623. onReady?: (mesh: GroundMesh) => void;
  57624. }, scene?: Nullable<Scene>): GroundMesh;
  57625. /**
  57626. * Creates a polygon mesh
  57627. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57628. * * 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
  57629. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57631. * * 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)
  57632. * * Remember you can only change the shape positions, not their number when updating a polygon
  57633. * @param name defines the name of the mesh
  57634. * @param options defines the options used to create the mesh
  57635. * @param scene defines the hosting scene
  57636. * @param earcutInjection can be used to inject your own earcut reference
  57637. * @returns the polygon mesh
  57638. */
  57639. static CreatePolygon(name: string, options: {
  57640. shape: Vector3[];
  57641. holes?: Vector3[][];
  57642. depth?: number;
  57643. faceUV?: Vector4[];
  57644. faceColors?: Color4[];
  57645. updatable?: boolean;
  57646. sideOrientation?: number;
  57647. frontUVs?: Vector4;
  57648. backUVs?: Vector4;
  57649. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57650. /**
  57651. * Creates an extruded polygon mesh, with depth in the Y direction.
  57652. * * 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)
  57653. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57654. * @param name defines the name of the mesh
  57655. * @param options defines the options used to create the mesh
  57656. * @param scene defines the hosting scene
  57657. * @param earcutInjection can be used to inject your own earcut reference
  57658. * @returns the polygon mesh
  57659. */
  57660. static ExtrudePolygon(name: string, options: {
  57661. shape: Vector3[];
  57662. holes?: Vector3[][];
  57663. depth?: number;
  57664. faceUV?: Vector4[];
  57665. faceColors?: Color4[];
  57666. updatable?: boolean;
  57667. sideOrientation?: number;
  57668. frontUVs?: Vector4;
  57669. backUVs?: Vector4;
  57670. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57671. /**
  57672. * Creates a tube mesh.
  57673. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57674. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57675. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57676. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57677. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57678. * * 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)
  57679. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57680. * * 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
  57681. * * 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
  57682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57683. * * 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
  57684. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57686. * @param name defines the name of the mesh
  57687. * @param options defines the options used to create the mesh
  57688. * @param scene defines the hosting scene
  57689. * @returns the tube mesh
  57690. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57691. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57692. */
  57693. static CreateTube(name: string, options: {
  57694. path: Vector3[];
  57695. radius?: number;
  57696. tessellation?: number;
  57697. radiusFunction?: {
  57698. (i: number, distance: number): number;
  57699. };
  57700. cap?: number;
  57701. arc?: number;
  57702. updatable?: boolean;
  57703. sideOrientation?: number;
  57704. frontUVs?: Vector4;
  57705. backUVs?: Vector4;
  57706. instance?: Mesh;
  57707. invertUV?: boolean;
  57708. }, scene?: Nullable<Scene>): Mesh;
  57709. /**
  57710. * Creates a polyhedron mesh
  57711. * * 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
  57712. * * The parameter `size` (positive float, default 1) sets the polygon size
  57713. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57714. * * 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`
  57715. * * 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
  57716. * * 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)`)
  57717. * * 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
  57718. * * 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
  57719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57720. * * 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
  57721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57722. * @param name defines the name of the mesh
  57723. * @param options defines the options used to create the mesh
  57724. * @param scene defines the hosting scene
  57725. * @returns the polyhedron mesh
  57726. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57727. */
  57728. static CreatePolyhedron(name: string, options: {
  57729. type?: number;
  57730. size?: number;
  57731. sizeX?: number;
  57732. sizeY?: number;
  57733. sizeZ?: number;
  57734. custom?: any;
  57735. faceUV?: Vector4[];
  57736. faceColors?: Color4[];
  57737. flat?: boolean;
  57738. updatable?: boolean;
  57739. sideOrientation?: number;
  57740. frontUVs?: Vector4;
  57741. backUVs?: Vector4;
  57742. }, scene?: Nullable<Scene>): Mesh;
  57743. /**
  57744. * Creates a decal mesh.
  57745. * 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
  57746. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57747. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57748. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57749. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57750. * @param name defines the name of the mesh
  57751. * @param sourceMesh defines the mesh where the decal must be applied
  57752. * @param options defines the options used to create the mesh
  57753. * @param scene defines the hosting scene
  57754. * @returns the decal mesh
  57755. * @see https://doc.babylonjs.com/how_to/decals
  57756. */
  57757. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57758. position?: Vector3;
  57759. normal?: Vector3;
  57760. size?: Vector3;
  57761. angle?: number;
  57762. }): Mesh;
  57763. }
  57764. }
  57765. declare module BABYLON {
  57766. /**
  57767. * A simplifier interface for future simplification implementations
  57768. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57769. */
  57770. export interface ISimplifier {
  57771. /**
  57772. * Simplification of a given mesh according to the given settings.
  57773. * Since this requires computation, it is assumed that the function runs async.
  57774. * @param settings The settings of the simplification, including quality and distance
  57775. * @param successCallback A callback that will be called after the mesh was simplified.
  57776. * @param errorCallback in case of an error, this callback will be called. optional.
  57777. */
  57778. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57779. }
  57780. /**
  57781. * Expected simplification settings.
  57782. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57783. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57784. */
  57785. export interface ISimplificationSettings {
  57786. /**
  57787. * Gets or sets the expected quality
  57788. */
  57789. quality: number;
  57790. /**
  57791. * Gets or sets the distance when this optimized version should be used
  57792. */
  57793. distance: number;
  57794. /**
  57795. * Gets an already optimized mesh
  57796. */
  57797. optimizeMesh?: boolean;
  57798. }
  57799. /**
  57800. * Class used to specify simplification options
  57801. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57802. */
  57803. export class SimplificationSettings implements ISimplificationSettings {
  57804. /** expected quality */
  57805. quality: number;
  57806. /** distance when this optimized version should be used */
  57807. distance: number;
  57808. /** already optimized mesh */
  57809. optimizeMesh?: boolean | undefined;
  57810. /**
  57811. * Creates a SimplificationSettings
  57812. * @param quality expected quality
  57813. * @param distance distance when this optimized version should be used
  57814. * @param optimizeMesh already optimized mesh
  57815. */
  57816. constructor(
  57817. /** expected quality */
  57818. quality: number,
  57819. /** distance when this optimized version should be used */
  57820. distance: number,
  57821. /** already optimized mesh */
  57822. optimizeMesh?: boolean | undefined);
  57823. }
  57824. /**
  57825. * Interface used to define a simplification task
  57826. */
  57827. export interface ISimplificationTask {
  57828. /**
  57829. * Array of settings
  57830. */
  57831. settings: Array<ISimplificationSettings>;
  57832. /**
  57833. * Simplification type
  57834. */
  57835. simplificationType: SimplificationType;
  57836. /**
  57837. * Mesh to simplify
  57838. */
  57839. mesh: Mesh;
  57840. /**
  57841. * Callback called on success
  57842. */
  57843. successCallback?: () => void;
  57844. /**
  57845. * Defines if parallel processing can be used
  57846. */
  57847. parallelProcessing: boolean;
  57848. }
  57849. /**
  57850. * Queue used to order the simplification tasks
  57851. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57852. */
  57853. export class SimplificationQueue {
  57854. private _simplificationArray;
  57855. /**
  57856. * Gets a boolean indicating that the process is still running
  57857. */
  57858. running: boolean;
  57859. /**
  57860. * Creates a new queue
  57861. */
  57862. constructor();
  57863. /**
  57864. * Adds a new simplification task
  57865. * @param task defines a task to add
  57866. */
  57867. addTask(task: ISimplificationTask): void;
  57868. /**
  57869. * Execute next task
  57870. */
  57871. executeNext(): void;
  57872. /**
  57873. * Execute a simplification task
  57874. * @param task defines the task to run
  57875. */
  57876. runSimplification(task: ISimplificationTask): void;
  57877. private getSimplifier;
  57878. }
  57879. /**
  57880. * The implemented types of simplification
  57881. * At the moment only Quadratic Error Decimation is implemented
  57882. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57883. */
  57884. export enum SimplificationType {
  57885. /** Quadratic error decimation */
  57886. QUADRATIC = 0
  57887. }
  57888. }
  57889. declare module BABYLON {
  57890. interface Scene {
  57891. /** @hidden (Backing field) */
  57892. _simplificationQueue: SimplificationQueue;
  57893. /**
  57894. * Gets or sets the simplification queue attached to the scene
  57895. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57896. */
  57897. simplificationQueue: SimplificationQueue;
  57898. }
  57899. interface Mesh {
  57900. /**
  57901. * Simplify the mesh according to the given array of settings.
  57902. * Function will return immediately and will simplify async
  57903. * @param settings a collection of simplification settings
  57904. * @param parallelProcessing should all levels calculate parallel or one after the other
  57905. * @param simplificationType the type of simplification to run
  57906. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57907. * @returns the current mesh
  57908. */
  57909. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57910. }
  57911. /**
  57912. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57913. * created in a scene
  57914. */
  57915. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57916. /**
  57917. * The component name helpfull to identify the component in the list of scene components.
  57918. */
  57919. readonly name: string;
  57920. /**
  57921. * The scene the component belongs to.
  57922. */
  57923. scene: Scene;
  57924. /**
  57925. * Creates a new instance of the component for the given scene
  57926. * @param scene Defines the scene to register the component in
  57927. */
  57928. constructor(scene: Scene);
  57929. /**
  57930. * Registers the component in a given scene
  57931. */
  57932. register(): void;
  57933. /**
  57934. * Rebuilds the elements related to this component in case of
  57935. * context lost for instance.
  57936. */
  57937. rebuild(): void;
  57938. /**
  57939. * Disposes the component and the associated ressources
  57940. */
  57941. dispose(): void;
  57942. private _beforeCameraUpdate;
  57943. }
  57944. }
  57945. declare module BABYLON {
  57946. /**
  57947. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57948. */
  57949. export interface INavigationEnginePlugin {
  57950. /**
  57951. * plugin name
  57952. */
  57953. name: string;
  57954. /**
  57955. * Creates a navigation mesh
  57956. * @param meshes array of all the geometry used to compute the navigatio mesh
  57957. * @param parameters bunch of parameters used to filter geometry
  57958. */
  57959. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57960. /**
  57961. * Create a navigation mesh debug mesh
  57962. * @param scene is where the mesh will be added
  57963. * @returns debug display mesh
  57964. */
  57965. createDebugNavMesh(scene: Scene): Mesh;
  57966. /**
  57967. * Get a navigation mesh constrained position, closest to the parameter position
  57968. * @param position world position
  57969. * @returns the closest point to position constrained by the navigation mesh
  57970. */
  57971. getClosestPoint(position: Vector3): Vector3;
  57972. /**
  57973. * Get a navigation mesh constrained position, within a particular radius
  57974. * @param position world position
  57975. * @param maxRadius the maximum distance to the constrained world position
  57976. * @returns the closest point to position constrained by the navigation mesh
  57977. */
  57978. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57979. /**
  57980. * Compute the final position from a segment made of destination-position
  57981. * @param position world position
  57982. * @param destination world position
  57983. * @returns the resulting point along the navmesh
  57984. */
  57985. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57986. /**
  57987. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57988. * @param start world position
  57989. * @param end world position
  57990. * @returns array containing world position composing the path
  57991. */
  57992. computePath(start: Vector3, end: Vector3): Vector3[];
  57993. /**
  57994. * If this plugin is supported
  57995. * @returns true if plugin is supported
  57996. */
  57997. isSupported(): boolean;
  57998. /**
  57999. * Create a new Crowd so you can add agents
  58000. * @param maxAgents the maximum agent count in the crowd
  58001. * @param maxAgentRadius the maximum radius an agent can have
  58002. * @param scene to attach the crowd to
  58003. * @returns the crowd you can add agents to
  58004. */
  58005. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58006. /**
  58007. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58008. * The queries will try to find a solution within those bounds
  58009. * default is (1,1,1)
  58010. * @param extent x,y,z value that define the extent around the queries point of reference
  58011. */
  58012. setDefaultQueryExtent(extent: Vector3): void;
  58013. /**
  58014. * Get the Bounding box extent specified by setDefaultQueryExtent
  58015. * @returns the box extent values
  58016. */
  58017. getDefaultQueryExtent(): Vector3;
  58018. /**
  58019. * Release all resources
  58020. */
  58021. dispose(): void;
  58022. }
  58023. /**
  58024. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  58025. */
  58026. export interface ICrowd {
  58027. /**
  58028. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58029. * You can attach anything to that node. The node position is updated in the scene update tick.
  58030. * @param pos world position that will be constrained by the navigation mesh
  58031. * @param parameters agent parameters
  58032. * @param transform hooked to the agent that will be update by the scene
  58033. * @returns agent index
  58034. */
  58035. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58036. /**
  58037. * Returns the agent position in world space
  58038. * @param index agent index returned by addAgent
  58039. * @returns world space position
  58040. */
  58041. getAgentPosition(index: number): Vector3;
  58042. /**
  58043. * Gets the agent velocity in world space
  58044. * @param index agent index returned by addAgent
  58045. * @returns world space velocity
  58046. */
  58047. getAgentVelocity(index: number): Vector3;
  58048. /**
  58049. * remove a particular agent previously created
  58050. * @param index agent index returned by addAgent
  58051. */
  58052. removeAgent(index: number): void;
  58053. /**
  58054. * get the list of all agents attached to this crowd
  58055. * @returns list of agent indices
  58056. */
  58057. getAgents(): number[];
  58058. /**
  58059. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58060. * @param deltaTime in seconds
  58061. */
  58062. update(deltaTime: number): void;
  58063. /**
  58064. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58065. * @param index agent index returned by addAgent
  58066. * @param destination targeted world position
  58067. */
  58068. agentGoto(index: number, destination: Vector3): void;
  58069. /**
  58070. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58071. * The queries will try to find a solution within those bounds
  58072. * default is (1,1,1)
  58073. * @param extent x,y,z value that define the extent around the queries point of reference
  58074. */
  58075. setDefaultQueryExtent(extent: Vector3): void;
  58076. /**
  58077. * Get the Bounding box extent specified by setDefaultQueryExtent
  58078. * @returns the box extent values
  58079. */
  58080. getDefaultQueryExtent(): Vector3;
  58081. /**
  58082. * Release all resources
  58083. */
  58084. dispose(): void;
  58085. }
  58086. /**
  58087. * Configures an agent
  58088. */
  58089. export interface IAgentParameters {
  58090. /**
  58091. * Agent radius. [Limit: >= 0]
  58092. */
  58093. radius: number;
  58094. /**
  58095. * Agent height. [Limit: > 0]
  58096. */
  58097. height: number;
  58098. /**
  58099. * Maximum allowed acceleration. [Limit: >= 0]
  58100. */
  58101. maxAcceleration: number;
  58102. /**
  58103. * Maximum allowed speed. [Limit: >= 0]
  58104. */
  58105. maxSpeed: number;
  58106. /**
  58107. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  58108. */
  58109. collisionQueryRange: number;
  58110. /**
  58111. * The path visibility optimization range. [Limit: > 0]
  58112. */
  58113. pathOptimizationRange: number;
  58114. /**
  58115. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  58116. */
  58117. separationWeight: number;
  58118. }
  58119. /**
  58120. * Configures the navigation mesh creation
  58121. */
  58122. export interface INavMeshParameters {
  58123. /**
  58124. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  58125. */
  58126. cs: number;
  58127. /**
  58128. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  58129. */
  58130. ch: number;
  58131. /**
  58132. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  58133. */
  58134. walkableSlopeAngle: number;
  58135. /**
  58136. * Minimum floor to 'ceiling' height that will still allow the floor area to
  58137. * be considered walkable. [Limit: >= 3] [Units: vx]
  58138. */
  58139. walkableHeight: number;
  58140. /**
  58141. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  58142. */
  58143. walkableClimb: number;
  58144. /**
  58145. * The distance to erode/shrink the walkable area of the heightfield away from
  58146. * obstructions. [Limit: >=0] [Units: vx]
  58147. */
  58148. walkableRadius: number;
  58149. /**
  58150. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  58151. */
  58152. maxEdgeLen: number;
  58153. /**
  58154. * The maximum distance a simplfied contour's border edges should deviate
  58155. * the original raw contour. [Limit: >=0] [Units: vx]
  58156. */
  58157. maxSimplificationError: number;
  58158. /**
  58159. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  58160. */
  58161. minRegionArea: number;
  58162. /**
  58163. * Any regions with a span count smaller than this value will, if possible,
  58164. * be merged with larger regions. [Limit: >=0] [Units: vx]
  58165. */
  58166. mergeRegionArea: number;
  58167. /**
  58168. * The maximum number of vertices allowed for polygons generated during the
  58169. * contour to polygon conversion process. [Limit: >= 3]
  58170. */
  58171. maxVertsPerPoly: number;
  58172. /**
  58173. * Sets the sampling distance to use when generating the detail mesh.
  58174. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  58175. */
  58176. detailSampleDist: number;
  58177. /**
  58178. * The maximum distance the detail mesh surface should deviate from heightfield
  58179. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  58180. */
  58181. detailSampleMaxError: number;
  58182. }
  58183. }
  58184. declare module BABYLON {
  58185. /**
  58186. * RecastJS navigation plugin
  58187. */
  58188. export class RecastJSPlugin implements INavigationEnginePlugin {
  58189. /**
  58190. * Reference to the Recast library
  58191. */
  58192. bjsRECAST: any;
  58193. /**
  58194. * plugin name
  58195. */
  58196. name: string;
  58197. /**
  58198. * the first navmesh created. We might extend this to support multiple navmeshes
  58199. */
  58200. navMesh: any;
  58201. /**
  58202. * Initializes the recastJS plugin
  58203. * @param recastInjection can be used to inject your own recast reference
  58204. */
  58205. constructor(recastInjection?: any);
  58206. /**
  58207. * Creates a navigation mesh
  58208. * @param meshes array of all the geometry used to compute the navigatio mesh
  58209. * @param parameters bunch of parameters used to filter geometry
  58210. */
  58211. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58212. /**
  58213. * Create a navigation mesh debug mesh
  58214. * @param scene is where the mesh will be added
  58215. * @returns debug display mesh
  58216. */
  58217. createDebugNavMesh(scene: Scene): Mesh;
  58218. /**
  58219. * Get a navigation mesh constrained position, closest to the parameter position
  58220. * @param position world position
  58221. * @returns the closest point to position constrained by the navigation mesh
  58222. */
  58223. getClosestPoint(position: Vector3): Vector3;
  58224. /**
  58225. * Get a navigation mesh constrained position, within a particular radius
  58226. * @param position world position
  58227. * @param maxRadius the maximum distance to the constrained world position
  58228. * @returns the closest point to position constrained by the navigation mesh
  58229. */
  58230. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58231. /**
  58232. * Compute the final position from a segment made of destination-position
  58233. * @param position world position
  58234. * @param destination world position
  58235. * @returns the resulting point along the navmesh
  58236. */
  58237. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58238. /**
  58239. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58240. * @param start world position
  58241. * @param end world position
  58242. * @returns array containing world position composing the path
  58243. */
  58244. computePath(start: Vector3, end: Vector3): Vector3[];
  58245. /**
  58246. * Create a new Crowd so you can add agents
  58247. * @param maxAgents the maximum agent count in the crowd
  58248. * @param maxAgentRadius the maximum radius an agent can have
  58249. * @param scene to attach the crowd to
  58250. * @returns the crowd you can add agents to
  58251. */
  58252. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58253. /**
  58254. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58255. * The queries will try to find a solution within those bounds
  58256. * default is (1,1,1)
  58257. * @param extent x,y,z value that define the extent around the queries point of reference
  58258. */
  58259. setDefaultQueryExtent(extent: Vector3): void;
  58260. /**
  58261. * Get the Bounding box extent specified by setDefaultQueryExtent
  58262. * @returns the box extent values
  58263. */
  58264. getDefaultQueryExtent(): Vector3;
  58265. /**
  58266. * Disposes
  58267. */
  58268. dispose(): void;
  58269. /**
  58270. * If this plugin is supported
  58271. * @returns true if plugin is supported
  58272. */
  58273. isSupported(): boolean;
  58274. }
  58275. /**
  58276. * Recast detour crowd implementation
  58277. */
  58278. export class RecastJSCrowd implements ICrowd {
  58279. /**
  58280. * Recast/detour plugin
  58281. */
  58282. bjsRECASTPlugin: RecastJSPlugin;
  58283. /**
  58284. * Link to the detour crowd
  58285. */
  58286. recastCrowd: any;
  58287. /**
  58288. * One transform per agent
  58289. */
  58290. transforms: TransformNode[];
  58291. /**
  58292. * All agents created
  58293. */
  58294. agents: number[];
  58295. /**
  58296. * Link to the scene is kept to unregister the crowd from the scene
  58297. */
  58298. private _scene;
  58299. /**
  58300. * Observer for crowd updates
  58301. */
  58302. private _onBeforeAnimationsObserver;
  58303. /**
  58304. * Constructor
  58305. * @param plugin recastJS plugin
  58306. * @param maxAgents the maximum agent count in the crowd
  58307. * @param maxAgentRadius the maximum radius an agent can have
  58308. * @param scene to attach the crowd to
  58309. * @returns the crowd you can add agents to
  58310. */
  58311. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  58312. /**
  58313. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58314. * You can attach anything to that node. The node position is updated in the scene update tick.
  58315. * @param pos world position that will be constrained by the navigation mesh
  58316. * @param parameters agent parameters
  58317. * @param transform hooked to the agent that will be update by the scene
  58318. * @returns agent index
  58319. */
  58320. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58321. /**
  58322. * Returns the agent position in world space
  58323. * @param index agent index returned by addAgent
  58324. * @returns world space position
  58325. */
  58326. getAgentPosition(index: number): Vector3;
  58327. /**
  58328. * Returns the agent velocity in world space
  58329. * @param index agent index returned by addAgent
  58330. * @returns world space velocity
  58331. */
  58332. getAgentVelocity(index: number): Vector3;
  58333. /**
  58334. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58335. * @param index agent index returned by addAgent
  58336. * @param destination targeted world position
  58337. */
  58338. agentGoto(index: number, destination: Vector3): void;
  58339. /**
  58340. * remove a particular agent previously created
  58341. * @param index agent index returned by addAgent
  58342. */
  58343. removeAgent(index: number): void;
  58344. /**
  58345. * get the list of all agents attached to this crowd
  58346. * @returns list of agent indices
  58347. */
  58348. getAgents(): number[];
  58349. /**
  58350. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58351. * @param deltaTime in seconds
  58352. */
  58353. update(deltaTime: number): void;
  58354. /**
  58355. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58356. * The queries will try to find a solution within those bounds
  58357. * default is (1,1,1)
  58358. * @param extent x,y,z value that define the extent around the queries point of reference
  58359. */
  58360. setDefaultQueryExtent(extent: Vector3): void;
  58361. /**
  58362. * Get the Bounding box extent specified by setDefaultQueryExtent
  58363. * @returns the box extent values
  58364. */
  58365. getDefaultQueryExtent(): Vector3;
  58366. /**
  58367. * Release all resources
  58368. */
  58369. dispose(): void;
  58370. }
  58371. }
  58372. declare module BABYLON {
  58373. /**
  58374. * Class used to enable access to IndexedDB
  58375. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  58376. */
  58377. export class Database implements IOfflineProvider {
  58378. private _callbackManifestChecked;
  58379. private _currentSceneUrl;
  58380. private _db;
  58381. private _enableSceneOffline;
  58382. private _enableTexturesOffline;
  58383. private _manifestVersionFound;
  58384. private _mustUpdateRessources;
  58385. private _hasReachedQuota;
  58386. private _isSupported;
  58387. private _idbFactory;
  58388. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  58389. private static IsUASupportingBlobStorage;
  58390. /**
  58391. * Gets a boolean indicating if Database storate is enabled (off by default)
  58392. */
  58393. static IDBStorageEnabled: boolean;
  58394. /**
  58395. * Gets a boolean indicating if scene must be saved in the database
  58396. */
  58397. readonly enableSceneOffline: boolean;
  58398. /**
  58399. * Gets a boolean indicating if textures must be saved in the database
  58400. */
  58401. readonly enableTexturesOffline: boolean;
  58402. /**
  58403. * Creates a new Database
  58404. * @param urlToScene defines the url to load the scene
  58405. * @param callbackManifestChecked defines the callback to use when manifest is checked
  58406. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  58407. */
  58408. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  58409. private static _ParseURL;
  58410. private static _ReturnFullUrlLocation;
  58411. private _checkManifestFile;
  58412. /**
  58413. * Open the database and make it available
  58414. * @param successCallback defines the callback to call on success
  58415. * @param errorCallback defines the callback to call on error
  58416. */
  58417. open(successCallback: () => void, errorCallback: () => void): void;
  58418. /**
  58419. * Loads an image from the database
  58420. * @param url defines the url to load from
  58421. * @param image defines the target DOM image
  58422. */
  58423. loadImage(url: string, image: HTMLImageElement): void;
  58424. private _loadImageFromDBAsync;
  58425. private _saveImageIntoDBAsync;
  58426. private _checkVersionFromDB;
  58427. private _loadVersionFromDBAsync;
  58428. private _saveVersionIntoDBAsync;
  58429. /**
  58430. * Loads a file from database
  58431. * @param url defines the URL to load from
  58432. * @param sceneLoaded defines a callback to call on success
  58433. * @param progressCallBack defines a callback to call when progress changed
  58434. * @param errorCallback defines a callback to call on error
  58435. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  58436. */
  58437. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  58438. private _loadFileAsync;
  58439. private _saveFileAsync;
  58440. /**
  58441. * Validates if xhr data is correct
  58442. * @param xhr defines the request to validate
  58443. * @param dataType defines the expected data type
  58444. * @returns true if data is correct
  58445. */
  58446. private static _ValidateXHRData;
  58447. }
  58448. }
  58449. declare module BABYLON {
  58450. /** @hidden */
  58451. export var gpuUpdateParticlesPixelShader: {
  58452. name: string;
  58453. shader: string;
  58454. };
  58455. }
  58456. declare module BABYLON {
  58457. /** @hidden */
  58458. export var gpuUpdateParticlesVertexShader: {
  58459. name: string;
  58460. shader: string;
  58461. };
  58462. }
  58463. declare module BABYLON {
  58464. /** @hidden */
  58465. export var clipPlaneFragmentDeclaration2: {
  58466. name: string;
  58467. shader: string;
  58468. };
  58469. }
  58470. declare module BABYLON {
  58471. /** @hidden */
  58472. export var gpuRenderParticlesPixelShader: {
  58473. name: string;
  58474. shader: string;
  58475. };
  58476. }
  58477. declare module BABYLON {
  58478. /** @hidden */
  58479. export var clipPlaneVertexDeclaration2: {
  58480. name: string;
  58481. shader: string;
  58482. };
  58483. }
  58484. declare module BABYLON {
  58485. /** @hidden */
  58486. export var gpuRenderParticlesVertexShader: {
  58487. name: string;
  58488. shader: string;
  58489. };
  58490. }
  58491. declare module BABYLON {
  58492. /**
  58493. * This represents a GPU particle system in Babylon
  58494. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  58495. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  58496. */
  58497. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  58498. /**
  58499. * The layer mask we are rendering the particles through.
  58500. */
  58501. layerMask: number;
  58502. private _capacity;
  58503. private _activeCount;
  58504. private _currentActiveCount;
  58505. private _accumulatedCount;
  58506. private _renderEffect;
  58507. private _updateEffect;
  58508. private _buffer0;
  58509. private _buffer1;
  58510. private _spriteBuffer;
  58511. private _updateVAO;
  58512. private _renderVAO;
  58513. private _targetIndex;
  58514. private _sourceBuffer;
  58515. private _targetBuffer;
  58516. private _engine;
  58517. private _currentRenderId;
  58518. private _started;
  58519. private _stopped;
  58520. private _timeDelta;
  58521. private _randomTexture;
  58522. private _randomTexture2;
  58523. private _attributesStrideSize;
  58524. private _updateEffectOptions;
  58525. private _randomTextureSize;
  58526. private _actualFrame;
  58527. private readonly _rawTextureWidth;
  58528. /**
  58529. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58530. */
  58531. static readonly IsSupported: boolean;
  58532. /**
  58533. * An event triggered when the system is disposed.
  58534. */
  58535. onDisposeObservable: Observable<GPUParticleSystem>;
  58536. /**
  58537. * Gets the maximum number of particles active at the same time.
  58538. * @returns The max number of active particles.
  58539. */
  58540. getCapacity(): number;
  58541. /**
  58542. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58543. * to override the particles.
  58544. */
  58545. forceDepthWrite: boolean;
  58546. /**
  58547. * Gets or set the number of active particles
  58548. */
  58549. activeParticleCount: number;
  58550. private _preWarmDone;
  58551. /**
  58552. * Is this system ready to be used/rendered
  58553. * @return true if the system is ready
  58554. */
  58555. isReady(): boolean;
  58556. /**
  58557. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58558. * @returns True if it has been started, otherwise false.
  58559. */
  58560. isStarted(): boolean;
  58561. /**
  58562. * Starts the particle system and begins to emit
  58563. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58564. */
  58565. start(delay?: number): void;
  58566. /**
  58567. * Stops the particle system.
  58568. */
  58569. stop(): void;
  58570. /**
  58571. * Remove all active particles
  58572. */
  58573. reset(): void;
  58574. /**
  58575. * Returns the string "GPUParticleSystem"
  58576. * @returns a string containing the class name
  58577. */
  58578. getClassName(): string;
  58579. private _colorGradientsTexture;
  58580. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  58581. /**
  58582. * Adds a new color gradient
  58583. * @param gradient defines the gradient to use (between 0 and 1)
  58584. * @param color1 defines the color to affect to the specified gradient
  58585. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58586. * @returns the current particle system
  58587. */
  58588. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58589. /**
  58590. * Remove a specific color gradient
  58591. * @param gradient defines the gradient to remove
  58592. * @returns the current particle system
  58593. */
  58594. removeColorGradient(gradient: number): GPUParticleSystem;
  58595. private _angularSpeedGradientsTexture;
  58596. private _sizeGradientsTexture;
  58597. private _velocityGradientsTexture;
  58598. private _limitVelocityGradientsTexture;
  58599. private _dragGradientsTexture;
  58600. private _addFactorGradient;
  58601. /**
  58602. * Adds a new size gradient
  58603. * @param gradient defines the gradient to use (between 0 and 1)
  58604. * @param factor defines the size factor to affect to the specified gradient
  58605. * @returns the current particle system
  58606. */
  58607. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58608. /**
  58609. * Remove a specific size gradient
  58610. * @param gradient defines the gradient to remove
  58611. * @returns the current particle system
  58612. */
  58613. removeSizeGradient(gradient: number): GPUParticleSystem;
  58614. /**
  58615. * Adds a new angular speed gradient
  58616. * @param gradient defines the gradient to use (between 0 and 1)
  58617. * @param factor defines the angular speed to affect to the specified gradient
  58618. * @returns the current particle system
  58619. */
  58620. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58621. /**
  58622. * Remove a specific angular speed gradient
  58623. * @param gradient defines the gradient to remove
  58624. * @returns the current particle system
  58625. */
  58626. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58627. /**
  58628. * Adds a new velocity gradient
  58629. * @param gradient defines the gradient to use (between 0 and 1)
  58630. * @param factor defines the velocity to affect to the specified gradient
  58631. * @returns the current particle system
  58632. */
  58633. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58634. /**
  58635. * Remove a specific velocity gradient
  58636. * @param gradient defines the gradient to remove
  58637. * @returns the current particle system
  58638. */
  58639. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58640. /**
  58641. * Adds a new limit velocity gradient
  58642. * @param gradient defines the gradient to use (between 0 and 1)
  58643. * @param factor defines the limit velocity value to affect to the specified gradient
  58644. * @returns the current particle system
  58645. */
  58646. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58647. /**
  58648. * Remove a specific limit velocity gradient
  58649. * @param gradient defines the gradient to remove
  58650. * @returns the current particle system
  58651. */
  58652. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58653. /**
  58654. * Adds a new drag gradient
  58655. * @param gradient defines the gradient to use (between 0 and 1)
  58656. * @param factor defines the drag value to affect to the specified gradient
  58657. * @returns the current particle system
  58658. */
  58659. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58660. /**
  58661. * Remove a specific drag gradient
  58662. * @param gradient defines the gradient to remove
  58663. * @returns the current particle system
  58664. */
  58665. removeDragGradient(gradient: number): GPUParticleSystem;
  58666. /**
  58667. * Not supported by GPUParticleSystem
  58668. * @param gradient defines the gradient to use (between 0 and 1)
  58669. * @param factor defines the emit rate value to affect to the specified gradient
  58670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58671. * @returns the current particle system
  58672. */
  58673. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58674. /**
  58675. * Not supported by GPUParticleSystem
  58676. * @param gradient defines the gradient to remove
  58677. * @returns the current particle system
  58678. */
  58679. removeEmitRateGradient(gradient: number): IParticleSystem;
  58680. /**
  58681. * Not supported by GPUParticleSystem
  58682. * @param gradient defines the gradient to use (between 0 and 1)
  58683. * @param factor defines the start size value to affect to the specified gradient
  58684. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58685. * @returns the current particle system
  58686. */
  58687. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58688. /**
  58689. * Not supported by GPUParticleSystem
  58690. * @param gradient defines the gradient to remove
  58691. * @returns the current particle system
  58692. */
  58693. removeStartSizeGradient(gradient: number): IParticleSystem;
  58694. /**
  58695. * Not supported by GPUParticleSystem
  58696. * @param gradient defines the gradient to use (between 0 and 1)
  58697. * @param min defines the color remap minimal range
  58698. * @param max defines the color remap maximal range
  58699. * @returns the current particle system
  58700. */
  58701. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58702. /**
  58703. * Not supported by GPUParticleSystem
  58704. * @param gradient defines the gradient to remove
  58705. * @returns the current particle system
  58706. */
  58707. removeColorRemapGradient(): IParticleSystem;
  58708. /**
  58709. * Not supported by GPUParticleSystem
  58710. * @param gradient defines the gradient to use (between 0 and 1)
  58711. * @param min defines the alpha remap minimal range
  58712. * @param max defines the alpha remap maximal range
  58713. * @returns the current particle system
  58714. */
  58715. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58716. /**
  58717. * Not supported by GPUParticleSystem
  58718. * @param gradient defines the gradient to remove
  58719. * @returns the current particle system
  58720. */
  58721. removeAlphaRemapGradient(): IParticleSystem;
  58722. /**
  58723. * Not supported by GPUParticleSystem
  58724. * @param gradient defines the gradient to use (between 0 and 1)
  58725. * @param color defines the color to affect to the specified gradient
  58726. * @returns the current particle system
  58727. */
  58728. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58729. /**
  58730. * Not supported by GPUParticleSystem
  58731. * @param gradient defines the gradient to remove
  58732. * @returns the current particle system
  58733. */
  58734. removeRampGradient(): IParticleSystem;
  58735. /**
  58736. * Not supported by GPUParticleSystem
  58737. * @returns the list of ramp gradients
  58738. */
  58739. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58740. /**
  58741. * Not supported by GPUParticleSystem
  58742. * Gets or sets a boolean indicating that ramp gradients must be used
  58743. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58744. */
  58745. useRampGradients: boolean;
  58746. /**
  58747. * Not supported by GPUParticleSystem
  58748. * @param gradient defines the gradient to use (between 0 and 1)
  58749. * @param factor defines the life time factor to affect to the specified gradient
  58750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58751. * @returns the current particle system
  58752. */
  58753. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58754. /**
  58755. * Not supported by GPUParticleSystem
  58756. * @param gradient defines the gradient to remove
  58757. * @returns the current particle system
  58758. */
  58759. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58760. /**
  58761. * Instantiates a GPU particle system.
  58762. * 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.
  58763. * @param name The name of the particle system
  58764. * @param options The options used to create the system
  58765. * @param scene The scene the particle system belongs to
  58766. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58767. */
  58768. constructor(name: string, options: Partial<{
  58769. capacity: number;
  58770. randomTextureSize: number;
  58771. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58772. protected _reset(): void;
  58773. private _createUpdateVAO;
  58774. private _createRenderVAO;
  58775. private _initialize;
  58776. /** @hidden */
  58777. _recreateUpdateEffect(): void;
  58778. /** @hidden */
  58779. _recreateRenderEffect(): void;
  58780. /**
  58781. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58782. * @param preWarm defines if we are in the pre-warmimg phase
  58783. */
  58784. animate(preWarm?: boolean): void;
  58785. private _createFactorGradientTexture;
  58786. private _createSizeGradientTexture;
  58787. private _createAngularSpeedGradientTexture;
  58788. private _createVelocityGradientTexture;
  58789. private _createLimitVelocityGradientTexture;
  58790. private _createDragGradientTexture;
  58791. private _createColorGradientTexture;
  58792. /**
  58793. * Renders the particle system in its current state
  58794. * @param preWarm defines if the system should only update the particles but not render them
  58795. * @returns the current number of particles
  58796. */
  58797. render(preWarm?: boolean): number;
  58798. /**
  58799. * Rebuilds the particle system
  58800. */
  58801. rebuild(): void;
  58802. private _releaseBuffers;
  58803. private _releaseVAOs;
  58804. /**
  58805. * Disposes the particle system and free the associated resources
  58806. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58807. */
  58808. dispose(disposeTexture?: boolean): void;
  58809. /**
  58810. * Clones the particle system.
  58811. * @param name The name of the cloned object
  58812. * @param newEmitter The new emitter to use
  58813. * @returns the cloned particle system
  58814. */
  58815. clone(name: string, newEmitter: any): GPUParticleSystem;
  58816. /**
  58817. * Serializes the particle system to a JSON object.
  58818. * @returns the JSON object
  58819. */
  58820. serialize(): any;
  58821. /**
  58822. * Parses a JSON object to create a GPU particle system.
  58823. * @param parsedParticleSystem The JSON object to parse
  58824. * @param scene The scene to create the particle system in
  58825. * @param rootUrl The root url to use to load external dependencies like texture
  58826. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58827. * @returns the parsed GPU particle system
  58828. */
  58829. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58830. }
  58831. }
  58832. declare module BABYLON {
  58833. /**
  58834. * Represents a set of particle systems working together to create a specific effect
  58835. */
  58836. export class ParticleSystemSet implements IDisposable {
  58837. /**
  58838. * Gets or sets base Assets URL
  58839. */
  58840. static BaseAssetsUrl: string;
  58841. private _emitterCreationOptions;
  58842. private _emitterNode;
  58843. /**
  58844. * Gets the particle system list
  58845. */
  58846. systems: IParticleSystem[];
  58847. /**
  58848. * Gets the emitter node used with this set
  58849. */
  58850. readonly emitterNode: Nullable<TransformNode>;
  58851. /**
  58852. * Creates a new emitter mesh as a sphere
  58853. * @param options defines the options used to create the sphere
  58854. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58855. * @param scene defines the hosting scene
  58856. */
  58857. setEmitterAsSphere(options: {
  58858. diameter: number;
  58859. segments: number;
  58860. color: Color3;
  58861. }, renderingGroupId: number, scene: Scene): void;
  58862. /**
  58863. * Starts all particle systems of the set
  58864. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58865. */
  58866. start(emitter?: AbstractMesh): void;
  58867. /**
  58868. * Release all associated resources
  58869. */
  58870. dispose(): void;
  58871. /**
  58872. * Serialize the set into a JSON compatible object
  58873. * @returns a JSON compatible representation of the set
  58874. */
  58875. serialize(): any;
  58876. /**
  58877. * Parse a new ParticleSystemSet from a serialized source
  58878. * @param data defines a JSON compatible representation of the set
  58879. * @param scene defines the hosting scene
  58880. * @param gpu defines if we want GPU particles or CPU particles
  58881. * @returns a new ParticleSystemSet
  58882. */
  58883. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58884. }
  58885. }
  58886. declare module BABYLON {
  58887. /**
  58888. * This class is made for on one-liner static method to help creating particle system set.
  58889. */
  58890. export class ParticleHelper {
  58891. /**
  58892. * Gets or sets base Assets URL
  58893. */
  58894. static BaseAssetsUrl: string;
  58895. /**
  58896. * Create a default particle system that you can tweak
  58897. * @param emitter defines the emitter to use
  58898. * @param capacity defines the system capacity (default is 500 particles)
  58899. * @param scene defines the hosting scene
  58900. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58901. * @returns the new Particle system
  58902. */
  58903. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58904. /**
  58905. * This is the main static method (one-liner) of this helper to create different particle systems
  58906. * @param type This string represents the type to the particle system to create
  58907. * @param scene The scene where the particle system should live
  58908. * @param gpu If the system will use gpu
  58909. * @returns the ParticleSystemSet created
  58910. */
  58911. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58912. /**
  58913. * Static function used to export a particle system to a ParticleSystemSet variable.
  58914. * Please note that the emitter shape is not exported
  58915. * @param systems defines the particle systems to export
  58916. * @returns the created particle system set
  58917. */
  58918. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58919. }
  58920. }
  58921. declare module BABYLON {
  58922. interface Engine {
  58923. /**
  58924. * Create an effect to use with particle systems.
  58925. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58926. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58927. * @param uniformsNames defines a list of attribute names
  58928. * @param samplers defines an array of string used to represent textures
  58929. * @param defines defines the string containing the defines to use to compile the shaders
  58930. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58931. * @param onCompiled defines a function to call when the effect creation is successful
  58932. * @param onError defines a function to call when the effect creation has failed
  58933. * @returns the new Effect
  58934. */
  58935. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58936. }
  58937. interface Mesh {
  58938. /**
  58939. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58940. * @returns an array of IParticleSystem
  58941. */
  58942. getEmittedParticleSystems(): IParticleSystem[];
  58943. /**
  58944. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58945. * @returns an array of IParticleSystem
  58946. */
  58947. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58948. }
  58949. /**
  58950. * @hidden
  58951. */
  58952. export var _IDoNeedToBeInTheBuild: number;
  58953. }
  58954. declare module BABYLON {
  58955. /** Defines the 4 color options */
  58956. export enum PointColor {
  58957. /** color value */
  58958. Color = 2,
  58959. /** uv value */
  58960. UV = 1,
  58961. /** random value */
  58962. Random = 0,
  58963. /** stated value */
  58964. Stated = 3
  58965. }
  58966. /**
  58967. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  58968. * 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.
  58969. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  58970. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  58971. *
  58972. * Full documentation here : TO BE ENTERED
  58973. */
  58974. export class PointsCloudSystem implements IDisposable {
  58975. /**
  58976. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  58977. * Example : var p = SPS.particles[i];
  58978. */
  58979. particles: CloudPoint[];
  58980. /**
  58981. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  58982. */
  58983. nbParticles: number;
  58984. /**
  58985. * This a counter for your own usage. It's not set by any SPS functions.
  58986. */
  58987. counter: number;
  58988. /**
  58989. * The PCS name. This name is also given to the underlying mesh.
  58990. */
  58991. name: string;
  58992. /**
  58993. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  58994. */
  58995. mesh: Mesh;
  58996. /**
  58997. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  58998. * Please read :
  58999. */
  59000. vars: any;
  59001. /**
  59002. * @hidden
  59003. */
  59004. _size: number;
  59005. private _scene;
  59006. private _promises;
  59007. private _positions;
  59008. private _indices;
  59009. private _normals;
  59010. private _colors;
  59011. private _uvs;
  59012. private _indices32;
  59013. private _positions32;
  59014. private _colors32;
  59015. private _uvs32;
  59016. private _updatable;
  59017. private _isVisibilityBoxLocked;
  59018. private _alwaysVisible;
  59019. private _groups;
  59020. private _groupCounter;
  59021. private _computeParticleColor;
  59022. private _computeParticleTexture;
  59023. private _computeParticleRotation;
  59024. private _computeBoundingBox;
  59025. private _isReady;
  59026. /**
  59027. * Creates a PCS (Points Cloud System) object
  59028. * @param name (String) is the PCS name, this will be the underlying mesh name
  59029. * @param pointSize (number) is the size for each point
  59030. * @param scene (Scene) is the scene in which the PCS is added
  59031. * @param options defines the options of the PCS e.g.
  59032. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  59033. */
  59034. constructor(name: string, pointSize: number, scene: Scene, options?: {
  59035. updatable?: boolean;
  59036. });
  59037. /**
  59038. * Builds the PCS underlying mesh. Returns a standard Mesh.
  59039. * If no points were added to the PCS, the returned mesh is just a single point.
  59040. * @returns a promise for the created mesh
  59041. */
  59042. buildMeshAsync(): Promise<Mesh>;
  59043. /**
  59044. * @hidden
  59045. */
  59046. private _buildMesh;
  59047. private _addParticle;
  59048. private _randomUnitVector;
  59049. private _getColorIndicesForCoord;
  59050. private _setPointsColorOrUV;
  59051. private _colorFromTexture;
  59052. private _calculateDensity;
  59053. /**
  59054. * Adds points to the PCS in random positions within a unit sphere
  59055. * @param nb (positive integer) the number of particles to be created from this model
  59056. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  59057. * @returns the number of groups in the system
  59058. */
  59059. addPoints(nb: number, pointFunction?: any): number;
  59060. /**
  59061. * Adds points to the PCS from the surface of the model shape
  59062. * @param mesh is any Mesh object that will be used as a surface model for the points
  59063. * @param nb (positive integer) the number of particles to be created from this model
  59064. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  59065. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  59066. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  59067. * @returns the number of groups in the system
  59068. */
  59069. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  59070. /**
  59071. * Adds points to the PCS inside the model shape
  59072. * @param mesh is any Mesh object that will be used as a surface model for the points
  59073. * @param nb (positive integer) the number of particles to be created from this model
  59074. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  59075. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  59076. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  59077. * @returns the number of groups in the system
  59078. */
  59079. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  59080. /**
  59081. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  59082. * This method calls `updateParticle()` for each particle of the SPS.
  59083. * For an animated SPS, it is usually called within the render loop.
  59084. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  59085. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  59086. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  59087. * @returns the PCS.
  59088. */
  59089. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  59090. /**
  59091. * Disposes the PCS.
  59092. */
  59093. dispose(): void;
  59094. /**
  59095. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  59096. * doc :
  59097. * @returns the PCS.
  59098. */
  59099. refreshVisibleSize(): PointsCloudSystem;
  59100. /**
  59101. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  59102. * @param size the size (float) of the visibility box
  59103. * note : this doesn't lock the PCS mesh bounding box.
  59104. * doc :
  59105. */
  59106. setVisibilityBox(size: number): void;
  59107. /**
  59108. * Gets whether the PCS is always visible or not
  59109. * doc :
  59110. */
  59111. /**
  59112. * Sets the PCS as always visible or not
  59113. * doc :
  59114. */
  59115. isAlwaysVisible: boolean;
  59116. /**
  59117. * Tells to `setParticles()` to compute the particle rotations or not
  59118. * Default value : false. The PCS is faster when it's set to false
  59119. * Note : particle rotations are only applied to parent particles
  59120. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  59121. */
  59122. computeParticleRotation: boolean;
  59123. /**
  59124. * Tells to `setParticles()` to compute the particle colors or not.
  59125. * Default value : true. The PCS is faster when it's set to false.
  59126. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  59127. */
  59128. /**
  59129. * Gets if `setParticles()` computes the particle colors or not.
  59130. * Default value : false. The PCS is faster when it's set to false.
  59131. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  59132. */
  59133. computeParticleColor: boolean;
  59134. /**
  59135. * Gets if `setParticles()` computes the particle textures or not.
  59136. * Default value : false. The PCS is faster when it's set to false.
  59137. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  59138. */
  59139. computeParticleTexture: boolean;
  59140. /**
  59141. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  59142. */
  59143. /**
  59144. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  59145. */
  59146. computeBoundingBox: boolean;
  59147. /**
  59148. * This function does nothing. It may be overwritten to set all the particle first values.
  59149. * The PCS doesn't call this function, you may have to call it by your own.
  59150. * doc :
  59151. */
  59152. initParticles(): void;
  59153. /**
  59154. * This function does nothing. It may be overwritten to recycle a particle
  59155. * The PCS doesn't call this function, you can to call it
  59156. * doc :
  59157. * @param particle The particle to recycle
  59158. * @returns the recycled particle
  59159. */
  59160. recycleParticle(particle: CloudPoint): CloudPoint;
  59161. /**
  59162. * Updates a particle : this function should be overwritten by the user.
  59163. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  59164. * doc :
  59165. * @example : just set a particle position or velocity and recycle conditions
  59166. * @param particle The particle to update
  59167. * @returns the updated particle
  59168. */
  59169. updateParticle(particle: CloudPoint): CloudPoint;
  59170. /**
  59171. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  59172. * This does nothing and may be overwritten by the user.
  59173. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  59174. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  59175. * @param update the boolean update value actually passed to setParticles()
  59176. */
  59177. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  59178. /**
  59179. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  59180. * This will be passed three parameters.
  59181. * This does nothing and may be overwritten by the user.
  59182. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  59183. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  59184. * @param update the boolean update value actually passed to setParticles()
  59185. */
  59186. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  59187. }
  59188. }
  59189. declare module BABYLON {
  59190. /**
  59191. * Represents one particle of a points cloud system.
  59192. */
  59193. export class CloudPoint {
  59194. /**
  59195. * particle global index
  59196. */
  59197. idx: number;
  59198. /**
  59199. * The color of the particle
  59200. */
  59201. color: Nullable<Color4>;
  59202. /**
  59203. * The world space position of the particle.
  59204. */
  59205. position: Vector3;
  59206. /**
  59207. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  59208. */
  59209. rotation: Vector3;
  59210. /**
  59211. * The world space rotation quaternion of the particle.
  59212. */
  59213. rotationQuaternion: Nullable<Quaternion>;
  59214. /**
  59215. * The uv of the particle.
  59216. */
  59217. uv: Nullable<Vector2>;
  59218. /**
  59219. * The current speed of the particle.
  59220. */
  59221. velocity: Vector3;
  59222. /**
  59223. * The pivot point in the particle local space.
  59224. */
  59225. pivot: Vector3;
  59226. /**
  59227. * Must the particle be translated from its pivot point in its local space ?
  59228. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  59229. * Default : false
  59230. */
  59231. translateFromPivot: boolean;
  59232. /**
  59233. * Index of this particle in the global "positions" array (Internal use)
  59234. * @hidden
  59235. */
  59236. _pos: number;
  59237. /**
  59238. * @hidden Index of this particle in the global "indices" array (Internal use)
  59239. */
  59240. _ind: number;
  59241. /**
  59242. * Group this particle belongs to
  59243. */
  59244. _group: PointsGroup;
  59245. /**
  59246. * Group id of this particle
  59247. */
  59248. groupId: number;
  59249. /**
  59250. * Index of the particle in its group id (Internal use)
  59251. */
  59252. idxInGroup: number;
  59253. /**
  59254. * @hidden Particle BoundingInfo object (Internal use)
  59255. */
  59256. _boundingInfo: BoundingInfo;
  59257. /**
  59258. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  59259. */
  59260. _pcs: PointsCloudSystem;
  59261. /**
  59262. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  59263. */
  59264. _stillInvisible: boolean;
  59265. /**
  59266. * @hidden Last computed particle rotation matrix
  59267. */
  59268. _rotationMatrix: number[];
  59269. /**
  59270. * Parent particle Id, if any.
  59271. * Default null.
  59272. */
  59273. parentId: Nullable<number>;
  59274. /**
  59275. * @hidden Internal global position in the PCS.
  59276. */
  59277. _globalPosition: Vector3;
  59278. /**
  59279. * Creates a Point Cloud object.
  59280. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  59281. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  59282. * @param group (PointsGroup) is the group the particle belongs to
  59283. * @param groupId (integer) is the group identifier in the PCS.
  59284. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  59285. * @param pcs defines the PCS it is associated to
  59286. */
  59287. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  59288. /**
  59289. * get point size
  59290. */
  59291. /**
  59292. * Set point size
  59293. */
  59294. size: Vector3;
  59295. /**
  59296. * Legacy support, changed quaternion to rotationQuaternion
  59297. */
  59298. /**
  59299. * Legacy support, changed quaternion to rotationQuaternion
  59300. */
  59301. quaternion: Nullable<Quaternion>;
  59302. /**
  59303. * Returns a boolean. True if the particle intersects a mesh, else false
  59304. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  59305. * @param target is the object (point or mesh) what the intersection is computed against
  59306. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  59307. * @returns true if it intersects
  59308. */
  59309. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  59310. /**
  59311. * get the rotation matrix of the particle
  59312. * @hidden
  59313. */
  59314. getRotationMatrix(m: Matrix): void;
  59315. }
  59316. /**
  59317. * Represents a group of points in a points cloud system
  59318. * * PCS internal tool, don't use it manually.
  59319. */
  59320. export class PointsGroup {
  59321. /**
  59322. * The group id
  59323. * @hidden
  59324. */
  59325. groupID: number;
  59326. /**
  59327. * image data for group (internal use)
  59328. * @hidden
  59329. */
  59330. _groupImageData: Nullable<ArrayBufferView>;
  59331. /**
  59332. * Image Width (internal use)
  59333. * @hidden
  59334. */
  59335. _groupImgWidth: number;
  59336. /**
  59337. * Image Height (internal use)
  59338. * @hidden
  59339. */
  59340. _groupImgHeight: number;
  59341. /**
  59342. * Custom position function (internal use)
  59343. * @hidden
  59344. */
  59345. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  59346. /**
  59347. * density per facet for surface points
  59348. * @hidden
  59349. */
  59350. _groupDensity: number[];
  59351. /**
  59352. * Only when points are colored by texture carries pointer to texture list array
  59353. * @hidden
  59354. */
  59355. _textureNb: number;
  59356. /**
  59357. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  59358. * PCS internal tool, don't use it manually.
  59359. * @hidden
  59360. */
  59361. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  59362. }
  59363. }
  59364. declare module BABYLON {
  59365. interface Scene {
  59366. /** @hidden (Backing field) */
  59367. _physicsEngine: Nullable<IPhysicsEngine>;
  59368. /**
  59369. * Gets the current physics engine
  59370. * @returns a IPhysicsEngine or null if none attached
  59371. */
  59372. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  59373. /**
  59374. * Enables physics to the current scene
  59375. * @param gravity defines the scene's gravity for the physics engine
  59376. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  59377. * @return a boolean indicating if the physics engine was initialized
  59378. */
  59379. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  59380. /**
  59381. * Disables and disposes the physics engine associated with the scene
  59382. */
  59383. disablePhysicsEngine(): void;
  59384. /**
  59385. * Gets a boolean indicating if there is an active physics engine
  59386. * @returns a boolean indicating if there is an active physics engine
  59387. */
  59388. isPhysicsEnabled(): boolean;
  59389. /**
  59390. * Deletes a physics compound impostor
  59391. * @param compound defines the compound to delete
  59392. */
  59393. deleteCompoundImpostor(compound: any): void;
  59394. /**
  59395. * An event triggered when physic simulation is about to be run
  59396. */
  59397. onBeforePhysicsObservable: Observable<Scene>;
  59398. /**
  59399. * An event triggered when physic simulation has been done
  59400. */
  59401. onAfterPhysicsObservable: Observable<Scene>;
  59402. }
  59403. interface AbstractMesh {
  59404. /** @hidden */
  59405. _physicsImpostor: Nullable<PhysicsImpostor>;
  59406. /**
  59407. * Gets or sets impostor used for physic simulation
  59408. * @see http://doc.babylonjs.com/features/physics_engine
  59409. */
  59410. physicsImpostor: Nullable<PhysicsImpostor>;
  59411. /**
  59412. * Gets the current physics impostor
  59413. * @see http://doc.babylonjs.com/features/physics_engine
  59414. * @returns a physics impostor or null
  59415. */
  59416. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  59417. /** Apply a physic impulse to the mesh
  59418. * @param force defines the force to apply
  59419. * @param contactPoint defines where to apply the force
  59420. * @returns the current mesh
  59421. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59422. */
  59423. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  59424. /**
  59425. * Creates a physic joint between two meshes
  59426. * @param otherMesh defines the other mesh to use
  59427. * @param pivot1 defines the pivot to use on this mesh
  59428. * @param pivot2 defines the pivot to use on the other mesh
  59429. * @param options defines additional options (can be plugin dependent)
  59430. * @returns the current mesh
  59431. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  59432. */
  59433. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  59434. /** @hidden */
  59435. _disposePhysicsObserver: Nullable<Observer<Node>>;
  59436. }
  59437. /**
  59438. * Defines the physics engine scene component responsible to manage a physics engine
  59439. */
  59440. export class PhysicsEngineSceneComponent implements ISceneComponent {
  59441. /**
  59442. * The component name helpful to identify the component in the list of scene components.
  59443. */
  59444. readonly name: string;
  59445. /**
  59446. * The scene the component belongs to.
  59447. */
  59448. scene: Scene;
  59449. /**
  59450. * Creates a new instance of the component for the given scene
  59451. * @param scene Defines the scene to register the component in
  59452. */
  59453. constructor(scene: Scene);
  59454. /**
  59455. * Registers the component in a given scene
  59456. */
  59457. register(): void;
  59458. /**
  59459. * Rebuilds the elements related to this component in case of
  59460. * context lost for instance.
  59461. */
  59462. rebuild(): void;
  59463. /**
  59464. * Disposes the component and the associated ressources
  59465. */
  59466. dispose(): void;
  59467. }
  59468. }
  59469. declare module BABYLON {
  59470. /**
  59471. * A helper for physics simulations
  59472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59473. */
  59474. export class PhysicsHelper {
  59475. private _scene;
  59476. private _physicsEngine;
  59477. /**
  59478. * Initializes the Physics helper
  59479. * @param scene Babylon.js scene
  59480. */
  59481. constructor(scene: Scene);
  59482. /**
  59483. * Applies a radial explosion impulse
  59484. * @param origin the origin of the explosion
  59485. * @param radiusOrEventOptions the radius or the options of radial explosion
  59486. * @param strength the explosion strength
  59487. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59488. * @returns A physics radial explosion event, or null
  59489. */
  59490. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59491. /**
  59492. * Applies a radial explosion force
  59493. * @param origin the origin of the explosion
  59494. * @param radiusOrEventOptions the radius or the options of radial explosion
  59495. * @param strength the explosion strength
  59496. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59497. * @returns A physics radial explosion event, or null
  59498. */
  59499. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59500. /**
  59501. * Creates a gravitational field
  59502. * @param origin the origin of the explosion
  59503. * @param radiusOrEventOptions the radius or the options of radial explosion
  59504. * @param strength the explosion strength
  59505. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59506. * @returns A physics gravitational field event, or null
  59507. */
  59508. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  59509. /**
  59510. * Creates a physics updraft event
  59511. * @param origin the origin of the updraft
  59512. * @param radiusOrEventOptions the radius or the options of the updraft
  59513. * @param strength the strength of the updraft
  59514. * @param height the height of the updraft
  59515. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  59516. * @returns A physics updraft event, or null
  59517. */
  59518. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  59519. /**
  59520. * Creates a physics vortex event
  59521. * @param origin the of the vortex
  59522. * @param radiusOrEventOptions the radius or the options of the vortex
  59523. * @param strength the strength of the vortex
  59524. * @param height the height of the vortex
  59525. * @returns a Physics vortex event, or null
  59526. * A physics vortex event or null
  59527. */
  59528. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  59529. }
  59530. /**
  59531. * Represents a physics radial explosion event
  59532. */
  59533. class PhysicsRadialExplosionEvent {
  59534. private _scene;
  59535. private _options;
  59536. private _sphere;
  59537. private _dataFetched;
  59538. /**
  59539. * Initializes a radial explosioin event
  59540. * @param _scene BabylonJS scene
  59541. * @param _options The options for the vortex event
  59542. */
  59543. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  59544. /**
  59545. * Returns the data related to the radial explosion event (sphere).
  59546. * @returns The radial explosion event data
  59547. */
  59548. getData(): PhysicsRadialExplosionEventData;
  59549. /**
  59550. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  59551. * @param impostor A physics imposter
  59552. * @param origin the origin of the explosion
  59553. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  59554. */
  59555. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  59556. /**
  59557. * Triggers affecterd impostors callbacks
  59558. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  59559. */
  59560. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  59561. /**
  59562. * Disposes the sphere.
  59563. * @param force Specifies if the sphere should be disposed by force
  59564. */
  59565. dispose(force?: boolean): void;
  59566. /*** Helpers ***/
  59567. private _prepareSphere;
  59568. private _intersectsWithSphere;
  59569. }
  59570. /**
  59571. * Represents a gravitational field event
  59572. */
  59573. class PhysicsGravitationalFieldEvent {
  59574. private _physicsHelper;
  59575. private _scene;
  59576. private _origin;
  59577. private _options;
  59578. private _tickCallback;
  59579. private _sphere;
  59580. private _dataFetched;
  59581. /**
  59582. * Initializes the physics gravitational field event
  59583. * @param _physicsHelper A physics helper
  59584. * @param _scene BabylonJS scene
  59585. * @param _origin The origin position of the gravitational field event
  59586. * @param _options The options for the vortex event
  59587. */
  59588. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  59589. /**
  59590. * Returns the data related to the gravitational field event (sphere).
  59591. * @returns A gravitational field event
  59592. */
  59593. getData(): PhysicsGravitationalFieldEventData;
  59594. /**
  59595. * Enables the gravitational field.
  59596. */
  59597. enable(): void;
  59598. /**
  59599. * Disables the gravitational field.
  59600. */
  59601. disable(): void;
  59602. /**
  59603. * Disposes the sphere.
  59604. * @param force The force to dispose from the gravitational field event
  59605. */
  59606. dispose(force?: boolean): void;
  59607. private _tick;
  59608. }
  59609. /**
  59610. * Represents a physics updraft event
  59611. */
  59612. class PhysicsUpdraftEvent {
  59613. private _scene;
  59614. private _origin;
  59615. private _options;
  59616. private _physicsEngine;
  59617. private _originTop;
  59618. private _originDirection;
  59619. private _tickCallback;
  59620. private _cylinder;
  59621. private _cylinderPosition;
  59622. private _dataFetched;
  59623. /**
  59624. * Initializes the physics updraft event
  59625. * @param _scene BabylonJS scene
  59626. * @param _origin The origin position of the updraft
  59627. * @param _options The options for the updraft event
  59628. */
  59629. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59630. /**
  59631. * Returns the data related to the updraft event (cylinder).
  59632. * @returns A physics updraft event
  59633. */
  59634. getData(): PhysicsUpdraftEventData;
  59635. /**
  59636. * Enables the updraft.
  59637. */
  59638. enable(): void;
  59639. /**
  59640. * Disables the updraft.
  59641. */
  59642. disable(): void;
  59643. /**
  59644. * Disposes the cylinder.
  59645. * @param force Specifies if the updraft should be disposed by force
  59646. */
  59647. dispose(force?: boolean): void;
  59648. private getImpostorHitData;
  59649. private _tick;
  59650. /*** Helpers ***/
  59651. private _prepareCylinder;
  59652. private _intersectsWithCylinder;
  59653. }
  59654. /**
  59655. * Represents a physics vortex event
  59656. */
  59657. class PhysicsVortexEvent {
  59658. private _scene;
  59659. private _origin;
  59660. private _options;
  59661. private _physicsEngine;
  59662. private _originTop;
  59663. private _tickCallback;
  59664. private _cylinder;
  59665. private _cylinderPosition;
  59666. private _dataFetched;
  59667. /**
  59668. * Initializes the physics vortex event
  59669. * @param _scene The BabylonJS scene
  59670. * @param _origin The origin position of the vortex
  59671. * @param _options The options for the vortex event
  59672. */
  59673. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59674. /**
  59675. * Returns the data related to the vortex event (cylinder).
  59676. * @returns The physics vortex event data
  59677. */
  59678. getData(): PhysicsVortexEventData;
  59679. /**
  59680. * Enables the vortex.
  59681. */
  59682. enable(): void;
  59683. /**
  59684. * Disables the cortex.
  59685. */
  59686. disable(): void;
  59687. /**
  59688. * Disposes the sphere.
  59689. * @param force
  59690. */
  59691. dispose(force?: boolean): void;
  59692. private getImpostorHitData;
  59693. private _tick;
  59694. /*** Helpers ***/
  59695. private _prepareCylinder;
  59696. private _intersectsWithCylinder;
  59697. }
  59698. /**
  59699. * Options fot the radial explosion event
  59700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59701. */
  59702. export class PhysicsRadialExplosionEventOptions {
  59703. /**
  59704. * The radius of the sphere for the radial explosion.
  59705. */
  59706. radius: number;
  59707. /**
  59708. * The strenth of the explosion.
  59709. */
  59710. strength: number;
  59711. /**
  59712. * The strenght of the force in correspondence to the distance of the affected object
  59713. */
  59714. falloff: PhysicsRadialImpulseFalloff;
  59715. /**
  59716. * Sphere options for the radial explosion.
  59717. */
  59718. sphere: {
  59719. segments: number;
  59720. diameter: number;
  59721. };
  59722. /**
  59723. * Sphere options for the radial explosion.
  59724. */
  59725. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59726. }
  59727. /**
  59728. * Options fot the updraft event
  59729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59730. */
  59731. export class PhysicsUpdraftEventOptions {
  59732. /**
  59733. * The radius of the cylinder for the vortex
  59734. */
  59735. radius: number;
  59736. /**
  59737. * The strenth of the updraft.
  59738. */
  59739. strength: number;
  59740. /**
  59741. * The height of the cylinder for the updraft.
  59742. */
  59743. height: number;
  59744. /**
  59745. * The mode for the the updraft.
  59746. */
  59747. updraftMode: PhysicsUpdraftMode;
  59748. }
  59749. /**
  59750. * Options fot the vortex event
  59751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59752. */
  59753. export class PhysicsVortexEventOptions {
  59754. /**
  59755. * The radius of the cylinder for the vortex
  59756. */
  59757. radius: number;
  59758. /**
  59759. * The strenth of the vortex.
  59760. */
  59761. strength: number;
  59762. /**
  59763. * The height of the cylinder for the vortex.
  59764. */
  59765. height: number;
  59766. /**
  59767. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59768. */
  59769. centripetalForceThreshold: number;
  59770. /**
  59771. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59772. */
  59773. centripetalForceMultiplier: number;
  59774. /**
  59775. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59776. */
  59777. centrifugalForceMultiplier: number;
  59778. /**
  59779. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59780. */
  59781. updraftForceMultiplier: number;
  59782. }
  59783. /**
  59784. * The strenght of the force in correspondence to the distance of the affected object
  59785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59786. */
  59787. export enum PhysicsRadialImpulseFalloff {
  59788. /** Defines that impulse is constant in strength across it's whole radius */
  59789. Constant = 0,
  59790. /** Defines that impulse gets weaker if it's further from the origin */
  59791. Linear = 1
  59792. }
  59793. /**
  59794. * The strength of the force in correspondence to the distance of the affected object
  59795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59796. */
  59797. export enum PhysicsUpdraftMode {
  59798. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59799. Center = 0,
  59800. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59801. Perpendicular = 1
  59802. }
  59803. /**
  59804. * Interface for a physics hit data
  59805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59806. */
  59807. export interface PhysicsHitData {
  59808. /**
  59809. * The force applied at the contact point
  59810. */
  59811. force: Vector3;
  59812. /**
  59813. * The contact point
  59814. */
  59815. contactPoint: Vector3;
  59816. /**
  59817. * The distance from the origin to the contact point
  59818. */
  59819. distanceFromOrigin: number;
  59820. }
  59821. /**
  59822. * Interface for radial explosion event data
  59823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59824. */
  59825. export interface PhysicsRadialExplosionEventData {
  59826. /**
  59827. * A sphere used for the radial explosion event
  59828. */
  59829. sphere: Mesh;
  59830. }
  59831. /**
  59832. * Interface for gravitational field event data
  59833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59834. */
  59835. export interface PhysicsGravitationalFieldEventData {
  59836. /**
  59837. * A sphere mesh used for the gravitational field event
  59838. */
  59839. sphere: Mesh;
  59840. }
  59841. /**
  59842. * Interface for updraft event data
  59843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59844. */
  59845. export interface PhysicsUpdraftEventData {
  59846. /**
  59847. * A cylinder used for the updraft event
  59848. */
  59849. cylinder: Mesh;
  59850. }
  59851. /**
  59852. * Interface for vortex event data
  59853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59854. */
  59855. export interface PhysicsVortexEventData {
  59856. /**
  59857. * A cylinder used for the vortex event
  59858. */
  59859. cylinder: Mesh;
  59860. }
  59861. /**
  59862. * Interface for an affected physics impostor
  59863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59864. */
  59865. export interface PhysicsAffectedImpostorWithData {
  59866. /**
  59867. * The impostor affected by the effect
  59868. */
  59869. impostor: PhysicsImpostor;
  59870. /**
  59871. * The data about the hit/horce from the explosion
  59872. */
  59873. hitData: PhysicsHitData;
  59874. }
  59875. }
  59876. declare module BABYLON {
  59877. /** @hidden */
  59878. export var blackAndWhitePixelShader: {
  59879. name: string;
  59880. shader: string;
  59881. };
  59882. }
  59883. declare module BABYLON {
  59884. /**
  59885. * Post process used to render in black and white
  59886. */
  59887. export class BlackAndWhitePostProcess extends PostProcess {
  59888. /**
  59889. * Linear about to convert he result to black and white (default: 1)
  59890. */
  59891. degree: number;
  59892. /**
  59893. * Creates a black and white post process
  59894. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59895. * @param name The name of the effect.
  59896. * @param options The required width/height ratio to downsize to before computing the render pass.
  59897. * @param camera The camera to apply the render pass to.
  59898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59899. * @param engine The engine which the post process will be applied. (default: current engine)
  59900. * @param reusable If the post process can be reused on the same frame. (default: false)
  59901. */
  59902. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59903. }
  59904. }
  59905. declare module BABYLON {
  59906. /**
  59907. * This represents a set of one or more post processes in Babylon.
  59908. * A post process can be used to apply a shader to a texture after it is rendered.
  59909. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59910. */
  59911. export class PostProcessRenderEffect {
  59912. private _postProcesses;
  59913. private _getPostProcesses;
  59914. private _singleInstance;
  59915. private _cameras;
  59916. private _indicesForCamera;
  59917. /**
  59918. * Name of the effect
  59919. * @hidden
  59920. */
  59921. _name: string;
  59922. /**
  59923. * Instantiates a post process render effect.
  59924. * A post process can be used to apply a shader to a texture after it is rendered.
  59925. * @param engine The engine the effect is tied to
  59926. * @param name The name of the effect
  59927. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59928. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59929. */
  59930. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59931. /**
  59932. * Checks if all the post processes in the effect are supported.
  59933. */
  59934. readonly isSupported: boolean;
  59935. /**
  59936. * Updates the current state of the effect
  59937. * @hidden
  59938. */
  59939. _update(): void;
  59940. /**
  59941. * Attaches the effect on cameras
  59942. * @param cameras The camera to attach to.
  59943. * @hidden
  59944. */
  59945. _attachCameras(cameras: Camera): void;
  59946. /**
  59947. * Attaches the effect on cameras
  59948. * @param cameras The camera to attach to.
  59949. * @hidden
  59950. */
  59951. _attachCameras(cameras: Camera[]): void;
  59952. /**
  59953. * Detaches the effect on cameras
  59954. * @param cameras The camera to detatch from.
  59955. * @hidden
  59956. */
  59957. _detachCameras(cameras: Camera): void;
  59958. /**
  59959. * Detatches the effect on cameras
  59960. * @param cameras The camera to detatch from.
  59961. * @hidden
  59962. */
  59963. _detachCameras(cameras: Camera[]): void;
  59964. /**
  59965. * Enables the effect on given cameras
  59966. * @param cameras The camera to enable.
  59967. * @hidden
  59968. */
  59969. _enable(cameras: Camera): void;
  59970. /**
  59971. * Enables the effect on given cameras
  59972. * @param cameras The camera to enable.
  59973. * @hidden
  59974. */
  59975. _enable(cameras: Nullable<Camera[]>): void;
  59976. /**
  59977. * Disables the effect on the given cameras
  59978. * @param cameras The camera to disable.
  59979. * @hidden
  59980. */
  59981. _disable(cameras: Camera): void;
  59982. /**
  59983. * Disables the effect on the given cameras
  59984. * @param cameras The camera to disable.
  59985. * @hidden
  59986. */
  59987. _disable(cameras: Nullable<Camera[]>): void;
  59988. /**
  59989. * Gets a list of the post processes contained in the effect.
  59990. * @param camera The camera to get the post processes on.
  59991. * @returns The list of the post processes in the effect.
  59992. */
  59993. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59994. }
  59995. }
  59996. declare module BABYLON {
  59997. /** @hidden */
  59998. export var extractHighlightsPixelShader: {
  59999. name: string;
  60000. shader: string;
  60001. };
  60002. }
  60003. declare module BABYLON {
  60004. /**
  60005. * 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.
  60006. */
  60007. export class ExtractHighlightsPostProcess extends PostProcess {
  60008. /**
  60009. * The luminance threshold, pixels below this value will be set to black.
  60010. */
  60011. threshold: number;
  60012. /** @hidden */
  60013. _exposure: number;
  60014. /**
  60015. * Post process which has the input texture to be used when performing highlight extraction
  60016. * @hidden
  60017. */
  60018. _inputPostProcess: Nullable<PostProcess>;
  60019. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60020. }
  60021. }
  60022. declare module BABYLON {
  60023. /** @hidden */
  60024. export var bloomMergePixelShader: {
  60025. name: string;
  60026. shader: string;
  60027. };
  60028. }
  60029. declare module BABYLON {
  60030. /**
  60031. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60032. */
  60033. export class BloomMergePostProcess extends PostProcess {
  60034. /** Weight of the bloom to be added to the original input. */
  60035. weight: number;
  60036. /**
  60037. * Creates a new instance of @see BloomMergePostProcess
  60038. * @param name The name of the effect.
  60039. * @param originalFromInput Post process which's input will be used for the merge.
  60040. * @param blurred Blurred highlights post process which's output will be used.
  60041. * @param weight Weight of the bloom to be added to the original input.
  60042. * @param options The required width/height ratio to downsize to before computing the render pass.
  60043. * @param camera The camera to apply the render pass to.
  60044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60045. * @param engine The engine which the post process will be applied. (default: current engine)
  60046. * @param reusable If the post process can be reused on the same frame. (default: false)
  60047. * @param textureType Type of textures used when performing the post process. (default: 0)
  60048. * @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)
  60049. */
  60050. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  60051. /** Weight of the bloom to be added to the original input. */
  60052. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60053. }
  60054. }
  60055. declare module BABYLON {
  60056. /**
  60057. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  60058. */
  60059. export class BloomEffect extends PostProcessRenderEffect {
  60060. private bloomScale;
  60061. /**
  60062. * @hidden Internal
  60063. */
  60064. _effects: Array<PostProcess>;
  60065. /**
  60066. * @hidden Internal
  60067. */
  60068. _downscale: ExtractHighlightsPostProcess;
  60069. private _blurX;
  60070. private _blurY;
  60071. private _merge;
  60072. /**
  60073. * The luminance threshold to find bright areas of the image to bloom.
  60074. */
  60075. threshold: number;
  60076. /**
  60077. * The strength of the bloom.
  60078. */
  60079. weight: number;
  60080. /**
  60081. * Specifies the size of the bloom blur kernel, relative to the final output size
  60082. */
  60083. kernel: number;
  60084. /**
  60085. * Creates a new instance of @see BloomEffect
  60086. * @param scene The scene the effect belongs to.
  60087. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  60088. * @param bloomKernel The size of the kernel to be used when applying the blur.
  60089. * @param bloomWeight The the strength of bloom.
  60090. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60091. * @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)
  60092. */
  60093. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  60094. /**
  60095. * Disposes each of the internal effects for a given camera.
  60096. * @param camera The camera to dispose the effect on.
  60097. */
  60098. disposeEffects(camera: Camera): void;
  60099. /**
  60100. * @hidden Internal
  60101. */
  60102. _updateEffects(): void;
  60103. /**
  60104. * Internal
  60105. * @returns if all the contained post processes are ready.
  60106. * @hidden
  60107. */
  60108. _isReady(): boolean;
  60109. }
  60110. }
  60111. declare module BABYLON {
  60112. /** @hidden */
  60113. export var chromaticAberrationPixelShader: {
  60114. name: string;
  60115. shader: string;
  60116. };
  60117. }
  60118. declare module BABYLON {
  60119. /**
  60120. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  60121. */
  60122. export class ChromaticAberrationPostProcess extends PostProcess {
  60123. /**
  60124. * The amount of seperation of rgb channels (default: 30)
  60125. */
  60126. aberrationAmount: number;
  60127. /**
  60128. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  60129. */
  60130. radialIntensity: number;
  60131. /**
  60132. * 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))
  60133. */
  60134. direction: Vector2;
  60135. /**
  60136. * 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))
  60137. */
  60138. centerPosition: Vector2;
  60139. /**
  60140. * Creates a new instance ChromaticAberrationPostProcess
  60141. * @param name The name of the effect.
  60142. * @param screenWidth The width of the screen to apply the effect on.
  60143. * @param screenHeight The height of the screen to apply the effect on.
  60144. * @param options The required width/height ratio to downsize to before computing the render pass.
  60145. * @param camera The camera to apply the render pass to.
  60146. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60147. * @param engine The engine which the post process will be applied. (default: current engine)
  60148. * @param reusable If the post process can be reused on the same frame. (default: false)
  60149. * @param textureType Type of textures used when performing the post process. (default: 0)
  60150. * @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)
  60151. */
  60152. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60153. }
  60154. }
  60155. declare module BABYLON {
  60156. /** @hidden */
  60157. export var circleOfConfusionPixelShader: {
  60158. name: string;
  60159. shader: string;
  60160. };
  60161. }
  60162. declare module BABYLON {
  60163. /**
  60164. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  60165. */
  60166. export class CircleOfConfusionPostProcess extends PostProcess {
  60167. /**
  60168. * 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.
  60169. */
  60170. lensSize: number;
  60171. /**
  60172. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60173. */
  60174. fStop: number;
  60175. /**
  60176. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60177. */
  60178. focusDistance: number;
  60179. /**
  60180. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  60181. */
  60182. focalLength: number;
  60183. private _depthTexture;
  60184. /**
  60185. * Creates a new instance CircleOfConfusionPostProcess
  60186. * @param name The name of the effect.
  60187. * @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.
  60188. * @param options The required width/height ratio to downsize to before computing the render pass.
  60189. * @param camera The camera to apply the render pass to.
  60190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60191. * @param engine The engine which the post process will be applied. (default: current engine)
  60192. * @param reusable If the post process can be reused on the same frame. (default: false)
  60193. * @param textureType Type of textures used when performing the post process. (default: 0)
  60194. * @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)
  60195. */
  60196. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60197. /**
  60198. * 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.
  60199. */
  60200. depthTexture: RenderTargetTexture;
  60201. }
  60202. }
  60203. declare module BABYLON {
  60204. /** @hidden */
  60205. export var colorCorrectionPixelShader: {
  60206. name: string;
  60207. shader: string;
  60208. };
  60209. }
  60210. declare module BABYLON {
  60211. /**
  60212. *
  60213. * This post-process allows the modification of rendered colors by using
  60214. * a 'look-up table' (LUT). This effect is also called Color Grading.
  60215. *
  60216. * The object needs to be provided an url to a texture containing the color
  60217. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  60218. * Use an image editing software to tweak the LUT to match your needs.
  60219. *
  60220. * For an example of a color LUT, see here:
  60221. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  60222. * For explanations on color grading, see here:
  60223. * @see http://udn.epicgames.com/Three/ColorGrading.html
  60224. *
  60225. */
  60226. export class ColorCorrectionPostProcess extends PostProcess {
  60227. private _colorTableTexture;
  60228. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60229. }
  60230. }
  60231. declare module BABYLON {
  60232. /** @hidden */
  60233. export var convolutionPixelShader: {
  60234. name: string;
  60235. shader: string;
  60236. };
  60237. }
  60238. declare module BABYLON {
  60239. /**
  60240. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  60241. * input texture to perform effects such as edge detection or sharpening
  60242. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60243. */
  60244. export class ConvolutionPostProcess extends PostProcess {
  60245. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60246. kernel: number[];
  60247. /**
  60248. * Creates a new instance ConvolutionPostProcess
  60249. * @param name The name of the effect.
  60250. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  60251. * @param options The required width/height ratio to downsize to before computing the render pass.
  60252. * @param camera The camera to apply the render pass to.
  60253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60254. * @param engine The engine which the post process will be applied. (default: current engine)
  60255. * @param reusable If the post process can be reused on the same frame. (default: false)
  60256. * @param textureType Type of textures used when performing the post process. (default: 0)
  60257. */
  60258. constructor(name: string,
  60259. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60260. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60261. /**
  60262. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60263. */
  60264. static EdgeDetect0Kernel: number[];
  60265. /**
  60266. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60267. */
  60268. static EdgeDetect1Kernel: number[];
  60269. /**
  60270. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60271. */
  60272. static EdgeDetect2Kernel: number[];
  60273. /**
  60274. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60275. */
  60276. static SharpenKernel: number[];
  60277. /**
  60278. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60279. */
  60280. static EmbossKernel: number[];
  60281. /**
  60282. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60283. */
  60284. static GaussianKernel: number[];
  60285. }
  60286. }
  60287. declare module BABYLON {
  60288. /**
  60289. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  60290. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  60291. * based on samples that have a large difference in distance than the center pixel.
  60292. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  60293. */
  60294. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  60295. direction: Vector2;
  60296. /**
  60297. * Creates a new instance CircleOfConfusionPostProcess
  60298. * @param name The name of the effect.
  60299. * @param scene The scene the effect belongs to.
  60300. * @param direction The direction the blur should be applied.
  60301. * @param kernel The size of the kernel used to blur.
  60302. * @param options The required width/height ratio to downsize to before computing the render pass.
  60303. * @param camera The camera to apply the render pass to.
  60304. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  60305. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  60306. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60307. * @param engine The engine which the post process will be applied. (default: current engine)
  60308. * @param reusable If the post process can be reused on the same frame. (default: false)
  60309. * @param textureType Type of textures used when performing the post process. (default: 0)
  60310. * @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)
  60311. */
  60312. 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);
  60313. }
  60314. }
  60315. declare module BABYLON {
  60316. /** @hidden */
  60317. export var depthOfFieldMergePixelShader: {
  60318. name: string;
  60319. shader: string;
  60320. };
  60321. }
  60322. declare module BABYLON {
  60323. /**
  60324. * Options to be set when merging outputs from the default pipeline.
  60325. */
  60326. export class DepthOfFieldMergePostProcessOptions {
  60327. /**
  60328. * The original image to merge on top of
  60329. */
  60330. originalFromInput: PostProcess;
  60331. /**
  60332. * Parameters to perform the merge of the depth of field effect
  60333. */
  60334. depthOfField?: {
  60335. circleOfConfusion: PostProcess;
  60336. blurSteps: Array<PostProcess>;
  60337. };
  60338. /**
  60339. * Parameters to perform the merge of bloom effect
  60340. */
  60341. bloom?: {
  60342. blurred: PostProcess;
  60343. weight: number;
  60344. };
  60345. }
  60346. /**
  60347. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60348. */
  60349. export class DepthOfFieldMergePostProcess extends PostProcess {
  60350. private blurSteps;
  60351. /**
  60352. * Creates a new instance of DepthOfFieldMergePostProcess
  60353. * @param name The name of the effect.
  60354. * @param originalFromInput Post process which's input will be used for the merge.
  60355. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  60356. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  60357. * @param options The required width/height ratio to downsize to before computing the render pass.
  60358. * @param camera The camera to apply the render pass to.
  60359. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60360. * @param engine The engine which the post process will be applied. (default: current engine)
  60361. * @param reusable If the post process can be reused on the same frame. (default: false)
  60362. * @param textureType Type of textures used when performing the post process. (default: 0)
  60363. * @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)
  60364. */
  60365. 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);
  60366. /**
  60367. * Updates the effect with the current post process compile time values and recompiles the shader.
  60368. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  60369. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  60370. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  60371. * @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
  60372. * @param onCompiled Called when the shader has been compiled.
  60373. * @param onError Called if there is an error when compiling a shader.
  60374. */
  60375. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  60376. }
  60377. }
  60378. declare module BABYLON {
  60379. /**
  60380. * Specifies the level of max blur that should be applied when using the depth of field effect
  60381. */
  60382. export enum DepthOfFieldEffectBlurLevel {
  60383. /**
  60384. * Subtle blur
  60385. */
  60386. Low = 0,
  60387. /**
  60388. * Medium blur
  60389. */
  60390. Medium = 1,
  60391. /**
  60392. * Large blur
  60393. */
  60394. High = 2
  60395. }
  60396. /**
  60397. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  60398. */
  60399. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  60400. private _circleOfConfusion;
  60401. /**
  60402. * @hidden Internal, blurs from high to low
  60403. */
  60404. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  60405. private _depthOfFieldBlurY;
  60406. private _dofMerge;
  60407. /**
  60408. * @hidden Internal post processes in depth of field effect
  60409. */
  60410. _effects: Array<PostProcess>;
  60411. /**
  60412. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  60413. */
  60414. focalLength: number;
  60415. /**
  60416. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60417. */
  60418. fStop: number;
  60419. /**
  60420. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60421. */
  60422. focusDistance: number;
  60423. /**
  60424. * 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.
  60425. */
  60426. lensSize: number;
  60427. /**
  60428. * Creates a new instance DepthOfFieldEffect
  60429. * @param scene The scene the effect belongs to.
  60430. * @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.
  60431. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60432. * @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)
  60433. */
  60434. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  60435. /**
  60436. * Get the current class name of the current effet
  60437. * @returns "DepthOfFieldEffect"
  60438. */
  60439. getClassName(): string;
  60440. /**
  60441. * 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.
  60442. */
  60443. depthTexture: RenderTargetTexture;
  60444. /**
  60445. * Disposes each of the internal effects for a given camera.
  60446. * @param camera The camera to dispose the effect on.
  60447. */
  60448. disposeEffects(camera: Camera): void;
  60449. /**
  60450. * @hidden Internal
  60451. */
  60452. _updateEffects(): void;
  60453. /**
  60454. * Internal
  60455. * @returns if all the contained post processes are ready.
  60456. * @hidden
  60457. */
  60458. _isReady(): boolean;
  60459. }
  60460. }
  60461. declare module BABYLON {
  60462. /** @hidden */
  60463. export var displayPassPixelShader: {
  60464. name: string;
  60465. shader: string;
  60466. };
  60467. }
  60468. declare module BABYLON {
  60469. /**
  60470. * DisplayPassPostProcess which produces an output the same as it's input
  60471. */
  60472. export class DisplayPassPostProcess extends PostProcess {
  60473. /**
  60474. * Creates the DisplayPassPostProcess
  60475. * @param name The name of the effect.
  60476. * @param options The required width/height ratio to downsize to before computing the render pass.
  60477. * @param camera The camera to apply the render pass to.
  60478. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60479. * @param engine The engine which the post process will be applied. (default: current engine)
  60480. * @param reusable If the post process can be reused on the same frame. (default: false)
  60481. */
  60482. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60483. }
  60484. }
  60485. declare module BABYLON {
  60486. /** @hidden */
  60487. export var filterPixelShader: {
  60488. name: string;
  60489. shader: string;
  60490. };
  60491. }
  60492. declare module BABYLON {
  60493. /**
  60494. * Applies a kernel filter to the image
  60495. */
  60496. export class FilterPostProcess extends PostProcess {
  60497. /** The matrix to be applied to the image */
  60498. kernelMatrix: Matrix;
  60499. /**
  60500. *
  60501. * @param name The name of the effect.
  60502. * @param kernelMatrix The matrix to be applied to the image
  60503. * @param options The required width/height ratio to downsize to before computing the render pass.
  60504. * @param camera The camera to apply the render pass to.
  60505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60506. * @param engine The engine which the post process will be applied. (default: current engine)
  60507. * @param reusable If the post process can be reused on the same frame. (default: false)
  60508. */
  60509. constructor(name: string,
  60510. /** The matrix to be applied to the image */
  60511. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60512. }
  60513. }
  60514. declare module BABYLON {
  60515. /** @hidden */
  60516. export var fxaaPixelShader: {
  60517. name: string;
  60518. shader: string;
  60519. };
  60520. }
  60521. declare module BABYLON {
  60522. /** @hidden */
  60523. export var fxaaVertexShader: {
  60524. name: string;
  60525. shader: string;
  60526. };
  60527. }
  60528. declare module BABYLON {
  60529. /**
  60530. * Fxaa post process
  60531. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60532. */
  60533. export class FxaaPostProcess extends PostProcess {
  60534. /** @hidden */
  60535. texelWidth: number;
  60536. /** @hidden */
  60537. texelHeight: number;
  60538. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60539. private _getDefines;
  60540. }
  60541. }
  60542. declare module BABYLON {
  60543. /** @hidden */
  60544. export var grainPixelShader: {
  60545. name: string;
  60546. shader: string;
  60547. };
  60548. }
  60549. declare module BABYLON {
  60550. /**
  60551. * The GrainPostProcess adds noise to the image at mid luminance levels
  60552. */
  60553. export class GrainPostProcess extends PostProcess {
  60554. /**
  60555. * The intensity of the grain added (default: 30)
  60556. */
  60557. intensity: number;
  60558. /**
  60559. * If the grain should be randomized on every frame
  60560. */
  60561. animated: boolean;
  60562. /**
  60563. * Creates a new instance of @see GrainPostProcess
  60564. * @param name The name of the effect.
  60565. * @param options The required width/height ratio to downsize to before computing the render pass.
  60566. * @param camera The camera to apply the render pass to.
  60567. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60568. * @param engine The engine which the post process will be applied. (default: current engine)
  60569. * @param reusable If the post process can be reused on the same frame. (default: false)
  60570. * @param textureType Type of textures used when performing the post process. (default: 0)
  60571. * @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)
  60572. */
  60573. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60574. }
  60575. }
  60576. declare module BABYLON {
  60577. /** @hidden */
  60578. export var highlightsPixelShader: {
  60579. name: string;
  60580. shader: string;
  60581. };
  60582. }
  60583. declare module BABYLON {
  60584. /**
  60585. * Extracts highlights from the image
  60586. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60587. */
  60588. export class HighlightsPostProcess extends PostProcess {
  60589. /**
  60590. * Extracts highlights from the image
  60591. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60592. * @param name The name of the effect.
  60593. * @param options The required width/height ratio to downsize to before computing the render pass.
  60594. * @param camera The camera to apply the render pass to.
  60595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60596. * @param engine The engine which the post process will be applied. (default: current engine)
  60597. * @param reusable If the post process can be reused on the same frame. (default: false)
  60598. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60599. */
  60600. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60601. }
  60602. }
  60603. declare module BABYLON {
  60604. /** @hidden */
  60605. export var mrtFragmentDeclaration: {
  60606. name: string;
  60607. shader: string;
  60608. };
  60609. }
  60610. declare module BABYLON {
  60611. /** @hidden */
  60612. export var geometryPixelShader: {
  60613. name: string;
  60614. shader: string;
  60615. };
  60616. }
  60617. declare module BABYLON {
  60618. /** @hidden */
  60619. export var geometryVertexShader: {
  60620. name: string;
  60621. shader: string;
  60622. };
  60623. }
  60624. declare module BABYLON {
  60625. /** @hidden */
  60626. interface ISavedTransformationMatrix {
  60627. world: Matrix;
  60628. viewProjection: Matrix;
  60629. }
  60630. /**
  60631. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60632. */
  60633. export class GeometryBufferRenderer {
  60634. /**
  60635. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60636. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60637. */
  60638. static readonly POSITION_TEXTURE_TYPE: number;
  60639. /**
  60640. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60641. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60642. */
  60643. static readonly VELOCITY_TEXTURE_TYPE: number;
  60644. /**
  60645. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60646. * in order to compute objects velocities when enableVelocity is set to "true"
  60647. * @hidden
  60648. */
  60649. _previousTransformationMatrices: {
  60650. [index: number]: ISavedTransformationMatrix;
  60651. };
  60652. /**
  60653. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60654. * in order to compute objects velocities when enableVelocity is set to "true"
  60655. * @hidden
  60656. */
  60657. _previousBonesTransformationMatrices: {
  60658. [index: number]: Float32Array;
  60659. };
  60660. /**
  60661. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60662. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60663. */
  60664. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60665. private _scene;
  60666. private _multiRenderTarget;
  60667. private _ratio;
  60668. private _enablePosition;
  60669. private _enableVelocity;
  60670. private _positionIndex;
  60671. private _velocityIndex;
  60672. protected _effect: Effect;
  60673. protected _cachedDefines: string;
  60674. /**
  60675. * Set the render list (meshes to be rendered) used in the G buffer.
  60676. */
  60677. renderList: Mesh[];
  60678. /**
  60679. * Gets wether or not G buffer are supported by the running hardware.
  60680. * This requires draw buffer supports
  60681. */
  60682. readonly isSupported: boolean;
  60683. /**
  60684. * Returns the index of the given texture type in the G-Buffer textures array
  60685. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60686. * @returns the index of the given texture type in the G-Buffer textures array
  60687. */
  60688. getTextureIndex(textureType: number): number;
  60689. /**
  60690. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60691. */
  60692. /**
  60693. * Sets whether or not objects positions are enabled for the G buffer.
  60694. */
  60695. enablePosition: boolean;
  60696. /**
  60697. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60698. */
  60699. /**
  60700. * Sets wether or not objects velocities are enabled for the G buffer.
  60701. */
  60702. enableVelocity: boolean;
  60703. /**
  60704. * Gets the scene associated with the buffer.
  60705. */
  60706. readonly scene: Scene;
  60707. /**
  60708. * Gets the ratio used by the buffer during its creation.
  60709. * How big is the buffer related to the main canvas.
  60710. */
  60711. readonly ratio: number;
  60712. /** @hidden */
  60713. static _SceneComponentInitialization: (scene: Scene) => void;
  60714. /**
  60715. * Creates a new G Buffer for the scene
  60716. * @param scene The scene the buffer belongs to
  60717. * @param ratio How big is the buffer related to the main canvas.
  60718. */
  60719. constructor(scene: Scene, ratio?: number);
  60720. /**
  60721. * Checks wether everything is ready to render a submesh to the G buffer.
  60722. * @param subMesh the submesh to check readiness for
  60723. * @param useInstances is the mesh drawn using instance or not
  60724. * @returns true if ready otherwise false
  60725. */
  60726. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60727. /**
  60728. * Gets the current underlying G Buffer.
  60729. * @returns the buffer
  60730. */
  60731. getGBuffer(): MultiRenderTarget;
  60732. /**
  60733. * Gets the number of samples used to render the buffer (anti aliasing).
  60734. */
  60735. /**
  60736. * Sets the number of samples used to render the buffer (anti aliasing).
  60737. */
  60738. samples: number;
  60739. /**
  60740. * Disposes the renderer and frees up associated resources.
  60741. */
  60742. dispose(): void;
  60743. protected _createRenderTargets(): void;
  60744. private _copyBonesTransformationMatrices;
  60745. }
  60746. }
  60747. declare module BABYLON {
  60748. interface Scene {
  60749. /** @hidden (Backing field) */
  60750. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60751. /**
  60752. * Gets or Sets the current geometry buffer associated to the scene.
  60753. */
  60754. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60755. /**
  60756. * Enables a GeometryBufferRender and associates it with the scene
  60757. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60758. * @returns the GeometryBufferRenderer
  60759. */
  60760. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60761. /**
  60762. * Disables the GeometryBufferRender associated with the scene
  60763. */
  60764. disableGeometryBufferRenderer(): void;
  60765. }
  60766. /**
  60767. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60768. * in several rendering techniques.
  60769. */
  60770. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60771. /**
  60772. * The component name helpful to identify the component in the list of scene components.
  60773. */
  60774. readonly name: string;
  60775. /**
  60776. * The scene the component belongs to.
  60777. */
  60778. scene: Scene;
  60779. /**
  60780. * Creates a new instance of the component for the given scene
  60781. * @param scene Defines the scene to register the component in
  60782. */
  60783. constructor(scene: Scene);
  60784. /**
  60785. * Registers the component in a given scene
  60786. */
  60787. register(): void;
  60788. /**
  60789. * Rebuilds the elements related to this component in case of
  60790. * context lost for instance.
  60791. */
  60792. rebuild(): void;
  60793. /**
  60794. * Disposes the component and the associated ressources
  60795. */
  60796. dispose(): void;
  60797. private _gatherRenderTargets;
  60798. }
  60799. }
  60800. declare module BABYLON {
  60801. /** @hidden */
  60802. export var motionBlurPixelShader: {
  60803. name: string;
  60804. shader: string;
  60805. };
  60806. }
  60807. declare module BABYLON {
  60808. /**
  60809. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60810. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60811. * As an example, all you have to do is to create the post-process:
  60812. * var mb = new BABYLON.MotionBlurPostProcess(
  60813. * 'mb', // The name of the effect.
  60814. * scene, // The scene containing the objects to blur according to their velocity.
  60815. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60816. * camera // The camera to apply the render pass to.
  60817. * );
  60818. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60819. */
  60820. export class MotionBlurPostProcess extends PostProcess {
  60821. /**
  60822. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60823. */
  60824. motionStrength: number;
  60825. /**
  60826. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60827. */
  60828. /**
  60829. * Sets the number of iterations to be used for motion blur quality
  60830. */
  60831. motionBlurSamples: number;
  60832. private _motionBlurSamples;
  60833. private _geometryBufferRenderer;
  60834. /**
  60835. * Creates a new instance MotionBlurPostProcess
  60836. * @param name The name of the effect.
  60837. * @param scene The scene containing the objects to blur according to their velocity.
  60838. * @param options The required width/height ratio to downsize to before computing the render pass.
  60839. * @param camera The camera to apply the render pass to.
  60840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60841. * @param engine The engine which the post process will be applied. (default: current engine)
  60842. * @param reusable If the post process can be reused on the same frame. (default: false)
  60843. * @param textureType Type of textures used when performing the post process. (default: 0)
  60844. * @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)
  60845. */
  60846. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60847. /**
  60848. * Excludes the given skinned mesh from computing bones velocities.
  60849. * 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.
  60850. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60851. */
  60852. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60853. /**
  60854. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60855. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60856. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60857. */
  60858. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60859. /**
  60860. * Disposes the post process.
  60861. * @param camera The camera to dispose the post process on.
  60862. */
  60863. dispose(camera?: Camera): void;
  60864. }
  60865. }
  60866. declare module BABYLON {
  60867. /** @hidden */
  60868. export var refractionPixelShader: {
  60869. name: string;
  60870. shader: string;
  60871. };
  60872. }
  60873. declare module BABYLON {
  60874. /**
  60875. * Post process which applies a refractin texture
  60876. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60877. */
  60878. export class RefractionPostProcess extends PostProcess {
  60879. /** the base color of the refraction (used to taint the rendering) */
  60880. color: Color3;
  60881. /** simulated refraction depth */
  60882. depth: number;
  60883. /** the coefficient of the base color (0 to remove base color tainting) */
  60884. colorLevel: number;
  60885. private _refTexture;
  60886. private _ownRefractionTexture;
  60887. /**
  60888. * Gets or sets the refraction texture
  60889. * Please note that you are responsible for disposing the texture if you set it manually
  60890. */
  60891. refractionTexture: Texture;
  60892. /**
  60893. * Initializes the RefractionPostProcess
  60894. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60895. * @param name The name of the effect.
  60896. * @param refractionTextureUrl Url of the refraction texture to use
  60897. * @param color the base color of the refraction (used to taint the rendering)
  60898. * @param depth simulated refraction depth
  60899. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60900. * @param camera The camera to apply the render pass to.
  60901. * @param options The required width/height ratio to downsize to before computing the render pass.
  60902. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60903. * @param engine The engine which the post process will be applied. (default: current engine)
  60904. * @param reusable If the post process can be reused on the same frame. (default: false)
  60905. */
  60906. constructor(name: string, refractionTextureUrl: string,
  60907. /** the base color of the refraction (used to taint the rendering) */
  60908. color: Color3,
  60909. /** simulated refraction depth */
  60910. depth: number,
  60911. /** the coefficient of the base color (0 to remove base color tainting) */
  60912. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60913. /**
  60914. * Disposes of the post process
  60915. * @param camera Camera to dispose post process on
  60916. */
  60917. dispose(camera: Camera): void;
  60918. }
  60919. }
  60920. declare module BABYLON {
  60921. /** @hidden */
  60922. export var sharpenPixelShader: {
  60923. name: string;
  60924. shader: string;
  60925. };
  60926. }
  60927. declare module BABYLON {
  60928. /**
  60929. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60930. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60931. */
  60932. export class SharpenPostProcess extends PostProcess {
  60933. /**
  60934. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60935. */
  60936. colorAmount: number;
  60937. /**
  60938. * How much sharpness should be applied (default: 0.3)
  60939. */
  60940. edgeAmount: number;
  60941. /**
  60942. * Creates a new instance ConvolutionPostProcess
  60943. * @param name The name of the effect.
  60944. * @param options The required width/height ratio to downsize to before computing the render pass.
  60945. * @param camera The camera to apply the render pass to.
  60946. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60947. * @param engine The engine which the post process will be applied. (default: current engine)
  60948. * @param reusable If the post process can be reused on the same frame. (default: false)
  60949. * @param textureType Type of textures used when performing the post process. (default: 0)
  60950. * @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)
  60951. */
  60952. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60953. }
  60954. }
  60955. declare module BABYLON {
  60956. /**
  60957. * PostProcessRenderPipeline
  60958. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60959. */
  60960. export class PostProcessRenderPipeline {
  60961. private engine;
  60962. private _renderEffects;
  60963. private _renderEffectsForIsolatedPass;
  60964. /**
  60965. * List of inspectable custom properties (used by the Inspector)
  60966. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60967. */
  60968. inspectableCustomProperties: IInspectable[];
  60969. /**
  60970. * @hidden
  60971. */
  60972. protected _cameras: Camera[];
  60973. /** @hidden */
  60974. _name: string;
  60975. /**
  60976. * Gets pipeline name
  60977. */
  60978. readonly name: string;
  60979. /** Gets the list of attached cameras */
  60980. readonly cameras: Camera[];
  60981. /**
  60982. * Initializes a PostProcessRenderPipeline
  60983. * @param engine engine to add the pipeline to
  60984. * @param name name of the pipeline
  60985. */
  60986. constructor(engine: Engine, name: string);
  60987. /**
  60988. * Gets the class name
  60989. * @returns "PostProcessRenderPipeline"
  60990. */
  60991. getClassName(): string;
  60992. /**
  60993. * If all the render effects in the pipeline are supported
  60994. */
  60995. readonly isSupported: boolean;
  60996. /**
  60997. * Adds an effect to the pipeline
  60998. * @param renderEffect the effect to add
  60999. */
  61000. addEffect(renderEffect: PostProcessRenderEffect): void;
  61001. /** @hidden */
  61002. _rebuild(): void;
  61003. /** @hidden */
  61004. _enableEffect(renderEffectName: string, cameras: Camera): void;
  61005. /** @hidden */
  61006. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  61007. /** @hidden */
  61008. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61009. /** @hidden */
  61010. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61011. /** @hidden */
  61012. _attachCameras(cameras: Camera, unique: boolean): void;
  61013. /** @hidden */
  61014. _attachCameras(cameras: Camera[], unique: boolean): void;
  61015. /** @hidden */
  61016. _detachCameras(cameras: Camera): void;
  61017. /** @hidden */
  61018. _detachCameras(cameras: Nullable<Camera[]>): void;
  61019. /** @hidden */
  61020. _update(): void;
  61021. /** @hidden */
  61022. _reset(): void;
  61023. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  61024. /**
  61025. * Disposes of the pipeline
  61026. */
  61027. dispose(): void;
  61028. }
  61029. }
  61030. declare module BABYLON {
  61031. /**
  61032. * PostProcessRenderPipelineManager class
  61033. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61034. */
  61035. export class PostProcessRenderPipelineManager {
  61036. private _renderPipelines;
  61037. /**
  61038. * Initializes a PostProcessRenderPipelineManager
  61039. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61040. */
  61041. constructor();
  61042. /**
  61043. * Gets the list of supported render pipelines
  61044. */
  61045. readonly supportedPipelines: PostProcessRenderPipeline[];
  61046. /**
  61047. * Adds a pipeline to the manager
  61048. * @param renderPipeline The pipeline to add
  61049. */
  61050. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  61051. /**
  61052. * Attaches a camera to the pipeline
  61053. * @param renderPipelineName The name of the pipeline to attach to
  61054. * @param cameras the camera to attach
  61055. * @param unique if the camera can be attached multiple times to the pipeline
  61056. */
  61057. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  61058. /**
  61059. * Detaches a camera from the pipeline
  61060. * @param renderPipelineName The name of the pipeline to detach from
  61061. * @param cameras the camera to detach
  61062. */
  61063. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  61064. /**
  61065. * Enables an effect by name on a pipeline
  61066. * @param renderPipelineName the name of the pipeline to enable the effect in
  61067. * @param renderEffectName the name of the effect to enable
  61068. * @param cameras the cameras that the effect should be enabled on
  61069. */
  61070. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61071. /**
  61072. * Disables an effect by name on a pipeline
  61073. * @param renderPipelineName the name of the pipeline to disable the effect in
  61074. * @param renderEffectName the name of the effect to disable
  61075. * @param cameras the cameras that the effect should be disabled on
  61076. */
  61077. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61078. /**
  61079. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  61080. */
  61081. update(): void;
  61082. /** @hidden */
  61083. _rebuild(): void;
  61084. /**
  61085. * Disposes of the manager and pipelines
  61086. */
  61087. dispose(): void;
  61088. }
  61089. }
  61090. declare module BABYLON {
  61091. interface Scene {
  61092. /** @hidden (Backing field) */
  61093. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61094. /**
  61095. * Gets the postprocess render pipeline manager
  61096. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61097. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61098. */
  61099. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61100. }
  61101. /**
  61102. * Defines the Render Pipeline scene component responsible to rendering pipelines
  61103. */
  61104. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  61105. /**
  61106. * The component name helpfull to identify the component in the list of scene components.
  61107. */
  61108. readonly name: string;
  61109. /**
  61110. * The scene the component belongs to.
  61111. */
  61112. scene: Scene;
  61113. /**
  61114. * Creates a new instance of the component for the given scene
  61115. * @param scene Defines the scene to register the component in
  61116. */
  61117. constructor(scene: Scene);
  61118. /**
  61119. * Registers the component in a given scene
  61120. */
  61121. register(): void;
  61122. /**
  61123. * Rebuilds the elements related to this component in case of
  61124. * context lost for instance.
  61125. */
  61126. rebuild(): void;
  61127. /**
  61128. * Disposes the component and the associated ressources
  61129. */
  61130. dispose(): void;
  61131. private _gatherRenderTargets;
  61132. }
  61133. }
  61134. declare module BABYLON {
  61135. /**
  61136. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  61137. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61138. */
  61139. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61140. private _scene;
  61141. private _camerasToBeAttached;
  61142. /**
  61143. * ID of the sharpen post process,
  61144. */
  61145. private readonly SharpenPostProcessId;
  61146. /**
  61147. * @ignore
  61148. * ID of the image processing post process;
  61149. */
  61150. readonly ImageProcessingPostProcessId: string;
  61151. /**
  61152. * @ignore
  61153. * ID of the Fast Approximate Anti-Aliasing post process;
  61154. */
  61155. readonly FxaaPostProcessId: string;
  61156. /**
  61157. * ID of the chromatic aberration post process,
  61158. */
  61159. private readonly ChromaticAberrationPostProcessId;
  61160. /**
  61161. * ID of the grain post process
  61162. */
  61163. private readonly GrainPostProcessId;
  61164. /**
  61165. * Sharpen post process which will apply a sharpen convolution to enhance edges
  61166. */
  61167. sharpen: SharpenPostProcess;
  61168. private _sharpenEffect;
  61169. private bloom;
  61170. /**
  61171. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  61172. */
  61173. depthOfField: DepthOfFieldEffect;
  61174. /**
  61175. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61176. */
  61177. fxaa: FxaaPostProcess;
  61178. /**
  61179. * Image post processing pass used to perform operations such as tone mapping or color grading.
  61180. */
  61181. imageProcessing: ImageProcessingPostProcess;
  61182. /**
  61183. * Chromatic aberration post process which will shift rgb colors in the image
  61184. */
  61185. chromaticAberration: ChromaticAberrationPostProcess;
  61186. private _chromaticAberrationEffect;
  61187. /**
  61188. * Grain post process which add noise to the image
  61189. */
  61190. grain: GrainPostProcess;
  61191. private _grainEffect;
  61192. /**
  61193. * Glow post process which adds a glow to emissive areas of the image
  61194. */
  61195. private _glowLayer;
  61196. /**
  61197. * Animations which can be used to tweak settings over a period of time
  61198. */
  61199. animations: Animation[];
  61200. private _imageProcessingConfigurationObserver;
  61201. private _sharpenEnabled;
  61202. private _bloomEnabled;
  61203. private _depthOfFieldEnabled;
  61204. private _depthOfFieldBlurLevel;
  61205. private _fxaaEnabled;
  61206. private _imageProcessingEnabled;
  61207. private _defaultPipelineTextureType;
  61208. private _bloomScale;
  61209. private _chromaticAberrationEnabled;
  61210. private _grainEnabled;
  61211. private _buildAllowed;
  61212. /**
  61213. * Gets active scene
  61214. */
  61215. readonly scene: Scene;
  61216. /**
  61217. * Enable or disable the sharpen process from the pipeline
  61218. */
  61219. sharpenEnabled: boolean;
  61220. private _resizeObserver;
  61221. private _hardwareScaleLevel;
  61222. private _bloomKernel;
  61223. /**
  61224. * Specifies the size of the bloom blur kernel, relative to the final output size
  61225. */
  61226. bloomKernel: number;
  61227. /**
  61228. * Specifies the weight of the bloom in the final rendering
  61229. */
  61230. private _bloomWeight;
  61231. /**
  61232. * Specifies the luma threshold for the area that will be blurred by the bloom
  61233. */
  61234. private _bloomThreshold;
  61235. private _hdr;
  61236. /**
  61237. * The strength of the bloom.
  61238. */
  61239. bloomWeight: number;
  61240. /**
  61241. * The strength of the bloom.
  61242. */
  61243. bloomThreshold: number;
  61244. /**
  61245. * The scale of the bloom, lower value will provide better performance.
  61246. */
  61247. bloomScale: number;
  61248. /**
  61249. * Enable or disable the bloom from the pipeline
  61250. */
  61251. bloomEnabled: boolean;
  61252. private _rebuildBloom;
  61253. /**
  61254. * If the depth of field is enabled.
  61255. */
  61256. depthOfFieldEnabled: boolean;
  61257. /**
  61258. * Blur level of the depth of field effect. (Higher blur will effect performance)
  61259. */
  61260. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  61261. /**
  61262. * If the anti aliasing is enabled.
  61263. */
  61264. fxaaEnabled: boolean;
  61265. private _samples;
  61266. /**
  61267. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61268. */
  61269. samples: number;
  61270. /**
  61271. * If image processing is enabled.
  61272. */
  61273. imageProcessingEnabled: boolean;
  61274. /**
  61275. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  61276. */
  61277. glowLayerEnabled: boolean;
  61278. /**
  61279. * Gets the glow layer (or null if not defined)
  61280. */
  61281. readonly glowLayer: Nullable<GlowLayer>;
  61282. /**
  61283. * Enable or disable the chromaticAberration process from the pipeline
  61284. */
  61285. chromaticAberrationEnabled: boolean;
  61286. /**
  61287. * Enable or disable the grain process from the pipeline
  61288. */
  61289. grainEnabled: boolean;
  61290. /**
  61291. * @constructor
  61292. * @param name - The rendering pipeline name (default: "")
  61293. * @param hdr - If high dynamic range textures should be used (default: true)
  61294. * @param scene - The scene linked to this pipeline (default: the last created scene)
  61295. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  61296. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  61297. */
  61298. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  61299. /**
  61300. * Get the class name
  61301. * @returns "DefaultRenderingPipeline"
  61302. */
  61303. getClassName(): string;
  61304. /**
  61305. * Force the compilation of the entire pipeline.
  61306. */
  61307. prepare(): void;
  61308. private _hasCleared;
  61309. private _prevPostProcess;
  61310. private _prevPrevPostProcess;
  61311. private _setAutoClearAndTextureSharing;
  61312. private _depthOfFieldSceneObserver;
  61313. private _buildPipeline;
  61314. private _disposePostProcesses;
  61315. /**
  61316. * Adds a camera to the pipeline
  61317. * @param camera the camera to be added
  61318. */
  61319. addCamera(camera: Camera): void;
  61320. /**
  61321. * Removes a camera from the pipeline
  61322. * @param camera the camera to remove
  61323. */
  61324. removeCamera(camera: Camera): void;
  61325. /**
  61326. * Dispose of the pipeline and stop all post processes
  61327. */
  61328. dispose(): void;
  61329. /**
  61330. * Serialize the rendering pipeline (Used when exporting)
  61331. * @returns the serialized object
  61332. */
  61333. serialize(): any;
  61334. /**
  61335. * Parse the serialized pipeline
  61336. * @param source Source pipeline.
  61337. * @param scene The scene to load the pipeline to.
  61338. * @param rootUrl The URL of the serialized pipeline.
  61339. * @returns An instantiated pipeline from the serialized object.
  61340. */
  61341. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  61342. }
  61343. }
  61344. declare module BABYLON {
  61345. /** @hidden */
  61346. export var lensHighlightsPixelShader: {
  61347. name: string;
  61348. shader: string;
  61349. };
  61350. }
  61351. declare module BABYLON {
  61352. /** @hidden */
  61353. export var depthOfFieldPixelShader: {
  61354. name: string;
  61355. shader: string;
  61356. };
  61357. }
  61358. declare module BABYLON {
  61359. /**
  61360. * BABYLON.JS Chromatic Aberration GLSL Shader
  61361. * Author: Olivier Guyot
  61362. * Separates very slightly R, G and B colors on the edges of the screen
  61363. * Inspired by Francois Tarlier & Martins Upitis
  61364. */
  61365. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  61366. /**
  61367. * @ignore
  61368. * The chromatic aberration PostProcess id in the pipeline
  61369. */
  61370. LensChromaticAberrationEffect: string;
  61371. /**
  61372. * @ignore
  61373. * The highlights enhancing PostProcess id in the pipeline
  61374. */
  61375. HighlightsEnhancingEffect: string;
  61376. /**
  61377. * @ignore
  61378. * The depth-of-field PostProcess id in the pipeline
  61379. */
  61380. LensDepthOfFieldEffect: string;
  61381. private _scene;
  61382. private _depthTexture;
  61383. private _grainTexture;
  61384. private _chromaticAberrationPostProcess;
  61385. private _highlightsPostProcess;
  61386. private _depthOfFieldPostProcess;
  61387. private _edgeBlur;
  61388. private _grainAmount;
  61389. private _chromaticAberration;
  61390. private _distortion;
  61391. private _highlightsGain;
  61392. private _highlightsThreshold;
  61393. private _dofDistance;
  61394. private _dofAperture;
  61395. private _dofDarken;
  61396. private _dofPentagon;
  61397. private _blurNoise;
  61398. /**
  61399. * @constructor
  61400. *
  61401. * Effect parameters are as follow:
  61402. * {
  61403. * chromatic_aberration: number; // from 0 to x (1 for realism)
  61404. * edge_blur: number; // from 0 to x (1 for realism)
  61405. * distortion: number; // from 0 to x (1 for realism)
  61406. * grain_amount: number; // from 0 to 1
  61407. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  61408. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  61409. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  61410. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  61411. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  61412. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  61413. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  61414. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  61415. * }
  61416. * Note: if an effect parameter is unset, effect is disabled
  61417. *
  61418. * @param name The rendering pipeline name
  61419. * @param parameters - An object containing all parameters (see above)
  61420. * @param scene The scene linked to this pipeline
  61421. * @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)
  61422. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61423. */
  61424. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  61425. /**
  61426. * Get the class name
  61427. * @returns "LensRenderingPipeline"
  61428. */
  61429. getClassName(): string;
  61430. /**
  61431. * Gets associated scene
  61432. */
  61433. readonly scene: Scene;
  61434. /**
  61435. * Gets or sets the edge blur
  61436. */
  61437. edgeBlur: number;
  61438. /**
  61439. * Gets or sets the grain amount
  61440. */
  61441. grainAmount: number;
  61442. /**
  61443. * Gets or sets the chromatic aberration amount
  61444. */
  61445. chromaticAberration: number;
  61446. /**
  61447. * Gets or sets the depth of field aperture
  61448. */
  61449. dofAperture: number;
  61450. /**
  61451. * Gets or sets the edge distortion
  61452. */
  61453. edgeDistortion: number;
  61454. /**
  61455. * Gets or sets the depth of field distortion
  61456. */
  61457. dofDistortion: number;
  61458. /**
  61459. * Gets or sets the darken out of focus amount
  61460. */
  61461. darkenOutOfFocus: number;
  61462. /**
  61463. * Gets or sets a boolean indicating if blur noise is enabled
  61464. */
  61465. blurNoise: boolean;
  61466. /**
  61467. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  61468. */
  61469. pentagonBokeh: boolean;
  61470. /**
  61471. * Gets or sets the highlight grain amount
  61472. */
  61473. highlightsGain: number;
  61474. /**
  61475. * Gets or sets the highlight threshold
  61476. */
  61477. highlightsThreshold: number;
  61478. /**
  61479. * Sets the amount of blur at the edges
  61480. * @param amount blur amount
  61481. */
  61482. setEdgeBlur(amount: number): void;
  61483. /**
  61484. * Sets edge blur to 0
  61485. */
  61486. disableEdgeBlur(): void;
  61487. /**
  61488. * Sets the amout of grain
  61489. * @param amount Amount of grain
  61490. */
  61491. setGrainAmount(amount: number): void;
  61492. /**
  61493. * Set grain amount to 0
  61494. */
  61495. disableGrain(): void;
  61496. /**
  61497. * Sets the chromatic aberration amount
  61498. * @param amount amount of chromatic aberration
  61499. */
  61500. setChromaticAberration(amount: number): void;
  61501. /**
  61502. * Sets chromatic aberration amount to 0
  61503. */
  61504. disableChromaticAberration(): void;
  61505. /**
  61506. * Sets the EdgeDistortion amount
  61507. * @param amount amount of EdgeDistortion
  61508. */
  61509. setEdgeDistortion(amount: number): void;
  61510. /**
  61511. * Sets edge distortion to 0
  61512. */
  61513. disableEdgeDistortion(): void;
  61514. /**
  61515. * Sets the FocusDistance amount
  61516. * @param amount amount of FocusDistance
  61517. */
  61518. setFocusDistance(amount: number): void;
  61519. /**
  61520. * Disables depth of field
  61521. */
  61522. disableDepthOfField(): void;
  61523. /**
  61524. * Sets the Aperture amount
  61525. * @param amount amount of Aperture
  61526. */
  61527. setAperture(amount: number): void;
  61528. /**
  61529. * Sets the DarkenOutOfFocus amount
  61530. * @param amount amount of DarkenOutOfFocus
  61531. */
  61532. setDarkenOutOfFocus(amount: number): void;
  61533. private _pentagonBokehIsEnabled;
  61534. /**
  61535. * Creates a pentagon bokeh effect
  61536. */
  61537. enablePentagonBokeh(): void;
  61538. /**
  61539. * Disables the pentagon bokeh effect
  61540. */
  61541. disablePentagonBokeh(): void;
  61542. /**
  61543. * Enables noise blur
  61544. */
  61545. enableNoiseBlur(): void;
  61546. /**
  61547. * Disables noise blur
  61548. */
  61549. disableNoiseBlur(): void;
  61550. /**
  61551. * Sets the HighlightsGain amount
  61552. * @param amount amount of HighlightsGain
  61553. */
  61554. setHighlightsGain(amount: number): void;
  61555. /**
  61556. * Sets the HighlightsThreshold amount
  61557. * @param amount amount of HighlightsThreshold
  61558. */
  61559. setHighlightsThreshold(amount: number): void;
  61560. /**
  61561. * Disables highlights
  61562. */
  61563. disableHighlights(): void;
  61564. /**
  61565. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61566. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61567. */
  61568. dispose(disableDepthRender?: boolean): void;
  61569. private _createChromaticAberrationPostProcess;
  61570. private _createHighlightsPostProcess;
  61571. private _createDepthOfFieldPostProcess;
  61572. private _createGrainTexture;
  61573. }
  61574. }
  61575. declare module BABYLON {
  61576. /** @hidden */
  61577. export var ssao2PixelShader: {
  61578. name: string;
  61579. shader: string;
  61580. };
  61581. }
  61582. declare module BABYLON {
  61583. /** @hidden */
  61584. export var ssaoCombinePixelShader: {
  61585. name: string;
  61586. shader: string;
  61587. };
  61588. }
  61589. declare module BABYLON {
  61590. /**
  61591. * Render pipeline to produce ssao effect
  61592. */
  61593. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61594. /**
  61595. * @ignore
  61596. * The PassPostProcess id in the pipeline that contains the original scene color
  61597. */
  61598. SSAOOriginalSceneColorEffect: string;
  61599. /**
  61600. * @ignore
  61601. * The SSAO PostProcess id in the pipeline
  61602. */
  61603. SSAORenderEffect: string;
  61604. /**
  61605. * @ignore
  61606. * The horizontal blur PostProcess id in the pipeline
  61607. */
  61608. SSAOBlurHRenderEffect: string;
  61609. /**
  61610. * @ignore
  61611. * The vertical blur PostProcess id in the pipeline
  61612. */
  61613. SSAOBlurVRenderEffect: string;
  61614. /**
  61615. * @ignore
  61616. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61617. */
  61618. SSAOCombineRenderEffect: string;
  61619. /**
  61620. * The output strength of the SSAO post-process. Default value is 1.0.
  61621. */
  61622. totalStrength: number;
  61623. /**
  61624. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61625. */
  61626. maxZ: number;
  61627. /**
  61628. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61629. */
  61630. minZAspect: number;
  61631. private _samples;
  61632. /**
  61633. * Number of samples used for the SSAO calculations. Default value is 8
  61634. */
  61635. samples: number;
  61636. private _textureSamples;
  61637. /**
  61638. * Number of samples to use for antialiasing
  61639. */
  61640. textureSamples: number;
  61641. /**
  61642. * Ratio object used for SSAO ratio and blur ratio
  61643. */
  61644. private _ratio;
  61645. /**
  61646. * Dynamically generated sphere sampler.
  61647. */
  61648. private _sampleSphere;
  61649. /**
  61650. * Blur filter offsets
  61651. */
  61652. private _samplerOffsets;
  61653. private _expensiveBlur;
  61654. /**
  61655. * If bilateral blur should be used
  61656. */
  61657. expensiveBlur: boolean;
  61658. /**
  61659. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61660. */
  61661. radius: number;
  61662. /**
  61663. * The base color of the SSAO post-process
  61664. * The final result is "base + ssao" between [0, 1]
  61665. */
  61666. base: number;
  61667. /**
  61668. * Support test.
  61669. */
  61670. static readonly IsSupported: boolean;
  61671. private _scene;
  61672. private _depthTexture;
  61673. private _normalTexture;
  61674. private _randomTexture;
  61675. private _originalColorPostProcess;
  61676. private _ssaoPostProcess;
  61677. private _blurHPostProcess;
  61678. private _blurVPostProcess;
  61679. private _ssaoCombinePostProcess;
  61680. /**
  61681. * Gets active scene
  61682. */
  61683. readonly scene: Scene;
  61684. /**
  61685. * @constructor
  61686. * @param name The rendering pipeline name
  61687. * @param scene The scene linked to this pipeline
  61688. * @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 }
  61689. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61690. */
  61691. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61692. /**
  61693. * Get the class name
  61694. * @returns "SSAO2RenderingPipeline"
  61695. */
  61696. getClassName(): string;
  61697. /**
  61698. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61699. */
  61700. dispose(disableGeometryBufferRenderer?: boolean): void;
  61701. private _createBlurPostProcess;
  61702. /** @hidden */
  61703. _rebuild(): void;
  61704. private _bits;
  61705. private _radicalInverse_VdC;
  61706. private _hammersley;
  61707. private _hemisphereSample_uniform;
  61708. private _generateHemisphere;
  61709. private _createSSAOPostProcess;
  61710. private _createSSAOCombinePostProcess;
  61711. private _createRandomTexture;
  61712. /**
  61713. * Serialize the rendering pipeline (Used when exporting)
  61714. * @returns the serialized object
  61715. */
  61716. serialize(): any;
  61717. /**
  61718. * Parse the serialized pipeline
  61719. * @param source Source pipeline.
  61720. * @param scene The scene to load the pipeline to.
  61721. * @param rootUrl The URL of the serialized pipeline.
  61722. * @returns An instantiated pipeline from the serialized object.
  61723. */
  61724. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61725. }
  61726. }
  61727. declare module BABYLON {
  61728. /** @hidden */
  61729. export var ssaoPixelShader: {
  61730. name: string;
  61731. shader: string;
  61732. };
  61733. }
  61734. declare module BABYLON {
  61735. /**
  61736. * Render pipeline to produce ssao effect
  61737. */
  61738. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61739. /**
  61740. * @ignore
  61741. * The PassPostProcess id in the pipeline that contains the original scene color
  61742. */
  61743. SSAOOriginalSceneColorEffect: string;
  61744. /**
  61745. * @ignore
  61746. * The SSAO PostProcess id in the pipeline
  61747. */
  61748. SSAORenderEffect: string;
  61749. /**
  61750. * @ignore
  61751. * The horizontal blur PostProcess id in the pipeline
  61752. */
  61753. SSAOBlurHRenderEffect: string;
  61754. /**
  61755. * @ignore
  61756. * The vertical blur PostProcess id in the pipeline
  61757. */
  61758. SSAOBlurVRenderEffect: string;
  61759. /**
  61760. * @ignore
  61761. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61762. */
  61763. SSAOCombineRenderEffect: string;
  61764. /**
  61765. * The output strength of the SSAO post-process. Default value is 1.0.
  61766. */
  61767. totalStrength: number;
  61768. /**
  61769. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61770. */
  61771. radius: number;
  61772. /**
  61773. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61774. * Must not be equal to fallOff and superior to fallOff.
  61775. * Default value is 0.0075
  61776. */
  61777. area: number;
  61778. /**
  61779. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61780. * Must not be equal to area and inferior to area.
  61781. * Default value is 0.000001
  61782. */
  61783. fallOff: number;
  61784. /**
  61785. * The base color of the SSAO post-process
  61786. * The final result is "base + ssao" between [0, 1]
  61787. */
  61788. base: number;
  61789. private _scene;
  61790. private _depthTexture;
  61791. private _randomTexture;
  61792. private _originalColorPostProcess;
  61793. private _ssaoPostProcess;
  61794. private _blurHPostProcess;
  61795. private _blurVPostProcess;
  61796. private _ssaoCombinePostProcess;
  61797. private _firstUpdate;
  61798. /**
  61799. * Gets active scene
  61800. */
  61801. readonly scene: Scene;
  61802. /**
  61803. * @constructor
  61804. * @param name - The rendering pipeline name
  61805. * @param scene - The scene linked to this pipeline
  61806. * @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 }
  61807. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61808. */
  61809. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61810. /**
  61811. * Get the class name
  61812. * @returns "SSAORenderingPipeline"
  61813. */
  61814. getClassName(): string;
  61815. /**
  61816. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61817. */
  61818. dispose(disableDepthRender?: boolean): void;
  61819. private _createBlurPostProcess;
  61820. /** @hidden */
  61821. _rebuild(): void;
  61822. private _createSSAOPostProcess;
  61823. private _createSSAOCombinePostProcess;
  61824. private _createRandomTexture;
  61825. }
  61826. }
  61827. declare module BABYLON {
  61828. /** @hidden */
  61829. export var standardPixelShader: {
  61830. name: string;
  61831. shader: string;
  61832. };
  61833. }
  61834. declare module BABYLON {
  61835. /**
  61836. * Standard rendering pipeline
  61837. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61838. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61839. */
  61840. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61841. /**
  61842. * Public members
  61843. */
  61844. /**
  61845. * Post-process which contains the original scene color before the pipeline applies all the effects
  61846. */
  61847. originalPostProcess: Nullable<PostProcess>;
  61848. /**
  61849. * Post-process used to down scale an image x4
  61850. */
  61851. downSampleX4PostProcess: Nullable<PostProcess>;
  61852. /**
  61853. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61854. */
  61855. brightPassPostProcess: Nullable<PostProcess>;
  61856. /**
  61857. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61858. */
  61859. blurHPostProcesses: PostProcess[];
  61860. /**
  61861. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61862. */
  61863. blurVPostProcesses: PostProcess[];
  61864. /**
  61865. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61866. */
  61867. textureAdderPostProcess: Nullable<PostProcess>;
  61868. /**
  61869. * Post-process used to create volumetric lighting effect
  61870. */
  61871. volumetricLightPostProcess: Nullable<PostProcess>;
  61872. /**
  61873. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61874. */
  61875. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61876. /**
  61877. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61878. */
  61879. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61880. /**
  61881. * Post-process used to merge the volumetric light effect and the real scene color
  61882. */
  61883. volumetricLightMergePostProces: Nullable<PostProcess>;
  61884. /**
  61885. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61886. */
  61887. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61888. /**
  61889. * Base post-process used to calculate the average luminance of the final image for HDR
  61890. */
  61891. luminancePostProcess: Nullable<PostProcess>;
  61892. /**
  61893. * Post-processes used to create down sample post-processes in order to get
  61894. * the average luminance of the final image for HDR
  61895. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61896. */
  61897. luminanceDownSamplePostProcesses: PostProcess[];
  61898. /**
  61899. * Post-process used to create a HDR effect (light adaptation)
  61900. */
  61901. hdrPostProcess: Nullable<PostProcess>;
  61902. /**
  61903. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61904. */
  61905. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61906. /**
  61907. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61908. */
  61909. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61910. /**
  61911. * Post-process used to merge the final HDR post-process and the real scene color
  61912. */
  61913. hdrFinalPostProcess: Nullable<PostProcess>;
  61914. /**
  61915. * Post-process used to create a lens flare effect
  61916. */
  61917. lensFlarePostProcess: Nullable<PostProcess>;
  61918. /**
  61919. * Post-process that merges the result of the lens flare post-process and the real scene color
  61920. */
  61921. lensFlareComposePostProcess: Nullable<PostProcess>;
  61922. /**
  61923. * Post-process used to create a motion blur effect
  61924. */
  61925. motionBlurPostProcess: Nullable<PostProcess>;
  61926. /**
  61927. * Post-process used to create a depth of field effect
  61928. */
  61929. depthOfFieldPostProcess: Nullable<PostProcess>;
  61930. /**
  61931. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61932. */
  61933. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61934. /**
  61935. * Represents the brightness threshold in order to configure the illuminated surfaces
  61936. */
  61937. brightThreshold: number;
  61938. /**
  61939. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61940. */
  61941. blurWidth: number;
  61942. /**
  61943. * Sets if the blur for highlighted surfaces must be only horizontal
  61944. */
  61945. horizontalBlur: boolean;
  61946. /**
  61947. * Gets the overall exposure used by the pipeline
  61948. */
  61949. /**
  61950. * Sets the overall exposure used by the pipeline
  61951. */
  61952. exposure: number;
  61953. /**
  61954. * Texture used typically to simulate "dirty" on camera lens
  61955. */
  61956. lensTexture: Nullable<Texture>;
  61957. /**
  61958. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61959. */
  61960. volumetricLightCoefficient: number;
  61961. /**
  61962. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61963. */
  61964. volumetricLightPower: number;
  61965. /**
  61966. * Used the set the blur intensity to smooth the volumetric lights
  61967. */
  61968. volumetricLightBlurScale: number;
  61969. /**
  61970. * Light (spot or directional) used to generate the volumetric lights rays
  61971. * The source light must have a shadow generate so the pipeline can get its
  61972. * depth map
  61973. */
  61974. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61975. /**
  61976. * For eye adaptation, represents the minimum luminance the eye can see
  61977. */
  61978. hdrMinimumLuminance: number;
  61979. /**
  61980. * For eye adaptation, represents the decrease luminance speed
  61981. */
  61982. hdrDecreaseRate: number;
  61983. /**
  61984. * For eye adaptation, represents the increase luminance speed
  61985. */
  61986. hdrIncreaseRate: number;
  61987. /**
  61988. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61989. */
  61990. /**
  61991. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61992. */
  61993. hdrAutoExposure: boolean;
  61994. /**
  61995. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61996. */
  61997. lensColorTexture: Nullable<Texture>;
  61998. /**
  61999. * The overall strengh for the lens flare effect
  62000. */
  62001. lensFlareStrength: number;
  62002. /**
  62003. * Dispersion coefficient for lens flare ghosts
  62004. */
  62005. lensFlareGhostDispersal: number;
  62006. /**
  62007. * Main lens flare halo width
  62008. */
  62009. lensFlareHaloWidth: number;
  62010. /**
  62011. * Based on the lens distortion effect, defines how much the lens flare result
  62012. * is distorted
  62013. */
  62014. lensFlareDistortionStrength: number;
  62015. /**
  62016. * Configures the blur intensity used for for lens flare (halo)
  62017. */
  62018. lensFlareBlurWidth: number;
  62019. /**
  62020. * Lens star texture must be used to simulate rays on the flares and is available
  62021. * in the documentation
  62022. */
  62023. lensStarTexture: Nullable<Texture>;
  62024. /**
  62025. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  62026. * flare effect by taking account of the dirt texture
  62027. */
  62028. lensFlareDirtTexture: Nullable<Texture>;
  62029. /**
  62030. * Represents the focal length for the depth of field effect
  62031. */
  62032. depthOfFieldDistance: number;
  62033. /**
  62034. * Represents the blur intensity for the blurred part of the depth of field effect
  62035. */
  62036. depthOfFieldBlurWidth: number;
  62037. /**
  62038. * Gets how much the image is blurred by the movement while using the motion blur post-process
  62039. */
  62040. /**
  62041. * Sets how much the image is blurred by the movement while using the motion blur post-process
  62042. */
  62043. motionStrength: number;
  62044. /**
  62045. * Gets wether or not the motion blur post-process is object based or screen based.
  62046. */
  62047. /**
  62048. * Sets wether or not the motion blur post-process should be object based or screen based
  62049. */
  62050. objectBasedMotionBlur: boolean;
  62051. /**
  62052. * List of animations for the pipeline (IAnimatable implementation)
  62053. */
  62054. animations: Animation[];
  62055. /**
  62056. * Private members
  62057. */
  62058. private _scene;
  62059. private _currentDepthOfFieldSource;
  62060. private _basePostProcess;
  62061. private _fixedExposure;
  62062. private _currentExposure;
  62063. private _hdrAutoExposure;
  62064. private _hdrCurrentLuminance;
  62065. private _motionStrength;
  62066. private _isObjectBasedMotionBlur;
  62067. private _floatTextureType;
  62068. private _camerasToBeAttached;
  62069. private _ratio;
  62070. private _bloomEnabled;
  62071. private _depthOfFieldEnabled;
  62072. private _vlsEnabled;
  62073. private _lensFlareEnabled;
  62074. private _hdrEnabled;
  62075. private _motionBlurEnabled;
  62076. private _fxaaEnabled;
  62077. private _motionBlurSamples;
  62078. private _volumetricLightStepsCount;
  62079. private _samples;
  62080. /**
  62081. * @ignore
  62082. * Specifies if the bloom pipeline is enabled
  62083. */
  62084. BloomEnabled: boolean;
  62085. /**
  62086. * @ignore
  62087. * Specifies if the depth of field pipeline is enabed
  62088. */
  62089. DepthOfFieldEnabled: boolean;
  62090. /**
  62091. * @ignore
  62092. * Specifies if the lens flare pipeline is enabed
  62093. */
  62094. LensFlareEnabled: boolean;
  62095. /**
  62096. * @ignore
  62097. * Specifies if the HDR pipeline is enabled
  62098. */
  62099. HDREnabled: boolean;
  62100. /**
  62101. * @ignore
  62102. * Specifies if the volumetric lights scattering effect is enabled
  62103. */
  62104. VLSEnabled: boolean;
  62105. /**
  62106. * @ignore
  62107. * Specifies if the motion blur effect is enabled
  62108. */
  62109. MotionBlurEnabled: boolean;
  62110. /**
  62111. * Specifies if anti-aliasing is enabled
  62112. */
  62113. fxaaEnabled: boolean;
  62114. /**
  62115. * Specifies the number of steps used to calculate the volumetric lights
  62116. * Typically in interval [50, 200]
  62117. */
  62118. volumetricLightStepsCount: number;
  62119. /**
  62120. * Specifies the number of samples used for the motion blur effect
  62121. * Typically in interval [16, 64]
  62122. */
  62123. motionBlurSamples: number;
  62124. /**
  62125. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62126. */
  62127. samples: number;
  62128. /**
  62129. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62130. * @constructor
  62131. * @param name The rendering pipeline name
  62132. * @param scene The scene linked to this pipeline
  62133. * @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)
  62134. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  62135. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62136. */
  62137. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  62138. private _buildPipeline;
  62139. private _createDownSampleX4PostProcess;
  62140. private _createBrightPassPostProcess;
  62141. private _createBlurPostProcesses;
  62142. private _createTextureAdderPostProcess;
  62143. private _createVolumetricLightPostProcess;
  62144. private _createLuminancePostProcesses;
  62145. private _createHdrPostProcess;
  62146. private _createLensFlarePostProcess;
  62147. private _createDepthOfFieldPostProcess;
  62148. private _createMotionBlurPostProcess;
  62149. private _getDepthTexture;
  62150. private _disposePostProcesses;
  62151. /**
  62152. * Dispose of the pipeline and stop all post processes
  62153. */
  62154. dispose(): void;
  62155. /**
  62156. * Serialize the rendering pipeline (Used when exporting)
  62157. * @returns the serialized object
  62158. */
  62159. serialize(): any;
  62160. /**
  62161. * Parse the serialized pipeline
  62162. * @param source Source pipeline.
  62163. * @param scene The scene to load the pipeline to.
  62164. * @param rootUrl The URL of the serialized pipeline.
  62165. * @returns An instantiated pipeline from the serialized object.
  62166. */
  62167. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  62168. /**
  62169. * Luminance steps
  62170. */
  62171. static LuminanceSteps: number;
  62172. }
  62173. }
  62174. declare module BABYLON {
  62175. /** @hidden */
  62176. export var tonemapPixelShader: {
  62177. name: string;
  62178. shader: string;
  62179. };
  62180. }
  62181. declare module BABYLON {
  62182. /** Defines operator used for tonemapping */
  62183. export enum TonemappingOperator {
  62184. /** Hable */
  62185. Hable = 0,
  62186. /** Reinhard */
  62187. Reinhard = 1,
  62188. /** HejiDawson */
  62189. HejiDawson = 2,
  62190. /** Photographic */
  62191. Photographic = 3
  62192. }
  62193. /**
  62194. * Defines a post process to apply tone mapping
  62195. */
  62196. export class TonemapPostProcess extends PostProcess {
  62197. private _operator;
  62198. /** Defines the required exposure adjustement */
  62199. exposureAdjustment: number;
  62200. /**
  62201. * Creates a new TonemapPostProcess
  62202. * @param name defines the name of the postprocess
  62203. * @param _operator defines the operator to use
  62204. * @param exposureAdjustment defines the required exposure adjustement
  62205. * @param camera defines the camera to use (can be null)
  62206. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  62207. * @param engine defines the hosting engine (can be ignore if camera is set)
  62208. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62209. */
  62210. constructor(name: string, _operator: TonemappingOperator,
  62211. /** Defines the required exposure adjustement */
  62212. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  62213. }
  62214. }
  62215. declare module BABYLON {
  62216. /** @hidden */
  62217. export var depthVertexShader: {
  62218. name: string;
  62219. shader: string;
  62220. };
  62221. }
  62222. declare module BABYLON {
  62223. /** @hidden */
  62224. export var volumetricLightScatteringPixelShader: {
  62225. name: string;
  62226. shader: string;
  62227. };
  62228. }
  62229. declare module BABYLON {
  62230. /** @hidden */
  62231. export var volumetricLightScatteringPassVertexShader: {
  62232. name: string;
  62233. shader: string;
  62234. };
  62235. }
  62236. declare module BABYLON {
  62237. /** @hidden */
  62238. export var volumetricLightScatteringPassPixelShader: {
  62239. name: string;
  62240. shader: string;
  62241. };
  62242. }
  62243. declare module BABYLON {
  62244. /**
  62245. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  62246. */
  62247. export class VolumetricLightScatteringPostProcess extends PostProcess {
  62248. private _volumetricLightScatteringPass;
  62249. private _volumetricLightScatteringRTT;
  62250. private _viewPort;
  62251. private _screenCoordinates;
  62252. private _cachedDefines;
  62253. /**
  62254. * If not undefined, the mesh position is computed from the attached node position
  62255. */
  62256. attachedNode: {
  62257. position: Vector3;
  62258. };
  62259. /**
  62260. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  62261. */
  62262. customMeshPosition: Vector3;
  62263. /**
  62264. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  62265. */
  62266. useCustomMeshPosition: boolean;
  62267. /**
  62268. * If the post-process should inverse the light scattering direction
  62269. */
  62270. invert: boolean;
  62271. /**
  62272. * The internal mesh used by the post-process
  62273. */
  62274. mesh: Mesh;
  62275. /**
  62276. * @hidden
  62277. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  62278. */
  62279. useDiffuseColor: boolean;
  62280. /**
  62281. * Array containing the excluded meshes not rendered in the internal pass
  62282. */
  62283. excludedMeshes: AbstractMesh[];
  62284. /**
  62285. * Controls the overall intensity of the post-process
  62286. */
  62287. exposure: number;
  62288. /**
  62289. * Dissipates each sample's contribution in range [0, 1]
  62290. */
  62291. decay: number;
  62292. /**
  62293. * Controls the overall intensity of each sample
  62294. */
  62295. weight: number;
  62296. /**
  62297. * Controls the density of each sample
  62298. */
  62299. density: number;
  62300. /**
  62301. * @constructor
  62302. * @param name The post-process name
  62303. * @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)
  62304. * @param camera The camera that the post-process will be attached to
  62305. * @param mesh The mesh used to create the light scattering
  62306. * @param samples The post-process quality, default 100
  62307. * @param samplingModeThe post-process filtering mode
  62308. * @param engine The babylon engine
  62309. * @param reusable If the post-process is reusable
  62310. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  62311. */
  62312. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  62313. /**
  62314. * Returns the string "VolumetricLightScatteringPostProcess"
  62315. * @returns "VolumetricLightScatteringPostProcess"
  62316. */
  62317. getClassName(): string;
  62318. private _isReady;
  62319. /**
  62320. * Sets the new light position for light scattering effect
  62321. * @param position The new custom light position
  62322. */
  62323. setCustomMeshPosition(position: Vector3): void;
  62324. /**
  62325. * Returns the light position for light scattering effect
  62326. * @return Vector3 The custom light position
  62327. */
  62328. getCustomMeshPosition(): Vector3;
  62329. /**
  62330. * Disposes the internal assets and detaches the post-process from the camera
  62331. */
  62332. dispose(camera: Camera): void;
  62333. /**
  62334. * Returns the render target texture used by the post-process
  62335. * @return the render target texture used by the post-process
  62336. */
  62337. getPass(): RenderTargetTexture;
  62338. private _meshExcluded;
  62339. private _createPass;
  62340. private _updateMeshScreenCoordinates;
  62341. /**
  62342. * Creates a default mesh for the Volumeric Light Scattering post-process
  62343. * @param name The mesh name
  62344. * @param scene The scene where to create the mesh
  62345. * @return the default mesh
  62346. */
  62347. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  62348. }
  62349. }
  62350. declare module BABYLON {
  62351. interface Scene {
  62352. /** @hidden (Backing field) */
  62353. _boundingBoxRenderer: BoundingBoxRenderer;
  62354. /** @hidden (Backing field) */
  62355. _forceShowBoundingBoxes: boolean;
  62356. /**
  62357. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  62358. */
  62359. forceShowBoundingBoxes: boolean;
  62360. /**
  62361. * Gets the bounding box renderer associated with the scene
  62362. * @returns a BoundingBoxRenderer
  62363. */
  62364. getBoundingBoxRenderer(): BoundingBoxRenderer;
  62365. }
  62366. interface AbstractMesh {
  62367. /** @hidden (Backing field) */
  62368. _showBoundingBox: boolean;
  62369. /**
  62370. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  62371. */
  62372. showBoundingBox: boolean;
  62373. }
  62374. /**
  62375. * Component responsible of rendering the bounding box of the meshes in a scene.
  62376. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  62377. */
  62378. export class BoundingBoxRenderer implements ISceneComponent {
  62379. /**
  62380. * The component name helpfull to identify the component in the list of scene components.
  62381. */
  62382. readonly name: string;
  62383. /**
  62384. * The scene the component belongs to.
  62385. */
  62386. scene: Scene;
  62387. /**
  62388. * Color of the bounding box lines placed in front of an object
  62389. */
  62390. frontColor: Color3;
  62391. /**
  62392. * Color of the bounding box lines placed behind an object
  62393. */
  62394. backColor: Color3;
  62395. /**
  62396. * Defines if the renderer should show the back lines or not
  62397. */
  62398. showBackLines: boolean;
  62399. /**
  62400. * @hidden
  62401. */
  62402. renderList: SmartArray<BoundingBox>;
  62403. private _colorShader;
  62404. private _vertexBuffers;
  62405. private _indexBuffer;
  62406. private _fillIndexBuffer;
  62407. private _fillIndexData;
  62408. /**
  62409. * Instantiates a new bounding box renderer in a scene.
  62410. * @param scene the scene the renderer renders in
  62411. */
  62412. constructor(scene: Scene);
  62413. /**
  62414. * Registers the component in a given scene
  62415. */
  62416. register(): void;
  62417. private _evaluateSubMesh;
  62418. private _activeMesh;
  62419. private _prepareRessources;
  62420. private _createIndexBuffer;
  62421. /**
  62422. * Rebuilds the elements related to this component in case of
  62423. * context lost for instance.
  62424. */
  62425. rebuild(): void;
  62426. /**
  62427. * @hidden
  62428. */
  62429. reset(): void;
  62430. /**
  62431. * Render the bounding boxes of a specific rendering group
  62432. * @param renderingGroupId defines the rendering group to render
  62433. */
  62434. render(renderingGroupId: number): void;
  62435. /**
  62436. * In case of occlusion queries, we can render the occlusion bounding box through this method
  62437. * @param mesh Define the mesh to render the occlusion bounding box for
  62438. */
  62439. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  62440. /**
  62441. * Dispose and release the resources attached to this renderer.
  62442. */
  62443. dispose(): void;
  62444. }
  62445. }
  62446. declare module BABYLON {
  62447. /** @hidden */
  62448. export var depthPixelShader: {
  62449. name: string;
  62450. shader: string;
  62451. };
  62452. }
  62453. declare module BABYLON {
  62454. /**
  62455. * This represents a depth renderer in Babylon.
  62456. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62457. */
  62458. export class DepthRenderer {
  62459. private _scene;
  62460. private _depthMap;
  62461. private _effect;
  62462. private readonly _storeNonLinearDepth;
  62463. private readonly _clearColor;
  62464. /** Get if the depth renderer is using packed depth or not */
  62465. readonly isPacked: boolean;
  62466. private _cachedDefines;
  62467. private _camera;
  62468. /**
  62469. * Specifiess that the depth renderer will only be used within
  62470. * the camera it is created for.
  62471. * This can help forcing its rendering during the camera processing.
  62472. */
  62473. useOnlyInActiveCamera: boolean;
  62474. /** @hidden */
  62475. static _SceneComponentInitialization: (scene: Scene) => void;
  62476. /**
  62477. * Instantiates a depth renderer
  62478. * @param scene The scene the renderer belongs to
  62479. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62480. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62481. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62482. */
  62483. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62484. /**
  62485. * Creates the depth rendering effect and checks if the effect is ready.
  62486. * @param subMesh The submesh to be used to render the depth map of
  62487. * @param useInstances If multiple world instances should be used
  62488. * @returns if the depth renderer is ready to render the depth map
  62489. */
  62490. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62491. /**
  62492. * Gets the texture which the depth map will be written to.
  62493. * @returns The depth map texture
  62494. */
  62495. getDepthMap(): RenderTargetTexture;
  62496. /**
  62497. * Disposes of the depth renderer.
  62498. */
  62499. dispose(): void;
  62500. }
  62501. }
  62502. declare module BABYLON {
  62503. interface Scene {
  62504. /** @hidden (Backing field) */
  62505. _depthRenderer: {
  62506. [id: string]: DepthRenderer;
  62507. };
  62508. /**
  62509. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  62510. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  62511. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62512. * @returns the created depth renderer
  62513. */
  62514. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  62515. /**
  62516. * Disables a depth renderer for a given camera
  62517. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  62518. */
  62519. disableDepthRenderer(camera?: Nullable<Camera>): void;
  62520. }
  62521. /**
  62522. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  62523. * in several rendering techniques.
  62524. */
  62525. export class DepthRendererSceneComponent implements ISceneComponent {
  62526. /**
  62527. * The component name helpfull to identify the component in the list of scene components.
  62528. */
  62529. readonly name: string;
  62530. /**
  62531. * The scene the component belongs to.
  62532. */
  62533. scene: Scene;
  62534. /**
  62535. * Creates a new instance of the component for the given scene
  62536. * @param scene Defines the scene to register the component in
  62537. */
  62538. constructor(scene: Scene);
  62539. /**
  62540. * Registers the component in a given scene
  62541. */
  62542. register(): void;
  62543. /**
  62544. * Rebuilds the elements related to this component in case of
  62545. * context lost for instance.
  62546. */
  62547. rebuild(): void;
  62548. /**
  62549. * Disposes the component and the associated ressources
  62550. */
  62551. dispose(): void;
  62552. private _gatherRenderTargets;
  62553. private _gatherActiveCameraRenderTargets;
  62554. }
  62555. }
  62556. declare module BABYLON {
  62557. /** @hidden */
  62558. export var outlinePixelShader: {
  62559. name: string;
  62560. shader: string;
  62561. };
  62562. }
  62563. declare module BABYLON {
  62564. /** @hidden */
  62565. export var outlineVertexShader: {
  62566. name: string;
  62567. shader: string;
  62568. };
  62569. }
  62570. declare module BABYLON {
  62571. interface Scene {
  62572. /** @hidden */
  62573. _outlineRenderer: OutlineRenderer;
  62574. /**
  62575. * Gets the outline renderer associated with the scene
  62576. * @returns a OutlineRenderer
  62577. */
  62578. getOutlineRenderer(): OutlineRenderer;
  62579. }
  62580. interface AbstractMesh {
  62581. /** @hidden (Backing field) */
  62582. _renderOutline: boolean;
  62583. /**
  62584. * Gets or sets a boolean indicating if the outline must be rendered as well
  62585. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62586. */
  62587. renderOutline: boolean;
  62588. /** @hidden (Backing field) */
  62589. _renderOverlay: boolean;
  62590. /**
  62591. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62592. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62593. */
  62594. renderOverlay: boolean;
  62595. }
  62596. /**
  62597. * This class is responsible to draw bothe outline/overlay of meshes.
  62598. * It should not be used directly but through the available method on mesh.
  62599. */
  62600. export class OutlineRenderer implements ISceneComponent {
  62601. /**
  62602. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62603. */
  62604. private static _StencilReference;
  62605. /**
  62606. * The name of the component. Each component must have a unique name.
  62607. */
  62608. name: string;
  62609. /**
  62610. * The scene the component belongs to.
  62611. */
  62612. scene: Scene;
  62613. /**
  62614. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62615. */
  62616. zOffset: number;
  62617. private _engine;
  62618. private _effect;
  62619. private _cachedDefines;
  62620. private _savedDepthWrite;
  62621. /**
  62622. * Instantiates a new outline renderer. (There could be only one per scene).
  62623. * @param scene Defines the scene it belongs to
  62624. */
  62625. constructor(scene: Scene);
  62626. /**
  62627. * Register the component to one instance of a scene.
  62628. */
  62629. register(): void;
  62630. /**
  62631. * Rebuilds the elements related to this component in case of
  62632. * context lost for instance.
  62633. */
  62634. rebuild(): void;
  62635. /**
  62636. * Disposes the component and the associated ressources.
  62637. */
  62638. dispose(): void;
  62639. /**
  62640. * Renders the outline in the canvas.
  62641. * @param subMesh Defines the sumesh to render
  62642. * @param batch Defines the batch of meshes in case of instances
  62643. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62644. */
  62645. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62646. /**
  62647. * Returns whether or not the outline renderer is ready for a given submesh.
  62648. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62649. * @param subMesh Defines the submesh to check readyness for
  62650. * @param useInstances Defines wheter wee are trying to render instances or not
  62651. * @returns true if ready otherwise false
  62652. */
  62653. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62654. private _beforeRenderingMesh;
  62655. private _afterRenderingMesh;
  62656. }
  62657. }
  62658. declare module BABYLON {
  62659. /**
  62660. * Class used to manage multiple sprites of different sizes on the same spritesheet
  62661. * @see http://doc.babylonjs.com/babylon101/sprites
  62662. */
  62663. export class SpritePackedManager extends SpriteManager {
  62664. /** defines the packed manager's name */
  62665. name: string;
  62666. /**
  62667. * Creates a new sprite manager from a packed sprite sheet
  62668. * @param name defines the manager's name
  62669. * @param imgUrl defines the sprite sheet url
  62670. * @param capacity defines the maximum allowed number of sprites
  62671. * @param scene defines the hosting scene
  62672. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  62673. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  62674. * @param samplingMode defines the smapling mode to use with spritesheet
  62675. * @param fromPacked set to true; do not alter
  62676. */
  62677. constructor(
  62678. /** defines the packed manager's name */
  62679. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  62680. }
  62681. }
  62682. declare module BABYLON {
  62683. /**
  62684. * Defines the list of states available for a task inside a AssetsManager
  62685. */
  62686. export enum AssetTaskState {
  62687. /**
  62688. * Initialization
  62689. */
  62690. INIT = 0,
  62691. /**
  62692. * Running
  62693. */
  62694. RUNNING = 1,
  62695. /**
  62696. * Done
  62697. */
  62698. DONE = 2,
  62699. /**
  62700. * Error
  62701. */
  62702. ERROR = 3
  62703. }
  62704. /**
  62705. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62706. */
  62707. export abstract class AbstractAssetTask {
  62708. /**
  62709. * Task name
  62710. */ name: string;
  62711. /**
  62712. * Callback called when the task is successful
  62713. */
  62714. onSuccess: (task: any) => void;
  62715. /**
  62716. * Callback called when the task is not successful
  62717. */
  62718. onError: (task: any, message?: string, exception?: any) => void;
  62719. /**
  62720. * Creates a new AssetsManager
  62721. * @param name defines the name of the task
  62722. */
  62723. constructor(
  62724. /**
  62725. * Task name
  62726. */ name: string);
  62727. private _isCompleted;
  62728. private _taskState;
  62729. private _errorObject;
  62730. /**
  62731. * Get if the task is completed
  62732. */
  62733. readonly isCompleted: boolean;
  62734. /**
  62735. * Gets the current state of the task
  62736. */
  62737. readonly taskState: AssetTaskState;
  62738. /**
  62739. * Gets the current error object (if task is in error)
  62740. */
  62741. readonly errorObject: {
  62742. message?: string;
  62743. exception?: any;
  62744. };
  62745. /**
  62746. * Internal only
  62747. * @hidden
  62748. */
  62749. _setErrorObject(message?: string, exception?: any): void;
  62750. /**
  62751. * Execute the current task
  62752. * @param scene defines the scene where you want your assets to be loaded
  62753. * @param onSuccess is a callback called when the task is successfully executed
  62754. * @param onError is a callback called if an error occurs
  62755. */
  62756. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62757. /**
  62758. * Execute the current task
  62759. * @param scene defines the scene where you want your assets to be loaded
  62760. * @param onSuccess is a callback called when the task is successfully executed
  62761. * @param onError is a callback called if an error occurs
  62762. */
  62763. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62764. /**
  62765. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62766. * This can be used with failed tasks that have the reason for failure fixed.
  62767. */
  62768. reset(): void;
  62769. private onErrorCallback;
  62770. private onDoneCallback;
  62771. }
  62772. /**
  62773. * Define the interface used by progress events raised during assets loading
  62774. */
  62775. export interface IAssetsProgressEvent {
  62776. /**
  62777. * Defines the number of remaining tasks to process
  62778. */
  62779. remainingCount: number;
  62780. /**
  62781. * Defines the total number of tasks
  62782. */
  62783. totalCount: number;
  62784. /**
  62785. * Defines the task that was just processed
  62786. */
  62787. task: AbstractAssetTask;
  62788. }
  62789. /**
  62790. * Class used to share progress information about assets loading
  62791. */
  62792. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62793. /**
  62794. * Defines the number of remaining tasks to process
  62795. */
  62796. remainingCount: number;
  62797. /**
  62798. * Defines the total number of tasks
  62799. */
  62800. totalCount: number;
  62801. /**
  62802. * Defines the task that was just processed
  62803. */
  62804. task: AbstractAssetTask;
  62805. /**
  62806. * Creates a AssetsProgressEvent
  62807. * @param remainingCount defines the number of remaining tasks to process
  62808. * @param totalCount defines the total number of tasks
  62809. * @param task defines the task that was just processed
  62810. */
  62811. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62812. }
  62813. /**
  62814. * Define a task used by AssetsManager to load meshes
  62815. */
  62816. export class MeshAssetTask extends AbstractAssetTask {
  62817. /**
  62818. * Defines the name of the task
  62819. */
  62820. name: string;
  62821. /**
  62822. * Defines the list of mesh's names you want to load
  62823. */
  62824. meshesNames: any;
  62825. /**
  62826. * Defines the root url to use as a base to load your meshes and associated resources
  62827. */
  62828. rootUrl: string;
  62829. /**
  62830. * Defines the filename of the scene to load from
  62831. */
  62832. sceneFilename: string;
  62833. /**
  62834. * Gets the list of loaded meshes
  62835. */
  62836. loadedMeshes: Array<AbstractMesh>;
  62837. /**
  62838. * Gets the list of loaded particle systems
  62839. */
  62840. loadedParticleSystems: Array<IParticleSystem>;
  62841. /**
  62842. * Gets the list of loaded skeletons
  62843. */
  62844. loadedSkeletons: Array<Skeleton>;
  62845. /**
  62846. * Gets the list of loaded animation groups
  62847. */
  62848. loadedAnimationGroups: Array<AnimationGroup>;
  62849. /**
  62850. * Callback called when the task is successful
  62851. */
  62852. onSuccess: (task: MeshAssetTask) => void;
  62853. /**
  62854. * Callback called when the task is successful
  62855. */
  62856. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62857. /**
  62858. * Creates a new MeshAssetTask
  62859. * @param name defines the name of the task
  62860. * @param meshesNames defines the list of mesh's names you want to load
  62861. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62862. * @param sceneFilename defines the filename of the scene to load from
  62863. */
  62864. constructor(
  62865. /**
  62866. * Defines the name of the task
  62867. */
  62868. name: string,
  62869. /**
  62870. * Defines the list of mesh's names you want to load
  62871. */
  62872. meshesNames: any,
  62873. /**
  62874. * Defines the root url to use as a base to load your meshes and associated resources
  62875. */
  62876. rootUrl: string,
  62877. /**
  62878. * Defines the filename of the scene to load from
  62879. */
  62880. sceneFilename: string);
  62881. /**
  62882. * Execute the current task
  62883. * @param scene defines the scene where you want your assets to be loaded
  62884. * @param onSuccess is a callback called when the task is successfully executed
  62885. * @param onError is a callback called if an error occurs
  62886. */
  62887. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62888. }
  62889. /**
  62890. * Define a task used by AssetsManager to load text content
  62891. */
  62892. export class TextFileAssetTask extends AbstractAssetTask {
  62893. /**
  62894. * Defines the name of the task
  62895. */
  62896. name: string;
  62897. /**
  62898. * Defines the location of the file to load
  62899. */
  62900. url: string;
  62901. /**
  62902. * Gets the loaded text string
  62903. */
  62904. text: string;
  62905. /**
  62906. * Callback called when the task is successful
  62907. */
  62908. onSuccess: (task: TextFileAssetTask) => void;
  62909. /**
  62910. * Callback called when the task is successful
  62911. */
  62912. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62913. /**
  62914. * Creates a new TextFileAssetTask object
  62915. * @param name defines the name of the task
  62916. * @param url defines the location of the file to load
  62917. */
  62918. constructor(
  62919. /**
  62920. * Defines the name of the task
  62921. */
  62922. name: string,
  62923. /**
  62924. * Defines the location of the file to load
  62925. */
  62926. url: string);
  62927. /**
  62928. * Execute the current task
  62929. * @param scene defines the scene where you want your assets to be loaded
  62930. * @param onSuccess is a callback called when the task is successfully executed
  62931. * @param onError is a callback called if an error occurs
  62932. */
  62933. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62934. }
  62935. /**
  62936. * Define a task used by AssetsManager to load binary data
  62937. */
  62938. export class BinaryFileAssetTask extends AbstractAssetTask {
  62939. /**
  62940. * Defines the name of the task
  62941. */
  62942. name: string;
  62943. /**
  62944. * Defines the location of the file to load
  62945. */
  62946. url: string;
  62947. /**
  62948. * Gets the lodaded data (as an array buffer)
  62949. */
  62950. data: ArrayBuffer;
  62951. /**
  62952. * Callback called when the task is successful
  62953. */
  62954. onSuccess: (task: BinaryFileAssetTask) => void;
  62955. /**
  62956. * Callback called when the task is successful
  62957. */
  62958. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62959. /**
  62960. * Creates a new BinaryFileAssetTask object
  62961. * @param name defines the name of the new task
  62962. * @param url defines the location of the file to load
  62963. */
  62964. constructor(
  62965. /**
  62966. * Defines the name of the task
  62967. */
  62968. name: string,
  62969. /**
  62970. * Defines the location of the file to load
  62971. */
  62972. url: string);
  62973. /**
  62974. * Execute the current task
  62975. * @param scene defines the scene where you want your assets to be loaded
  62976. * @param onSuccess is a callback called when the task is successfully executed
  62977. * @param onError is a callback called if an error occurs
  62978. */
  62979. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62980. }
  62981. /**
  62982. * Define a task used by AssetsManager to load images
  62983. */
  62984. export class ImageAssetTask extends AbstractAssetTask {
  62985. /**
  62986. * Defines the name of the task
  62987. */
  62988. name: string;
  62989. /**
  62990. * Defines the location of the image to load
  62991. */
  62992. url: string;
  62993. /**
  62994. * Gets the loaded images
  62995. */
  62996. image: HTMLImageElement;
  62997. /**
  62998. * Callback called when the task is successful
  62999. */
  63000. onSuccess: (task: ImageAssetTask) => void;
  63001. /**
  63002. * Callback called when the task is successful
  63003. */
  63004. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  63005. /**
  63006. * Creates a new ImageAssetTask
  63007. * @param name defines the name of the task
  63008. * @param url defines the location of the image to load
  63009. */
  63010. constructor(
  63011. /**
  63012. * Defines the name of the task
  63013. */
  63014. name: string,
  63015. /**
  63016. * Defines the location of the image to load
  63017. */
  63018. url: string);
  63019. /**
  63020. * Execute the current task
  63021. * @param scene defines the scene where you want your assets to be loaded
  63022. * @param onSuccess is a callback called when the task is successfully executed
  63023. * @param onError is a callback called if an error occurs
  63024. */
  63025. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63026. }
  63027. /**
  63028. * Defines the interface used by texture loading tasks
  63029. */
  63030. export interface ITextureAssetTask<TEX extends BaseTexture> {
  63031. /**
  63032. * Gets the loaded texture
  63033. */
  63034. texture: TEX;
  63035. }
  63036. /**
  63037. * Define a task used by AssetsManager to load 2D textures
  63038. */
  63039. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  63040. /**
  63041. * Defines the name of the task
  63042. */
  63043. name: string;
  63044. /**
  63045. * Defines the location of the file to load
  63046. */
  63047. url: string;
  63048. /**
  63049. * Defines if mipmap should not be generated (default is false)
  63050. */
  63051. noMipmap?: boolean | undefined;
  63052. /**
  63053. * Defines if texture must be inverted on Y axis (default is false)
  63054. */
  63055. invertY?: boolean | undefined;
  63056. /**
  63057. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63058. */
  63059. samplingMode: number;
  63060. /**
  63061. * Gets the loaded texture
  63062. */
  63063. texture: Texture;
  63064. /**
  63065. * Callback called when the task is successful
  63066. */
  63067. onSuccess: (task: TextureAssetTask) => void;
  63068. /**
  63069. * Callback called when the task is successful
  63070. */
  63071. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  63072. /**
  63073. * Creates a new TextureAssetTask object
  63074. * @param name defines the name of the task
  63075. * @param url defines the location of the file to load
  63076. * @param noMipmap defines if mipmap should not be generated (default is false)
  63077. * @param invertY defines if texture must be inverted on Y axis (default is false)
  63078. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63079. */
  63080. constructor(
  63081. /**
  63082. * Defines the name of the task
  63083. */
  63084. name: string,
  63085. /**
  63086. * Defines the location of the file to load
  63087. */
  63088. url: string,
  63089. /**
  63090. * Defines if mipmap should not be generated (default is false)
  63091. */
  63092. noMipmap?: boolean | undefined,
  63093. /**
  63094. * Defines if texture must be inverted on Y axis (default is false)
  63095. */
  63096. invertY?: boolean | undefined,
  63097. /**
  63098. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63099. */
  63100. samplingMode?: number);
  63101. /**
  63102. * Execute the current task
  63103. * @param scene defines the scene where you want your assets to be loaded
  63104. * @param onSuccess is a callback called when the task is successfully executed
  63105. * @param onError is a callback called if an error occurs
  63106. */
  63107. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63108. }
  63109. /**
  63110. * Define a task used by AssetsManager to load cube textures
  63111. */
  63112. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  63113. /**
  63114. * Defines the name of the task
  63115. */
  63116. name: string;
  63117. /**
  63118. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63119. */
  63120. url: string;
  63121. /**
  63122. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63123. */
  63124. extensions?: string[] | undefined;
  63125. /**
  63126. * Defines if mipmaps should not be generated (default is false)
  63127. */
  63128. noMipmap?: boolean | undefined;
  63129. /**
  63130. * Defines the explicit list of files (undefined by default)
  63131. */
  63132. files?: string[] | undefined;
  63133. /**
  63134. * Gets the loaded texture
  63135. */
  63136. texture: CubeTexture;
  63137. /**
  63138. * Callback called when the task is successful
  63139. */
  63140. onSuccess: (task: CubeTextureAssetTask) => void;
  63141. /**
  63142. * Callback called when the task is successful
  63143. */
  63144. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  63145. /**
  63146. * Creates a new CubeTextureAssetTask
  63147. * @param name defines the name of the task
  63148. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63149. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63150. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63151. * @param files defines the explicit list of files (undefined by default)
  63152. */
  63153. constructor(
  63154. /**
  63155. * Defines the name of the task
  63156. */
  63157. name: string,
  63158. /**
  63159. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63160. */
  63161. url: string,
  63162. /**
  63163. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63164. */
  63165. extensions?: string[] | undefined,
  63166. /**
  63167. * Defines if mipmaps should not be generated (default is false)
  63168. */
  63169. noMipmap?: boolean | undefined,
  63170. /**
  63171. * Defines the explicit list of files (undefined by default)
  63172. */
  63173. files?: string[] | undefined);
  63174. /**
  63175. * Execute the current task
  63176. * @param scene defines the scene where you want your assets to be loaded
  63177. * @param onSuccess is a callback called when the task is successfully executed
  63178. * @param onError is a callback called if an error occurs
  63179. */
  63180. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63181. }
  63182. /**
  63183. * Define a task used by AssetsManager to load HDR cube textures
  63184. */
  63185. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  63186. /**
  63187. * Defines the name of the task
  63188. */
  63189. name: string;
  63190. /**
  63191. * Defines the location of the file to load
  63192. */
  63193. url: string;
  63194. /**
  63195. * Defines the desired size (the more it increases the longer the generation will be)
  63196. */
  63197. size: number;
  63198. /**
  63199. * Defines if mipmaps should not be generated (default is false)
  63200. */
  63201. noMipmap: boolean;
  63202. /**
  63203. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63204. */
  63205. generateHarmonics: boolean;
  63206. /**
  63207. * 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)
  63208. */
  63209. gammaSpace: boolean;
  63210. /**
  63211. * Internal Use Only
  63212. */
  63213. reserved: boolean;
  63214. /**
  63215. * Gets the loaded texture
  63216. */
  63217. texture: HDRCubeTexture;
  63218. /**
  63219. * Callback called when the task is successful
  63220. */
  63221. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  63222. /**
  63223. * Callback called when the task is successful
  63224. */
  63225. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  63226. /**
  63227. * Creates a new HDRCubeTextureAssetTask object
  63228. * @param name defines the name of the task
  63229. * @param url defines the location of the file to load
  63230. * @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.
  63231. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63232. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63233. * @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)
  63234. * @param reserved Internal use only
  63235. */
  63236. constructor(
  63237. /**
  63238. * Defines the name of the task
  63239. */
  63240. name: string,
  63241. /**
  63242. * Defines the location of the file to load
  63243. */
  63244. url: string,
  63245. /**
  63246. * Defines the desired size (the more it increases the longer the generation will be)
  63247. */
  63248. size: number,
  63249. /**
  63250. * Defines if mipmaps should not be generated (default is false)
  63251. */
  63252. noMipmap?: boolean,
  63253. /**
  63254. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63255. */
  63256. generateHarmonics?: boolean,
  63257. /**
  63258. * 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)
  63259. */
  63260. gammaSpace?: boolean,
  63261. /**
  63262. * Internal Use Only
  63263. */
  63264. reserved?: boolean);
  63265. /**
  63266. * Execute the current task
  63267. * @param scene defines the scene where you want your assets to be loaded
  63268. * @param onSuccess is a callback called when the task is successfully executed
  63269. * @param onError is a callback called if an error occurs
  63270. */
  63271. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63272. }
  63273. /**
  63274. * Define a task used by AssetsManager to load Equirectangular cube textures
  63275. */
  63276. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  63277. /**
  63278. * Defines the name of the task
  63279. */
  63280. name: string;
  63281. /**
  63282. * Defines the location of the file to load
  63283. */
  63284. url: string;
  63285. /**
  63286. * Defines the desired size (the more it increases the longer the generation will be)
  63287. */
  63288. size: number;
  63289. /**
  63290. * Defines if mipmaps should not be generated (default is false)
  63291. */
  63292. noMipmap: boolean;
  63293. /**
  63294. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63295. * but the standard material would require them in Gamma space) (default is true)
  63296. */
  63297. gammaSpace: boolean;
  63298. /**
  63299. * Gets the loaded texture
  63300. */
  63301. texture: EquiRectangularCubeTexture;
  63302. /**
  63303. * Callback called when the task is successful
  63304. */
  63305. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  63306. /**
  63307. * Callback called when the task is successful
  63308. */
  63309. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  63310. /**
  63311. * Creates a new EquiRectangularCubeTextureAssetTask object
  63312. * @param name defines the name of the task
  63313. * @param url defines the location of the file to load
  63314. * @param size defines the desired size (the more it increases the longer the generation will be)
  63315. * If the size is omitted this implies you are using a preprocessed cubemap.
  63316. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63317. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  63318. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  63319. * (default is true)
  63320. */
  63321. constructor(
  63322. /**
  63323. * Defines the name of the task
  63324. */
  63325. name: string,
  63326. /**
  63327. * Defines the location of the file to load
  63328. */
  63329. url: string,
  63330. /**
  63331. * Defines the desired size (the more it increases the longer the generation will be)
  63332. */
  63333. size: number,
  63334. /**
  63335. * Defines if mipmaps should not be generated (default is false)
  63336. */
  63337. noMipmap?: boolean,
  63338. /**
  63339. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63340. * but the standard material would require them in Gamma space) (default is true)
  63341. */
  63342. gammaSpace?: boolean);
  63343. /**
  63344. * Execute the current task
  63345. * @param scene defines the scene where you want your assets to be loaded
  63346. * @param onSuccess is a callback called when the task is successfully executed
  63347. * @param onError is a callback called if an error occurs
  63348. */
  63349. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63350. }
  63351. /**
  63352. * This class can be used to easily import assets into a scene
  63353. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  63354. */
  63355. export class AssetsManager {
  63356. private _scene;
  63357. private _isLoading;
  63358. protected _tasks: AbstractAssetTask[];
  63359. protected _waitingTasksCount: number;
  63360. protected _totalTasksCount: number;
  63361. /**
  63362. * Callback called when all tasks are processed
  63363. */
  63364. onFinish: (tasks: AbstractAssetTask[]) => void;
  63365. /**
  63366. * Callback called when a task is successful
  63367. */
  63368. onTaskSuccess: (task: AbstractAssetTask) => void;
  63369. /**
  63370. * Callback called when a task had an error
  63371. */
  63372. onTaskError: (task: AbstractAssetTask) => void;
  63373. /**
  63374. * Callback called when a task is done (whatever the result is)
  63375. */
  63376. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  63377. /**
  63378. * Observable called when all tasks are processed
  63379. */
  63380. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  63381. /**
  63382. * Observable called when a task had an error
  63383. */
  63384. onTaskErrorObservable: Observable<AbstractAssetTask>;
  63385. /**
  63386. * Observable called when all tasks were executed
  63387. */
  63388. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  63389. /**
  63390. * Observable called when a task is done (whatever the result is)
  63391. */
  63392. onProgressObservable: Observable<IAssetsProgressEvent>;
  63393. /**
  63394. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  63395. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  63396. */
  63397. useDefaultLoadingScreen: boolean;
  63398. /**
  63399. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  63400. * when all assets have been downloaded.
  63401. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  63402. */
  63403. autoHideLoadingUI: boolean;
  63404. /**
  63405. * Creates a new AssetsManager
  63406. * @param scene defines the scene to work on
  63407. */
  63408. constructor(scene: Scene);
  63409. /**
  63410. * Add a MeshAssetTask to the list of active tasks
  63411. * @param taskName defines the name of the new task
  63412. * @param meshesNames defines the name of meshes to load
  63413. * @param rootUrl defines the root url to use to locate files
  63414. * @param sceneFilename defines the filename of the scene file
  63415. * @returns a new MeshAssetTask object
  63416. */
  63417. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  63418. /**
  63419. * Add a TextFileAssetTask to the list of active tasks
  63420. * @param taskName defines the name of the new task
  63421. * @param url defines the url of the file to load
  63422. * @returns a new TextFileAssetTask object
  63423. */
  63424. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  63425. /**
  63426. * Add a BinaryFileAssetTask to the list of active tasks
  63427. * @param taskName defines the name of the new task
  63428. * @param url defines the url of the file to load
  63429. * @returns a new BinaryFileAssetTask object
  63430. */
  63431. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  63432. /**
  63433. * Add a ImageAssetTask to the list of active tasks
  63434. * @param taskName defines the name of the new task
  63435. * @param url defines the url of the file to load
  63436. * @returns a new ImageAssetTask object
  63437. */
  63438. addImageTask(taskName: string, url: string): ImageAssetTask;
  63439. /**
  63440. * Add a TextureAssetTask to the list of active tasks
  63441. * @param taskName defines the name of the new task
  63442. * @param url defines the url of the file to load
  63443. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63444. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  63445. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63446. * @returns a new TextureAssetTask object
  63447. */
  63448. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  63449. /**
  63450. * Add a CubeTextureAssetTask to the list of active tasks
  63451. * @param taskName defines the name of the new task
  63452. * @param url defines the url of the file to load
  63453. * @param extensions defines the extension to use to load the cube map (can be null)
  63454. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63455. * @param files defines the list of files to load (can be null)
  63456. * @returns a new CubeTextureAssetTask object
  63457. */
  63458. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  63459. /**
  63460. *
  63461. * Add a HDRCubeTextureAssetTask to the list of active tasks
  63462. * @param taskName defines the name of the new task
  63463. * @param url defines the url of the file to load
  63464. * @param size defines the size you want for the cubemap (can be null)
  63465. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63466. * @param generateHarmonics defines if you want to automatically generate (true by default)
  63467. * @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)
  63468. * @param reserved Internal use only
  63469. * @returns a new HDRCubeTextureAssetTask object
  63470. */
  63471. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  63472. /**
  63473. *
  63474. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  63475. * @param taskName defines the name of the new task
  63476. * @param url defines the url of the file to load
  63477. * @param size defines the size you want for the cubemap (can be null)
  63478. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63479. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63480. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63481. * @returns a new EquiRectangularCubeTextureAssetTask object
  63482. */
  63483. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  63484. /**
  63485. * Remove a task from the assets manager.
  63486. * @param task the task to remove
  63487. */
  63488. removeTask(task: AbstractAssetTask): void;
  63489. private _decreaseWaitingTasksCount;
  63490. private _runTask;
  63491. /**
  63492. * Reset the AssetsManager and remove all tasks
  63493. * @return the current instance of the AssetsManager
  63494. */
  63495. reset(): AssetsManager;
  63496. /**
  63497. * Start the loading process
  63498. * @return the current instance of the AssetsManager
  63499. */
  63500. load(): AssetsManager;
  63501. /**
  63502. * Start the loading process as an async operation
  63503. * @return a promise returning the list of failed tasks
  63504. */
  63505. loadAsync(): Promise<void>;
  63506. }
  63507. }
  63508. declare module BABYLON {
  63509. /**
  63510. * Wrapper class for promise with external resolve and reject.
  63511. */
  63512. export class Deferred<T> {
  63513. /**
  63514. * The promise associated with this deferred object.
  63515. */
  63516. readonly promise: Promise<T>;
  63517. private _resolve;
  63518. private _reject;
  63519. /**
  63520. * The resolve method of the promise associated with this deferred object.
  63521. */
  63522. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  63523. /**
  63524. * The reject method of the promise associated with this deferred object.
  63525. */
  63526. readonly reject: (reason?: any) => void;
  63527. /**
  63528. * Constructor for this deferred object.
  63529. */
  63530. constructor();
  63531. }
  63532. }
  63533. declare module BABYLON {
  63534. /**
  63535. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  63536. */
  63537. export class MeshExploder {
  63538. private _centerMesh;
  63539. private _meshes;
  63540. private _meshesOrigins;
  63541. private _toCenterVectors;
  63542. private _scaledDirection;
  63543. private _newPosition;
  63544. private _centerPosition;
  63545. /**
  63546. * Explodes meshes from a center mesh.
  63547. * @param meshes The meshes to explode.
  63548. * @param centerMesh The mesh to be center of explosion.
  63549. */
  63550. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63551. private _setCenterMesh;
  63552. /**
  63553. * Get class name
  63554. * @returns "MeshExploder"
  63555. */
  63556. getClassName(): string;
  63557. /**
  63558. * "Exploded meshes"
  63559. * @returns Array of meshes with the centerMesh at index 0.
  63560. */
  63561. getMeshes(): Array<Mesh>;
  63562. /**
  63563. * Explodes meshes giving a specific direction
  63564. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  63565. */
  63566. explode(direction?: number): void;
  63567. }
  63568. }
  63569. declare module BABYLON {
  63570. /**
  63571. * Class used to help managing file picking and drag'n'drop
  63572. */
  63573. export class FilesInput {
  63574. /**
  63575. * List of files ready to be loaded
  63576. */
  63577. static readonly FilesToLoad: {
  63578. [key: string]: File;
  63579. };
  63580. /**
  63581. * Callback called when a file is processed
  63582. */
  63583. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  63584. private _engine;
  63585. private _currentScene;
  63586. private _sceneLoadedCallback;
  63587. private _progressCallback;
  63588. private _additionalRenderLoopLogicCallback;
  63589. private _textureLoadingCallback;
  63590. private _startingProcessingFilesCallback;
  63591. private _onReloadCallback;
  63592. private _errorCallback;
  63593. private _elementToMonitor;
  63594. private _sceneFileToLoad;
  63595. private _filesToLoad;
  63596. /**
  63597. * Creates a new FilesInput
  63598. * @param engine defines the rendering engine
  63599. * @param scene defines the hosting scene
  63600. * @param sceneLoadedCallback callback called when scene is loaded
  63601. * @param progressCallback callback called to track progress
  63602. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63603. * @param textureLoadingCallback callback called when a texture is loading
  63604. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63605. * @param onReloadCallback callback called when a reload is requested
  63606. * @param errorCallback callback call if an error occurs
  63607. */
  63608. 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);
  63609. private _dragEnterHandler;
  63610. private _dragOverHandler;
  63611. private _dropHandler;
  63612. /**
  63613. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63614. * @param elementToMonitor defines the DOM element to track
  63615. */
  63616. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63617. /**
  63618. * Release all associated resources
  63619. */
  63620. dispose(): void;
  63621. private renderFunction;
  63622. private drag;
  63623. private drop;
  63624. private _traverseFolder;
  63625. private _processFiles;
  63626. /**
  63627. * Load files from a drop event
  63628. * @param event defines the drop event to use as source
  63629. */
  63630. loadFiles(event: any): void;
  63631. private _processReload;
  63632. /**
  63633. * Reload the current scene from the loaded files
  63634. */
  63635. reload(): void;
  63636. }
  63637. }
  63638. declare module BABYLON {
  63639. /**
  63640. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63641. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63642. */
  63643. export class SceneOptimization {
  63644. /**
  63645. * Defines the priority of this optimization (0 by default which means first in the list)
  63646. */
  63647. priority: number;
  63648. /**
  63649. * Gets a string describing the action executed by the current optimization
  63650. * @returns description string
  63651. */
  63652. getDescription(): string;
  63653. /**
  63654. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63655. * @param scene defines the current scene where to apply this optimization
  63656. * @param optimizer defines the current optimizer
  63657. * @returns true if everything that can be done was applied
  63658. */
  63659. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63660. /**
  63661. * Creates the SceneOptimization object
  63662. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63663. * @param desc defines the description associated with the optimization
  63664. */
  63665. constructor(
  63666. /**
  63667. * Defines the priority of this optimization (0 by default which means first in the list)
  63668. */
  63669. priority?: number);
  63670. }
  63671. /**
  63672. * Defines an optimization used to reduce the size of render target textures
  63673. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63674. */
  63675. export class TextureOptimization extends SceneOptimization {
  63676. /**
  63677. * Defines the priority of this optimization (0 by default which means first in the list)
  63678. */
  63679. priority: number;
  63680. /**
  63681. * 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
  63682. */
  63683. maximumSize: number;
  63684. /**
  63685. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63686. */
  63687. step: number;
  63688. /**
  63689. * Gets a string describing the action executed by the current optimization
  63690. * @returns description string
  63691. */
  63692. getDescription(): string;
  63693. /**
  63694. * Creates the TextureOptimization object
  63695. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63696. * @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
  63697. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63698. */
  63699. constructor(
  63700. /**
  63701. * Defines the priority of this optimization (0 by default which means first in the list)
  63702. */
  63703. priority?: number,
  63704. /**
  63705. * 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
  63706. */
  63707. maximumSize?: number,
  63708. /**
  63709. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63710. */
  63711. step?: number);
  63712. /**
  63713. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63714. * @param scene defines the current scene where to apply this optimization
  63715. * @param optimizer defines the current optimizer
  63716. * @returns true if everything that can be done was applied
  63717. */
  63718. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63719. }
  63720. /**
  63721. * Defines an optimization used to increase or decrease the rendering resolution
  63722. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63723. */
  63724. export class HardwareScalingOptimization extends SceneOptimization {
  63725. /**
  63726. * Defines the priority of this optimization (0 by default which means first in the list)
  63727. */
  63728. priority: number;
  63729. /**
  63730. * Defines the maximum scale to use (2 by default)
  63731. */
  63732. maximumScale: number;
  63733. /**
  63734. * Defines the step to use between two passes (0.5 by default)
  63735. */
  63736. step: number;
  63737. private _currentScale;
  63738. private _directionOffset;
  63739. /**
  63740. * Gets a string describing the action executed by the current optimization
  63741. * @return description string
  63742. */
  63743. getDescription(): string;
  63744. /**
  63745. * Creates the HardwareScalingOptimization object
  63746. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63747. * @param maximumScale defines the maximum scale to use (2 by default)
  63748. * @param step defines the step to use between two passes (0.5 by default)
  63749. */
  63750. constructor(
  63751. /**
  63752. * Defines the priority of this optimization (0 by default which means first in the list)
  63753. */
  63754. priority?: number,
  63755. /**
  63756. * Defines the maximum scale to use (2 by default)
  63757. */
  63758. maximumScale?: number,
  63759. /**
  63760. * Defines the step to use between two passes (0.5 by default)
  63761. */
  63762. step?: number);
  63763. /**
  63764. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63765. * @param scene defines the current scene where to apply this optimization
  63766. * @param optimizer defines the current optimizer
  63767. * @returns true if everything that can be done was applied
  63768. */
  63769. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63770. }
  63771. /**
  63772. * Defines an optimization used to remove shadows
  63773. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63774. */
  63775. export class ShadowsOptimization extends SceneOptimization {
  63776. /**
  63777. * Gets a string describing the action executed by the current optimization
  63778. * @return description string
  63779. */
  63780. getDescription(): string;
  63781. /**
  63782. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63783. * @param scene defines the current scene where to apply this optimization
  63784. * @param optimizer defines the current optimizer
  63785. * @returns true if everything that can be done was applied
  63786. */
  63787. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63788. }
  63789. /**
  63790. * Defines an optimization used to turn post-processes off
  63791. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63792. */
  63793. export class PostProcessesOptimization extends SceneOptimization {
  63794. /**
  63795. * Gets a string describing the action executed by the current optimization
  63796. * @return description string
  63797. */
  63798. getDescription(): string;
  63799. /**
  63800. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63801. * @param scene defines the current scene where to apply this optimization
  63802. * @param optimizer defines the current optimizer
  63803. * @returns true if everything that can be done was applied
  63804. */
  63805. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63806. }
  63807. /**
  63808. * Defines an optimization used to turn lens flares off
  63809. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63810. */
  63811. export class LensFlaresOptimization extends SceneOptimization {
  63812. /**
  63813. * Gets a string describing the action executed by the current optimization
  63814. * @return description string
  63815. */
  63816. getDescription(): string;
  63817. /**
  63818. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63819. * @param scene defines the current scene where to apply this optimization
  63820. * @param optimizer defines the current optimizer
  63821. * @returns true if everything that can be done was applied
  63822. */
  63823. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63824. }
  63825. /**
  63826. * Defines an optimization based on user defined callback.
  63827. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63828. */
  63829. export class CustomOptimization extends SceneOptimization {
  63830. /**
  63831. * Callback called to apply the custom optimization.
  63832. */
  63833. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63834. /**
  63835. * Callback called to get custom description
  63836. */
  63837. onGetDescription: () => string;
  63838. /**
  63839. * Gets a string describing the action executed by the current optimization
  63840. * @returns description string
  63841. */
  63842. getDescription(): string;
  63843. /**
  63844. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63845. * @param scene defines the current scene where to apply this optimization
  63846. * @param optimizer defines the current optimizer
  63847. * @returns true if everything that can be done was applied
  63848. */
  63849. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63850. }
  63851. /**
  63852. * Defines an optimization used to turn particles off
  63853. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63854. */
  63855. export class ParticlesOptimization extends SceneOptimization {
  63856. /**
  63857. * Gets a string describing the action executed by the current optimization
  63858. * @return description string
  63859. */
  63860. getDescription(): string;
  63861. /**
  63862. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63863. * @param scene defines the current scene where to apply this optimization
  63864. * @param optimizer defines the current optimizer
  63865. * @returns true if everything that can be done was applied
  63866. */
  63867. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63868. }
  63869. /**
  63870. * Defines an optimization used to turn render targets off
  63871. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63872. */
  63873. export class RenderTargetsOptimization extends SceneOptimization {
  63874. /**
  63875. * Gets a string describing the action executed by the current optimization
  63876. * @return description string
  63877. */
  63878. getDescription(): string;
  63879. /**
  63880. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63881. * @param scene defines the current scene where to apply this optimization
  63882. * @param optimizer defines the current optimizer
  63883. * @returns true if everything that can be done was applied
  63884. */
  63885. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63886. }
  63887. /**
  63888. * Defines an optimization used to merge meshes with compatible materials
  63889. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63890. */
  63891. export class MergeMeshesOptimization extends SceneOptimization {
  63892. private static _UpdateSelectionTree;
  63893. /**
  63894. * Gets or sets a boolean which defines if optimization octree has to be updated
  63895. */
  63896. /**
  63897. * Gets or sets a boolean which defines if optimization octree has to be updated
  63898. */
  63899. static UpdateSelectionTree: boolean;
  63900. /**
  63901. * Gets a string describing the action executed by the current optimization
  63902. * @return description string
  63903. */
  63904. getDescription(): string;
  63905. private _canBeMerged;
  63906. /**
  63907. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63908. * @param scene defines the current scene where to apply this optimization
  63909. * @param optimizer defines the current optimizer
  63910. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63911. * @returns true if everything that can be done was applied
  63912. */
  63913. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63914. }
  63915. /**
  63916. * Defines a list of options used by SceneOptimizer
  63917. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63918. */
  63919. export class SceneOptimizerOptions {
  63920. /**
  63921. * Defines the target frame rate to reach (60 by default)
  63922. */
  63923. targetFrameRate: number;
  63924. /**
  63925. * Defines the interval between two checkes (2000ms by default)
  63926. */
  63927. trackerDuration: number;
  63928. /**
  63929. * Gets the list of optimizations to apply
  63930. */
  63931. optimizations: SceneOptimization[];
  63932. /**
  63933. * Creates a new list of options used by SceneOptimizer
  63934. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63935. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63936. */
  63937. constructor(
  63938. /**
  63939. * Defines the target frame rate to reach (60 by default)
  63940. */
  63941. targetFrameRate?: number,
  63942. /**
  63943. * Defines the interval between two checkes (2000ms by default)
  63944. */
  63945. trackerDuration?: number);
  63946. /**
  63947. * Add a new optimization
  63948. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63949. * @returns the current SceneOptimizerOptions
  63950. */
  63951. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63952. /**
  63953. * Add a new custom optimization
  63954. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63955. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63956. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63957. * @returns the current SceneOptimizerOptions
  63958. */
  63959. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63960. /**
  63961. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63962. * @param targetFrameRate defines the target frame rate (60 by default)
  63963. * @returns a SceneOptimizerOptions object
  63964. */
  63965. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63966. /**
  63967. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63968. * @param targetFrameRate defines the target frame rate (60 by default)
  63969. * @returns a SceneOptimizerOptions object
  63970. */
  63971. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63972. /**
  63973. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63974. * @param targetFrameRate defines the target frame rate (60 by default)
  63975. * @returns a SceneOptimizerOptions object
  63976. */
  63977. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63978. }
  63979. /**
  63980. * Class used to run optimizations in order to reach a target frame rate
  63981. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63982. */
  63983. export class SceneOptimizer implements IDisposable {
  63984. private _isRunning;
  63985. private _options;
  63986. private _scene;
  63987. private _currentPriorityLevel;
  63988. private _targetFrameRate;
  63989. private _trackerDuration;
  63990. private _currentFrameRate;
  63991. private _sceneDisposeObserver;
  63992. private _improvementMode;
  63993. /**
  63994. * Defines an observable called when the optimizer reaches the target frame rate
  63995. */
  63996. onSuccessObservable: Observable<SceneOptimizer>;
  63997. /**
  63998. * Defines an observable called when the optimizer enables an optimization
  63999. */
  64000. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  64001. /**
  64002. * Defines an observable called when the optimizer is not able to reach the target frame rate
  64003. */
  64004. onFailureObservable: Observable<SceneOptimizer>;
  64005. /**
  64006. * Gets a boolean indicating if the optimizer is in improvement mode
  64007. */
  64008. readonly isInImprovementMode: boolean;
  64009. /**
  64010. * Gets the current priority level (0 at start)
  64011. */
  64012. readonly currentPriorityLevel: number;
  64013. /**
  64014. * Gets the current frame rate checked by the SceneOptimizer
  64015. */
  64016. readonly currentFrameRate: number;
  64017. /**
  64018. * Gets or sets the current target frame rate (60 by default)
  64019. */
  64020. /**
  64021. * Gets or sets the current target frame rate (60 by default)
  64022. */
  64023. targetFrameRate: number;
  64024. /**
  64025. * Gets or sets the current interval between two checks (every 2000ms by default)
  64026. */
  64027. /**
  64028. * Gets or sets the current interval between two checks (every 2000ms by default)
  64029. */
  64030. trackerDuration: number;
  64031. /**
  64032. * Gets the list of active optimizations
  64033. */
  64034. readonly optimizations: SceneOptimization[];
  64035. /**
  64036. * Creates a new SceneOptimizer
  64037. * @param scene defines the scene to work on
  64038. * @param options defines the options to use with the SceneOptimizer
  64039. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  64040. * @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)
  64041. */
  64042. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  64043. /**
  64044. * Stops the current optimizer
  64045. */
  64046. stop(): void;
  64047. /**
  64048. * Reset the optimizer to initial step (current priority level = 0)
  64049. */
  64050. reset(): void;
  64051. /**
  64052. * Start the optimizer. By default it will try to reach a specific framerate
  64053. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  64054. */
  64055. start(): void;
  64056. private _checkCurrentState;
  64057. /**
  64058. * Release all resources
  64059. */
  64060. dispose(): void;
  64061. /**
  64062. * Helper function to create a SceneOptimizer with one single line of code
  64063. * @param scene defines the scene to work on
  64064. * @param options defines the options to use with the SceneOptimizer
  64065. * @param onSuccess defines a callback to call on success
  64066. * @param onFailure defines a callback to call on failure
  64067. * @returns the new SceneOptimizer object
  64068. */
  64069. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  64070. }
  64071. }
  64072. declare module BABYLON {
  64073. /**
  64074. * Class used to serialize a scene into a string
  64075. */
  64076. export class SceneSerializer {
  64077. /**
  64078. * Clear cache used by a previous serialization
  64079. */
  64080. static ClearCache(): void;
  64081. /**
  64082. * Serialize a scene into a JSON compatible object
  64083. * @param scene defines the scene to serialize
  64084. * @returns a JSON compatible object
  64085. */
  64086. static Serialize(scene: Scene): any;
  64087. /**
  64088. * Serialize a mesh into a JSON compatible object
  64089. * @param toSerialize defines the mesh to serialize
  64090. * @param withParents defines if parents must be serialized as well
  64091. * @param withChildren defines if children must be serialized as well
  64092. * @returns a JSON compatible object
  64093. */
  64094. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  64095. }
  64096. }
  64097. declare module BABYLON {
  64098. /**
  64099. * Class used to host texture specific utilities
  64100. */
  64101. export class TextureTools {
  64102. /**
  64103. * Uses the GPU to create a copy texture rescaled at a given size
  64104. * @param texture Texture to copy from
  64105. * @param width defines the desired width
  64106. * @param height defines the desired height
  64107. * @param useBilinearMode defines if bilinear mode has to be used
  64108. * @return the generated texture
  64109. */
  64110. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  64111. }
  64112. }
  64113. declare module BABYLON {
  64114. /**
  64115. * This represents the different options available for the video capture.
  64116. */
  64117. export interface VideoRecorderOptions {
  64118. /** Defines the mime type of the video. */
  64119. mimeType: string;
  64120. /** Defines the FPS the video should be recorded at. */
  64121. fps: number;
  64122. /** Defines the chunk size for the recording data. */
  64123. recordChunckSize: number;
  64124. /** The audio tracks to attach to the recording. */
  64125. audioTracks?: MediaStreamTrack[];
  64126. }
  64127. /**
  64128. * This can help with recording videos from BabylonJS.
  64129. * This is based on the available WebRTC functionalities of the browser.
  64130. *
  64131. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  64132. */
  64133. export class VideoRecorder {
  64134. private static readonly _defaultOptions;
  64135. /**
  64136. * Returns whether or not the VideoRecorder is available in your browser.
  64137. * @param engine Defines the Babylon Engine.
  64138. * @returns true if supported otherwise false.
  64139. */
  64140. static IsSupported(engine: Engine): boolean;
  64141. private readonly _options;
  64142. private _canvas;
  64143. private _mediaRecorder;
  64144. private _recordedChunks;
  64145. private _fileName;
  64146. private _resolve;
  64147. private _reject;
  64148. /**
  64149. * True when a recording is already in progress.
  64150. */
  64151. readonly isRecording: boolean;
  64152. /**
  64153. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  64154. * @param engine Defines the BabylonJS Engine you wish to record.
  64155. * @param options Defines options that can be used to customize the capture.
  64156. */
  64157. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  64158. /**
  64159. * Stops the current recording before the default capture timeout passed in the startRecording function.
  64160. */
  64161. stopRecording(): void;
  64162. /**
  64163. * Starts recording the canvas for a max duration specified in parameters.
  64164. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  64165. * If null no automatic download will start and you can rely on the promise to get the data back.
  64166. * @param maxDuration Defines the maximum recording time in seconds.
  64167. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  64168. * @return A promise callback at the end of the recording with the video data in Blob.
  64169. */
  64170. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  64171. /**
  64172. * Releases internal resources used during the recording.
  64173. */
  64174. dispose(): void;
  64175. private _handleDataAvailable;
  64176. private _handleError;
  64177. private _handleStop;
  64178. }
  64179. }
  64180. declare module BABYLON {
  64181. /**
  64182. * Class containing a set of static utilities functions for screenshots
  64183. */
  64184. export class ScreenshotTools {
  64185. /**
  64186. * Captures a screenshot of the current rendering
  64187. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64188. * @param engine defines the rendering engine
  64189. * @param camera defines the source camera
  64190. * @param size This parameter can be set to a single number or to an object with the
  64191. * following (optional) properties: precision, width, height. If a single number is passed,
  64192. * it will be used for both width and height. If an object is passed, the screenshot size
  64193. * will be derived from the parameters. The precision property is a multiplier allowing
  64194. * rendering at a higher or lower resolution
  64195. * @param successCallback defines the callback receives a single parameter which contains the
  64196. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64197. * src parameter of an <img> to display it
  64198. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64199. * Check your browser for supported MIME types
  64200. */
  64201. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  64202. /**
  64203. * Captures a screenshot of the current rendering
  64204. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64205. * @param engine defines the rendering engine
  64206. * @param camera defines the source camera
  64207. * @param size This parameter can be set to a single number or to an object with the
  64208. * following (optional) properties: precision, width, height. If a single number is passed,
  64209. * it will be used for both width and height. If an object is passed, the screenshot size
  64210. * will be derived from the parameters. The precision property is a multiplier allowing
  64211. * rendering at a higher or lower resolution
  64212. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64213. * Check your browser for supported MIME types
  64214. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64215. * to the src parameter of an <img> to display it
  64216. */
  64217. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  64218. /**
  64219. * Generates an image screenshot from the specified camera.
  64220. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64221. * @param engine The engine to use for rendering
  64222. * @param camera The camera to use for rendering
  64223. * @param size This parameter can be set to a single number or to an object with the
  64224. * following (optional) properties: precision, width, height. If a single number is passed,
  64225. * it will be used for both width and height. If an object is passed, the screenshot size
  64226. * will be derived from the parameters. The precision property is a multiplier allowing
  64227. * rendering at a higher or lower resolution
  64228. * @param successCallback The callback receives a single parameter which contains the
  64229. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64230. * src parameter of an <img> to display it
  64231. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64232. * Check your browser for supported MIME types
  64233. * @param samples Texture samples (default: 1)
  64234. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64235. * @param fileName A name for for the downloaded file.
  64236. */
  64237. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  64238. /**
  64239. * Generates an image screenshot from the specified camera.
  64240. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64241. * @param engine The engine to use for rendering
  64242. * @param camera The camera to use for rendering
  64243. * @param size This parameter can be set to a single number or to an object with the
  64244. * following (optional) properties: precision, width, height. If a single number is passed,
  64245. * it will be used for both width and height. If an object is passed, the screenshot size
  64246. * will be derived from the parameters. The precision property is a multiplier allowing
  64247. * rendering at a higher or lower resolution
  64248. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64249. * Check your browser for supported MIME types
  64250. * @param samples Texture samples (default: 1)
  64251. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64252. * @param fileName A name for for the downloaded file.
  64253. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64254. * to the src parameter of an <img> to display it
  64255. */
  64256. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  64257. /**
  64258. * Gets height and width for screenshot size
  64259. * @private
  64260. */
  64261. private static _getScreenshotSize;
  64262. }
  64263. }
  64264. declare module BABYLON {
  64265. /**
  64266. * Interface for a data buffer
  64267. */
  64268. export interface IDataBuffer {
  64269. /**
  64270. * Reads bytes from the data buffer.
  64271. * @param byteOffset The byte offset to read
  64272. * @param byteLength The byte length to read
  64273. * @returns A promise that resolves when the bytes are read
  64274. */
  64275. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  64276. /**
  64277. * The byte length of the buffer.
  64278. */
  64279. readonly byteLength: number;
  64280. }
  64281. /**
  64282. * Utility class for reading from a data buffer
  64283. */
  64284. export class DataReader {
  64285. /**
  64286. * The data buffer associated with this data reader.
  64287. */
  64288. readonly buffer: IDataBuffer;
  64289. /**
  64290. * The current byte offset from the beginning of the data buffer.
  64291. */
  64292. byteOffset: number;
  64293. private _dataView;
  64294. private _dataByteOffset;
  64295. /**
  64296. * Constructor
  64297. * @param buffer The buffer to read
  64298. */
  64299. constructor(buffer: IDataBuffer);
  64300. /**
  64301. * Loads the given byte length.
  64302. * @param byteLength The byte length to load
  64303. * @returns A promise that resolves when the load is complete
  64304. */
  64305. loadAsync(byteLength: number): Promise<void>;
  64306. /**
  64307. * Read a unsigned 32-bit integer from the currently loaded data range.
  64308. * @returns The 32-bit integer read
  64309. */
  64310. readUint32(): number;
  64311. /**
  64312. * Read a byte array from the currently loaded data range.
  64313. * @param byteLength The byte length to read
  64314. * @returns The byte array read
  64315. */
  64316. readUint8Array(byteLength: number): Uint8Array;
  64317. /**
  64318. * Read a string from the currently loaded data range.
  64319. * @param byteLength The byte length to read
  64320. * @returns The string read
  64321. */
  64322. readString(byteLength: number): string;
  64323. /**
  64324. * Skips the given byte length the currently loaded data range.
  64325. * @param byteLength The byte length to skip
  64326. */
  64327. skipBytes(byteLength: number): void;
  64328. }
  64329. }
  64330. declare module BABYLON {
  64331. /**
  64332. * A cursor which tracks a point on a path
  64333. */
  64334. export class PathCursor {
  64335. private path;
  64336. /**
  64337. * Stores path cursor callbacks for when an onchange event is triggered
  64338. */
  64339. private _onchange;
  64340. /**
  64341. * The value of the path cursor
  64342. */
  64343. value: number;
  64344. /**
  64345. * The animation array of the path cursor
  64346. */
  64347. animations: Animation[];
  64348. /**
  64349. * Initializes the path cursor
  64350. * @param path The path to track
  64351. */
  64352. constructor(path: Path2);
  64353. /**
  64354. * Gets the cursor point on the path
  64355. * @returns A point on the path cursor at the cursor location
  64356. */
  64357. getPoint(): Vector3;
  64358. /**
  64359. * Moves the cursor ahead by the step amount
  64360. * @param step The amount to move the cursor forward
  64361. * @returns This path cursor
  64362. */
  64363. moveAhead(step?: number): PathCursor;
  64364. /**
  64365. * Moves the cursor behind by the step amount
  64366. * @param step The amount to move the cursor back
  64367. * @returns This path cursor
  64368. */
  64369. moveBack(step?: number): PathCursor;
  64370. /**
  64371. * Moves the cursor by the step amount
  64372. * If the step amount is greater than one, an exception is thrown
  64373. * @param step The amount to move the cursor
  64374. * @returns This path cursor
  64375. */
  64376. move(step: number): PathCursor;
  64377. /**
  64378. * Ensures that the value is limited between zero and one
  64379. * @returns This path cursor
  64380. */
  64381. private ensureLimits;
  64382. /**
  64383. * Runs onchange callbacks on change (used by the animation engine)
  64384. * @returns This path cursor
  64385. */
  64386. private raiseOnChange;
  64387. /**
  64388. * Executes a function on change
  64389. * @param f A path cursor onchange callback
  64390. * @returns This path cursor
  64391. */
  64392. onchange(f: (cursor: PathCursor) => void): PathCursor;
  64393. }
  64394. }
  64395. declare module BABYLON {
  64396. /** @hidden */
  64397. export var blurPixelShader: {
  64398. name: string;
  64399. shader: string;
  64400. };
  64401. }
  64402. declare module BABYLON {
  64403. /** @hidden */
  64404. export var pointCloudVertexDeclaration: {
  64405. name: string;
  64406. shader: string;
  64407. };
  64408. }
  64409. // Mixins
  64410. interface Window {
  64411. mozIndexedDB: IDBFactory;
  64412. webkitIndexedDB: IDBFactory;
  64413. msIndexedDB: IDBFactory;
  64414. webkitURL: typeof URL;
  64415. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  64416. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  64417. WebGLRenderingContext: WebGLRenderingContext;
  64418. MSGesture: MSGesture;
  64419. CANNON: any;
  64420. AudioContext: AudioContext;
  64421. webkitAudioContext: AudioContext;
  64422. PointerEvent: any;
  64423. Math: Math;
  64424. Uint8Array: Uint8ArrayConstructor;
  64425. Float32Array: Float32ArrayConstructor;
  64426. mozURL: typeof URL;
  64427. msURL: typeof URL;
  64428. VRFrameData: any; // WebVR, from specs 1.1
  64429. DracoDecoderModule: any;
  64430. setImmediate(handler: (...args: any[]) => void): number;
  64431. }
  64432. interface HTMLCanvasElement {
  64433. requestPointerLock(): void;
  64434. msRequestPointerLock?(): void;
  64435. mozRequestPointerLock?(): void;
  64436. webkitRequestPointerLock?(): void;
  64437. /** Track wether a record is in progress */
  64438. isRecording: boolean;
  64439. /** Capture Stream method defined by some browsers */
  64440. captureStream(fps?: number): MediaStream;
  64441. }
  64442. interface CanvasRenderingContext2D {
  64443. msImageSmoothingEnabled: boolean;
  64444. }
  64445. interface MouseEvent {
  64446. mozMovementX: number;
  64447. mozMovementY: number;
  64448. webkitMovementX: number;
  64449. webkitMovementY: number;
  64450. msMovementX: number;
  64451. msMovementY: number;
  64452. }
  64453. interface Navigator {
  64454. mozGetVRDevices: (any: any) => any;
  64455. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64456. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64457. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64458. webkitGetGamepads(): Gamepad[];
  64459. msGetGamepads(): Gamepad[];
  64460. webkitGamepads(): Gamepad[];
  64461. }
  64462. interface HTMLVideoElement {
  64463. mozSrcObject: any;
  64464. }
  64465. interface Math {
  64466. fround(x: number): number;
  64467. imul(a: number, b: number): number;
  64468. }
  64469. interface WebGLRenderingContext {
  64470. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  64471. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  64472. vertexAttribDivisor(index: number, divisor: number): void;
  64473. createVertexArray(): any;
  64474. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  64475. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  64476. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  64477. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  64478. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  64479. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  64480. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  64481. // Queries
  64482. createQuery(): WebGLQuery;
  64483. deleteQuery(query: WebGLQuery): void;
  64484. beginQuery(target: number, query: WebGLQuery): void;
  64485. endQuery(target: number): void;
  64486. getQueryParameter(query: WebGLQuery, pname: number): any;
  64487. getQuery(target: number, pname: number): any;
  64488. MAX_SAMPLES: number;
  64489. RGBA8: number;
  64490. READ_FRAMEBUFFER: number;
  64491. DRAW_FRAMEBUFFER: number;
  64492. UNIFORM_BUFFER: number;
  64493. HALF_FLOAT_OES: number;
  64494. RGBA16F: number;
  64495. RGBA32F: number;
  64496. R32F: number;
  64497. RG32F: number;
  64498. RGB32F: number;
  64499. R16F: number;
  64500. RG16F: number;
  64501. RGB16F: number;
  64502. RED: number;
  64503. RG: number;
  64504. R8: number;
  64505. RG8: number;
  64506. UNSIGNED_INT_24_8: number;
  64507. DEPTH24_STENCIL8: number;
  64508. MIN: number;
  64509. MAX: number;
  64510. /* Multiple Render Targets */
  64511. drawBuffers(buffers: number[]): void;
  64512. readBuffer(src: number): void;
  64513. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  64514. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  64515. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  64516. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  64517. // Occlusion Query
  64518. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  64519. ANY_SAMPLES_PASSED: number;
  64520. QUERY_RESULT_AVAILABLE: number;
  64521. QUERY_RESULT: number;
  64522. }
  64523. interface WebGLProgram {
  64524. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  64525. }
  64526. interface EXT_disjoint_timer_query {
  64527. QUERY_COUNTER_BITS_EXT: number;
  64528. TIME_ELAPSED_EXT: number;
  64529. TIMESTAMP_EXT: number;
  64530. GPU_DISJOINT_EXT: number;
  64531. QUERY_RESULT_EXT: number;
  64532. QUERY_RESULT_AVAILABLE_EXT: number;
  64533. queryCounterEXT(query: WebGLQuery, target: number): void;
  64534. createQueryEXT(): WebGLQuery;
  64535. beginQueryEXT(target: number, query: WebGLQuery): void;
  64536. endQueryEXT(target: number): void;
  64537. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  64538. deleteQueryEXT(query: WebGLQuery): void;
  64539. }
  64540. interface WebGLUniformLocation {
  64541. _currentState: any;
  64542. }
  64543. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  64544. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  64545. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  64546. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  64547. interface WebGLRenderingContext {
  64548. readonly RASTERIZER_DISCARD: number;
  64549. readonly DEPTH_COMPONENT24: number;
  64550. readonly TEXTURE_3D: number;
  64551. readonly TEXTURE_2D_ARRAY: number;
  64552. readonly TEXTURE_COMPARE_FUNC: number;
  64553. readonly TEXTURE_COMPARE_MODE: number;
  64554. readonly COMPARE_REF_TO_TEXTURE: number;
  64555. readonly TEXTURE_WRAP_R: number;
  64556. readonly HALF_FLOAT: number;
  64557. readonly RGB8: number;
  64558. readonly RED_INTEGER: number;
  64559. readonly RG_INTEGER: number;
  64560. readonly RGB_INTEGER: number;
  64561. readonly RGBA_INTEGER: number;
  64562. readonly R8_SNORM: number;
  64563. readonly RG8_SNORM: number;
  64564. readonly RGB8_SNORM: number;
  64565. readonly RGBA8_SNORM: number;
  64566. readonly R8I: number;
  64567. readonly RG8I: number;
  64568. readonly RGB8I: number;
  64569. readonly RGBA8I: number;
  64570. readonly R8UI: number;
  64571. readonly RG8UI: number;
  64572. readonly RGB8UI: number;
  64573. readonly RGBA8UI: number;
  64574. readonly R16I: number;
  64575. readonly RG16I: number;
  64576. readonly RGB16I: number;
  64577. readonly RGBA16I: number;
  64578. readonly R16UI: number;
  64579. readonly RG16UI: number;
  64580. readonly RGB16UI: number;
  64581. readonly RGBA16UI: number;
  64582. readonly R32I: number;
  64583. readonly RG32I: number;
  64584. readonly RGB32I: number;
  64585. readonly RGBA32I: number;
  64586. readonly R32UI: number;
  64587. readonly RG32UI: number;
  64588. readonly RGB32UI: number;
  64589. readonly RGBA32UI: number;
  64590. readonly RGB10_A2UI: number;
  64591. readonly R11F_G11F_B10F: number;
  64592. readonly RGB9_E5: number;
  64593. readonly RGB10_A2: number;
  64594. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  64595. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  64596. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  64597. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64598. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  64599. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  64600. 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;
  64601. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  64602. readonly TRANSFORM_FEEDBACK: number;
  64603. readonly INTERLEAVED_ATTRIBS: number;
  64604. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  64605. createTransformFeedback(): WebGLTransformFeedback;
  64606. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  64607. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  64608. beginTransformFeedback(primitiveMode: number): void;
  64609. endTransformFeedback(): void;
  64610. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  64611. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64612. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64613. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64614. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  64615. }
  64616. interface ImageBitmap {
  64617. readonly width: number;
  64618. readonly height: number;
  64619. close(): void;
  64620. }
  64621. interface WebGLQuery extends WebGLObject {
  64622. }
  64623. declare var WebGLQuery: {
  64624. prototype: WebGLQuery;
  64625. new(): WebGLQuery;
  64626. };
  64627. interface WebGLSampler extends WebGLObject {
  64628. }
  64629. declare var WebGLSampler: {
  64630. prototype: WebGLSampler;
  64631. new(): WebGLSampler;
  64632. };
  64633. interface WebGLSync extends WebGLObject {
  64634. }
  64635. declare var WebGLSync: {
  64636. prototype: WebGLSync;
  64637. new(): WebGLSync;
  64638. };
  64639. interface WebGLTransformFeedback extends WebGLObject {
  64640. }
  64641. declare var WebGLTransformFeedback: {
  64642. prototype: WebGLTransformFeedback;
  64643. new(): WebGLTransformFeedback;
  64644. };
  64645. interface WebGLVertexArrayObject extends WebGLObject {
  64646. }
  64647. declare var WebGLVertexArrayObject: {
  64648. prototype: WebGLVertexArrayObject;
  64649. new(): WebGLVertexArrayObject;
  64650. };
  64651. // Type definitions for WebVR API
  64652. // Project: https://w3c.github.io/webvr/
  64653. // Definitions by: six a <https://github.com/lostfictions>
  64654. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  64655. interface VRDisplay extends EventTarget {
  64656. /**
  64657. * Dictionary of capabilities describing the VRDisplay.
  64658. */
  64659. readonly capabilities: VRDisplayCapabilities;
  64660. /**
  64661. * z-depth defining the far plane of the eye view frustum
  64662. * enables mapping of values in the render target depth
  64663. * attachment to scene coordinates. Initially set to 10000.0.
  64664. */
  64665. depthFar: number;
  64666. /**
  64667. * z-depth defining the near plane of the eye view frustum
  64668. * enables mapping of values in the render target depth
  64669. * attachment to scene coordinates. Initially set to 0.01.
  64670. */
  64671. depthNear: number;
  64672. /**
  64673. * An identifier for this distinct VRDisplay. Used as an
  64674. * association point in the Gamepad API.
  64675. */
  64676. readonly displayId: number;
  64677. /**
  64678. * A display name, a user-readable name identifying it.
  64679. */
  64680. readonly displayName: string;
  64681. readonly isConnected: boolean;
  64682. readonly isPresenting: boolean;
  64683. /**
  64684. * If this VRDisplay supports room-scale experiences, the optional
  64685. * stage attribute contains details on the room-scale parameters.
  64686. */
  64687. readonly stageParameters: VRStageParameters | null;
  64688. /**
  64689. * Passing the value returned by `requestAnimationFrame` to
  64690. * `cancelAnimationFrame` will unregister the callback.
  64691. * @param handle Define the hanle of the request to cancel
  64692. */
  64693. cancelAnimationFrame(handle: number): void;
  64694. /**
  64695. * Stops presenting to the VRDisplay.
  64696. * @returns a promise to know when it stopped
  64697. */
  64698. exitPresent(): Promise<void>;
  64699. /**
  64700. * Return the current VREyeParameters for the given eye.
  64701. * @param whichEye Define the eye we want the parameter for
  64702. * @returns the eye parameters
  64703. */
  64704. getEyeParameters(whichEye: string): VREyeParameters;
  64705. /**
  64706. * Populates the passed VRFrameData with the information required to render
  64707. * the current frame.
  64708. * @param frameData Define the data structure to populate
  64709. * @returns true if ok otherwise false
  64710. */
  64711. getFrameData(frameData: VRFrameData): boolean;
  64712. /**
  64713. * Get the layers currently being presented.
  64714. * @returns the list of VR layers
  64715. */
  64716. getLayers(): VRLayer[];
  64717. /**
  64718. * Return a VRPose containing the future predicted pose of the VRDisplay
  64719. * when the current frame will be presented. The value returned will not
  64720. * change until JavaScript has returned control to the browser.
  64721. *
  64722. * The VRPose will contain the position, orientation, velocity,
  64723. * and acceleration of each of these properties.
  64724. * @returns the pose object
  64725. */
  64726. getPose(): VRPose;
  64727. /**
  64728. * Return the current instantaneous pose of the VRDisplay, with no
  64729. * prediction applied.
  64730. * @returns the current instantaneous pose
  64731. */
  64732. getImmediatePose(): VRPose;
  64733. /**
  64734. * The callback passed to `requestAnimationFrame` will be called
  64735. * any time a new frame should be rendered. When the VRDisplay is
  64736. * presenting the callback will be called at the native refresh
  64737. * rate of the HMD. When not presenting this function acts
  64738. * identically to how window.requestAnimationFrame acts. Content should
  64739. * make no assumptions of frame rate or vsync behavior as the HMD runs
  64740. * asynchronously from other displays and at differing refresh rates.
  64741. * @param callback Define the eaction to run next frame
  64742. * @returns the request handle it
  64743. */
  64744. requestAnimationFrame(callback: FrameRequestCallback): number;
  64745. /**
  64746. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  64747. * Repeat calls while already presenting will update the VRLayers being displayed.
  64748. * @param layers Define the list of layer to present
  64749. * @returns a promise to know when the request has been fulfilled
  64750. */
  64751. requestPresent(layers: VRLayer[]): Promise<void>;
  64752. /**
  64753. * Reset the pose for this display, treating its current position and
  64754. * orientation as the "origin/zero" values. VRPose.position,
  64755. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  64756. * updated when calling resetPose(). This should be called in only
  64757. * sitting-space experiences.
  64758. */
  64759. resetPose(): void;
  64760. /**
  64761. * The VRLayer provided to the VRDisplay will be captured and presented
  64762. * in the HMD. Calling this function has the same effect on the source
  64763. * canvas as any other operation that uses its source image, and canvases
  64764. * created without preserveDrawingBuffer set to true will be cleared.
  64765. * @param pose Define the pose to submit
  64766. */
  64767. submitFrame(pose?: VRPose): void;
  64768. }
  64769. declare var VRDisplay: {
  64770. prototype: VRDisplay;
  64771. new(): VRDisplay;
  64772. };
  64773. interface VRLayer {
  64774. leftBounds?: number[] | Float32Array | null;
  64775. rightBounds?: number[] | Float32Array | null;
  64776. source?: HTMLCanvasElement | null;
  64777. }
  64778. interface VRDisplayCapabilities {
  64779. readonly canPresent: boolean;
  64780. readonly hasExternalDisplay: boolean;
  64781. readonly hasOrientation: boolean;
  64782. readonly hasPosition: boolean;
  64783. readonly maxLayers: number;
  64784. }
  64785. interface VREyeParameters {
  64786. /** @deprecated */
  64787. readonly fieldOfView: VRFieldOfView;
  64788. readonly offset: Float32Array;
  64789. readonly renderHeight: number;
  64790. readonly renderWidth: number;
  64791. }
  64792. interface VRFieldOfView {
  64793. readonly downDegrees: number;
  64794. readonly leftDegrees: number;
  64795. readonly rightDegrees: number;
  64796. readonly upDegrees: number;
  64797. }
  64798. interface VRFrameData {
  64799. readonly leftProjectionMatrix: Float32Array;
  64800. readonly leftViewMatrix: Float32Array;
  64801. readonly pose: VRPose;
  64802. readonly rightProjectionMatrix: Float32Array;
  64803. readonly rightViewMatrix: Float32Array;
  64804. readonly timestamp: number;
  64805. }
  64806. interface VRPose {
  64807. readonly angularAcceleration: Float32Array | null;
  64808. readonly angularVelocity: Float32Array | null;
  64809. readonly linearAcceleration: Float32Array | null;
  64810. readonly linearVelocity: Float32Array | null;
  64811. readonly orientation: Float32Array | null;
  64812. readonly position: Float32Array | null;
  64813. readonly timestamp: number;
  64814. }
  64815. interface VRStageParameters {
  64816. sittingToStandingTransform?: Float32Array;
  64817. sizeX?: number;
  64818. sizeY?: number;
  64819. }
  64820. interface Navigator {
  64821. getVRDisplays(): Promise<VRDisplay[]>;
  64822. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  64823. }
  64824. interface Window {
  64825. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  64826. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  64827. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  64828. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64829. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64830. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  64831. }
  64832. interface Gamepad {
  64833. readonly displayId: number;
  64834. }
  64835. type XRSessionMode =
  64836. | "inline"
  64837. | "immersive-vr"
  64838. | "immersive-ar";
  64839. type XRReferenceSpaceType =
  64840. | "viewer"
  64841. | "local"
  64842. | "local-floor"
  64843. | "bounded-floor"
  64844. | "unbounded";
  64845. type XREnvironmentBlendMode =
  64846. | "opaque"
  64847. | "additive"
  64848. | "alpha-blend";
  64849. type XRVisibilityState =
  64850. | "visible"
  64851. | "visible-blurred"
  64852. | "hidden";
  64853. type XRHandedness =
  64854. | "none"
  64855. | "left"
  64856. | "right";
  64857. type XRTargetRayMode =
  64858. | "gaze"
  64859. | "tracked-pointer"
  64860. | "screen";
  64861. type XREye =
  64862. | "none"
  64863. | "left"
  64864. | "right";
  64865. interface XRSpace extends EventTarget {
  64866. }
  64867. interface XRRenderState {
  64868. depthNear?: number;
  64869. depthFar?: number;
  64870. inlineVerticalFieldOfView?: number;
  64871. baseLayer?: XRWebGLLayer;
  64872. }
  64873. interface XRInputSource {
  64874. handedness: XRHandedness;
  64875. targetRayMode: XRTargetRayMode;
  64876. targetRaySpace: XRSpace;
  64877. gripSpace: XRSpace | undefined;
  64878. gamepad: Gamepad | undefined;
  64879. profiles: Array<string>;
  64880. }
  64881. interface XRSession {
  64882. addEventListener: Function;
  64883. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  64884. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  64885. requestAnimationFrame: Function;
  64886. end(): Promise<void>;
  64887. renderState: XRRenderState;
  64888. inputSources: Array<XRInputSource>;
  64889. }
  64890. interface XRReferenceSpace extends XRSpace {
  64891. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  64892. onreset: any;
  64893. }
  64894. interface XRFrame {
  64895. session: XRSession;
  64896. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  64897. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  64898. }
  64899. interface XRViewerPose extends XRPose {
  64900. views: Array<XRView>;
  64901. }
  64902. interface XRPose {
  64903. transform: XRRigidTransform;
  64904. emulatedPosition: boolean;
  64905. }
  64906. declare var XRWebGLLayer: {
  64907. prototype: XRWebGLLayer;
  64908. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  64909. };
  64910. interface XRWebGLLayer {
  64911. framebuffer: WebGLFramebuffer;
  64912. framebufferWidth: number;
  64913. framebufferHeight: number;
  64914. getViewport: Function;
  64915. }
  64916. interface XRRigidTransform {
  64917. position: DOMPointReadOnly;
  64918. orientation: DOMPointReadOnly;
  64919. matrix: Float32Array;
  64920. inverse: XRRigidTransform;
  64921. }
  64922. interface XRView {
  64923. eye: XREye;
  64924. projectionMatrix: Float32Array;
  64925. transform: XRRigidTransform;
  64926. }
  64927. interface XRInputSourceChangeEvent {
  64928. session: XRSession;
  64929. removed: Array<XRInputSource>;
  64930. added: Array<XRInputSource>;
  64931. }
  64932. /**
  64933. * @ignore
  64934. */
  64935. declare module BABYLON.GLTF2.Exporter {
  64936. }
  64937. /**
  64938. * @ignore
  64939. */
  64940. declare module BABYLON.GLTF1 {
  64941. }
  64942. declare module BABYLON.GUI {
  64943. /**
  64944. * Class used to specific a value and its associated unit
  64945. */
  64946. export class ValueAndUnit {
  64947. /** defines the unit to store */
  64948. unit: number;
  64949. /** defines a boolean indicating if the value can be negative */
  64950. negativeValueAllowed: boolean;
  64951. private _value;
  64952. private _originalUnit;
  64953. /**
  64954. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  64955. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64956. */
  64957. ignoreAdaptiveScaling: boolean;
  64958. /**
  64959. * Creates a new ValueAndUnit
  64960. * @param value defines the value to store
  64961. * @param unit defines the unit to store
  64962. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  64963. */
  64964. constructor(value: number,
  64965. /** defines the unit to store */
  64966. unit?: number,
  64967. /** defines a boolean indicating if the value can be negative */
  64968. negativeValueAllowed?: boolean);
  64969. /** Gets a boolean indicating if the value is a percentage */
  64970. readonly isPercentage: boolean;
  64971. /** Gets a boolean indicating if the value is store as pixel */
  64972. readonly isPixel: boolean;
  64973. /** Gets direct internal value */
  64974. readonly internalValue: number;
  64975. /**
  64976. * Gets value as pixel
  64977. * @param host defines the root host
  64978. * @param refValue defines the reference value for percentages
  64979. * @returns the value as pixel
  64980. */
  64981. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  64982. /**
  64983. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  64984. * @param value defines the value to store
  64985. * @param unit defines the unit to store
  64986. * @returns the current ValueAndUnit
  64987. */
  64988. updateInPlace(value: number, unit?: number): ValueAndUnit;
  64989. /**
  64990. * Gets the value accordingly to its unit
  64991. * @param host defines the root host
  64992. * @returns the value
  64993. */
  64994. getValue(host: AdvancedDynamicTexture): number;
  64995. /**
  64996. * Gets a string representation of the value
  64997. * @param host defines the root host
  64998. * @param decimals defines an optional number of decimals to display
  64999. * @returns a string
  65000. */
  65001. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  65002. /**
  65003. * Store a value parsed from a string
  65004. * @param source defines the source string
  65005. * @returns true if the value was successfully parsed
  65006. */
  65007. fromString(source: string | number): boolean;
  65008. private static _Regex;
  65009. private static _UNITMODE_PERCENTAGE;
  65010. private static _UNITMODE_PIXEL;
  65011. /** UNITMODE_PERCENTAGE */
  65012. static readonly UNITMODE_PERCENTAGE: number;
  65013. /** UNITMODE_PIXEL */
  65014. static readonly UNITMODE_PIXEL: number;
  65015. }
  65016. }
  65017. declare module BABYLON.GUI {
  65018. /**
  65019. * Define a style used by control to automatically setup properties based on a template.
  65020. * Only support font related properties so far
  65021. */
  65022. export class Style implements BABYLON.IDisposable {
  65023. private _fontFamily;
  65024. private _fontStyle;
  65025. private _fontWeight;
  65026. /** @hidden */
  65027. _host: AdvancedDynamicTexture;
  65028. /** @hidden */
  65029. _fontSize: ValueAndUnit;
  65030. /**
  65031. * BABYLON.Observable raised when the style values are changed
  65032. */
  65033. onChangedObservable: BABYLON.Observable<Style>;
  65034. /**
  65035. * Creates a new style object
  65036. * @param host defines the AdvancedDynamicTexture which hosts this style
  65037. */
  65038. constructor(host: AdvancedDynamicTexture);
  65039. /**
  65040. * Gets or sets the font size
  65041. */
  65042. fontSize: string | number;
  65043. /**
  65044. * Gets or sets the font family
  65045. */
  65046. fontFamily: string;
  65047. /**
  65048. * Gets or sets the font style
  65049. */
  65050. fontStyle: string;
  65051. /** Gets or sets font weight */
  65052. fontWeight: string;
  65053. /** Dispose all associated resources */
  65054. dispose(): void;
  65055. }
  65056. }
  65057. declare module BABYLON.GUI {
  65058. /**
  65059. * Class used to transport BABYLON.Vector2 information for pointer events
  65060. */
  65061. export class Vector2WithInfo extends BABYLON.Vector2 {
  65062. /** defines the current mouse button index */
  65063. buttonIndex: number;
  65064. /**
  65065. * Creates a new Vector2WithInfo
  65066. * @param source defines the vector2 data to transport
  65067. * @param buttonIndex defines the current mouse button index
  65068. */
  65069. constructor(source: BABYLON.Vector2,
  65070. /** defines the current mouse button index */
  65071. buttonIndex?: number);
  65072. }
  65073. /** Class used to provide 2D matrix features */
  65074. export class Matrix2D {
  65075. /** Gets the internal array of 6 floats used to store matrix data */
  65076. m: Float32Array;
  65077. /**
  65078. * Creates a new matrix
  65079. * @param m00 defines value for (0, 0)
  65080. * @param m01 defines value for (0, 1)
  65081. * @param m10 defines value for (1, 0)
  65082. * @param m11 defines value for (1, 1)
  65083. * @param m20 defines value for (2, 0)
  65084. * @param m21 defines value for (2, 1)
  65085. */
  65086. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  65087. /**
  65088. * Fills the matrix from direct values
  65089. * @param m00 defines value for (0, 0)
  65090. * @param m01 defines value for (0, 1)
  65091. * @param m10 defines value for (1, 0)
  65092. * @param m11 defines value for (1, 1)
  65093. * @param m20 defines value for (2, 0)
  65094. * @param m21 defines value for (2, 1)
  65095. * @returns the current modified matrix
  65096. */
  65097. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  65098. /**
  65099. * Gets matrix determinant
  65100. * @returns the determinant
  65101. */
  65102. determinant(): number;
  65103. /**
  65104. * Inverses the matrix and stores it in a target matrix
  65105. * @param result defines the target matrix
  65106. * @returns the current matrix
  65107. */
  65108. invertToRef(result: Matrix2D): Matrix2D;
  65109. /**
  65110. * Multiplies the current matrix with another one
  65111. * @param other defines the second operand
  65112. * @param result defines the target matrix
  65113. * @returns the current matrix
  65114. */
  65115. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  65116. /**
  65117. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  65118. * @param x defines the x coordinate to transform
  65119. * @param y defines the x coordinate to transform
  65120. * @param result defines the target vector2
  65121. * @returns the current matrix
  65122. */
  65123. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  65124. /**
  65125. * Creates an identity matrix
  65126. * @returns a new matrix
  65127. */
  65128. static Identity(): Matrix2D;
  65129. /**
  65130. * Creates a translation matrix and stores it in a target matrix
  65131. * @param x defines the x coordinate of the translation
  65132. * @param y defines the y coordinate of the translation
  65133. * @param result defines the target matrix
  65134. */
  65135. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  65136. /**
  65137. * Creates a scaling matrix and stores it in a target matrix
  65138. * @param x defines the x coordinate of the scaling
  65139. * @param y defines the y coordinate of the scaling
  65140. * @param result defines the target matrix
  65141. */
  65142. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  65143. /**
  65144. * Creates a rotation matrix and stores it in a target matrix
  65145. * @param angle defines the rotation angle
  65146. * @param result defines the target matrix
  65147. */
  65148. static RotationToRef(angle: number, result: Matrix2D): void;
  65149. private static _TempPreTranslationMatrix;
  65150. private static _TempPostTranslationMatrix;
  65151. private static _TempRotationMatrix;
  65152. private static _TempScalingMatrix;
  65153. private static _TempCompose0;
  65154. private static _TempCompose1;
  65155. private static _TempCompose2;
  65156. /**
  65157. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  65158. * @param tx defines the x coordinate of the translation
  65159. * @param ty defines the y coordinate of the translation
  65160. * @param angle defines the rotation angle
  65161. * @param scaleX defines the x coordinate of the scaling
  65162. * @param scaleY defines the y coordinate of the scaling
  65163. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  65164. * @param result defines the target matrix
  65165. */
  65166. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  65167. }
  65168. }
  65169. declare module BABYLON.GUI {
  65170. /**
  65171. * Class used to store 2D control sizes
  65172. */
  65173. export class Measure {
  65174. /** defines left coordinate */
  65175. left: number;
  65176. /** defines top coordinate */
  65177. top: number;
  65178. /** defines width dimension */
  65179. width: number;
  65180. /** defines height dimension */
  65181. height: number;
  65182. /**
  65183. * Creates a new measure
  65184. * @param left defines left coordinate
  65185. * @param top defines top coordinate
  65186. * @param width defines width dimension
  65187. * @param height defines height dimension
  65188. */
  65189. constructor(
  65190. /** defines left coordinate */
  65191. left: number,
  65192. /** defines top coordinate */
  65193. top: number,
  65194. /** defines width dimension */
  65195. width: number,
  65196. /** defines height dimension */
  65197. height: number);
  65198. /**
  65199. * Copy from another measure
  65200. * @param other defines the other measure to copy from
  65201. */
  65202. copyFrom(other: Measure): void;
  65203. /**
  65204. * Copy from a group of 4 floats
  65205. * @param left defines left coordinate
  65206. * @param top defines top coordinate
  65207. * @param width defines width dimension
  65208. * @param height defines height dimension
  65209. */
  65210. copyFromFloats(left: number, top: number, width: number, height: number): void;
  65211. /**
  65212. * Computes the axis aligned bounding box measure for two given measures
  65213. * @param a Input measure
  65214. * @param b Input measure
  65215. * @param result the resulting bounding measure
  65216. */
  65217. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  65218. /**
  65219. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  65220. * @param transform the matrix to transform the measure before computing the AABB
  65221. * @param result the resulting AABB
  65222. */
  65223. transformToRef(transform: Matrix2D, result: Measure): void;
  65224. /**
  65225. * Check equality between this measure and another one
  65226. * @param other defines the other measures
  65227. * @returns true if both measures are equals
  65228. */
  65229. isEqualsTo(other: Measure): boolean;
  65230. /**
  65231. * Creates an empty measure
  65232. * @returns a new measure
  65233. */
  65234. static Empty(): Measure;
  65235. }
  65236. }
  65237. declare module BABYLON.GUI {
  65238. /**
  65239. * Interface used to define a control that can receive focus
  65240. */
  65241. export interface IFocusableControl {
  65242. /**
  65243. * Function called when the control receives the focus
  65244. */
  65245. onFocus(): void;
  65246. /**
  65247. * Function called when the control loses the focus
  65248. */
  65249. onBlur(): void;
  65250. /**
  65251. * Function called to let the control handle keyboard events
  65252. * @param evt defines the current keyboard event
  65253. */
  65254. processKeyboard(evt: KeyboardEvent): void;
  65255. /**
  65256. * Function called to get the list of controls that should not steal the focus from this control
  65257. * @returns an array of controls
  65258. */
  65259. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  65260. }
  65261. /**
  65262. * Class used to create texture to support 2D GUI elements
  65263. * @see http://doc.babylonjs.com/how_to/gui
  65264. */
  65265. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  65266. private _isDirty;
  65267. private _renderObserver;
  65268. private _resizeObserver;
  65269. private _preKeyboardObserver;
  65270. private _pointerMoveObserver;
  65271. private _pointerObserver;
  65272. private _canvasPointerOutObserver;
  65273. private _background;
  65274. /** @hidden */
  65275. _rootContainer: Container;
  65276. /** @hidden */
  65277. _lastPickedControl: Control;
  65278. /** @hidden */
  65279. _lastControlOver: {
  65280. [pointerId: number]: Control;
  65281. };
  65282. /** @hidden */
  65283. _lastControlDown: {
  65284. [pointerId: number]: Control;
  65285. };
  65286. /** @hidden */
  65287. _capturingControl: {
  65288. [pointerId: number]: Control;
  65289. };
  65290. /** @hidden */
  65291. _shouldBlockPointer: boolean;
  65292. /** @hidden */
  65293. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  65294. /** @hidden */
  65295. _linkedControls: Control[];
  65296. private _isFullscreen;
  65297. private _fullscreenViewport;
  65298. private _idealWidth;
  65299. private _idealHeight;
  65300. private _useSmallestIdeal;
  65301. private _renderAtIdealSize;
  65302. private _focusedControl;
  65303. private _blockNextFocusCheck;
  65304. private _renderScale;
  65305. private _rootElement;
  65306. private _cursorChanged;
  65307. /**
  65308. * Define type to string to ensure compatibility across browsers
  65309. * Safari doesn't support DataTransfer constructor
  65310. */
  65311. private _clipboardData;
  65312. /**
  65313. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  65314. */
  65315. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  65316. /**
  65317. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  65318. */
  65319. onControlPickedObservable: BABYLON.Observable<Control>;
  65320. /**
  65321. * BABYLON.Observable event triggered before layout is evaluated
  65322. */
  65323. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65324. /**
  65325. * BABYLON.Observable event triggered after the layout was evaluated
  65326. */
  65327. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65328. /**
  65329. * BABYLON.Observable event triggered before the texture is rendered
  65330. */
  65331. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65332. /**
  65333. * BABYLON.Observable event triggered after the texture was rendered
  65334. */
  65335. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65336. /**
  65337. * Gets or sets a boolean defining if alpha is stored as premultiplied
  65338. */
  65339. premulAlpha: boolean;
  65340. /**
  65341. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  65342. * Useful when you want more antialiasing
  65343. */
  65344. renderScale: number;
  65345. /** Gets or sets the background color */
  65346. background: string;
  65347. /**
  65348. * Gets or sets the ideal width used to design controls.
  65349. * The GUI will then rescale everything accordingly
  65350. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65351. */
  65352. idealWidth: number;
  65353. /**
  65354. * Gets or sets the ideal height used to design controls.
  65355. * The GUI will then rescale everything accordingly
  65356. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65357. */
  65358. idealHeight: number;
  65359. /**
  65360. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  65361. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65362. */
  65363. useSmallestIdeal: boolean;
  65364. /**
  65365. * Gets or sets a boolean indicating if adaptive scaling must be used
  65366. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65367. */
  65368. renderAtIdealSize: boolean;
  65369. /**
  65370. * Gets the underlying layer used to render the texture when in fullscreen mode
  65371. */
  65372. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  65373. /**
  65374. * Gets the root container control
  65375. */
  65376. readonly rootContainer: Container;
  65377. /**
  65378. * Returns an array containing the root container.
  65379. * This is mostly used to let the Inspector introspects the ADT
  65380. * @returns an array containing the rootContainer
  65381. */
  65382. getChildren(): Array<Container>;
  65383. /**
  65384. * Will return all controls that are inside this texture
  65385. * @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
  65386. * @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
  65387. * @return all child controls
  65388. */
  65389. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  65390. /**
  65391. * Gets or sets the current focused control
  65392. */
  65393. focusedControl: BABYLON.Nullable<IFocusableControl>;
  65394. /**
  65395. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  65396. */
  65397. isForeground: boolean;
  65398. /**
  65399. * Gets or set information about clipboardData
  65400. */
  65401. clipboardData: string;
  65402. /**
  65403. * Creates a new AdvancedDynamicTexture
  65404. * @param name defines the name of the texture
  65405. * @param width defines the width of the texture
  65406. * @param height defines the height of the texture
  65407. * @param scene defines the hosting scene
  65408. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  65409. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  65410. */
  65411. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  65412. /**
  65413. * Get the current class name of the texture useful for serialization or dynamic coding.
  65414. * @returns "AdvancedDynamicTexture"
  65415. */
  65416. getClassName(): string;
  65417. /**
  65418. * Function used to execute a function on all controls
  65419. * @param func defines the function to execute
  65420. * @param container defines the container where controls belong. If null the root container will be used
  65421. */
  65422. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  65423. private _useInvalidateRectOptimization;
  65424. /**
  65425. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  65426. */
  65427. useInvalidateRectOptimization: boolean;
  65428. private _invalidatedRectangle;
  65429. /**
  65430. * Invalidates a rectangle area on the gui texture
  65431. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  65432. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  65433. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  65434. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  65435. */
  65436. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  65437. /**
  65438. * Marks the texture as dirty forcing a complete update
  65439. */
  65440. markAsDirty(): void;
  65441. /**
  65442. * Helper function used to create a new style
  65443. * @returns a new style
  65444. * @see http://doc.babylonjs.com/how_to/gui#styles
  65445. */
  65446. createStyle(): Style;
  65447. /**
  65448. * Adds a new control to the root container
  65449. * @param control defines the control to add
  65450. * @returns the current texture
  65451. */
  65452. addControl(control: Control): AdvancedDynamicTexture;
  65453. /**
  65454. * Removes a control from the root container
  65455. * @param control defines the control to remove
  65456. * @returns the current texture
  65457. */
  65458. removeControl(control: Control): AdvancedDynamicTexture;
  65459. /**
  65460. * Release all resources
  65461. */
  65462. dispose(): void;
  65463. private _onResize;
  65464. /** @hidden */
  65465. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  65466. /**
  65467. * Get screen coordinates for a vector3
  65468. * @param position defines the position to project
  65469. * @param worldMatrix defines the world matrix to use
  65470. * @returns the projected position
  65471. */
  65472. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  65473. private _checkUpdate;
  65474. private _clearMeasure;
  65475. private _render;
  65476. /** @hidden */
  65477. _changeCursor(cursor: string): void;
  65478. /** @hidden */
  65479. _registerLastControlDown(control: Control, pointerId: number): void;
  65480. private _doPicking;
  65481. /** @hidden */
  65482. _cleanControlAfterRemovalFromList(list: {
  65483. [pointerId: number]: Control;
  65484. }, control: Control): void;
  65485. /** @hidden */
  65486. _cleanControlAfterRemoval(control: Control): void;
  65487. /** Attach to all scene events required to support pointer events */
  65488. attach(): void;
  65489. /** @hidden */
  65490. private onClipboardCopy;
  65491. /** @hidden */
  65492. private onClipboardCut;
  65493. /** @hidden */
  65494. private onClipboardPaste;
  65495. /**
  65496. * Register the clipboard Events onto the canvas
  65497. */
  65498. registerClipboardEvents(): void;
  65499. /**
  65500. * Unregister the clipboard Events from the canvas
  65501. */
  65502. unRegisterClipboardEvents(): void;
  65503. /**
  65504. * Connect the texture to a hosting mesh to enable interactions
  65505. * @param mesh defines the mesh to attach to
  65506. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  65507. */
  65508. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  65509. /**
  65510. * Move the focus to a specific control
  65511. * @param control defines the control which will receive the focus
  65512. */
  65513. moveFocusToControl(control: IFocusableControl): void;
  65514. private _manageFocus;
  65515. private _attachToOnPointerOut;
  65516. /**
  65517. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  65518. * @param mesh defines the mesh which will receive the texture
  65519. * @param width defines the texture width (1024 by default)
  65520. * @param height defines the texture height (1024 by default)
  65521. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  65522. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  65523. * @returns a new AdvancedDynamicTexture
  65524. */
  65525. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  65526. /**
  65527. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  65528. * In this mode the texture will rely on a layer for its rendering.
  65529. * This allows it to be treated like any other layer.
  65530. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  65531. * LayerMask is set through advancedTexture.layer.layerMask
  65532. * @param name defines name for the texture
  65533. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  65534. * @param scene defines the hsoting scene
  65535. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  65536. * @returns a new AdvancedDynamicTexture
  65537. */
  65538. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  65539. }
  65540. }
  65541. declare module BABYLON.GUI {
  65542. /**
  65543. * Root class used for all 2D controls
  65544. * @see http://doc.babylonjs.com/how_to/gui#controls
  65545. */
  65546. export class Control {
  65547. /** defines the name of the control */
  65548. name?: string | undefined;
  65549. /**
  65550. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  65551. */
  65552. static AllowAlphaInheritance: boolean;
  65553. private _alpha;
  65554. private _alphaSet;
  65555. private _zIndex;
  65556. /** @hidden */
  65557. _host: AdvancedDynamicTexture;
  65558. /** Gets or sets the control parent */
  65559. parent: BABYLON.Nullable<Container>;
  65560. /** @hidden */
  65561. _currentMeasure: Measure;
  65562. private _fontFamily;
  65563. private _fontStyle;
  65564. private _fontWeight;
  65565. private _fontSize;
  65566. private _font;
  65567. /** @hidden */
  65568. _width: ValueAndUnit;
  65569. /** @hidden */
  65570. _height: ValueAndUnit;
  65571. /** @hidden */
  65572. protected _fontOffset: {
  65573. ascent: number;
  65574. height: number;
  65575. descent: number;
  65576. };
  65577. private _color;
  65578. private _style;
  65579. private _styleObserver;
  65580. /** @hidden */
  65581. protected _horizontalAlignment: number;
  65582. /** @hidden */
  65583. protected _verticalAlignment: number;
  65584. /** @hidden */
  65585. protected _isDirty: boolean;
  65586. /** @hidden */
  65587. protected _wasDirty: boolean;
  65588. /** @hidden */
  65589. _tempParentMeasure: Measure;
  65590. /** @hidden */
  65591. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  65592. /** @hidden */
  65593. protected _cachedParentMeasure: Measure;
  65594. private _paddingLeft;
  65595. private _paddingRight;
  65596. private _paddingTop;
  65597. private _paddingBottom;
  65598. /** @hidden */
  65599. _left: ValueAndUnit;
  65600. /** @hidden */
  65601. _top: ValueAndUnit;
  65602. private _scaleX;
  65603. private _scaleY;
  65604. private _rotation;
  65605. private _transformCenterX;
  65606. private _transformCenterY;
  65607. /** @hidden */
  65608. _transformMatrix: Matrix2D;
  65609. /** @hidden */
  65610. protected _invertTransformMatrix: Matrix2D;
  65611. /** @hidden */
  65612. protected _transformedPosition: BABYLON.Vector2;
  65613. private _isMatrixDirty;
  65614. private _cachedOffsetX;
  65615. private _cachedOffsetY;
  65616. private _isVisible;
  65617. private _isHighlighted;
  65618. /** @hidden */
  65619. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65620. private _fontSet;
  65621. private _dummyVector2;
  65622. private _downCount;
  65623. private _enterCount;
  65624. private _doNotRender;
  65625. private _downPointerIds;
  65626. protected _isEnabled: boolean;
  65627. protected _disabledColor: string;
  65628. /** @hidden */
  65629. protected _rebuildLayout: boolean;
  65630. /** @hidden */
  65631. _isClipped: boolean;
  65632. /** @hidden */
  65633. _tag: any;
  65634. /**
  65635. * 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
  65636. */
  65637. uniqueId: number;
  65638. /**
  65639. * Gets or sets an object used to store user defined information for the node
  65640. */
  65641. metadata: any;
  65642. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  65643. isHitTestVisible: boolean;
  65644. /** Gets or sets a boolean indicating if the control can block pointer events */
  65645. isPointerBlocker: boolean;
  65646. /** Gets or sets a boolean indicating if the control can be focusable */
  65647. isFocusInvisible: boolean;
  65648. /**
  65649. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  65650. * 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
  65651. */
  65652. clipChildren: boolean;
  65653. /**
  65654. * Gets or sets a boolean indicating that control content must be clipped
  65655. * 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
  65656. */
  65657. clipContent: boolean;
  65658. /**
  65659. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  65660. */
  65661. useBitmapCache: boolean;
  65662. private _cacheData;
  65663. private _shadowOffsetX;
  65664. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  65665. shadowOffsetX: number;
  65666. private _shadowOffsetY;
  65667. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  65668. shadowOffsetY: number;
  65669. private _shadowBlur;
  65670. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  65671. shadowBlur: number;
  65672. private _shadowColor;
  65673. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  65674. shadowColor: string;
  65675. /** Gets or sets the cursor to use when the control is hovered */
  65676. hoverCursor: string;
  65677. /** @hidden */
  65678. protected _linkOffsetX: ValueAndUnit;
  65679. /** @hidden */
  65680. protected _linkOffsetY: ValueAndUnit;
  65681. /** Gets the control type name */
  65682. readonly typeName: string;
  65683. /**
  65684. * Get the current class name of the control.
  65685. * @returns current class name
  65686. */
  65687. getClassName(): string;
  65688. /**
  65689. * An event triggered when the pointer move over the control.
  65690. */
  65691. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  65692. /**
  65693. * An event triggered when the pointer move out of the control.
  65694. */
  65695. onPointerOutObservable: BABYLON.Observable<Control>;
  65696. /**
  65697. * An event triggered when the pointer taps the control
  65698. */
  65699. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  65700. /**
  65701. * An event triggered when pointer up
  65702. */
  65703. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  65704. /**
  65705. * An event triggered when a control is clicked on
  65706. */
  65707. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  65708. /**
  65709. * An event triggered when pointer enters the control
  65710. */
  65711. onPointerEnterObservable: BABYLON.Observable<Control>;
  65712. /**
  65713. * An event triggered when the control is marked as dirty
  65714. */
  65715. onDirtyObservable: BABYLON.Observable<Control>;
  65716. /**
  65717. * An event triggered before drawing the control
  65718. */
  65719. onBeforeDrawObservable: BABYLON.Observable<Control>;
  65720. /**
  65721. * An event triggered after the control was drawn
  65722. */
  65723. onAfterDrawObservable: BABYLON.Observable<Control>;
  65724. /**
  65725. * Get the hosting AdvancedDynamicTexture
  65726. */
  65727. readonly host: AdvancedDynamicTexture;
  65728. /** Gets or set information about font offsets (used to render and align text) */
  65729. fontOffset: {
  65730. ascent: number;
  65731. height: number;
  65732. descent: number;
  65733. };
  65734. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  65735. alpha: number;
  65736. /**
  65737. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  65738. */
  65739. isHighlighted: boolean;
  65740. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  65741. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65742. */
  65743. scaleX: number;
  65744. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  65745. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65746. */
  65747. scaleY: number;
  65748. /** Gets or sets the rotation angle (0 by default)
  65749. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65750. */
  65751. rotation: number;
  65752. /** Gets or sets the transformation center on Y axis (0 by default)
  65753. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65754. */
  65755. transformCenterY: number;
  65756. /** Gets or sets the transformation center on X axis (0 by default)
  65757. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65758. */
  65759. transformCenterX: number;
  65760. /**
  65761. * Gets or sets the horizontal alignment
  65762. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65763. */
  65764. horizontalAlignment: number;
  65765. /**
  65766. * Gets or sets the vertical alignment
  65767. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65768. */
  65769. verticalAlignment: number;
  65770. /**
  65771. * Gets or sets control width
  65772. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65773. */
  65774. width: string | number;
  65775. /**
  65776. * Gets or sets the control width in pixel
  65777. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65778. */
  65779. widthInPixels: number;
  65780. /**
  65781. * Gets or sets control height
  65782. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65783. */
  65784. height: string | number;
  65785. /**
  65786. * Gets or sets control height in pixel
  65787. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65788. */
  65789. heightInPixels: number;
  65790. /** Gets or set font family */
  65791. fontFamily: string;
  65792. /** Gets or sets font style */
  65793. fontStyle: string;
  65794. /** Gets or sets font weight */
  65795. fontWeight: string;
  65796. /**
  65797. * Gets or sets style
  65798. * @see http://doc.babylonjs.com/how_to/gui#styles
  65799. */
  65800. style: BABYLON.Nullable<Style>;
  65801. /** @hidden */
  65802. readonly _isFontSizeInPercentage: boolean;
  65803. /** Gets or sets font size in pixels */
  65804. fontSizeInPixels: number;
  65805. /** Gets or sets font size */
  65806. fontSize: string | number;
  65807. /** Gets or sets foreground color */
  65808. color: string;
  65809. /** Gets or sets z index which is used to reorder controls on the z axis */
  65810. zIndex: number;
  65811. /** Gets or sets a boolean indicating if the control can be rendered */
  65812. notRenderable: boolean;
  65813. /** Gets or sets a boolean indicating if the control is visible */
  65814. isVisible: boolean;
  65815. /** Gets a boolean indicating that the control needs to update its rendering */
  65816. readonly isDirty: boolean;
  65817. /**
  65818. * Gets the current linked mesh (or null if none)
  65819. */
  65820. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65821. /**
  65822. * Gets or sets a value indicating the padding to use on the left of the control
  65823. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65824. */
  65825. paddingLeft: string | number;
  65826. /**
  65827. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  65828. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65829. */
  65830. paddingLeftInPixels: number;
  65831. /**
  65832. * Gets or sets a value indicating the padding to use on the right of the control
  65833. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65834. */
  65835. paddingRight: string | number;
  65836. /**
  65837. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  65838. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65839. */
  65840. paddingRightInPixels: number;
  65841. /**
  65842. * Gets or sets a value indicating the padding to use on the top of the control
  65843. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65844. */
  65845. paddingTop: string | number;
  65846. /**
  65847. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  65848. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65849. */
  65850. paddingTopInPixels: number;
  65851. /**
  65852. * Gets or sets a value indicating the padding to use on the bottom of the control
  65853. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65854. */
  65855. paddingBottom: string | number;
  65856. /**
  65857. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  65858. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65859. */
  65860. paddingBottomInPixels: number;
  65861. /**
  65862. * Gets or sets a value indicating the left coordinate of the control
  65863. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65864. */
  65865. left: string | number;
  65866. /**
  65867. * Gets or sets a value indicating the left coordinate in pixels of the control
  65868. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65869. */
  65870. leftInPixels: number;
  65871. /**
  65872. * Gets or sets a value indicating the top coordinate of the control
  65873. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65874. */
  65875. top: string | number;
  65876. /**
  65877. * Gets or sets a value indicating the top coordinate in pixels of the control
  65878. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65879. */
  65880. topInPixels: number;
  65881. /**
  65882. * Gets or sets a value indicating the offset on X axis to the linked mesh
  65883. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65884. */
  65885. linkOffsetX: string | number;
  65886. /**
  65887. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  65888. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65889. */
  65890. linkOffsetXInPixels: number;
  65891. /**
  65892. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  65893. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65894. */
  65895. linkOffsetY: string | number;
  65896. /**
  65897. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  65898. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65899. */
  65900. linkOffsetYInPixels: number;
  65901. /** Gets the center coordinate on X axis */
  65902. readonly centerX: number;
  65903. /** Gets the center coordinate on Y axis */
  65904. readonly centerY: number;
  65905. /** Gets or sets if control is Enabled*/
  65906. isEnabled: boolean;
  65907. /** Gets or sets background color of control if it's disabled*/
  65908. disabledColor: string;
  65909. /**
  65910. * Creates a new control
  65911. * @param name defines the name of the control
  65912. */
  65913. constructor(
  65914. /** defines the name of the control */
  65915. name?: string | undefined);
  65916. /** @hidden */
  65917. protected _getTypeName(): string;
  65918. /**
  65919. * Gets the first ascendant in the hierarchy of the given type
  65920. * @param className defines the required type
  65921. * @returns the ascendant or null if not found
  65922. */
  65923. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  65924. /** @hidden */
  65925. _resetFontCache(): void;
  65926. /**
  65927. * Determines if a container is an ascendant of the current control
  65928. * @param container defines the container to look for
  65929. * @returns true if the container is one of the ascendant of the control
  65930. */
  65931. isAscendant(container: Control): boolean;
  65932. /**
  65933. * Gets coordinates in local control space
  65934. * @param globalCoordinates defines the coordinates to transform
  65935. * @returns the new coordinates in local space
  65936. */
  65937. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65938. /**
  65939. * Gets coordinates in local control space
  65940. * @param globalCoordinates defines the coordinates to transform
  65941. * @param result defines the target vector2 where to store the result
  65942. * @returns the current control
  65943. */
  65944. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  65945. /**
  65946. * Gets coordinates in parent local control space
  65947. * @param globalCoordinates defines the coordinates to transform
  65948. * @returns the new coordinates in parent local space
  65949. */
  65950. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65951. /**
  65952. * Move the current control to a vector3 position projected onto the screen.
  65953. * @param position defines the target position
  65954. * @param scene defines the hosting scene
  65955. */
  65956. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  65957. /** @hidden */
  65958. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65959. /**
  65960. * Will return all controls that have this control as ascendant
  65961. * @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
  65962. * @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
  65963. * @return all child controls
  65964. */
  65965. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  65966. /**
  65967. * Link current control with a target mesh
  65968. * @param mesh defines the mesh to link with
  65969. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65970. */
  65971. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  65972. /** @hidden */
  65973. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  65974. /** @hidden */
  65975. _offsetLeft(offset: number): void;
  65976. /** @hidden */
  65977. _offsetTop(offset: number): void;
  65978. /** @hidden */
  65979. _markMatrixAsDirty(): void;
  65980. /** @hidden */
  65981. _flagDescendantsAsMatrixDirty(): void;
  65982. /** @hidden */
  65983. _intersectsRect(rect: Measure): boolean;
  65984. /** @hidden */
  65985. protected invalidateRect(): void;
  65986. /** @hidden */
  65987. _markAsDirty(force?: boolean): void;
  65988. /** @hidden */
  65989. _markAllAsDirty(): void;
  65990. /** @hidden */
  65991. _link(host: AdvancedDynamicTexture): void;
  65992. /** @hidden */
  65993. protected _transform(context?: CanvasRenderingContext2D): void;
  65994. /** @hidden */
  65995. _renderHighlight(context: CanvasRenderingContext2D): void;
  65996. /** @hidden */
  65997. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65998. /** @hidden */
  65999. protected _applyStates(context: CanvasRenderingContext2D): void;
  66000. /** @hidden */
  66001. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  66002. /** @hidden */
  66003. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66004. protected _evaluateClippingState(parentMeasure: Measure): void;
  66005. /** @hidden */
  66006. _measure(): void;
  66007. /** @hidden */
  66008. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66009. /** @hidden */
  66010. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66011. /** @hidden */
  66012. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66013. /** @hidden */
  66014. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  66015. private static _ClipMeasure;
  66016. private _tmpMeasureA;
  66017. private _clip;
  66018. /** @hidden */
  66019. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  66020. /** @hidden */
  66021. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  66022. /**
  66023. * Tests if a given coordinates belong to the current control
  66024. * @param x defines x coordinate to test
  66025. * @param y defines y coordinate to test
  66026. * @returns true if the coordinates are inside the control
  66027. */
  66028. contains(x: number, y: number): boolean;
  66029. /** @hidden */
  66030. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  66031. /** @hidden */
  66032. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66033. /** @hidden */
  66034. _onPointerEnter(target: Control): boolean;
  66035. /** @hidden */
  66036. _onPointerOut(target: Control, force?: boolean): void;
  66037. /** @hidden */
  66038. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66039. /** @hidden */
  66040. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66041. /** @hidden */
  66042. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66043. /** @hidden */
  66044. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  66045. private _prepareFont;
  66046. /** Releases associated resources */
  66047. dispose(): void;
  66048. private static _HORIZONTAL_ALIGNMENT_LEFT;
  66049. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  66050. private static _HORIZONTAL_ALIGNMENT_CENTER;
  66051. private static _VERTICAL_ALIGNMENT_TOP;
  66052. private static _VERTICAL_ALIGNMENT_BOTTOM;
  66053. private static _VERTICAL_ALIGNMENT_CENTER;
  66054. /** HORIZONTAL_ALIGNMENT_LEFT */
  66055. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  66056. /** HORIZONTAL_ALIGNMENT_RIGHT */
  66057. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  66058. /** HORIZONTAL_ALIGNMENT_CENTER */
  66059. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  66060. /** VERTICAL_ALIGNMENT_TOP */
  66061. static readonly VERTICAL_ALIGNMENT_TOP: number;
  66062. /** VERTICAL_ALIGNMENT_BOTTOM */
  66063. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  66064. /** VERTICAL_ALIGNMENT_CENTER */
  66065. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  66066. private static _FontHeightSizes;
  66067. /** @hidden */
  66068. static _GetFontOffset(font: string): {
  66069. ascent: number;
  66070. height: number;
  66071. descent: number;
  66072. };
  66073. /**
  66074. * Creates a stack panel that can be used to render headers
  66075. * @param control defines the control to associate with the header
  66076. * @param text defines the text of the header
  66077. * @param size defines the size of the header
  66078. * @param options defines options used to configure the header
  66079. * @returns a new StackPanel
  66080. * @ignore
  66081. * @hidden
  66082. */
  66083. static AddHeader: (control: Control, text: string, size: string | number, options: {
  66084. isHorizontal: boolean;
  66085. controlFirst: boolean;
  66086. }) => any;
  66087. /** @hidden */
  66088. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  66089. }
  66090. }
  66091. declare module BABYLON.GUI {
  66092. /**
  66093. * Root class for 2D containers
  66094. * @see http://doc.babylonjs.com/how_to/gui#containers
  66095. */
  66096. export class Container extends Control {
  66097. name?: string | undefined;
  66098. /** @hidden */
  66099. protected _children: Control[];
  66100. /** @hidden */
  66101. protected _measureForChildren: Measure;
  66102. /** @hidden */
  66103. protected _background: string;
  66104. /** @hidden */
  66105. protected _adaptWidthToChildren: boolean;
  66106. /** @hidden */
  66107. protected _adaptHeightToChildren: boolean;
  66108. /**
  66109. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  66110. */
  66111. logLayoutCycleErrors: boolean;
  66112. /**
  66113. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  66114. */
  66115. maxLayoutCycle: number;
  66116. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  66117. adaptHeightToChildren: boolean;
  66118. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  66119. adaptWidthToChildren: boolean;
  66120. /** Gets or sets background color */
  66121. background: string;
  66122. /** Gets the list of children */
  66123. readonly children: Control[];
  66124. /**
  66125. * Creates a new Container
  66126. * @param name defines the name of the container
  66127. */
  66128. constructor(name?: string | undefined);
  66129. protected _getTypeName(): string;
  66130. _flagDescendantsAsMatrixDirty(): void;
  66131. /**
  66132. * Gets a child using its name
  66133. * @param name defines the child name to look for
  66134. * @returns the child control if found
  66135. */
  66136. getChildByName(name: string): BABYLON.Nullable<Control>;
  66137. /**
  66138. * Gets a child using its type and its name
  66139. * @param name defines the child name to look for
  66140. * @param type defines the child type to look for
  66141. * @returns the child control if found
  66142. */
  66143. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  66144. /**
  66145. * Search for a specific control in children
  66146. * @param control defines the control to look for
  66147. * @returns true if the control is in child list
  66148. */
  66149. containsControl(control: Control): boolean;
  66150. /**
  66151. * Adds a new control to the current container
  66152. * @param control defines the control to add
  66153. * @returns the current container
  66154. */
  66155. addControl(control: BABYLON.Nullable<Control>): Container;
  66156. /**
  66157. * Removes all controls from the current container
  66158. * @returns the current container
  66159. */
  66160. clearControls(): Container;
  66161. /**
  66162. * Removes a control from the current container
  66163. * @param control defines the control to remove
  66164. * @returns the current container
  66165. */
  66166. removeControl(control: Control): Container;
  66167. /** @hidden */
  66168. _reOrderControl(control: Control): void;
  66169. /** @hidden */
  66170. _offsetLeft(offset: number): void;
  66171. /** @hidden */
  66172. _offsetTop(offset: number): void;
  66173. /** @hidden */
  66174. _markAllAsDirty(): void;
  66175. /** @hidden */
  66176. protected _localDraw(context: CanvasRenderingContext2D): void;
  66177. /** @hidden */
  66178. _link(host: AdvancedDynamicTexture): void;
  66179. /** @hidden */
  66180. protected _beforeLayout(): void;
  66181. /** @hidden */
  66182. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66183. /** @hidden */
  66184. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  66185. protected _postMeasure(): void;
  66186. /** @hidden */
  66187. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  66188. /** @hidden */
  66189. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  66190. /** @hidden */
  66191. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  66192. /** @hidden */
  66193. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66194. /** Releases associated resources */
  66195. dispose(): void;
  66196. }
  66197. }
  66198. declare module BABYLON.GUI {
  66199. /** Class used to create rectangle container */
  66200. export class Rectangle extends Container {
  66201. name?: string | undefined;
  66202. private _thickness;
  66203. private _cornerRadius;
  66204. /** Gets or sets border thickness */
  66205. thickness: number;
  66206. /** Gets or sets the corner radius angle */
  66207. cornerRadius: number;
  66208. /**
  66209. * Creates a new Rectangle
  66210. * @param name defines the control name
  66211. */
  66212. constructor(name?: string | undefined);
  66213. protected _getTypeName(): string;
  66214. protected _localDraw(context: CanvasRenderingContext2D): void;
  66215. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66216. private _drawRoundedRect;
  66217. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  66218. }
  66219. }
  66220. declare module BABYLON.GUI {
  66221. /**
  66222. * Enum that determines the text-wrapping mode to use.
  66223. */
  66224. export enum TextWrapping {
  66225. /**
  66226. * Clip the text when it's larger than Control.width; this is the default mode.
  66227. */
  66228. Clip = 0,
  66229. /**
  66230. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  66231. */
  66232. WordWrap = 1,
  66233. /**
  66234. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  66235. */
  66236. Ellipsis = 2
  66237. }
  66238. /**
  66239. * Class used to create text block control
  66240. */
  66241. export class TextBlock extends Control {
  66242. /**
  66243. * Defines the name of the control
  66244. */
  66245. name?: string | undefined;
  66246. private _text;
  66247. private _textWrapping;
  66248. private _textHorizontalAlignment;
  66249. private _textVerticalAlignment;
  66250. private _lines;
  66251. private _resizeToFit;
  66252. private _lineSpacing;
  66253. private _outlineWidth;
  66254. private _outlineColor;
  66255. /**
  66256. * An event triggered after the text is changed
  66257. */
  66258. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  66259. /**
  66260. * An event triggered after the text was broken up into lines
  66261. */
  66262. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  66263. /**
  66264. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  66265. */
  66266. readonly lines: any[];
  66267. /**
  66268. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  66269. */
  66270. /**
  66271. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  66272. */
  66273. resizeToFit: boolean;
  66274. /**
  66275. * Gets or sets a boolean indicating if text must be wrapped
  66276. */
  66277. /**
  66278. * Gets or sets a boolean indicating if text must be wrapped
  66279. */
  66280. textWrapping: TextWrapping | boolean;
  66281. /**
  66282. * Gets or sets text to display
  66283. */
  66284. /**
  66285. * Gets or sets text to display
  66286. */
  66287. text: string;
  66288. /**
  66289. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  66290. */
  66291. /**
  66292. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  66293. */
  66294. textHorizontalAlignment: number;
  66295. /**
  66296. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  66297. */
  66298. /**
  66299. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  66300. */
  66301. textVerticalAlignment: number;
  66302. /**
  66303. * Gets or sets line spacing value
  66304. */
  66305. /**
  66306. * Gets or sets line spacing value
  66307. */
  66308. lineSpacing: string | number;
  66309. /**
  66310. * Gets or sets outlineWidth of the text to display
  66311. */
  66312. /**
  66313. * Gets or sets outlineWidth of the text to display
  66314. */
  66315. outlineWidth: number;
  66316. /**
  66317. * Gets or sets outlineColor of the text to display
  66318. */
  66319. /**
  66320. * Gets or sets outlineColor of the text to display
  66321. */
  66322. outlineColor: string;
  66323. /**
  66324. * Creates a new TextBlock object
  66325. * @param name defines the name of the control
  66326. * @param text defines the text to display (emptry string by default)
  66327. */
  66328. constructor(
  66329. /**
  66330. * Defines the name of the control
  66331. */
  66332. name?: string | undefined, text?: string);
  66333. protected _getTypeName(): string;
  66334. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66335. private _drawText;
  66336. /** @hidden */
  66337. _draw(context: CanvasRenderingContext2D): void;
  66338. protected _applyStates(context: CanvasRenderingContext2D): void;
  66339. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  66340. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  66341. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  66342. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  66343. protected _renderLines(context: CanvasRenderingContext2D): void;
  66344. /**
  66345. * Given a width constraint applied on the text block, find the expected height
  66346. * @returns expected height
  66347. */
  66348. computeExpectedHeight(): number;
  66349. dispose(): void;
  66350. }
  66351. }
  66352. declare module BABYLON.GUI {
  66353. /**
  66354. * Class used to create 2D images
  66355. */
  66356. export class Image extends Control {
  66357. name?: string | undefined;
  66358. private _workingCanvas;
  66359. private _domImage;
  66360. private _imageWidth;
  66361. private _imageHeight;
  66362. private _loaded;
  66363. private _stretch;
  66364. private _source;
  66365. private _autoScale;
  66366. private _sourceLeft;
  66367. private _sourceTop;
  66368. private _sourceWidth;
  66369. private _sourceHeight;
  66370. private _cellWidth;
  66371. private _cellHeight;
  66372. private _cellId;
  66373. private _populateNinePatchSlicesFromImage;
  66374. private _sliceLeft;
  66375. private _sliceRight;
  66376. private _sliceTop;
  66377. private _sliceBottom;
  66378. private _detectPointerOnOpaqueOnly;
  66379. /**
  66380. * BABYLON.Observable notified when the content is loaded
  66381. */
  66382. onImageLoadedObservable: BABYLON.Observable<Image>;
  66383. /**
  66384. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  66385. */
  66386. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  66387. /**
  66388. * Gets a boolean indicating that the content is loaded
  66389. */
  66390. readonly isLoaded: boolean;
  66391. /**
  66392. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  66393. */
  66394. populateNinePatchSlicesFromImage: boolean;
  66395. /**
  66396. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  66397. * Beware using this as this will comsume more memory as the image has to be stored twice
  66398. */
  66399. detectPointerOnOpaqueOnly: boolean;
  66400. /**
  66401. * Gets or sets the left value for slicing (9-patch)
  66402. */
  66403. sliceLeft: number;
  66404. /**
  66405. * Gets or sets the right value for slicing (9-patch)
  66406. */
  66407. sliceRight: number;
  66408. /**
  66409. * Gets or sets the top value for slicing (9-patch)
  66410. */
  66411. sliceTop: number;
  66412. /**
  66413. * Gets or sets the bottom value for slicing (9-patch)
  66414. */
  66415. sliceBottom: number;
  66416. /**
  66417. * Gets or sets the left coordinate in the source image
  66418. */
  66419. sourceLeft: number;
  66420. /**
  66421. * Gets or sets the top coordinate in the source image
  66422. */
  66423. sourceTop: number;
  66424. /**
  66425. * Gets or sets the width to capture in the source image
  66426. */
  66427. sourceWidth: number;
  66428. /**
  66429. * Gets or sets the height to capture in the source image
  66430. */
  66431. sourceHeight: number;
  66432. /**
  66433. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  66434. * @see http://doc.babylonjs.com/how_to/gui#image
  66435. */
  66436. autoScale: boolean;
  66437. /** Gets or sets the streching mode used by the image */
  66438. stretch: number;
  66439. /**
  66440. * Gets or sets the internal DOM image used to render the control
  66441. */
  66442. domImage: HTMLImageElement;
  66443. private _onImageLoaded;
  66444. private _extractNinePatchSliceDataFromImage;
  66445. /**
  66446. * Gets or sets image source url
  66447. */
  66448. source: BABYLON.Nullable<string>;
  66449. /**
  66450. * Checks for svg document with icon id present
  66451. */
  66452. private _svgCheck;
  66453. /**
  66454. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  66455. * given external svg file and icon id
  66456. */
  66457. private _getSVGAttribs;
  66458. /**
  66459. * Gets or sets the cell width to use when animation sheet is enabled
  66460. * @see http://doc.babylonjs.com/how_to/gui#image
  66461. */
  66462. cellWidth: number;
  66463. /**
  66464. * Gets or sets the cell height to use when animation sheet is enabled
  66465. * @see http://doc.babylonjs.com/how_to/gui#image
  66466. */
  66467. cellHeight: number;
  66468. /**
  66469. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  66470. * @see http://doc.babylonjs.com/how_to/gui#image
  66471. */
  66472. cellId: number;
  66473. /**
  66474. * Creates a new Image
  66475. * @param name defines the control name
  66476. * @param url defines the image url
  66477. */
  66478. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  66479. /**
  66480. * Tests if a given coordinates belong to the current control
  66481. * @param x defines x coordinate to test
  66482. * @param y defines y coordinate to test
  66483. * @returns true if the coordinates are inside the control
  66484. */
  66485. contains(x: number, y: number): boolean;
  66486. protected _getTypeName(): string;
  66487. /** Force the control to synchronize with its content */
  66488. synchronizeSizeWithContent(): void;
  66489. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66490. private _prepareWorkingCanvasForOpaqueDetection;
  66491. private _drawImage;
  66492. _draw(context: CanvasRenderingContext2D): void;
  66493. private _renderCornerPatch;
  66494. private _renderNinePatch;
  66495. dispose(): void;
  66496. /** STRETCH_NONE */
  66497. static readonly STRETCH_NONE: number;
  66498. /** STRETCH_FILL */
  66499. static readonly STRETCH_FILL: number;
  66500. /** STRETCH_UNIFORM */
  66501. static readonly STRETCH_UNIFORM: number;
  66502. /** STRETCH_EXTEND */
  66503. static readonly STRETCH_EXTEND: number;
  66504. /** NINE_PATCH */
  66505. static readonly STRETCH_NINE_PATCH: number;
  66506. }
  66507. }
  66508. declare module BABYLON.GUI {
  66509. /**
  66510. * Class used to create 2D buttons
  66511. */
  66512. export class Button extends Rectangle {
  66513. name?: string | undefined;
  66514. /**
  66515. * Function called to generate a pointer enter animation
  66516. */
  66517. pointerEnterAnimation: () => void;
  66518. /**
  66519. * Function called to generate a pointer out animation
  66520. */
  66521. pointerOutAnimation: () => void;
  66522. /**
  66523. * Function called to generate a pointer down animation
  66524. */
  66525. pointerDownAnimation: () => void;
  66526. /**
  66527. * Function called to generate a pointer up animation
  66528. */
  66529. pointerUpAnimation: () => void;
  66530. /**
  66531. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  66532. */
  66533. delegatePickingToChildren: boolean;
  66534. private _image;
  66535. /**
  66536. * Returns the image part of the button (if any)
  66537. */
  66538. readonly image: BABYLON.Nullable<Image>;
  66539. private _textBlock;
  66540. /**
  66541. * Returns the image part of the button (if any)
  66542. */
  66543. readonly textBlock: BABYLON.Nullable<TextBlock>;
  66544. /**
  66545. * Creates a new Button
  66546. * @param name defines the name of the button
  66547. */
  66548. constructor(name?: string | undefined);
  66549. protected _getTypeName(): string;
  66550. /** @hidden */
  66551. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  66552. /** @hidden */
  66553. _onPointerEnter(target: Control): boolean;
  66554. /** @hidden */
  66555. _onPointerOut(target: Control, force?: boolean): void;
  66556. /** @hidden */
  66557. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66558. /** @hidden */
  66559. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66560. /**
  66561. * Creates a new button made with an image and a text
  66562. * @param name defines the name of the button
  66563. * @param text defines the text of the button
  66564. * @param imageUrl defines the url of the image
  66565. * @returns a new Button
  66566. */
  66567. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  66568. /**
  66569. * Creates a new button made with an image
  66570. * @param name defines the name of the button
  66571. * @param imageUrl defines the url of the image
  66572. * @returns a new Button
  66573. */
  66574. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  66575. /**
  66576. * Creates a new button made with a text
  66577. * @param name defines the name of the button
  66578. * @param text defines the text of the button
  66579. * @returns a new Button
  66580. */
  66581. static CreateSimpleButton(name: string, text: string): Button;
  66582. /**
  66583. * Creates a new button made with an image and a centered text
  66584. * @param name defines the name of the button
  66585. * @param text defines the text of the button
  66586. * @param imageUrl defines the url of the image
  66587. * @returns a new Button
  66588. */
  66589. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  66590. }
  66591. }
  66592. declare module BABYLON.GUI {
  66593. /**
  66594. * Class used to create a 2D stack panel container
  66595. */
  66596. export class StackPanel extends Container {
  66597. name?: string | undefined;
  66598. private _isVertical;
  66599. private _manualWidth;
  66600. private _manualHeight;
  66601. private _doNotTrackManualChanges;
  66602. /**
  66603. * Gets or sets a boolean indicating that layou warnings should be ignored
  66604. */
  66605. ignoreLayoutWarnings: boolean;
  66606. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  66607. isVertical: boolean;
  66608. /**
  66609. * Gets or sets panel width.
  66610. * This value should not be set when in horizontal mode as it will be computed automatically
  66611. */
  66612. width: string | number;
  66613. /**
  66614. * Gets or sets panel height.
  66615. * This value should not be set when in vertical mode as it will be computed automatically
  66616. */
  66617. height: string | number;
  66618. /**
  66619. * Creates a new StackPanel
  66620. * @param name defines control name
  66621. */
  66622. constructor(name?: string | undefined);
  66623. protected _getTypeName(): string;
  66624. /** @hidden */
  66625. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66626. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66627. protected _postMeasure(): void;
  66628. }
  66629. }
  66630. declare module BABYLON.GUI {
  66631. /**
  66632. * Class used to represent a 2D checkbox
  66633. */
  66634. export class Checkbox extends Control {
  66635. name?: string | undefined;
  66636. private _isChecked;
  66637. private _background;
  66638. private _checkSizeRatio;
  66639. private _thickness;
  66640. /** Gets or sets border thickness */
  66641. thickness: number;
  66642. /**
  66643. * BABYLON.Observable raised when isChecked property changes
  66644. */
  66645. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  66646. /** Gets or sets a value indicating the ratio between overall size and check size */
  66647. checkSizeRatio: number;
  66648. /** Gets or sets background color */
  66649. background: string;
  66650. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  66651. isChecked: boolean;
  66652. /**
  66653. * Creates a new CheckBox
  66654. * @param name defines the control name
  66655. */
  66656. constructor(name?: string | undefined);
  66657. protected _getTypeName(): string;
  66658. /** @hidden */
  66659. _draw(context: CanvasRenderingContext2D): void;
  66660. /** @hidden */
  66661. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66662. /**
  66663. * Utility function to easily create a checkbox with a header
  66664. * @param title defines the label to use for the header
  66665. * @param onValueChanged defines the callback to call when value changes
  66666. * @returns a StackPanel containing the checkbox and a textBlock
  66667. */
  66668. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  66669. }
  66670. }
  66671. declare module BABYLON.GUI {
  66672. /**
  66673. * Class used to store key control properties
  66674. */
  66675. export class KeyPropertySet {
  66676. /** Width */
  66677. width?: string;
  66678. /** Height */
  66679. height?: string;
  66680. /** Left padding */
  66681. paddingLeft?: string;
  66682. /** Right padding */
  66683. paddingRight?: string;
  66684. /** Top padding */
  66685. paddingTop?: string;
  66686. /** Bottom padding */
  66687. paddingBottom?: string;
  66688. /** Foreground color */
  66689. color?: string;
  66690. /** Background color */
  66691. background?: string;
  66692. }
  66693. /**
  66694. * Class used to create virtual keyboard
  66695. */
  66696. export class VirtualKeyboard extends StackPanel {
  66697. /** BABYLON.Observable raised when a key is pressed */
  66698. onKeyPressObservable: BABYLON.Observable<string>;
  66699. /** Gets or sets default key button width */
  66700. defaultButtonWidth: string;
  66701. /** Gets or sets default key button height */
  66702. defaultButtonHeight: string;
  66703. /** Gets or sets default key button left padding */
  66704. defaultButtonPaddingLeft: string;
  66705. /** Gets or sets default key button right padding */
  66706. defaultButtonPaddingRight: string;
  66707. /** Gets or sets default key button top padding */
  66708. defaultButtonPaddingTop: string;
  66709. /** Gets or sets default key button bottom padding */
  66710. defaultButtonPaddingBottom: string;
  66711. /** Gets or sets default key button foreground color */
  66712. defaultButtonColor: string;
  66713. /** Gets or sets default key button background color */
  66714. defaultButtonBackground: string;
  66715. /** Gets or sets shift button foreground color */
  66716. shiftButtonColor: string;
  66717. /** Gets or sets shift button thickness*/
  66718. selectedShiftThickness: number;
  66719. /** Gets shift key state */
  66720. shiftState: number;
  66721. protected _getTypeName(): string;
  66722. private _createKey;
  66723. /**
  66724. * Adds a new row of keys
  66725. * @param keys defines the list of keys to add
  66726. * @param propertySets defines the associated property sets
  66727. */
  66728. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  66729. /**
  66730. * Set the shift key to a specific state
  66731. * @param shiftState defines the new shift state
  66732. */
  66733. applyShiftState(shiftState: number): void;
  66734. private _currentlyConnectedInputText;
  66735. private _connectedInputTexts;
  66736. private _onKeyPressObserver;
  66737. /** Gets the input text control currently attached to the keyboard */
  66738. readonly connectedInputText: BABYLON.Nullable<InputText>;
  66739. /**
  66740. * Connects the keyboard with an input text control
  66741. *
  66742. * @param input defines the target control
  66743. */
  66744. connect(input: InputText): void;
  66745. /**
  66746. * Disconnects the keyboard from connected InputText controls
  66747. *
  66748. * @param input optionally defines a target control, otherwise all are disconnected
  66749. */
  66750. disconnect(input?: InputText): void;
  66751. private _removeConnectedInputObservables;
  66752. /**
  66753. * Release all resources
  66754. */
  66755. dispose(): void;
  66756. /**
  66757. * Creates a new keyboard using a default layout
  66758. *
  66759. * @param name defines control name
  66760. * @returns a new VirtualKeyboard
  66761. */
  66762. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  66763. }
  66764. }
  66765. declare module BABYLON.GUI {
  66766. /**
  66767. * Class used to create input text control
  66768. */
  66769. export class InputText extends Control implements IFocusableControl {
  66770. name?: string | undefined;
  66771. private _text;
  66772. private _placeholderText;
  66773. private _background;
  66774. private _focusedBackground;
  66775. private _focusedColor;
  66776. private _placeholderColor;
  66777. private _thickness;
  66778. private _margin;
  66779. private _autoStretchWidth;
  66780. private _maxWidth;
  66781. private _isFocused;
  66782. private _blinkTimeout;
  66783. private _blinkIsEven;
  66784. private _cursorOffset;
  66785. private _scrollLeft;
  66786. private _textWidth;
  66787. private _clickedCoordinate;
  66788. private _deadKey;
  66789. private _addKey;
  66790. private _currentKey;
  66791. private _isTextHighlightOn;
  66792. private _textHighlightColor;
  66793. private _highligherOpacity;
  66794. private _highlightedText;
  66795. private _startHighlightIndex;
  66796. private _endHighlightIndex;
  66797. private _cursorIndex;
  66798. private _onFocusSelectAll;
  66799. private _isPointerDown;
  66800. private _onClipboardObserver;
  66801. private _onPointerDblTapObserver;
  66802. /** @hidden */
  66803. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  66804. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  66805. promptMessage: string;
  66806. /** Force disable prompt on mobile device */
  66807. disableMobilePrompt: boolean;
  66808. /** BABYLON.Observable raised when the text changes */
  66809. onTextChangedObservable: BABYLON.Observable<InputText>;
  66810. /** BABYLON.Observable raised just before an entered character is to be added */
  66811. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  66812. /** BABYLON.Observable raised when the control gets the focus */
  66813. onFocusObservable: BABYLON.Observable<InputText>;
  66814. /** BABYLON.Observable raised when the control loses the focus */
  66815. onBlurObservable: BABYLON.Observable<InputText>;
  66816. /**Observable raised when the text is highlighted */
  66817. onTextHighlightObservable: BABYLON.Observable<InputText>;
  66818. /**Observable raised when copy event is triggered */
  66819. onTextCopyObservable: BABYLON.Observable<InputText>;
  66820. /** BABYLON.Observable raised when cut event is triggered */
  66821. onTextCutObservable: BABYLON.Observable<InputText>;
  66822. /** BABYLON.Observable raised when paste event is triggered */
  66823. onTextPasteObservable: BABYLON.Observable<InputText>;
  66824. /** BABYLON.Observable raised when a key event was processed */
  66825. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  66826. /** Gets or sets the maximum width allowed by the control */
  66827. maxWidth: string | number;
  66828. /** Gets the maximum width allowed by the control in pixels */
  66829. readonly maxWidthInPixels: number;
  66830. /** Gets or sets the text highlighter transparency; default: 0.4 */
  66831. highligherOpacity: number;
  66832. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  66833. onFocusSelectAll: boolean;
  66834. /** Gets or sets the text hightlight color */
  66835. textHighlightColor: string;
  66836. /** Gets or sets control margin */
  66837. margin: string;
  66838. /** Gets control margin in pixels */
  66839. readonly marginInPixels: number;
  66840. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  66841. autoStretchWidth: boolean;
  66842. /** Gets or sets border thickness */
  66843. thickness: number;
  66844. /** Gets or sets the background color when focused */
  66845. focusedBackground: string;
  66846. /** Gets or sets the background color when focused */
  66847. focusedColor: string;
  66848. /** Gets or sets the background color */
  66849. background: string;
  66850. /** Gets or sets the placeholder color */
  66851. placeholderColor: string;
  66852. /** Gets or sets the text displayed when the control is empty */
  66853. placeholderText: string;
  66854. /** Gets or sets the dead key flag */
  66855. deadKey: boolean;
  66856. /** Gets or sets the highlight text */
  66857. highlightedText: string;
  66858. /** Gets or sets if the current key should be added */
  66859. addKey: boolean;
  66860. /** Gets or sets the value of the current key being entered */
  66861. currentKey: string;
  66862. /** Gets or sets the text displayed in the control */
  66863. text: string;
  66864. /** Gets or sets control width */
  66865. width: string | number;
  66866. /**
  66867. * Creates a new InputText
  66868. * @param name defines the control name
  66869. * @param text defines the text of the control
  66870. */
  66871. constructor(name?: string | undefined, text?: string);
  66872. /** @hidden */
  66873. onBlur(): void;
  66874. /** @hidden */
  66875. onFocus(): void;
  66876. protected _getTypeName(): string;
  66877. /**
  66878. * Function called to get the list of controls that should not steal the focus from this control
  66879. * @returns an array of controls
  66880. */
  66881. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  66882. /** @hidden */
  66883. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  66884. /** @hidden */
  66885. private _updateValueFromCursorIndex;
  66886. /** @hidden */
  66887. private _processDblClick;
  66888. /** @hidden */
  66889. private _selectAllText;
  66890. /**
  66891. * Handles the keyboard event
  66892. * @param evt Defines the KeyboardEvent
  66893. */
  66894. processKeyboard(evt: KeyboardEvent): void;
  66895. /** @hidden */
  66896. private _onCopyText;
  66897. /** @hidden */
  66898. private _onCutText;
  66899. /** @hidden */
  66900. private _onPasteText;
  66901. _draw(context: CanvasRenderingContext2D): void;
  66902. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66903. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66904. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66905. protected _beforeRenderText(text: string): string;
  66906. dispose(): void;
  66907. }
  66908. }
  66909. declare module BABYLON.GUI {
  66910. /**
  66911. * Class used to create a 2D grid container
  66912. */
  66913. export class Grid extends Container {
  66914. name?: string | undefined;
  66915. private _rowDefinitions;
  66916. private _columnDefinitions;
  66917. private _cells;
  66918. private _childControls;
  66919. /**
  66920. * Gets the number of columns
  66921. */
  66922. readonly columnCount: number;
  66923. /**
  66924. * Gets the number of rows
  66925. */
  66926. readonly rowCount: number;
  66927. /** Gets the list of children */
  66928. readonly children: Control[];
  66929. /** Gets the list of cells (e.g. the containers) */
  66930. readonly cells: {
  66931. [key: string]: Container;
  66932. };
  66933. /**
  66934. * Gets the definition of a specific row
  66935. * @param index defines the index of the row
  66936. * @returns the row definition
  66937. */
  66938. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66939. /**
  66940. * Gets the definition of a specific column
  66941. * @param index defines the index of the column
  66942. * @returns the column definition
  66943. */
  66944. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66945. /**
  66946. * Adds a new row to the grid
  66947. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66948. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  66949. * @returns the current grid
  66950. */
  66951. addRowDefinition(height: number, isPixel?: boolean): Grid;
  66952. /**
  66953. * Adds a new column to the grid
  66954. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66955. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66956. * @returns the current grid
  66957. */
  66958. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  66959. /**
  66960. * Update a row definition
  66961. * @param index defines the index of the row to update
  66962. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66963. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  66964. * @returns the current grid
  66965. */
  66966. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  66967. /**
  66968. * Update a column definition
  66969. * @param index defines the index of the column to update
  66970. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66971. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66972. * @returns the current grid
  66973. */
  66974. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  66975. /**
  66976. * Gets the list of children stored in a specific cell
  66977. * @param row defines the row to check
  66978. * @param column defines the column to check
  66979. * @returns the list of controls
  66980. */
  66981. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  66982. /**
  66983. * Gets a string representing the child cell info (row x column)
  66984. * @param child defines the control to get info from
  66985. * @returns a string containing the child cell info (row x column)
  66986. */
  66987. getChildCellInfo(child: Control): string;
  66988. private _removeCell;
  66989. private _offsetCell;
  66990. /**
  66991. * Remove a column definition at specified index
  66992. * @param index defines the index of the column to remove
  66993. * @returns the current grid
  66994. */
  66995. removeColumnDefinition(index: number): Grid;
  66996. /**
  66997. * Remove a row definition at specified index
  66998. * @param index defines the index of the row to remove
  66999. * @returns the current grid
  67000. */
  67001. removeRowDefinition(index: number): Grid;
  67002. /**
  67003. * Adds a new control to the current grid
  67004. * @param control defines the control to add
  67005. * @param row defines the row where to add the control (0 by default)
  67006. * @param column defines the column where to add the control (0 by default)
  67007. * @returns the current grid
  67008. */
  67009. addControl(control: Control, row?: number, column?: number): Grid;
  67010. /**
  67011. * Removes a control from the current container
  67012. * @param control defines the control to remove
  67013. * @returns the current container
  67014. */
  67015. removeControl(control: Control): Container;
  67016. /**
  67017. * Creates a new Grid
  67018. * @param name defines control name
  67019. */
  67020. constructor(name?: string | undefined);
  67021. protected _getTypeName(): string;
  67022. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  67023. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67024. _flagDescendantsAsMatrixDirty(): void;
  67025. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67026. /** Releases associated resources */
  67027. dispose(): void;
  67028. }
  67029. }
  67030. declare module BABYLON.GUI {
  67031. /** Class used to create color pickers */
  67032. export class ColorPicker extends Control {
  67033. name?: string | undefined;
  67034. private static _Epsilon;
  67035. private _colorWheelCanvas;
  67036. private _value;
  67037. private _tmpColor;
  67038. private _pointerStartedOnSquare;
  67039. private _pointerStartedOnWheel;
  67040. private _squareLeft;
  67041. private _squareTop;
  67042. private _squareSize;
  67043. private _h;
  67044. private _s;
  67045. private _v;
  67046. private _lastPointerDownID;
  67047. /**
  67048. * BABYLON.Observable raised when the value changes
  67049. */
  67050. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  67051. /** Gets or sets the color of the color picker */
  67052. value: BABYLON.Color3;
  67053. /**
  67054. * Gets or sets control width
  67055. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67056. */
  67057. width: string | number;
  67058. /**
  67059. * Gets or sets control height
  67060. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67061. */
  67062. /** Gets or sets control height */
  67063. height: string | number;
  67064. /** Gets or sets control size */
  67065. size: string | number;
  67066. /**
  67067. * Creates a new ColorPicker
  67068. * @param name defines the control name
  67069. */
  67070. constructor(name?: string | undefined);
  67071. protected _getTypeName(): string;
  67072. /** @hidden */
  67073. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67074. private _updateSquareProps;
  67075. private _drawGradientSquare;
  67076. private _drawCircle;
  67077. private _createColorWheelCanvas;
  67078. /** @hidden */
  67079. _draw(context: CanvasRenderingContext2D): void;
  67080. private _pointerIsDown;
  67081. private _updateValueFromPointer;
  67082. private _isPointOnSquare;
  67083. private _isPointOnWheel;
  67084. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67085. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67086. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67087. /**
  67088. * This function expands the color picker by creating a color picker dialog with manual
  67089. * color value input and the ability to save colors into an array to be used later in
  67090. * subsequent launches of the dialogue.
  67091. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  67092. * @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.
  67093. * @returns picked color as a hex string and the saved colors array as hex strings.
  67094. */
  67095. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  67096. pickerWidth?: string;
  67097. pickerHeight?: string;
  67098. headerHeight?: string;
  67099. lastColor?: string;
  67100. swatchLimit?: number;
  67101. numSwatchesPerLine?: number;
  67102. savedColors?: Array<string>;
  67103. }): Promise<{
  67104. savedColors?: string[];
  67105. pickedColor: string;
  67106. }>;
  67107. }
  67108. }
  67109. declare module BABYLON.GUI {
  67110. /** Class used to create 2D ellipse containers */
  67111. export class Ellipse extends Container {
  67112. name?: string | undefined;
  67113. private _thickness;
  67114. /** Gets or sets border thickness */
  67115. thickness: number;
  67116. /**
  67117. * Creates a new Ellipse
  67118. * @param name defines the control name
  67119. */
  67120. constructor(name?: string | undefined);
  67121. protected _getTypeName(): string;
  67122. protected _localDraw(context: CanvasRenderingContext2D): void;
  67123. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67124. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  67125. }
  67126. }
  67127. declare module BABYLON.GUI {
  67128. /**
  67129. * Class used to create a password control
  67130. */
  67131. export class InputPassword extends InputText {
  67132. protected _beforeRenderText(text: string): string;
  67133. }
  67134. }
  67135. declare module BABYLON.GUI {
  67136. /** Class used to render 2D lines */
  67137. export class Line extends Control {
  67138. name?: string | undefined;
  67139. private _lineWidth;
  67140. private _x1;
  67141. private _y1;
  67142. private _x2;
  67143. private _y2;
  67144. private _dash;
  67145. private _connectedControl;
  67146. private _connectedControlDirtyObserver;
  67147. /** Gets or sets the dash pattern */
  67148. dash: Array<number>;
  67149. /** Gets or sets the control connected with the line end */
  67150. connectedControl: Control;
  67151. /** Gets or sets start coordinates on X axis */
  67152. x1: string | number;
  67153. /** Gets or sets start coordinates on Y axis */
  67154. y1: string | number;
  67155. /** Gets or sets end coordinates on X axis */
  67156. x2: string | number;
  67157. /** Gets or sets end coordinates on Y axis */
  67158. y2: string | number;
  67159. /** Gets or sets line width */
  67160. lineWidth: number;
  67161. /** Gets or sets horizontal alignment */
  67162. horizontalAlignment: number;
  67163. /** Gets or sets vertical alignment */
  67164. verticalAlignment: number;
  67165. private readonly _effectiveX2;
  67166. private readonly _effectiveY2;
  67167. /**
  67168. * Creates a new Line
  67169. * @param name defines the control name
  67170. */
  67171. constructor(name?: string | undefined);
  67172. protected _getTypeName(): string;
  67173. _draw(context: CanvasRenderingContext2D): void;
  67174. _measure(): void;
  67175. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67176. /**
  67177. * Move one end of the line given 3D cartesian coordinates.
  67178. * @param position Targeted world position
  67179. * @param scene BABYLON.Scene
  67180. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  67181. */
  67182. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  67183. /**
  67184. * Move one end of the line to a position in screen absolute space.
  67185. * @param projectedPosition Position in screen absolute space (X, Y)
  67186. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  67187. */
  67188. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  67189. }
  67190. }
  67191. declare module BABYLON.GUI {
  67192. /**
  67193. * Class used to store a point for a MultiLine object.
  67194. * The point can be pure 2D coordinates, a mesh or a control
  67195. */
  67196. export class MultiLinePoint {
  67197. private _multiLine;
  67198. private _x;
  67199. private _y;
  67200. private _control;
  67201. private _mesh;
  67202. private _controlObserver;
  67203. private _meshObserver;
  67204. /** @hidden */
  67205. _point: BABYLON.Vector2;
  67206. /**
  67207. * Creates a new MultiLinePoint
  67208. * @param multiLine defines the source MultiLine object
  67209. */
  67210. constructor(multiLine: MultiLine);
  67211. /** Gets or sets x coordinate */
  67212. x: string | number;
  67213. /** Gets or sets y coordinate */
  67214. y: string | number;
  67215. /** Gets or sets the control associated with this point */
  67216. control: BABYLON.Nullable<Control>;
  67217. /** Gets or sets the mesh associated with this point */
  67218. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67219. /** Resets links */
  67220. resetLinks(): void;
  67221. /**
  67222. * Gets a translation vector
  67223. * @returns the translation vector
  67224. */
  67225. translate(): BABYLON.Vector2;
  67226. private _translatePoint;
  67227. /** Release associated resources */
  67228. dispose(): void;
  67229. }
  67230. }
  67231. declare module BABYLON.GUI {
  67232. /**
  67233. * Class used to create multi line control
  67234. */
  67235. export class MultiLine extends Control {
  67236. name?: string | undefined;
  67237. private _lineWidth;
  67238. private _dash;
  67239. private _points;
  67240. private _minX;
  67241. private _minY;
  67242. private _maxX;
  67243. private _maxY;
  67244. /**
  67245. * Creates a new MultiLine
  67246. * @param name defines the control name
  67247. */
  67248. constructor(name?: string | undefined);
  67249. /** Gets or sets dash pattern */
  67250. dash: Array<number>;
  67251. /**
  67252. * Gets point stored at specified index
  67253. * @param index defines the index to look for
  67254. * @returns the requested point if found
  67255. */
  67256. getAt(index: number): MultiLinePoint;
  67257. /** Function called when a point is updated */
  67258. onPointUpdate: () => void;
  67259. /**
  67260. * Adds new points to the point collection
  67261. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  67262. * @returns the list of created MultiLinePoint
  67263. */
  67264. add(...items: (AbstractMesh | Control | {
  67265. x: string | number;
  67266. y: string | number;
  67267. })[]): MultiLinePoint[];
  67268. /**
  67269. * Adds a new point to the point collection
  67270. * @param item defines the item (mesh, control or 2d coordiantes) to add
  67271. * @returns the created MultiLinePoint
  67272. */
  67273. push(item?: (AbstractMesh | Control | {
  67274. x: string | number;
  67275. y: string | number;
  67276. })): MultiLinePoint;
  67277. /**
  67278. * Remove a specific value or point from the active point collection
  67279. * @param value defines the value or point to remove
  67280. */
  67281. remove(value: number | MultiLinePoint): void;
  67282. /**
  67283. * Resets this object to initial state (no point)
  67284. */
  67285. reset(): void;
  67286. /**
  67287. * Resets all links
  67288. */
  67289. resetLinks(): void;
  67290. /** Gets or sets line width */
  67291. lineWidth: number;
  67292. horizontalAlignment: number;
  67293. verticalAlignment: number;
  67294. protected _getTypeName(): string;
  67295. _draw(context: CanvasRenderingContext2D): void;
  67296. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67297. _measure(): void;
  67298. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67299. dispose(): void;
  67300. }
  67301. }
  67302. declare module BABYLON.GUI {
  67303. /**
  67304. * Class used to create radio button controls
  67305. */
  67306. export class RadioButton extends Control {
  67307. name?: string | undefined;
  67308. private _isChecked;
  67309. private _background;
  67310. private _checkSizeRatio;
  67311. private _thickness;
  67312. /** Gets or sets border thickness */
  67313. thickness: number;
  67314. /** Gets or sets group name */
  67315. group: string;
  67316. /** BABYLON.Observable raised when isChecked is changed */
  67317. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  67318. /** Gets or sets a value indicating the ratio between overall size and check size */
  67319. checkSizeRatio: number;
  67320. /** Gets or sets background color */
  67321. background: string;
  67322. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  67323. isChecked: boolean;
  67324. /**
  67325. * Creates a new RadioButton
  67326. * @param name defines the control name
  67327. */
  67328. constructor(name?: string | undefined);
  67329. protected _getTypeName(): string;
  67330. _draw(context: CanvasRenderingContext2D): void;
  67331. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67332. /**
  67333. * Utility function to easily create a radio button with a header
  67334. * @param title defines the label to use for the header
  67335. * @param group defines the group to use for the radio button
  67336. * @param isChecked defines the initial state of the radio button
  67337. * @param onValueChanged defines the callback to call when value changes
  67338. * @returns a StackPanel containing the radio button and a textBlock
  67339. */
  67340. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  67341. }
  67342. }
  67343. declare module BABYLON.GUI {
  67344. /**
  67345. * Class used to create slider controls
  67346. */
  67347. export class BaseSlider extends Control {
  67348. name?: string | undefined;
  67349. protected _thumbWidth: ValueAndUnit;
  67350. private _minimum;
  67351. private _maximum;
  67352. private _value;
  67353. private _isVertical;
  67354. protected _barOffset: ValueAndUnit;
  67355. private _isThumbClamped;
  67356. protected _displayThumb: boolean;
  67357. private _step;
  67358. private _lastPointerDownID;
  67359. protected _effectiveBarOffset: number;
  67360. protected _renderLeft: number;
  67361. protected _renderTop: number;
  67362. protected _renderWidth: number;
  67363. protected _renderHeight: number;
  67364. protected _backgroundBoxLength: number;
  67365. protected _backgroundBoxThickness: number;
  67366. protected _effectiveThumbThickness: number;
  67367. /** BABYLON.Observable raised when the sldier value changes */
  67368. onValueChangedObservable: BABYLON.Observable<number>;
  67369. /** Gets or sets a boolean indicating if the thumb must be rendered */
  67370. displayThumb: boolean;
  67371. /** Gets or sets a step to apply to values (0 by default) */
  67372. step: number;
  67373. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  67374. barOffset: string | number;
  67375. /** Gets main bar offset in pixels*/
  67376. readonly barOffsetInPixels: number;
  67377. /** Gets or sets thumb width */
  67378. thumbWidth: string | number;
  67379. /** Gets thumb width in pixels */
  67380. readonly thumbWidthInPixels: number;
  67381. /** Gets or sets minimum value */
  67382. minimum: number;
  67383. /** Gets or sets maximum value */
  67384. maximum: number;
  67385. /** Gets or sets current value */
  67386. value: number;
  67387. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  67388. isVertical: boolean;
  67389. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  67390. isThumbClamped: boolean;
  67391. /**
  67392. * Creates a new BaseSlider
  67393. * @param name defines the control name
  67394. */
  67395. constructor(name?: string | undefined);
  67396. protected _getTypeName(): string;
  67397. protected _getThumbPosition(): number;
  67398. protected _getThumbThickness(type: string): number;
  67399. protected _prepareRenderingData(type: string): void;
  67400. private _pointerIsDown;
  67401. /** @hidden */
  67402. protected _updateValueFromPointer(x: number, y: number): void;
  67403. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67404. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67405. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67406. }
  67407. }
  67408. declare module BABYLON.GUI {
  67409. /**
  67410. * Class used to create slider controls
  67411. */
  67412. export class Slider extends BaseSlider {
  67413. name?: string | undefined;
  67414. private _background;
  67415. private _borderColor;
  67416. private _isThumbCircle;
  67417. protected _displayValueBar: boolean;
  67418. /** Gets or sets a boolean indicating if the value bar must be rendered */
  67419. displayValueBar: boolean;
  67420. /** Gets or sets border color */
  67421. borderColor: string;
  67422. /** Gets or sets background color */
  67423. background: string;
  67424. /** Gets or sets a boolean indicating if the thumb should be round or square */
  67425. isThumbCircle: boolean;
  67426. /**
  67427. * Creates a new Slider
  67428. * @param name defines the control name
  67429. */
  67430. constructor(name?: string | undefined);
  67431. protected _getTypeName(): string;
  67432. _draw(context: CanvasRenderingContext2D): void;
  67433. }
  67434. }
  67435. declare module BABYLON.GUI {
  67436. /** Class used to create a RadioGroup
  67437. * which contains groups of radio buttons
  67438. */
  67439. export class SelectorGroup {
  67440. /** name of SelectorGroup */
  67441. name: string;
  67442. private _groupPanel;
  67443. private _selectors;
  67444. private _groupHeader;
  67445. /**
  67446. * Creates a new SelectorGroup
  67447. * @param name of group, used as a group heading
  67448. */
  67449. constructor(
  67450. /** name of SelectorGroup */
  67451. name: string);
  67452. /** Gets the groupPanel of the SelectorGroup */
  67453. readonly groupPanel: StackPanel;
  67454. /** Gets the selectors array */
  67455. readonly selectors: StackPanel[];
  67456. /** Gets and sets the group header */
  67457. header: string;
  67458. /** @hidden */
  67459. private _addGroupHeader;
  67460. /** @hidden*/
  67461. _getSelector(selectorNb: number): StackPanel | undefined;
  67462. /** Removes the selector at the given position
  67463. * @param selectorNb the position of the selector within the group
  67464. */
  67465. removeSelector(selectorNb: number): void;
  67466. }
  67467. /** Class used to create a CheckboxGroup
  67468. * which contains groups of checkbox buttons
  67469. */
  67470. export class CheckboxGroup extends SelectorGroup {
  67471. /** Adds a checkbox as a control
  67472. * @param text is the label for the selector
  67473. * @param func is the function called when the Selector is checked
  67474. * @param checked is true when Selector is checked
  67475. */
  67476. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  67477. /** @hidden */
  67478. _setSelectorLabel(selectorNb: number, label: string): void;
  67479. /** @hidden */
  67480. _setSelectorLabelColor(selectorNb: number, color: string): void;
  67481. /** @hidden */
  67482. _setSelectorButtonColor(selectorNb: number, color: string): void;
  67483. /** @hidden */
  67484. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  67485. }
  67486. /** Class used to create a RadioGroup
  67487. * which contains groups of radio buttons
  67488. */
  67489. export class RadioGroup extends SelectorGroup {
  67490. private _selectNb;
  67491. /** Adds a radio button as a control
  67492. * @param label is the label for the selector
  67493. * @param func is the function called when the Selector is checked
  67494. * @param checked is true when Selector is checked
  67495. */
  67496. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  67497. /** @hidden */
  67498. _setSelectorLabel(selectorNb: number, label: string): void;
  67499. /** @hidden */
  67500. _setSelectorLabelColor(selectorNb: number, color: string): void;
  67501. /** @hidden */
  67502. _setSelectorButtonColor(selectorNb: number, color: string): void;
  67503. /** @hidden */
  67504. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  67505. }
  67506. /** Class used to create a SliderGroup
  67507. * which contains groups of slider buttons
  67508. */
  67509. export class SliderGroup extends SelectorGroup {
  67510. /**
  67511. * Adds a slider to the SelectorGroup
  67512. * @param label is the label for the SliderBar
  67513. * @param func is the function called when the Slider moves
  67514. * @param unit is a string describing the units used, eg degrees or metres
  67515. * @param min is the minimum value for the Slider
  67516. * @param max is the maximum value for the Slider
  67517. * @param value is the start value for the Slider between min and max
  67518. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  67519. */
  67520. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  67521. /** @hidden */
  67522. _setSelectorLabel(selectorNb: number, label: string): void;
  67523. /** @hidden */
  67524. _setSelectorLabelColor(selectorNb: number, color: string): void;
  67525. /** @hidden */
  67526. _setSelectorButtonColor(selectorNb: number, color: string): void;
  67527. /** @hidden */
  67528. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  67529. }
  67530. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  67531. * @see http://doc.babylonjs.com/how_to/selector
  67532. */
  67533. export class SelectionPanel extends Rectangle {
  67534. /** name of SelectionPanel */
  67535. name: string;
  67536. /** an array of SelectionGroups */
  67537. groups: SelectorGroup[];
  67538. private _panel;
  67539. private _buttonColor;
  67540. private _buttonBackground;
  67541. private _headerColor;
  67542. private _barColor;
  67543. private _barHeight;
  67544. private _spacerHeight;
  67545. private _labelColor;
  67546. private _groups;
  67547. private _bars;
  67548. /**
  67549. * Creates a new SelectionPanel
  67550. * @param name of SelectionPanel
  67551. * @param groups is an array of SelectionGroups
  67552. */
  67553. constructor(
  67554. /** name of SelectionPanel */
  67555. name: string,
  67556. /** an array of SelectionGroups */
  67557. groups?: SelectorGroup[]);
  67558. protected _getTypeName(): string;
  67559. /** Gets or sets the headerColor */
  67560. headerColor: string;
  67561. private _setHeaderColor;
  67562. /** Gets or sets the button color */
  67563. buttonColor: string;
  67564. private _setbuttonColor;
  67565. /** Gets or sets the label color */
  67566. labelColor: string;
  67567. private _setLabelColor;
  67568. /** Gets or sets the button background */
  67569. buttonBackground: string;
  67570. private _setButtonBackground;
  67571. /** Gets or sets the color of separator bar */
  67572. barColor: string;
  67573. private _setBarColor;
  67574. /** Gets or sets the height of separator bar */
  67575. barHeight: string;
  67576. private _setBarHeight;
  67577. /** Gets or sets the height of spacers*/
  67578. spacerHeight: string;
  67579. private _setSpacerHeight;
  67580. /** Adds a bar between groups */
  67581. private _addSpacer;
  67582. /** Add a group to the selection panel
  67583. * @param group is the selector group to add
  67584. */
  67585. addGroup(group: SelectorGroup): void;
  67586. /** Remove the group from the given position
  67587. * @param groupNb is the position of the group in the list
  67588. */
  67589. removeGroup(groupNb: number): void;
  67590. /** Change a group header label
  67591. * @param label is the new group header label
  67592. * @param groupNb is the number of the group to relabel
  67593. * */
  67594. setHeaderName(label: string, groupNb: number): void;
  67595. /** Change selector label to the one given
  67596. * @param label is the new selector label
  67597. * @param groupNb is the number of the groupcontaining the selector
  67598. * @param selectorNb is the number of the selector within a group to relabel
  67599. * */
  67600. relabel(label: string, groupNb: number, selectorNb: number): void;
  67601. /** For a given group position remove the selector at the given position
  67602. * @param groupNb is the number of the group to remove the selector from
  67603. * @param selectorNb is the number of the selector within the group
  67604. */
  67605. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  67606. /** For a given group position of correct type add a checkbox button
  67607. * @param groupNb is the number of the group to remove the selector from
  67608. * @param label is the label for the selector
  67609. * @param func is the function called when the Selector is checked
  67610. * @param checked is true when Selector is checked
  67611. */
  67612. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  67613. /** For a given group position of correct type add a radio button
  67614. * @param groupNb is the number of the group to remove the selector from
  67615. * @param label is the label for the selector
  67616. * @param func is the function called when the Selector is checked
  67617. * @param checked is true when Selector is checked
  67618. */
  67619. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  67620. /**
  67621. * For a given slider group add a slider
  67622. * @param groupNb is the number of the group to add the slider to
  67623. * @param label is the label for the Slider
  67624. * @param func is the function called when the Slider moves
  67625. * @param unit is a string describing the units used, eg degrees or metres
  67626. * @param min is the minimum value for the Slider
  67627. * @param max is the maximum value for the Slider
  67628. * @param value is the start value for the Slider between min and max
  67629. * @param onVal is the function used to format the value displayed, eg radians to degrees
  67630. */
  67631. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  67632. }
  67633. }
  67634. declare module BABYLON.GUI {
  67635. /**
  67636. * Class used to hold a the container for ScrollViewer
  67637. * @hidden
  67638. */
  67639. export class _ScrollViewerWindow extends Container {
  67640. parentClientWidth: number;
  67641. parentClientHeight: number;
  67642. /**
  67643. * Creates a new ScrollViewerWindow
  67644. * @param name of ScrollViewerWindow
  67645. */
  67646. constructor(name?: string);
  67647. protected _getTypeName(): string;
  67648. /** @hidden */
  67649. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67650. protected _postMeasure(): void;
  67651. }
  67652. }
  67653. declare module BABYLON.GUI {
  67654. /**
  67655. * Class used to create slider controls
  67656. */
  67657. export class ScrollBar extends BaseSlider {
  67658. name?: string | undefined;
  67659. private _background;
  67660. private _borderColor;
  67661. private _thumbMeasure;
  67662. /** Gets or sets border color */
  67663. borderColor: string;
  67664. /** Gets or sets background color */
  67665. background: string;
  67666. /**
  67667. * Creates a new Slider
  67668. * @param name defines the control name
  67669. */
  67670. constructor(name?: string | undefined);
  67671. protected _getTypeName(): string;
  67672. protected _getThumbThickness(): number;
  67673. _draw(context: CanvasRenderingContext2D): void;
  67674. private _first;
  67675. private _originX;
  67676. private _originY;
  67677. /** @hidden */
  67678. protected _updateValueFromPointer(x: number, y: number): void;
  67679. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67680. }
  67681. }
  67682. declare module BABYLON.GUI {
  67683. /**
  67684. * Class used to hold a viewer window and sliders in a grid
  67685. */
  67686. export class ScrollViewer extends Rectangle {
  67687. private _grid;
  67688. private _horizontalBarSpace;
  67689. private _verticalBarSpace;
  67690. private _dragSpace;
  67691. private _horizontalBar;
  67692. private _verticalBar;
  67693. private _barColor;
  67694. private _barBackground;
  67695. private _barSize;
  67696. private _endLeft;
  67697. private _endTop;
  67698. private _window;
  67699. private _pointerIsOver;
  67700. private _wheelPrecision;
  67701. private _onPointerObserver;
  67702. private _clientWidth;
  67703. private _clientHeight;
  67704. /**
  67705. * Gets the horizontal scrollbar
  67706. */
  67707. readonly horizontalBar: ScrollBar;
  67708. /**
  67709. * Gets the vertical scrollbar
  67710. */
  67711. readonly verticalBar: ScrollBar;
  67712. /**
  67713. * Adds a new control to the current container
  67714. * @param control defines the control to add
  67715. * @returns the current container
  67716. */
  67717. addControl(control: BABYLON.Nullable<Control>): Container;
  67718. /**
  67719. * Removes a control from the current container
  67720. * @param control defines the control to remove
  67721. * @returns the current container
  67722. */
  67723. removeControl(control: Control): Container;
  67724. /** Gets the list of children */
  67725. readonly children: Control[];
  67726. _flagDescendantsAsMatrixDirty(): void;
  67727. /**
  67728. * Creates a new ScrollViewer
  67729. * @param name of ScrollViewer
  67730. */
  67731. constructor(name?: string);
  67732. /** Reset the scroll viewer window to initial size */
  67733. resetWindow(): void;
  67734. protected _getTypeName(): string;
  67735. private _buildClientSizes;
  67736. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67737. protected _postMeasure(): void;
  67738. /**
  67739. * Gets or sets the mouse wheel precision
  67740. * from 0 to 1 with a default value of 0.05
  67741. * */
  67742. wheelPrecision: number;
  67743. /** Gets or sets the bar color */
  67744. barColor: string;
  67745. /** Gets or sets the size of the bar */
  67746. barSize: number;
  67747. /** Gets or sets the bar background */
  67748. barBackground: string;
  67749. /** @hidden */
  67750. private _updateScroller;
  67751. _link(host: AdvancedDynamicTexture): void;
  67752. /** @hidden */
  67753. private _attachWheel;
  67754. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67755. /** Releases associated resources */
  67756. dispose(): void;
  67757. }
  67758. }
  67759. declare module BABYLON.GUI {
  67760. /** Class used to render a grid */
  67761. export class DisplayGrid extends Control {
  67762. name?: string | undefined;
  67763. private _cellWidth;
  67764. private _cellHeight;
  67765. private _minorLineTickness;
  67766. private _minorLineColor;
  67767. private _majorLineTickness;
  67768. private _majorLineColor;
  67769. private _majorLineFrequency;
  67770. private _background;
  67771. private _displayMajorLines;
  67772. private _displayMinorLines;
  67773. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  67774. displayMinorLines: boolean;
  67775. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  67776. displayMajorLines: boolean;
  67777. /** Gets or sets background color (Black by default) */
  67778. background: string;
  67779. /** Gets or sets the width of each cell (20 by default) */
  67780. cellWidth: number;
  67781. /** Gets or sets the height of each cell (20 by default) */
  67782. cellHeight: number;
  67783. /** Gets or sets the tickness of minor lines (1 by default) */
  67784. minorLineTickness: number;
  67785. /** Gets or sets the color of minor lines (DarkGray by default) */
  67786. minorLineColor: string;
  67787. /** Gets or sets the tickness of major lines (2 by default) */
  67788. majorLineTickness: number;
  67789. /** Gets or sets the color of major lines (White by default) */
  67790. majorLineColor: string;
  67791. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  67792. majorLineFrequency: number;
  67793. /**
  67794. * Creates a new GridDisplayRectangle
  67795. * @param name defines the control name
  67796. */
  67797. constructor(name?: string | undefined);
  67798. _draw(context: CanvasRenderingContext2D): void;
  67799. protected _getTypeName(): string;
  67800. }
  67801. }
  67802. declare module BABYLON.GUI {
  67803. /**
  67804. * Class used to create slider controls based on images
  67805. */
  67806. export class ImageBasedSlider extends BaseSlider {
  67807. name?: string | undefined;
  67808. private _backgroundImage;
  67809. private _thumbImage;
  67810. private _valueBarImage;
  67811. private _tempMeasure;
  67812. displayThumb: boolean;
  67813. /**
  67814. * Gets or sets the image used to render the background
  67815. */
  67816. backgroundImage: Image;
  67817. /**
  67818. * Gets or sets the image used to render the value bar
  67819. */
  67820. valueBarImage: Image;
  67821. /**
  67822. * Gets or sets the image used to render the thumb
  67823. */
  67824. thumbImage: Image;
  67825. /**
  67826. * Creates a new ImageBasedSlider
  67827. * @param name defines the control name
  67828. */
  67829. constructor(name?: string | undefined);
  67830. protected _getTypeName(): string;
  67831. _draw(context: CanvasRenderingContext2D): void;
  67832. }
  67833. }
  67834. declare module BABYLON.GUI {
  67835. /**
  67836. * Forcing an export so that this code will execute
  67837. * @hidden
  67838. */
  67839. const name = "Statics";
  67840. }
  67841. declare module BABYLON.GUI {
  67842. /**
  67843. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  67844. */
  67845. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  67846. /**
  67847. * Define the instrumented AdvancedDynamicTexture.
  67848. */
  67849. texture: AdvancedDynamicTexture;
  67850. private _captureRenderTime;
  67851. private _renderTime;
  67852. private _captureLayoutTime;
  67853. private _layoutTime;
  67854. private _onBeginRenderObserver;
  67855. private _onEndRenderObserver;
  67856. private _onBeginLayoutObserver;
  67857. private _onEndLayoutObserver;
  67858. /**
  67859. * Gets the perf counter used to capture render time
  67860. */
  67861. readonly renderTimeCounter: BABYLON.PerfCounter;
  67862. /**
  67863. * Gets the perf counter used to capture layout time
  67864. */
  67865. readonly layoutTimeCounter: BABYLON.PerfCounter;
  67866. /**
  67867. * Enable or disable the render time capture
  67868. */
  67869. captureRenderTime: boolean;
  67870. /**
  67871. * Enable or disable the layout time capture
  67872. */
  67873. captureLayoutTime: boolean;
  67874. /**
  67875. * Instantiates a new advanced dynamic texture instrumentation.
  67876. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  67877. * @param texture Defines the AdvancedDynamicTexture to instrument
  67878. */
  67879. constructor(
  67880. /**
  67881. * Define the instrumented AdvancedDynamicTexture.
  67882. */
  67883. texture: AdvancedDynamicTexture);
  67884. /**
  67885. * Dispose and release associated resources.
  67886. */
  67887. dispose(): void;
  67888. }
  67889. }
  67890. declare module BABYLON.GUI {
  67891. /**
  67892. * Class used to load GUI via XML.
  67893. */
  67894. export class XmlLoader {
  67895. private _nodes;
  67896. private _nodeTypes;
  67897. private _isLoaded;
  67898. private _objectAttributes;
  67899. private _parentClass;
  67900. /**
  67901. * Create a new xml loader
  67902. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  67903. */
  67904. constructor(parentClass?: null);
  67905. private _getChainElement;
  67906. private _getClassAttribute;
  67907. private _createGuiElement;
  67908. private _parseGrid;
  67909. private _parseElement;
  67910. private _prepareSourceElement;
  67911. private _parseElementsFromSource;
  67912. private _parseXml;
  67913. /**
  67914. * Gets if the loading has finished.
  67915. * @returns whether the loading has finished or not
  67916. */
  67917. isLoaded(): boolean;
  67918. /**
  67919. * Gets a loaded node / control by id.
  67920. * @param id the Controls id set in the xml
  67921. * @returns element of type Control
  67922. */
  67923. getNodeById(id: string): any;
  67924. /**
  67925. * Gets all loaded nodes / controls
  67926. * @returns Array of controls
  67927. */
  67928. getNodes(): any;
  67929. /**
  67930. * Initiates the xml layout loading
  67931. * @param xmlFile defines the xml layout to load
  67932. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  67933. * @param callback defines the callback called on layout load.
  67934. */
  67935. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  67936. }
  67937. }
  67938. declare module BABYLON.GUI {
  67939. /**
  67940. * Class used to create containers for controls
  67941. */
  67942. export class Container3D extends Control3D {
  67943. private _blockLayout;
  67944. /**
  67945. * Gets the list of child controls
  67946. */
  67947. protected _children: Control3D[];
  67948. /**
  67949. * Gets the list of child controls
  67950. */
  67951. readonly children: Array<Control3D>;
  67952. /**
  67953. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  67954. * This is helpful to optimize layout operation when adding multiple children in a row
  67955. */
  67956. blockLayout: boolean;
  67957. /**
  67958. * Creates a new container
  67959. * @param name defines the container name
  67960. */
  67961. constructor(name?: string);
  67962. /**
  67963. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  67964. * @returns the current container
  67965. */
  67966. updateLayout(): Container3D;
  67967. /**
  67968. * Gets a boolean indicating if the given control is in the children of this control
  67969. * @param control defines the control to check
  67970. * @returns true if the control is in the child list
  67971. */
  67972. containsControl(control: Control3D): boolean;
  67973. /**
  67974. * Adds a control to the children of this control
  67975. * @param control defines the control to add
  67976. * @returns the current container
  67977. */
  67978. addControl(control: Control3D): Container3D;
  67979. /**
  67980. * This function will be called everytime a new control is added
  67981. */
  67982. protected _arrangeChildren(): void;
  67983. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67984. /**
  67985. * Removes a control from the children of this control
  67986. * @param control defines the control to remove
  67987. * @returns the current container
  67988. */
  67989. removeControl(control: Control3D): Container3D;
  67990. protected _getTypeName(): string;
  67991. /**
  67992. * Releases all associated resources
  67993. */
  67994. dispose(): void;
  67995. /** Control rotation will remain unchanged */
  67996. static readonly UNSET_ORIENTATION: number;
  67997. /** Control will rotate to make it look at sphere central axis */
  67998. static readonly FACEORIGIN_ORIENTATION: number;
  67999. /** Control will rotate to make it look back at sphere central axis */
  68000. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  68001. /** Control will rotate to look at z axis (0, 0, 1) */
  68002. static readonly FACEFORWARD_ORIENTATION: number;
  68003. /** Control will rotate to look at negative z axis (0, 0, -1) */
  68004. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  68005. }
  68006. }
  68007. declare module BABYLON.GUI {
  68008. /**
  68009. * Class used to manage 3D user interface
  68010. * @see http://doc.babylonjs.com/how_to/gui3d
  68011. */
  68012. export class GUI3DManager implements BABYLON.IDisposable {
  68013. private _scene;
  68014. private _sceneDisposeObserver;
  68015. private _utilityLayer;
  68016. private _rootContainer;
  68017. private _pointerObserver;
  68018. private _pointerOutObserver;
  68019. /** @hidden */
  68020. _lastPickedControl: Control3D;
  68021. /** @hidden */
  68022. _lastControlOver: {
  68023. [pointerId: number]: Control3D;
  68024. };
  68025. /** @hidden */
  68026. _lastControlDown: {
  68027. [pointerId: number]: Control3D;
  68028. };
  68029. /**
  68030. * BABYLON.Observable raised when the point picked by the pointer events changed
  68031. */
  68032. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  68033. /** @hidden */
  68034. _sharedMaterials: {
  68035. [key: string]: BABYLON.Material;
  68036. };
  68037. /** Gets the hosting scene */
  68038. readonly scene: BABYLON.Scene;
  68039. /** Gets associated utility layer */
  68040. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  68041. /**
  68042. * Creates a new GUI3DManager
  68043. * @param scene
  68044. */
  68045. constructor(scene?: BABYLON.Scene);
  68046. private _handlePointerOut;
  68047. private _doPicking;
  68048. /**
  68049. * Gets the root container
  68050. */
  68051. readonly rootContainer: Container3D;
  68052. /**
  68053. * Gets a boolean indicating if the given control is in the root child list
  68054. * @param control defines the control to check
  68055. * @returns true if the control is in the root child list
  68056. */
  68057. containsControl(control: Control3D): boolean;
  68058. /**
  68059. * Adds a control to the root child list
  68060. * @param control defines the control to add
  68061. * @returns the current manager
  68062. */
  68063. addControl(control: Control3D): GUI3DManager;
  68064. /**
  68065. * Removes a control from the root child list
  68066. * @param control defines the control to remove
  68067. * @returns the current container
  68068. */
  68069. removeControl(control: Control3D): GUI3DManager;
  68070. /**
  68071. * Releases all associated resources
  68072. */
  68073. dispose(): void;
  68074. }
  68075. }
  68076. declare module BABYLON.GUI {
  68077. /**
  68078. * Class used to transport BABYLON.Vector3 information for pointer events
  68079. */
  68080. export class Vector3WithInfo extends BABYLON.Vector3 {
  68081. /** defines the current mouse button index */
  68082. buttonIndex: number;
  68083. /**
  68084. * Creates a new Vector3WithInfo
  68085. * @param source defines the vector3 data to transport
  68086. * @param buttonIndex defines the current mouse button index
  68087. */
  68088. constructor(source: BABYLON.Vector3,
  68089. /** defines the current mouse button index */
  68090. buttonIndex?: number);
  68091. }
  68092. }
  68093. declare module BABYLON.GUI {
  68094. /**
  68095. * Class used as base class for controls
  68096. */
  68097. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  68098. /** Defines the control name */
  68099. name?: string | undefined;
  68100. /** @hidden */
  68101. _host: GUI3DManager;
  68102. private _node;
  68103. private _downCount;
  68104. private _enterCount;
  68105. private _downPointerIds;
  68106. private _isVisible;
  68107. /** Gets or sets the control position in world space */
  68108. position: BABYLON.Vector3;
  68109. /** Gets or sets the control scaling in world space */
  68110. scaling: BABYLON.Vector3;
  68111. /** Callback used to start pointer enter animation */
  68112. pointerEnterAnimation: () => void;
  68113. /** Callback used to start pointer out animation */
  68114. pointerOutAnimation: () => void;
  68115. /** Callback used to start pointer down animation */
  68116. pointerDownAnimation: () => void;
  68117. /** Callback used to start pointer up animation */
  68118. pointerUpAnimation: () => void;
  68119. /**
  68120. * An event triggered when the pointer move over the control
  68121. */
  68122. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  68123. /**
  68124. * An event triggered when the pointer move out of the control
  68125. */
  68126. onPointerOutObservable: BABYLON.Observable<Control3D>;
  68127. /**
  68128. * An event triggered when the pointer taps the control
  68129. */
  68130. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  68131. /**
  68132. * An event triggered when pointer is up
  68133. */
  68134. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  68135. /**
  68136. * An event triggered when a control is clicked on (with a mouse)
  68137. */
  68138. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  68139. /**
  68140. * An event triggered when pointer enters the control
  68141. */
  68142. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  68143. /**
  68144. * Gets or sets the parent container
  68145. */
  68146. parent: BABYLON.Nullable<Container3D>;
  68147. private _behaviors;
  68148. /**
  68149. * Gets the list of attached behaviors
  68150. * @see http://doc.babylonjs.com/features/behaviour
  68151. */
  68152. readonly behaviors: BABYLON.Behavior<Control3D>[];
  68153. /**
  68154. * Attach a behavior to the control
  68155. * @see http://doc.babylonjs.com/features/behaviour
  68156. * @param behavior defines the behavior to attach
  68157. * @returns the current control
  68158. */
  68159. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  68160. /**
  68161. * Remove an attached behavior
  68162. * @see http://doc.babylonjs.com/features/behaviour
  68163. * @param behavior defines the behavior to attach
  68164. * @returns the current control
  68165. */
  68166. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  68167. /**
  68168. * Gets an attached behavior by name
  68169. * @param name defines the name of the behavior to look for
  68170. * @see http://doc.babylonjs.com/features/behaviour
  68171. * @returns null if behavior was not found else the requested behavior
  68172. */
  68173. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  68174. /** Gets or sets a boolean indicating if the control is visible */
  68175. isVisible: boolean;
  68176. /**
  68177. * Creates a new control
  68178. * @param name defines the control name
  68179. */
  68180. constructor(
  68181. /** Defines the control name */
  68182. name?: string | undefined);
  68183. /**
  68184. * Gets a string representing the class name
  68185. */
  68186. readonly typeName: string;
  68187. /**
  68188. * Get the current class name of the control.
  68189. * @returns current class name
  68190. */
  68191. getClassName(): string;
  68192. protected _getTypeName(): string;
  68193. /**
  68194. * Gets the transform node used by this control
  68195. */
  68196. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  68197. /**
  68198. * Gets the mesh used to render this control
  68199. */
  68200. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  68201. /**
  68202. * Link the control as child of the given node
  68203. * @param node defines the node to link to. Use null to unlink the control
  68204. * @returns the current control
  68205. */
  68206. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  68207. /** @hidden **/
  68208. _prepareNode(scene: BABYLON.Scene): void;
  68209. /**
  68210. * Node creation.
  68211. * Can be overriden by children
  68212. * @param scene defines the scene where the node must be attached
  68213. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  68214. */
  68215. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  68216. /**
  68217. * Affect a material to the given mesh
  68218. * @param mesh defines the mesh which will represent the control
  68219. */
  68220. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  68221. /** @hidden */
  68222. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  68223. /** @hidden */
  68224. _onPointerEnter(target: Control3D): boolean;
  68225. /** @hidden */
  68226. _onPointerOut(target: Control3D): void;
  68227. /** @hidden */
  68228. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  68229. /** @hidden */
  68230. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68231. /** @hidden */
  68232. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  68233. /** @hidden */
  68234. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  68235. /** @hidden */
  68236. _disposeNode(): void;
  68237. /**
  68238. * Releases all associated resources
  68239. */
  68240. dispose(): void;
  68241. }
  68242. }
  68243. declare module BABYLON.GUI {
  68244. /**
  68245. * Class used as a root to all buttons
  68246. */
  68247. export class AbstractButton3D extends Control3D {
  68248. /**
  68249. * Creates a new button
  68250. * @param name defines the control name
  68251. */
  68252. constructor(name?: string);
  68253. protected _getTypeName(): string;
  68254. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68255. }
  68256. }
  68257. declare module BABYLON.GUI {
  68258. /**
  68259. * Class used to create a button in 3D
  68260. */
  68261. export class Button3D extends AbstractButton3D {
  68262. /** @hidden */
  68263. protected _currentMaterial: BABYLON.Material;
  68264. private _facadeTexture;
  68265. private _content;
  68266. private _contentResolution;
  68267. private _contentScaleRatio;
  68268. /**
  68269. * Gets or sets the texture resolution used to render content (512 by default)
  68270. */
  68271. contentResolution: BABYLON.int;
  68272. /**
  68273. * Gets or sets the texture scale ratio used to render content (2 by default)
  68274. */
  68275. contentScaleRatio: number;
  68276. protected _disposeFacadeTexture(): void;
  68277. protected _resetContent(): void;
  68278. /**
  68279. * Creates a new button
  68280. * @param name defines the control name
  68281. */
  68282. constructor(name?: string);
  68283. /**
  68284. * Gets or sets the GUI 2D content used to display the button's facade
  68285. */
  68286. content: Control;
  68287. /**
  68288. * Apply the facade texture (created from the content property).
  68289. * This function can be overloaded by child classes
  68290. * @param facadeTexture defines the AdvancedDynamicTexture to use
  68291. */
  68292. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  68293. protected _getTypeName(): string;
  68294. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68295. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  68296. /**
  68297. * Releases all associated resources
  68298. */
  68299. dispose(): void;
  68300. }
  68301. }
  68302. declare module BABYLON.GUI {
  68303. /**
  68304. * Abstract class used to create a container panel deployed on the surface of a volume
  68305. */
  68306. export abstract class VolumeBasedPanel extends Container3D {
  68307. private _columns;
  68308. private _rows;
  68309. private _rowThenColum;
  68310. private _orientation;
  68311. protected _cellWidth: number;
  68312. protected _cellHeight: number;
  68313. /**
  68314. * Gets or sets the distance between elements
  68315. */
  68316. margin: number;
  68317. /**
  68318. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  68319. * | Value | Type | Description |
  68320. * | ----- | ----------------------------------- | ----------- |
  68321. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  68322. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  68323. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  68324. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  68325. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  68326. */
  68327. orientation: number;
  68328. /**
  68329. * Gets or sets the number of columns requested (10 by default).
  68330. * The panel will automatically compute the number of rows based on number of child controls.
  68331. */
  68332. columns: BABYLON.int;
  68333. /**
  68334. * Gets or sets a the number of rows requested.
  68335. * The panel will automatically compute the number of columns based on number of child controls.
  68336. */
  68337. rows: BABYLON.int;
  68338. /**
  68339. * Creates new VolumeBasedPanel
  68340. */
  68341. constructor();
  68342. protected _arrangeChildren(): void;
  68343. /** Child classes must implement this function to provide correct control positioning */
  68344. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68345. /** Child classes can implement this function to provide additional processing */
  68346. protected _finalProcessing(): void;
  68347. }
  68348. }
  68349. declare module BABYLON.GUI {
  68350. /**
  68351. * Class used to create a container panel deployed on the surface of a cylinder
  68352. */
  68353. export class CylinderPanel extends VolumeBasedPanel {
  68354. private _radius;
  68355. /**
  68356. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  68357. */
  68358. radius: BABYLON.float;
  68359. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68360. private _cylindricalMapping;
  68361. }
  68362. }
  68363. declare module BABYLON.GUI {
  68364. /** @hidden */
  68365. export var fluentVertexShader: {
  68366. name: string;
  68367. shader: string;
  68368. };
  68369. }
  68370. declare module BABYLON.GUI {
  68371. /** @hidden */
  68372. export var fluentPixelShader: {
  68373. name: string;
  68374. shader: string;
  68375. };
  68376. }
  68377. declare module BABYLON.GUI {
  68378. /** @hidden */
  68379. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  68380. INNERGLOW: boolean;
  68381. BORDER: boolean;
  68382. HOVERLIGHT: boolean;
  68383. TEXTURE: boolean;
  68384. constructor();
  68385. }
  68386. /**
  68387. * Class used to render controls with fluent desgin
  68388. */
  68389. export class FluentMaterial extends BABYLON.PushMaterial {
  68390. /**
  68391. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  68392. */
  68393. innerGlowColorIntensity: number;
  68394. /**
  68395. * Gets or sets the inner glow color (white by default)
  68396. */
  68397. innerGlowColor: BABYLON.Color3;
  68398. /**
  68399. * Gets or sets alpha value (default is 1.0)
  68400. */
  68401. alpha: number;
  68402. /**
  68403. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  68404. */
  68405. albedoColor: BABYLON.Color3;
  68406. /**
  68407. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  68408. */
  68409. renderBorders: boolean;
  68410. /**
  68411. * Gets or sets border width (default is 0.5)
  68412. */
  68413. borderWidth: number;
  68414. /**
  68415. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  68416. */
  68417. edgeSmoothingValue: number;
  68418. /**
  68419. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  68420. */
  68421. borderMinValue: number;
  68422. /**
  68423. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  68424. */
  68425. renderHoverLight: boolean;
  68426. /**
  68427. * Gets or sets the radius used to render the hover light (default is 1.0)
  68428. */
  68429. hoverRadius: number;
  68430. /**
  68431. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  68432. */
  68433. hoverColor: BABYLON.Color4;
  68434. /**
  68435. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  68436. */
  68437. hoverPosition: BABYLON.Vector3;
  68438. private _albedoTexture;
  68439. /** Gets or sets the texture to use for albedo color */
  68440. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68441. /**
  68442. * Creates a new Fluent material
  68443. * @param name defines the name of the material
  68444. * @param scene defines the hosting scene
  68445. */
  68446. constructor(name: string, scene: BABYLON.Scene);
  68447. needAlphaBlending(): boolean;
  68448. needAlphaTesting(): boolean;
  68449. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68450. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68451. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68452. getActiveTextures(): BABYLON.BaseTexture[];
  68453. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68454. dispose(forceDisposeEffect?: boolean): void;
  68455. clone(name: string): FluentMaterial;
  68456. serialize(): any;
  68457. getClassName(): string;
  68458. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  68459. }
  68460. }
  68461. declare module BABYLON.GUI {
  68462. /**
  68463. * Class used to create a holographic button in 3D
  68464. */
  68465. export class HolographicButton extends Button3D {
  68466. private _backPlate;
  68467. private _textPlate;
  68468. private _frontPlate;
  68469. private _text;
  68470. private _imageUrl;
  68471. private _shareMaterials;
  68472. private _frontMaterial;
  68473. private _backMaterial;
  68474. private _plateMaterial;
  68475. private _pickedPointObserver;
  68476. private _tooltipFade;
  68477. private _tooltipTextBlock;
  68478. private _tooltipTexture;
  68479. private _tooltipMesh;
  68480. private _tooltipHoverObserver;
  68481. private _tooltipOutObserver;
  68482. private _disposeTooltip;
  68483. /**
  68484. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  68485. */
  68486. tooltipText: BABYLON.Nullable<string>;
  68487. /**
  68488. * Gets or sets text for the button
  68489. */
  68490. text: string;
  68491. /**
  68492. * Gets or sets the image url for the button
  68493. */
  68494. imageUrl: string;
  68495. /**
  68496. * Gets the back material used by this button
  68497. */
  68498. readonly backMaterial: FluentMaterial;
  68499. /**
  68500. * Gets the front material used by this button
  68501. */
  68502. readonly frontMaterial: FluentMaterial;
  68503. /**
  68504. * Gets the plate material used by this button
  68505. */
  68506. readonly plateMaterial: BABYLON.StandardMaterial;
  68507. /**
  68508. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  68509. */
  68510. readonly shareMaterials: boolean;
  68511. /**
  68512. * Creates a new button
  68513. * @param name defines the control name
  68514. */
  68515. constructor(name?: string, shareMaterials?: boolean);
  68516. protected _getTypeName(): string;
  68517. private _rebuildContent;
  68518. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68519. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  68520. private _createBackMaterial;
  68521. private _createFrontMaterial;
  68522. private _createPlateMaterial;
  68523. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  68524. /**
  68525. * Releases all associated resources
  68526. */
  68527. dispose(): void;
  68528. }
  68529. }
  68530. declare module BABYLON.GUI {
  68531. /**
  68532. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  68533. */
  68534. export class MeshButton3D extends Button3D {
  68535. /** @hidden */
  68536. protected _currentMesh: BABYLON.Mesh;
  68537. /**
  68538. * Creates a new 3D button based on a mesh
  68539. * @param mesh mesh to become a 3D button
  68540. * @param name defines the control name
  68541. */
  68542. constructor(mesh: BABYLON.Mesh, name?: string);
  68543. protected _getTypeName(): string;
  68544. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68545. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  68546. }
  68547. }
  68548. declare module BABYLON.GUI {
  68549. /**
  68550. * Class used to create a container panel deployed on the surface of a plane
  68551. */
  68552. export class PlanePanel extends VolumeBasedPanel {
  68553. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68554. }
  68555. }
  68556. declare module BABYLON.GUI {
  68557. /**
  68558. * Class used to create a container panel where items get randomized planar mapping
  68559. */
  68560. export class ScatterPanel extends VolumeBasedPanel {
  68561. private _iteration;
  68562. /**
  68563. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  68564. */
  68565. iteration: BABYLON.float;
  68566. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68567. private _scatterMapping;
  68568. protected _finalProcessing(): void;
  68569. }
  68570. }
  68571. declare module BABYLON.GUI {
  68572. /**
  68573. * Class used to create a container panel deployed on the surface of a sphere
  68574. */
  68575. export class SpherePanel extends VolumeBasedPanel {
  68576. private _radius;
  68577. /**
  68578. * Gets or sets the radius of the sphere where to project controls (5 by default)
  68579. */
  68580. radius: BABYLON.float;
  68581. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68582. private _sphericalMapping;
  68583. }
  68584. }
  68585. declare module BABYLON.GUI {
  68586. /**
  68587. * Class used to create a stack panel in 3D on XY plane
  68588. */
  68589. export class StackPanel3D extends Container3D {
  68590. private _isVertical;
  68591. /**
  68592. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  68593. */
  68594. isVertical: boolean;
  68595. /**
  68596. * Gets or sets the distance between elements
  68597. */
  68598. margin: number;
  68599. /**
  68600. * Creates new StackPanel
  68601. * @param isVertical
  68602. */
  68603. constructor(isVertical?: boolean);
  68604. protected _arrangeChildren(): void;
  68605. }
  68606. }
  68607. declare module BABYLON {
  68608. /**
  68609. * Mode that determines the coordinate system to use.
  68610. */
  68611. export enum GLTFLoaderCoordinateSystemMode {
  68612. /**
  68613. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  68614. */
  68615. AUTO = 0,
  68616. /**
  68617. * Sets the useRightHandedSystem flag on the scene.
  68618. */
  68619. FORCE_RIGHT_HANDED = 1
  68620. }
  68621. /**
  68622. * Mode that determines what animations will start.
  68623. */
  68624. export enum GLTFLoaderAnimationStartMode {
  68625. /**
  68626. * No animation will start.
  68627. */
  68628. NONE = 0,
  68629. /**
  68630. * The first animation will start.
  68631. */
  68632. FIRST = 1,
  68633. /**
  68634. * All animations will start.
  68635. */
  68636. ALL = 2
  68637. }
  68638. /**
  68639. * Interface that contains the data for the glTF asset.
  68640. */
  68641. export interface IGLTFLoaderData {
  68642. /**
  68643. * The object that represents the glTF JSON.
  68644. */
  68645. json: Object;
  68646. /**
  68647. * The BIN chunk of a binary glTF.
  68648. */
  68649. bin: Nullable<IDataBuffer>;
  68650. }
  68651. /**
  68652. * Interface for extending the loader.
  68653. */
  68654. export interface IGLTFLoaderExtension {
  68655. /**
  68656. * The name of this extension.
  68657. */
  68658. readonly name: string;
  68659. /**
  68660. * Defines whether this extension is enabled.
  68661. */
  68662. enabled: boolean;
  68663. /**
  68664. * Defines the order of this extension.
  68665. * The loader sorts the extensions using these values when loading.
  68666. */
  68667. order?: number;
  68668. }
  68669. /**
  68670. * Loader state.
  68671. */
  68672. export enum GLTFLoaderState {
  68673. /**
  68674. * The asset is loading.
  68675. */
  68676. LOADING = 0,
  68677. /**
  68678. * The asset is ready for rendering.
  68679. */
  68680. READY = 1,
  68681. /**
  68682. * The asset is completely loaded.
  68683. */
  68684. COMPLETE = 2
  68685. }
  68686. /** @hidden */
  68687. export interface IGLTFLoader extends IDisposable {
  68688. readonly state: Nullable<GLTFLoaderState>;
  68689. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  68690. meshes: AbstractMesh[];
  68691. particleSystems: IParticleSystem[];
  68692. skeletons: Skeleton[];
  68693. animationGroups: AnimationGroup[];
  68694. }>;
  68695. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  68696. }
  68697. /**
  68698. * File loader for loading glTF files into a scene.
  68699. */
  68700. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68701. /** @hidden */
  68702. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  68703. /** @hidden */
  68704. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  68705. /**
  68706. * Raised when the asset has been parsed
  68707. */
  68708. onParsedObservable: Observable<IGLTFLoaderData>;
  68709. private _onParsedObserver;
  68710. /**
  68711. * Raised when the asset has been parsed
  68712. */
  68713. onParsed: (loaderData: IGLTFLoaderData) => void;
  68714. /**
  68715. * 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.
  68716. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  68717. * Defaults to true.
  68718. * @hidden
  68719. */
  68720. static IncrementalLoading: boolean;
  68721. /**
  68722. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  68723. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  68724. * @hidden
  68725. */
  68726. static HomogeneousCoordinates: boolean;
  68727. /**
  68728. * The coordinate system mode. Defaults to AUTO.
  68729. */
  68730. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  68731. /**
  68732. * The animation start mode. Defaults to FIRST.
  68733. */
  68734. animationStartMode: GLTFLoaderAnimationStartMode;
  68735. /**
  68736. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  68737. */
  68738. compileMaterials: boolean;
  68739. /**
  68740. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  68741. */
  68742. useClipPlane: boolean;
  68743. /**
  68744. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  68745. */
  68746. compileShadowGenerators: boolean;
  68747. /**
  68748. * Defines if the Alpha blended materials are only applied as coverage.
  68749. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  68750. * If true, no extra effects are applied to transparent pixels.
  68751. */
  68752. transparencyAsCoverage: boolean;
  68753. /**
  68754. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  68755. * Enabling will disable offline support and glTF validator.
  68756. * Defaults to false.
  68757. */
  68758. useRangeRequests: boolean;
  68759. /**
  68760. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  68761. */
  68762. createInstances: boolean;
  68763. /**
  68764. * Function called before loading a url referenced by the asset.
  68765. */
  68766. preprocessUrlAsync: (url: string) => Promise<string>;
  68767. /**
  68768. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68769. */
  68770. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  68771. private _onMeshLoadedObserver;
  68772. /**
  68773. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68774. */
  68775. onMeshLoaded: (mesh: AbstractMesh) => void;
  68776. /**
  68777. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  68778. */
  68779. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  68780. private _onTextureLoadedObserver;
  68781. /**
  68782. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  68783. */
  68784. onTextureLoaded: (texture: BaseTexture) => void;
  68785. /**
  68786. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  68787. */
  68788. readonly onMaterialLoadedObservable: Observable<Material>;
  68789. private _onMaterialLoadedObserver;
  68790. /**
  68791. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  68792. */
  68793. onMaterialLoaded: (material: Material) => void;
  68794. /**
  68795. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  68796. */
  68797. readonly onCameraLoadedObservable: Observable<Camera>;
  68798. private _onCameraLoadedObserver;
  68799. /**
  68800. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  68801. */
  68802. onCameraLoaded: (camera: Camera) => void;
  68803. /**
  68804. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  68805. * For assets with LODs, raised when all of the LODs are complete.
  68806. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68807. */
  68808. readonly onCompleteObservable: Observable<void>;
  68809. private _onCompleteObserver;
  68810. /**
  68811. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  68812. * For assets with LODs, raised when all of the LODs are complete.
  68813. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68814. */
  68815. onComplete: () => void;
  68816. /**
  68817. * Observable raised when an error occurs.
  68818. */
  68819. readonly onErrorObservable: Observable<any>;
  68820. private _onErrorObserver;
  68821. /**
  68822. * Callback raised when an error occurs.
  68823. */
  68824. onError: (reason: any) => void;
  68825. /**
  68826. * Observable raised after the loader is disposed.
  68827. */
  68828. readonly onDisposeObservable: Observable<void>;
  68829. private _onDisposeObserver;
  68830. /**
  68831. * Callback raised after the loader is disposed.
  68832. */
  68833. onDispose: () => void;
  68834. /**
  68835. * Observable raised after a loader extension is created.
  68836. * Set additional options for a loader extension in this event.
  68837. */
  68838. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  68839. private _onExtensionLoadedObserver;
  68840. /**
  68841. * Callback raised after a loader extension is created.
  68842. */
  68843. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  68844. /**
  68845. * Defines if the loader logging is enabled.
  68846. */
  68847. loggingEnabled: boolean;
  68848. /**
  68849. * Defines if the loader should capture performance counters.
  68850. */
  68851. capturePerformanceCounters: boolean;
  68852. /**
  68853. * Defines if the loader should validate the asset.
  68854. */
  68855. validate: boolean;
  68856. /**
  68857. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  68858. */
  68859. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  68860. private _onValidatedObserver;
  68861. /**
  68862. * Callback raised after a loader extension is created.
  68863. */
  68864. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  68865. private _loader;
  68866. /**
  68867. * Name of the loader ("gltf")
  68868. */
  68869. name: string;
  68870. /** @hidden */
  68871. extensions: ISceneLoaderPluginExtensions;
  68872. /**
  68873. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  68874. */
  68875. dispose(): void;
  68876. /** @hidden */
  68877. _clear(): void;
  68878. /** @hidden */
  68879. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  68880. /** @hidden */
  68881. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  68882. /** @hidden */
  68883. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68884. meshes: AbstractMesh[];
  68885. particleSystems: IParticleSystem[];
  68886. skeletons: Skeleton[];
  68887. animationGroups: AnimationGroup[];
  68888. }>;
  68889. /** @hidden */
  68890. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68891. /** @hidden */
  68892. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68893. /** @hidden */
  68894. canDirectLoad(data: string): boolean;
  68895. /** @hidden */
  68896. directLoad(scene: Scene, data: string): any;
  68897. /**
  68898. * The callback that allows custom handling of the root url based on the response url.
  68899. * @param rootUrl the original root url
  68900. * @param responseURL the response url if available
  68901. * @returns the new root url
  68902. */
  68903. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  68904. /** @hidden */
  68905. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  68906. /**
  68907. * The loader state or null if the loader is not active.
  68908. */
  68909. readonly loaderState: Nullable<GLTFLoaderState>;
  68910. /**
  68911. * Returns a promise that resolves when the asset is completely loaded.
  68912. * @returns a promise that resolves when the asset is completely loaded.
  68913. */
  68914. whenCompleteAsync(): Promise<void>;
  68915. private _validateAsync;
  68916. private _getLoader;
  68917. private _parseJson;
  68918. private _unpackBinaryAsync;
  68919. private _unpackBinaryV1Async;
  68920. private _unpackBinaryV2Async;
  68921. private static _parseVersion;
  68922. private static _compareVersion;
  68923. private static readonly _logSpaces;
  68924. private _logIndentLevel;
  68925. private _loggingEnabled;
  68926. /** @hidden */
  68927. _log: (message: string) => void;
  68928. /** @hidden */
  68929. _logOpen(message: string): void;
  68930. /** @hidden */
  68931. _logClose(): void;
  68932. private _logEnabled;
  68933. private _logDisabled;
  68934. private _capturePerformanceCounters;
  68935. /** @hidden */
  68936. _startPerformanceCounter: (counterName: string) => void;
  68937. /** @hidden */
  68938. _endPerformanceCounter: (counterName: string) => void;
  68939. private _startPerformanceCounterEnabled;
  68940. private _startPerformanceCounterDisabled;
  68941. private _endPerformanceCounterEnabled;
  68942. private _endPerformanceCounterDisabled;
  68943. }
  68944. }
  68945. declare module BABYLON.GLTF1 {
  68946. /**
  68947. * Enums
  68948. * @hidden
  68949. */
  68950. export enum EComponentType {
  68951. BYTE = 5120,
  68952. UNSIGNED_BYTE = 5121,
  68953. SHORT = 5122,
  68954. UNSIGNED_SHORT = 5123,
  68955. FLOAT = 5126
  68956. }
  68957. /** @hidden */
  68958. export enum EShaderType {
  68959. FRAGMENT = 35632,
  68960. VERTEX = 35633
  68961. }
  68962. /** @hidden */
  68963. export enum EParameterType {
  68964. BYTE = 5120,
  68965. UNSIGNED_BYTE = 5121,
  68966. SHORT = 5122,
  68967. UNSIGNED_SHORT = 5123,
  68968. INT = 5124,
  68969. UNSIGNED_INT = 5125,
  68970. FLOAT = 5126,
  68971. FLOAT_VEC2 = 35664,
  68972. FLOAT_VEC3 = 35665,
  68973. FLOAT_VEC4 = 35666,
  68974. INT_VEC2 = 35667,
  68975. INT_VEC3 = 35668,
  68976. INT_VEC4 = 35669,
  68977. BOOL = 35670,
  68978. BOOL_VEC2 = 35671,
  68979. BOOL_VEC3 = 35672,
  68980. BOOL_VEC4 = 35673,
  68981. FLOAT_MAT2 = 35674,
  68982. FLOAT_MAT3 = 35675,
  68983. FLOAT_MAT4 = 35676,
  68984. SAMPLER_2D = 35678
  68985. }
  68986. /** @hidden */
  68987. export enum ETextureWrapMode {
  68988. CLAMP_TO_EDGE = 33071,
  68989. MIRRORED_REPEAT = 33648,
  68990. REPEAT = 10497
  68991. }
  68992. /** @hidden */
  68993. export enum ETextureFilterType {
  68994. NEAREST = 9728,
  68995. LINEAR = 9728,
  68996. NEAREST_MIPMAP_NEAREST = 9984,
  68997. LINEAR_MIPMAP_NEAREST = 9985,
  68998. NEAREST_MIPMAP_LINEAR = 9986,
  68999. LINEAR_MIPMAP_LINEAR = 9987
  69000. }
  69001. /** @hidden */
  69002. export enum ETextureFormat {
  69003. ALPHA = 6406,
  69004. RGB = 6407,
  69005. RGBA = 6408,
  69006. LUMINANCE = 6409,
  69007. LUMINANCE_ALPHA = 6410
  69008. }
  69009. /** @hidden */
  69010. export enum ECullingType {
  69011. FRONT = 1028,
  69012. BACK = 1029,
  69013. FRONT_AND_BACK = 1032
  69014. }
  69015. /** @hidden */
  69016. export enum EBlendingFunction {
  69017. ZERO = 0,
  69018. ONE = 1,
  69019. SRC_COLOR = 768,
  69020. ONE_MINUS_SRC_COLOR = 769,
  69021. DST_COLOR = 774,
  69022. ONE_MINUS_DST_COLOR = 775,
  69023. SRC_ALPHA = 770,
  69024. ONE_MINUS_SRC_ALPHA = 771,
  69025. DST_ALPHA = 772,
  69026. ONE_MINUS_DST_ALPHA = 773,
  69027. CONSTANT_COLOR = 32769,
  69028. ONE_MINUS_CONSTANT_COLOR = 32770,
  69029. CONSTANT_ALPHA = 32771,
  69030. ONE_MINUS_CONSTANT_ALPHA = 32772,
  69031. SRC_ALPHA_SATURATE = 776
  69032. }
  69033. /** @hidden */
  69034. export interface IGLTFProperty {
  69035. extensions?: {
  69036. [key: string]: any;
  69037. };
  69038. extras?: Object;
  69039. }
  69040. /** @hidden */
  69041. export interface IGLTFChildRootProperty extends IGLTFProperty {
  69042. name?: string;
  69043. }
  69044. /** @hidden */
  69045. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  69046. bufferView: string;
  69047. byteOffset: number;
  69048. byteStride: number;
  69049. count: number;
  69050. type: string;
  69051. componentType: EComponentType;
  69052. max?: number[];
  69053. min?: number[];
  69054. name?: string;
  69055. }
  69056. /** @hidden */
  69057. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  69058. buffer: string;
  69059. byteOffset: number;
  69060. byteLength: number;
  69061. byteStride: number;
  69062. target?: number;
  69063. }
  69064. /** @hidden */
  69065. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  69066. uri: string;
  69067. byteLength?: number;
  69068. type?: string;
  69069. }
  69070. /** @hidden */
  69071. export interface IGLTFShader extends IGLTFChildRootProperty {
  69072. uri: string;
  69073. type: EShaderType;
  69074. }
  69075. /** @hidden */
  69076. export interface IGLTFProgram extends IGLTFChildRootProperty {
  69077. attributes: string[];
  69078. fragmentShader: string;
  69079. vertexShader: string;
  69080. }
  69081. /** @hidden */
  69082. export interface IGLTFTechniqueParameter {
  69083. type: number;
  69084. count?: number;
  69085. semantic?: string;
  69086. node?: string;
  69087. value?: number | boolean | string | Array<any>;
  69088. source?: string;
  69089. babylonValue?: any;
  69090. }
  69091. /** @hidden */
  69092. export interface IGLTFTechniqueCommonProfile {
  69093. lightingModel: string;
  69094. texcoordBindings: Object;
  69095. parameters?: Array<any>;
  69096. }
  69097. /** @hidden */
  69098. export interface IGLTFTechniqueStatesFunctions {
  69099. blendColor?: number[];
  69100. blendEquationSeparate?: number[];
  69101. blendFuncSeparate?: number[];
  69102. colorMask: boolean[];
  69103. cullFace: number[];
  69104. }
  69105. /** @hidden */
  69106. export interface IGLTFTechniqueStates {
  69107. enable: number[];
  69108. functions: IGLTFTechniqueStatesFunctions;
  69109. }
  69110. /** @hidden */
  69111. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  69112. parameters: {
  69113. [key: string]: IGLTFTechniqueParameter;
  69114. };
  69115. program: string;
  69116. attributes: {
  69117. [key: string]: string;
  69118. };
  69119. uniforms: {
  69120. [key: string]: string;
  69121. };
  69122. states: IGLTFTechniqueStates;
  69123. }
  69124. /** @hidden */
  69125. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  69126. technique?: string;
  69127. values: string[];
  69128. }
  69129. /** @hidden */
  69130. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  69131. attributes: {
  69132. [key: string]: string;
  69133. };
  69134. indices: string;
  69135. material: string;
  69136. mode?: number;
  69137. }
  69138. /** @hidden */
  69139. export interface IGLTFMesh extends IGLTFChildRootProperty {
  69140. primitives: IGLTFMeshPrimitive[];
  69141. }
  69142. /** @hidden */
  69143. export interface IGLTFImage extends IGLTFChildRootProperty {
  69144. uri: string;
  69145. }
  69146. /** @hidden */
  69147. export interface IGLTFSampler extends IGLTFChildRootProperty {
  69148. magFilter?: number;
  69149. minFilter?: number;
  69150. wrapS?: number;
  69151. wrapT?: number;
  69152. }
  69153. /** @hidden */
  69154. export interface IGLTFTexture extends IGLTFChildRootProperty {
  69155. sampler: string;
  69156. source: string;
  69157. format?: ETextureFormat;
  69158. internalFormat?: ETextureFormat;
  69159. target?: number;
  69160. type?: number;
  69161. babylonTexture?: Texture;
  69162. }
  69163. /** @hidden */
  69164. export interface IGLTFAmbienLight {
  69165. color?: number[];
  69166. }
  69167. /** @hidden */
  69168. export interface IGLTFDirectionalLight {
  69169. color?: number[];
  69170. }
  69171. /** @hidden */
  69172. export interface IGLTFPointLight {
  69173. color?: number[];
  69174. constantAttenuation?: number;
  69175. linearAttenuation?: number;
  69176. quadraticAttenuation?: number;
  69177. }
  69178. /** @hidden */
  69179. export interface IGLTFSpotLight {
  69180. color?: number[];
  69181. constantAttenuation?: number;
  69182. fallOfAngle?: number;
  69183. fallOffExponent?: number;
  69184. linearAttenuation?: number;
  69185. quadraticAttenuation?: number;
  69186. }
  69187. /** @hidden */
  69188. export interface IGLTFLight extends IGLTFChildRootProperty {
  69189. type: string;
  69190. }
  69191. /** @hidden */
  69192. export interface IGLTFCameraOrthographic {
  69193. xmag: number;
  69194. ymag: number;
  69195. zfar: number;
  69196. znear: number;
  69197. }
  69198. /** @hidden */
  69199. export interface IGLTFCameraPerspective {
  69200. aspectRatio: number;
  69201. yfov: number;
  69202. zfar: number;
  69203. znear: number;
  69204. }
  69205. /** @hidden */
  69206. export interface IGLTFCamera extends IGLTFChildRootProperty {
  69207. type: string;
  69208. }
  69209. /** @hidden */
  69210. export interface IGLTFAnimationChannelTarget {
  69211. id: string;
  69212. path: string;
  69213. }
  69214. /** @hidden */
  69215. export interface IGLTFAnimationChannel {
  69216. sampler: string;
  69217. target: IGLTFAnimationChannelTarget;
  69218. }
  69219. /** @hidden */
  69220. export interface IGLTFAnimationSampler {
  69221. input: string;
  69222. output: string;
  69223. interpolation?: string;
  69224. }
  69225. /** @hidden */
  69226. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  69227. channels?: IGLTFAnimationChannel[];
  69228. parameters?: {
  69229. [key: string]: string;
  69230. };
  69231. samplers?: {
  69232. [key: string]: IGLTFAnimationSampler;
  69233. };
  69234. }
  69235. /** @hidden */
  69236. export interface IGLTFNodeInstanceSkin {
  69237. skeletons: string[];
  69238. skin: string;
  69239. meshes: string[];
  69240. }
  69241. /** @hidden */
  69242. export interface IGLTFSkins extends IGLTFChildRootProperty {
  69243. bindShapeMatrix: number[];
  69244. inverseBindMatrices: string;
  69245. jointNames: string[];
  69246. babylonSkeleton?: Skeleton;
  69247. }
  69248. /** @hidden */
  69249. export interface IGLTFNode extends IGLTFChildRootProperty {
  69250. camera?: string;
  69251. children: string[];
  69252. skin?: string;
  69253. jointName?: string;
  69254. light?: string;
  69255. matrix: number[];
  69256. mesh?: string;
  69257. meshes?: string[];
  69258. rotation?: number[];
  69259. scale?: number[];
  69260. translation?: number[];
  69261. babylonNode?: Node;
  69262. }
  69263. /** @hidden */
  69264. export interface IGLTFScene extends IGLTFChildRootProperty {
  69265. nodes: string[];
  69266. }
  69267. /** @hidden */
  69268. export interface IGLTFRuntime {
  69269. extensions: {
  69270. [key: string]: any;
  69271. };
  69272. accessors: {
  69273. [key: string]: IGLTFAccessor;
  69274. };
  69275. buffers: {
  69276. [key: string]: IGLTFBuffer;
  69277. };
  69278. bufferViews: {
  69279. [key: string]: IGLTFBufferView;
  69280. };
  69281. meshes: {
  69282. [key: string]: IGLTFMesh;
  69283. };
  69284. lights: {
  69285. [key: string]: IGLTFLight;
  69286. };
  69287. cameras: {
  69288. [key: string]: IGLTFCamera;
  69289. };
  69290. nodes: {
  69291. [key: string]: IGLTFNode;
  69292. };
  69293. images: {
  69294. [key: string]: IGLTFImage;
  69295. };
  69296. textures: {
  69297. [key: string]: IGLTFTexture;
  69298. };
  69299. shaders: {
  69300. [key: string]: IGLTFShader;
  69301. };
  69302. programs: {
  69303. [key: string]: IGLTFProgram;
  69304. };
  69305. samplers: {
  69306. [key: string]: IGLTFSampler;
  69307. };
  69308. techniques: {
  69309. [key: string]: IGLTFTechnique;
  69310. };
  69311. materials: {
  69312. [key: string]: IGLTFMaterial;
  69313. };
  69314. animations: {
  69315. [key: string]: IGLTFAnimation;
  69316. };
  69317. skins: {
  69318. [key: string]: IGLTFSkins;
  69319. };
  69320. currentScene?: Object;
  69321. scenes: {
  69322. [key: string]: IGLTFScene;
  69323. };
  69324. extensionsUsed: string[];
  69325. extensionsRequired?: string[];
  69326. buffersCount: number;
  69327. shaderscount: number;
  69328. scene: Scene;
  69329. rootUrl: string;
  69330. loadedBufferCount: number;
  69331. loadedBufferViews: {
  69332. [name: string]: ArrayBufferView;
  69333. };
  69334. loadedShaderCount: number;
  69335. importOnlyMeshes: boolean;
  69336. importMeshesNames?: string[];
  69337. dummyNodes: Node[];
  69338. }
  69339. /** @hidden */
  69340. export interface INodeToRoot {
  69341. bone: Bone;
  69342. node: IGLTFNode;
  69343. id: string;
  69344. }
  69345. /** @hidden */
  69346. export interface IJointNode {
  69347. node: IGLTFNode;
  69348. id: string;
  69349. }
  69350. }
  69351. declare module BABYLON.GLTF1 {
  69352. /**
  69353. * Utils functions for GLTF
  69354. * @hidden
  69355. */
  69356. export class GLTFUtils {
  69357. /**
  69358. * Sets the given "parameter" matrix
  69359. * @param scene: the Scene object
  69360. * @param source: the source node where to pick the matrix
  69361. * @param parameter: the GLTF technique parameter
  69362. * @param uniformName: the name of the shader's uniform
  69363. * @param shaderMaterial: the shader material
  69364. */
  69365. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  69366. /**
  69367. * Sets the given "parameter" matrix
  69368. * @param shaderMaterial: the shader material
  69369. * @param uniform: the name of the shader's uniform
  69370. * @param value: the value of the uniform
  69371. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  69372. */
  69373. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  69374. /**
  69375. * Returns the wrap mode of the texture
  69376. * @param mode: the mode value
  69377. */
  69378. static GetWrapMode(mode: number): number;
  69379. /**
  69380. * Returns the byte stride giving an accessor
  69381. * @param accessor: the GLTF accessor objet
  69382. */
  69383. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  69384. /**
  69385. * Returns the texture filter mode giving a mode value
  69386. * @param mode: the filter mode value
  69387. */
  69388. static GetTextureFilterMode(mode: number): ETextureFilterType;
  69389. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  69390. /**
  69391. * Returns a buffer from its accessor
  69392. * @param gltfRuntime: the GLTF runtime
  69393. * @param accessor: the GLTF accessor
  69394. */
  69395. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  69396. /**
  69397. * Decodes a buffer view into a string
  69398. * @param view: the buffer view
  69399. */
  69400. static DecodeBufferToText(view: ArrayBufferView): string;
  69401. /**
  69402. * Returns the default material of gltf. Related to
  69403. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  69404. * @param scene: the Babylon.js scene
  69405. */
  69406. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  69407. private static _DefaultMaterial;
  69408. }
  69409. }
  69410. declare module BABYLON.GLTF1 {
  69411. /**
  69412. * Implementation of the base glTF spec
  69413. * @hidden
  69414. */
  69415. export class GLTFLoaderBase {
  69416. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  69417. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  69418. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  69419. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  69420. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  69421. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  69422. }
  69423. /**
  69424. * glTF V1 Loader
  69425. * @hidden
  69426. */
  69427. export class GLTFLoader implements IGLTFLoader {
  69428. static Extensions: {
  69429. [name: string]: GLTFLoaderExtension;
  69430. };
  69431. static RegisterExtension(extension: GLTFLoaderExtension): void;
  69432. state: Nullable<GLTFLoaderState>;
  69433. dispose(): void;
  69434. private _importMeshAsync;
  69435. /**
  69436. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  69437. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69438. * @param scene the scene the meshes should be added to
  69439. * @param data gltf data containing information of the meshes in a loaded file
  69440. * @param rootUrl root url to load from
  69441. * @param onProgress event that fires when loading progress has occured
  69442. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69443. */
  69444. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  69445. meshes: AbstractMesh[];
  69446. particleSystems: IParticleSystem[];
  69447. skeletons: Skeleton[];
  69448. animationGroups: AnimationGroup[];
  69449. }>;
  69450. private _loadAsync;
  69451. /**
  69452. * Imports all objects from a loaded gltf file and adds them to the scene
  69453. * @param scene the scene the objects should be added to
  69454. * @param data gltf data containing information of the meshes in a loaded file
  69455. * @param rootUrl root url to load from
  69456. * @param onProgress event that fires when loading progress has occured
  69457. * @returns a promise which completes when objects have been loaded to the scene
  69458. */
  69459. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  69460. private _loadShadersAsync;
  69461. private _loadBuffersAsync;
  69462. private _createNodes;
  69463. }
  69464. /** @hidden */
  69465. export abstract class GLTFLoaderExtension {
  69466. private _name;
  69467. constructor(name: string);
  69468. readonly name: string;
  69469. /**
  69470. * Defines an override for loading the runtime
  69471. * Return true to stop further extensions from loading the runtime
  69472. */
  69473. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  69474. /**
  69475. * Defines an onverride for creating gltf runtime
  69476. * Return true to stop further extensions from creating the runtime
  69477. */
  69478. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  69479. /**
  69480. * Defines an override for loading buffers
  69481. * Return true to stop further extensions from loading this buffer
  69482. */
  69483. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  69484. /**
  69485. * Defines an override for loading texture buffers
  69486. * Return true to stop further extensions from loading this texture data
  69487. */
  69488. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69489. /**
  69490. * Defines an override for creating textures
  69491. * Return true to stop further extensions from loading this texture
  69492. */
  69493. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  69494. /**
  69495. * Defines an override for loading shader strings
  69496. * Return true to stop further extensions from loading this shader data
  69497. */
  69498. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  69499. /**
  69500. * Defines an override for loading materials
  69501. * Return true to stop further extensions from loading this material
  69502. */
  69503. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  69504. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  69505. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  69506. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  69507. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  69508. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  69509. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  69510. private static LoadTextureBufferAsync;
  69511. private static CreateTextureAsync;
  69512. private static ApplyExtensions;
  69513. }
  69514. }
  69515. declare module BABYLON.GLTF1 {
  69516. /** @hidden */
  69517. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  69518. private _bin;
  69519. constructor();
  69520. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  69521. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69522. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69523. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  69524. }
  69525. }
  69526. declare module BABYLON.GLTF1 {
  69527. /** @hidden */
  69528. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  69529. constructor();
  69530. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  69531. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  69532. private _loadTexture;
  69533. }
  69534. }
  69535. declare module BABYLON.GLTF2.Loader {
  69536. /**
  69537. * Loader interface with an index field.
  69538. */
  69539. export interface IArrayItem {
  69540. /**
  69541. * The index of this item in the array.
  69542. */
  69543. index: number;
  69544. }
  69545. /**
  69546. * Loader interface with additional members.
  69547. */
  69548. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  69549. /** @hidden */
  69550. _data?: Promise<ArrayBufferView>;
  69551. /** @hidden */
  69552. _babylonVertexBuffer?: Promise<VertexBuffer>;
  69553. }
  69554. /**
  69555. * Loader interface with additional members.
  69556. */
  69557. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  69558. }
  69559. /** @hidden */
  69560. export interface _IAnimationSamplerData {
  69561. input: Float32Array;
  69562. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  69563. output: Float32Array;
  69564. }
  69565. /**
  69566. * Loader interface with additional members.
  69567. */
  69568. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  69569. /** @hidden */
  69570. _data?: Promise<_IAnimationSamplerData>;
  69571. }
  69572. /**
  69573. * Loader interface with additional members.
  69574. */
  69575. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  69576. channels: IAnimationChannel[];
  69577. samplers: IAnimationSampler[];
  69578. /** @hidden */
  69579. _babylonAnimationGroup?: AnimationGroup;
  69580. }
  69581. /**
  69582. * Loader interface with additional members.
  69583. */
  69584. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  69585. /** @hidden */
  69586. _data?: Promise<ArrayBufferView>;
  69587. }
  69588. /**
  69589. * Loader interface with additional members.
  69590. */
  69591. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  69592. /** @hidden */
  69593. _data?: Promise<ArrayBufferView>;
  69594. /** @hidden */
  69595. _babylonBuffer?: Promise<Buffer>;
  69596. }
  69597. /**
  69598. * Loader interface with additional members.
  69599. */
  69600. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  69601. }
  69602. /**
  69603. * Loader interface with additional members.
  69604. */
  69605. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  69606. /** @hidden */
  69607. _data?: Promise<ArrayBufferView>;
  69608. }
  69609. /**
  69610. * Loader interface with additional members.
  69611. */
  69612. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  69613. }
  69614. /**
  69615. * Loader interface with additional members.
  69616. */
  69617. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  69618. }
  69619. /**
  69620. * Loader interface with additional members.
  69621. */
  69622. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  69623. baseColorTexture?: ITextureInfo;
  69624. metallicRoughnessTexture?: ITextureInfo;
  69625. }
  69626. /**
  69627. * Loader interface with additional members.
  69628. */
  69629. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  69630. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69631. normalTexture?: IMaterialNormalTextureInfo;
  69632. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69633. emissiveTexture?: ITextureInfo;
  69634. /** @hidden */
  69635. _data?: {
  69636. [babylonDrawMode: number]: {
  69637. babylonMaterial: Material;
  69638. babylonMeshes: AbstractMesh[];
  69639. promise: Promise<void>;
  69640. };
  69641. };
  69642. }
  69643. /**
  69644. * Loader interface with additional members.
  69645. */
  69646. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  69647. primitives: IMeshPrimitive[];
  69648. }
  69649. /**
  69650. * Loader interface with additional members.
  69651. */
  69652. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  69653. /** @hidden */
  69654. _instanceData?: {
  69655. babylonSourceMesh: Mesh;
  69656. promise: Promise<any>;
  69657. };
  69658. }
  69659. /**
  69660. * Loader interface with additional members.
  69661. */
  69662. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  69663. /**
  69664. * The parent glTF node.
  69665. */
  69666. parent?: INode;
  69667. /** @hidden */
  69668. _babylonTransformNode?: TransformNode;
  69669. /** @hidden */
  69670. _primitiveBabylonMeshes?: AbstractMesh[];
  69671. /** @hidden */
  69672. _babylonBones?: Bone[];
  69673. /** @hidden */
  69674. _numMorphTargets?: number;
  69675. }
  69676. /** @hidden */
  69677. export interface _ISamplerData {
  69678. noMipMaps: boolean;
  69679. samplingMode: number;
  69680. wrapU: number;
  69681. wrapV: number;
  69682. }
  69683. /**
  69684. * Loader interface with additional members.
  69685. */
  69686. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  69687. /** @hidden */
  69688. _data?: _ISamplerData;
  69689. }
  69690. /**
  69691. * Loader interface with additional members.
  69692. */
  69693. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  69694. }
  69695. /**
  69696. * Loader interface with additional members.
  69697. */
  69698. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  69699. /** @hidden */
  69700. _data?: {
  69701. babylonSkeleton: Skeleton;
  69702. promise: Promise<void>;
  69703. };
  69704. }
  69705. /**
  69706. * Loader interface with additional members.
  69707. */
  69708. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  69709. }
  69710. /**
  69711. * Loader interface with additional members.
  69712. */
  69713. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  69714. }
  69715. /**
  69716. * Loader interface with additional members.
  69717. */
  69718. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  69719. accessors?: IAccessor[];
  69720. animations?: IAnimation[];
  69721. buffers?: IBuffer[];
  69722. bufferViews?: IBufferView[];
  69723. cameras?: ICamera[];
  69724. images?: IImage[];
  69725. materials?: IMaterial[];
  69726. meshes?: IMesh[];
  69727. nodes?: INode[];
  69728. samplers?: ISampler[];
  69729. scenes?: IScene[];
  69730. skins?: ISkin[];
  69731. textures?: ITexture[];
  69732. }
  69733. }
  69734. declare module BABYLON.GLTF2 {
  69735. /**
  69736. * Interface for a glTF loader extension.
  69737. */
  69738. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  69739. /**
  69740. * Called after the loader state changes to LOADING.
  69741. */
  69742. onLoading?(): void;
  69743. /**
  69744. * Called after the loader state changes to READY.
  69745. */
  69746. onReady?(): void;
  69747. /**
  69748. * Define this method to modify the default behavior when loading scenes.
  69749. * @param context The context when loading the asset
  69750. * @param scene The glTF scene property
  69751. * @returns A promise that resolves when the load is complete or null if not handled
  69752. */
  69753. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  69754. /**
  69755. * Define this method to modify the default behavior when loading nodes.
  69756. * @param context The context when loading the asset
  69757. * @param node The glTF node property
  69758. * @param assign A function called synchronously after parsing the glTF properties
  69759. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  69760. */
  69761. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69762. /**
  69763. * Define this method to modify the default behavior when loading cameras.
  69764. * @param context The context when loading the asset
  69765. * @param camera The glTF camera property
  69766. * @param assign A function called synchronously after parsing the glTF properties
  69767. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  69768. */
  69769. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69770. /**
  69771. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  69772. * @param context The context when loading the asset
  69773. * @param primitive The glTF mesh primitive property
  69774. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  69775. */
  69776. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69777. /**
  69778. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69779. * @param context The context when loading the asset
  69780. * @param name The mesh name when loading the asset
  69781. * @param node The glTF node when loading the asset
  69782. * @param mesh The glTF mesh when loading the asset
  69783. * @param primitive The glTF mesh primitive property
  69784. * @param assign A function called synchronously after parsing the glTF properties
  69785. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69786. */
  69787. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69788. /**
  69789. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  69790. * @param context The context when loading the asset
  69791. * @param material The glTF material property
  69792. * @param assign A function called synchronously after parsing the glTF properties
  69793. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  69794. */
  69795. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69796. /**
  69797. * Define this method to modify the default behavior when creating materials.
  69798. * @param context The context when loading the asset
  69799. * @param material The glTF material property
  69800. * @param babylonDrawMode The draw mode for the Babylon material
  69801. * @returns The Babylon material or null if not handled
  69802. */
  69803. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69804. /**
  69805. * Define this method to modify the default behavior when loading material properties.
  69806. * @param context The context when loading the asset
  69807. * @param material The glTF material property
  69808. * @param babylonMaterial The Babylon material
  69809. * @returns A promise that resolves when the load is complete or null if not handled
  69810. */
  69811. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69812. /**
  69813. * Define this method to modify the default behavior when loading texture infos.
  69814. * @param context The context when loading the asset
  69815. * @param textureInfo The glTF texture info property
  69816. * @param assign A function called synchronously after parsing the glTF properties
  69817. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  69818. */
  69819. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69820. /**
  69821. * Define this method to modify the default behavior when loading animations.
  69822. * @param context The context when loading the asset
  69823. * @param animation The glTF animation property
  69824. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  69825. */
  69826. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69827. /**
  69828. * @hidden Define this method to modify the default behavior when loading skins.
  69829. * @param context The context when loading the asset
  69830. * @param node The glTF node property
  69831. * @param skin The glTF skin property
  69832. * @returns A promise that resolves when the load is complete or null if not handled
  69833. */
  69834. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  69835. /**
  69836. * @hidden Define this method to modify the default behavior when loading uris.
  69837. * @param context The context when loading the asset
  69838. * @param property The glTF property associated with the uri
  69839. * @param uri The uri to load
  69840. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69841. */
  69842. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69843. /**
  69844. * Define this method to modify the default behavior when loading buffer views.
  69845. * @param context The context when loading the asset
  69846. * @param bufferView The glTF buffer view property
  69847. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69848. */
  69849. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  69850. /**
  69851. * Define this method to modify the default behavior when loading buffers.
  69852. * @param context The context when loading the asset
  69853. * @param buffer The glTF buffer property
  69854. * @param byteOffset The byte offset to load
  69855. * @param byteLength The byte length to load
  69856. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69857. */
  69858. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  69859. }
  69860. }
  69861. declare module BABYLON.GLTF2 {
  69862. /**
  69863. * Helper class for working with arrays when loading the glTF asset
  69864. */
  69865. export class ArrayItem {
  69866. /**
  69867. * Gets an item from the given array.
  69868. * @param context The context when loading the asset
  69869. * @param array The array to get the item from
  69870. * @param index The index to the array
  69871. * @returns The array item
  69872. */
  69873. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  69874. /**
  69875. * Assign an `index` field to each item of the given array.
  69876. * @param array The array of items
  69877. */
  69878. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  69879. }
  69880. /**
  69881. * The glTF 2.0 loader
  69882. */
  69883. export class GLTFLoader implements IGLTFLoader {
  69884. /** @hidden */
  69885. _completePromises: Promise<any>[];
  69886. private _disposed;
  69887. private _parent;
  69888. private _state;
  69889. private _extensions;
  69890. private _rootUrl;
  69891. private _fileName;
  69892. private _uniqueRootUrl;
  69893. private _gltf;
  69894. private _bin;
  69895. private _babylonScene;
  69896. private _rootBabylonMesh;
  69897. private _defaultBabylonMaterialData;
  69898. private _progressCallback?;
  69899. private _requests;
  69900. private static readonly _DefaultSampler;
  69901. private static _RegisteredExtensions;
  69902. /**
  69903. * Registers a loader extension.
  69904. * @param name The name of the loader extension.
  69905. * @param factory The factory function that creates the loader extension.
  69906. */
  69907. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  69908. /**
  69909. * Unregisters a loader extension.
  69910. * @param name The name of the loader extension.
  69911. * @returns A boolean indicating whether the extension has been unregistered
  69912. */
  69913. static UnregisterExtension(name: string): boolean;
  69914. /**
  69915. * Gets the loader state.
  69916. */
  69917. readonly state: Nullable<GLTFLoaderState>;
  69918. /**
  69919. * The object that represents the glTF JSON.
  69920. */
  69921. readonly gltf: IGLTF;
  69922. /**
  69923. * The BIN chunk of a binary glTF.
  69924. */
  69925. readonly bin: Nullable<IDataBuffer>;
  69926. /**
  69927. * The parent file loader.
  69928. */
  69929. readonly parent: GLTFFileLoader;
  69930. /**
  69931. * The Babylon scene when loading the asset.
  69932. */
  69933. readonly babylonScene: Scene;
  69934. /**
  69935. * The root Babylon mesh when loading the asset.
  69936. */
  69937. readonly rootBabylonMesh: Mesh;
  69938. /** @hidden */
  69939. constructor(parent: GLTFFileLoader);
  69940. /** @hidden */
  69941. dispose(): void;
  69942. /** @hidden */
  69943. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69944. meshes: AbstractMesh[];
  69945. particleSystems: IParticleSystem[];
  69946. skeletons: Skeleton[];
  69947. animationGroups: AnimationGroup[];
  69948. }>;
  69949. /** @hidden */
  69950. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69951. private _loadAsync;
  69952. private _loadData;
  69953. private _setupData;
  69954. private _loadExtensions;
  69955. private _checkExtensions;
  69956. private _setState;
  69957. private _createRootNode;
  69958. /**
  69959. * Loads a glTF scene.
  69960. * @param context The context when loading the asset
  69961. * @param scene The glTF scene property
  69962. * @returns A promise that resolves when the load is complete
  69963. */
  69964. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  69965. private _forEachPrimitive;
  69966. private _getMeshes;
  69967. private _getSkeletons;
  69968. private _getAnimationGroups;
  69969. private _startAnimations;
  69970. /**
  69971. * Loads a glTF node.
  69972. * @param context The context when loading the asset
  69973. * @param node The glTF node property
  69974. * @param assign A function called synchronously after parsing the glTF properties
  69975. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  69976. */
  69977. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  69978. private _loadMeshAsync;
  69979. /**
  69980. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69981. * @param context The context when loading the asset
  69982. * @param name The mesh name when loading the asset
  69983. * @param node The glTF node when loading the asset
  69984. * @param mesh The glTF mesh when loading the asset
  69985. * @param primitive The glTF mesh primitive property
  69986. * @param assign A function called synchronously after parsing the glTF properties
  69987. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69988. */
  69989. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69990. private _loadVertexDataAsync;
  69991. private _createMorphTargets;
  69992. private _loadMorphTargetsAsync;
  69993. private _loadMorphTargetVertexDataAsync;
  69994. private static _LoadTransform;
  69995. private _loadSkinAsync;
  69996. private _loadBones;
  69997. private _loadBone;
  69998. private _loadSkinInverseBindMatricesDataAsync;
  69999. private _updateBoneMatrices;
  70000. private _getNodeMatrix;
  70001. /**
  70002. * Loads a glTF camera.
  70003. * @param context The context when loading the asset
  70004. * @param camera The glTF camera property
  70005. * @param assign A function called synchronously after parsing the glTF properties
  70006. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  70007. */
  70008. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  70009. private _loadAnimationsAsync;
  70010. /**
  70011. * Loads a glTF animation.
  70012. * @param context The context when loading the asset
  70013. * @param animation The glTF animation property
  70014. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  70015. */
  70016. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  70017. /**
  70018. * @hidden Loads a glTF animation channel.
  70019. * @param context The context when loading the asset
  70020. * @param animationContext The context of the animation when loading the asset
  70021. * @param animation The glTF animation property
  70022. * @param channel The glTF animation channel property
  70023. * @param babylonAnimationGroup The babylon animation group property
  70024. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  70025. * @returns A void promise when the channel load is complete
  70026. */
  70027. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  70028. private _loadAnimationSamplerAsync;
  70029. private _loadBufferAsync;
  70030. /**
  70031. * Loads a glTF buffer view.
  70032. * @param context The context when loading the asset
  70033. * @param bufferView The glTF buffer view property
  70034. * @returns A promise that resolves with the loaded data when the load is complete
  70035. */
  70036. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  70037. private _loadAccessorAsync;
  70038. private _loadFloatAccessorAsync;
  70039. private _loadIndicesAccessorAsync;
  70040. private _loadVertexBufferViewAsync;
  70041. private _loadVertexAccessorAsync;
  70042. private _loadMaterialMetallicRoughnessPropertiesAsync;
  70043. /** @hidden */
  70044. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  70045. private _createDefaultMaterial;
  70046. /**
  70047. * Creates a Babylon material from a glTF material.
  70048. * @param context The context when loading the asset
  70049. * @param material The glTF material property
  70050. * @param babylonDrawMode The draw mode for the Babylon material
  70051. * @returns The Babylon material
  70052. */
  70053. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  70054. /**
  70055. * Loads properties from a glTF material into a Babylon material.
  70056. * @param context The context when loading the asset
  70057. * @param material The glTF material property
  70058. * @param babylonMaterial The Babylon material
  70059. * @returns A promise that resolves when the load is complete
  70060. */
  70061. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  70062. /**
  70063. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  70064. * @param context The context when loading the asset
  70065. * @param material The glTF material property
  70066. * @param babylonMaterial The Babylon material
  70067. * @returns A promise that resolves when the load is complete
  70068. */
  70069. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  70070. /**
  70071. * Loads the alpha properties from a glTF material into a Babylon material.
  70072. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  70073. * @param context The context when loading the asset
  70074. * @param material The glTF material property
  70075. * @param babylonMaterial The Babylon material
  70076. */
  70077. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  70078. /**
  70079. * Loads a glTF texture info.
  70080. * @param context The context when loading the asset
  70081. * @param textureInfo The glTF texture info property
  70082. * @param assign A function called synchronously after parsing the glTF properties
  70083. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  70084. */
  70085. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  70086. private _loadTextureAsync;
  70087. private _loadSampler;
  70088. /**
  70089. * Loads a glTF image.
  70090. * @param context The context when loading the asset
  70091. * @param image The glTF image property
  70092. * @returns A promise that resolves with the loaded data when the load is complete
  70093. */
  70094. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  70095. /**
  70096. * Loads a glTF uri.
  70097. * @param context The context when loading the asset
  70098. * @param property The glTF property associated with the uri
  70099. * @param uri The base64 or relative uri
  70100. * @returns A promise that resolves with the loaded data when the load is complete
  70101. */
  70102. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  70103. private _onProgress;
  70104. /**
  70105. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  70106. * @param babylonObject the Babylon object with metadata
  70107. * @param pointer the JSON pointer
  70108. */
  70109. static AddPointerMetadata(babylonObject: {
  70110. metadata: any;
  70111. }, pointer: string): void;
  70112. private static _GetTextureWrapMode;
  70113. private static _GetTextureSamplingMode;
  70114. private static _GetTypedArrayConstructor;
  70115. private static _GetTypedArray;
  70116. private static _GetNumComponents;
  70117. private static _ValidateUri;
  70118. private static _GetDrawMode;
  70119. private _compileMaterialsAsync;
  70120. private _compileShadowGeneratorsAsync;
  70121. private _forEachExtensions;
  70122. private _applyExtensions;
  70123. private _extensionsOnLoading;
  70124. private _extensionsOnReady;
  70125. private _extensionsLoadSceneAsync;
  70126. private _extensionsLoadNodeAsync;
  70127. private _extensionsLoadCameraAsync;
  70128. private _extensionsLoadVertexDataAsync;
  70129. private _extensionsLoadMeshPrimitiveAsync;
  70130. private _extensionsLoadMaterialAsync;
  70131. private _extensionsCreateMaterial;
  70132. private _extensionsLoadMaterialPropertiesAsync;
  70133. private _extensionsLoadTextureInfoAsync;
  70134. private _extensionsLoadAnimationAsync;
  70135. private _extensionsLoadSkinAsync;
  70136. private _extensionsLoadUriAsync;
  70137. private _extensionsLoadBufferViewAsync;
  70138. private _extensionsLoadBufferAsync;
  70139. /**
  70140. * Helper method called by a loader extension to load an glTF extension.
  70141. * @param context The context when loading the asset
  70142. * @param property The glTF property to load the extension from
  70143. * @param extensionName The name of the extension to load
  70144. * @param actionAsync The action to run
  70145. * @returns The promise returned by actionAsync or null if the extension does not exist
  70146. */
  70147. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  70148. /**
  70149. * Helper method called by a loader extension to load a glTF extra.
  70150. * @param context The context when loading the asset
  70151. * @param property The glTF property to load the extra from
  70152. * @param extensionName The name of the extension to load
  70153. * @param actionAsync The action to run
  70154. * @returns The promise returned by actionAsync or null if the extra does not exist
  70155. */
  70156. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  70157. /**
  70158. * Checks for presence of an extension.
  70159. * @param name The name of the extension to check
  70160. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  70161. */
  70162. isExtensionUsed(name: string): boolean;
  70163. /**
  70164. * Increments the indentation level and logs a message.
  70165. * @param message The message to log
  70166. */
  70167. logOpen(message: string): void;
  70168. /**
  70169. * Decrements the indentation level.
  70170. */
  70171. logClose(): void;
  70172. /**
  70173. * Logs a message
  70174. * @param message The message to log
  70175. */
  70176. log(message: string): void;
  70177. /**
  70178. * Starts a performance counter.
  70179. * @param counterName The name of the performance counter
  70180. */
  70181. startPerformanceCounter(counterName: string): void;
  70182. /**
  70183. * Ends a performance counter.
  70184. * @param counterName The name of the performance counter
  70185. */
  70186. endPerformanceCounter(counterName: string): void;
  70187. }
  70188. }
  70189. declare module BABYLON.GLTF2.Loader.Extensions {
  70190. /**
  70191. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  70192. */
  70193. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  70194. /**
  70195. * The name of this extension.
  70196. */
  70197. readonly name: string;
  70198. /**
  70199. * Defines whether this extension is enabled.
  70200. */
  70201. enabled: boolean;
  70202. private _loader;
  70203. private _lights?;
  70204. /** @hidden */
  70205. constructor(loader: GLTFLoader);
  70206. /** @hidden */
  70207. dispose(): void;
  70208. /** @hidden */
  70209. onLoading(): void;
  70210. /** @hidden */
  70211. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  70212. private _loadLightAsync;
  70213. }
  70214. }
  70215. declare module BABYLON.GLTF2.Loader.Extensions {
  70216. /**
  70217. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  70218. */
  70219. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  70220. /**
  70221. * The name of this extension.
  70222. */
  70223. readonly name: string;
  70224. /**
  70225. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  70226. */
  70227. dracoCompression?: DracoCompression;
  70228. /**
  70229. * Defines whether this extension is enabled.
  70230. */
  70231. enabled: boolean;
  70232. private _loader;
  70233. /** @hidden */
  70234. constructor(loader: GLTFLoader);
  70235. /** @hidden */
  70236. dispose(): void;
  70237. /** @hidden */
  70238. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  70239. }
  70240. }
  70241. declare module BABYLON.GLTF2.Loader.Extensions {
  70242. /**
  70243. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  70244. */
  70245. export class KHR_lights implements IGLTFLoaderExtension {
  70246. /**
  70247. * The name of this extension.
  70248. */
  70249. readonly name: string;
  70250. /**
  70251. * Defines whether this extension is enabled.
  70252. */
  70253. enabled: boolean;
  70254. private _loader;
  70255. private _lights?;
  70256. /** @hidden */
  70257. constructor(loader: GLTFLoader);
  70258. /** @hidden */
  70259. dispose(): void;
  70260. /** @hidden */
  70261. onLoading(): void;
  70262. /** @hidden */
  70263. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70264. }
  70265. }
  70266. declare module BABYLON.GLTF2.Loader.Extensions {
  70267. /**
  70268. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  70269. */
  70270. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  70271. /**
  70272. * The name of this extension.
  70273. */
  70274. readonly name: string;
  70275. /**
  70276. * Defines whether this extension is enabled.
  70277. */
  70278. enabled: boolean;
  70279. /**
  70280. * Defines a number that determines the order the extensions are applied.
  70281. */
  70282. order: number;
  70283. private _loader;
  70284. /** @hidden */
  70285. constructor(loader: GLTFLoader);
  70286. /** @hidden */
  70287. dispose(): void;
  70288. /** @hidden */
  70289. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70290. private _loadSpecularGlossinessPropertiesAsync;
  70291. }
  70292. }
  70293. declare module BABYLON.GLTF2.Loader.Extensions {
  70294. /**
  70295. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  70296. */
  70297. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  70298. /**
  70299. * The name of this extension.
  70300. */
  70301. readonly name: string;
  70302. /**
  70303. * Defines whether this extension is enabled.
  70304. */
  70305. enabled: boolean;
  70306. /**
  70307. * Defines a number that determines the order the extensions are applied.
  70308. */
  70309. order: number;
  70310. private _loader;
  70311. /** @hidden */
  70312. constructor(loader: GLTFLoader);
  70313. /** @hidden */
  70314. dispose(): void;
  70315. /** @hidden */
  70316. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70317. private _loadUnlitPropertiesAsync;
  70318. }
  70319. }
  70320. declare module BABYLON.GLTF2.Loader.Extensions {
  70321. /**
  70322. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  70323. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  70324. * !!! Experimental Extension Subject to Changes !!!
  70325. */
  70326. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  70327. /**
  70328. * The name of this extension.
  70329. */
  70330. readonly name: string;
  70331. /**
  70332. * Defines whether this extension is enabled.
  70333. */
  70334. enabled: boolean;
  70335. /**
  70336. * Defines a number that determines the order the extensions are applied.
  70337. */
  70338. order: number;
  70339. private _loader;
  70340. /** @hidden */
  70341. constructor(loader: GLTFLoader);
  70342. /** @hidden */
  70343. dispose(): void;
  70344. /** @hidden */
  70345. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70346. private _loadClearCoatPropertiesAsync;
  70347. }
  70348. }
  70349. declare module BABYLON.GLTF2.Loader.Extensions {
  70350. /**
  70351. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  70352. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  70353. * !!! Experimental Extension Subject to Changes !!!
  70354. */
  70355. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  70356. /**
  70357. * The name of this extension.
  70358. */
  70359. readonly name: string;
  70360. /**
  70361. * Defines whether this extension is enabled.
  70362. */
  70363. enabled: boolean;
  70364. /**
  70365. * Defines a number that determines the order the extensions are applied.
  70366. */
  70367. order: number;
  70368. private _loader;
  70369. /** @hidden */
  70370. constructor(loader: GLTFLoader);
  70371. /** @hidden */
  70372. dispose(): void;
  70373. /** @hidden */
  70374. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70375. private _loadSheenPropertiesAsync;
  70376. }
  70377. }
  70378. declare module BABYLON.GLTF2.Loader.Extensions {
  70379. /**
  70380. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  70381. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  70382. * !!! Experimental Extension Subject to Changes !!!
  70383. */
  70384. export class KHR_materials_specular implements IGLTFLoaderExtension {
  70385. /**
  70386. * The name of this extension.
  70387. */
  70388. readonly name: string;
  70389. /**
  70390. * Defines whether this extension is enabled.
  70391. */
  70392. enabled: boolean;
  70393. /**
  70394. * Defines a number that determines the order the extensions are applied.
  70395. */
  70396. order: number;
  70397. private _loader;
  70398. /** @hidden */
  70399. constructor(loader: GLTFLoader);
  70400. /** @hidden */
  70401. dispose(): void;
  70402. /** @hidden */
  70403. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70404. private _loadSpecularPropertiesAsync;
  70405. }
  70406. }
  70407. declare module BABYLON.GLTF2.Loader.Extensions {
  70408. /**
  70409. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  70410. */
  70411. export class KHR_texture_transform implements IGLTFLoaderExtension {
  70412. /**
  70413. * The name of this extension.
  70414. */
  70415. readonly name: string;
  70416. /**
  70417. * Defines whether this extension is enabled.
  70418. */
  70419. enabled: boolean;
  70420. private _loader;
  70421. /** @hidden */
  70422. constructor(loader: GLTFLoader);
  70423. /** @hidden */
  70424. dispose(): void;
  70425. /** @hidden */
  70426. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  70427. }
  70428. }
  70429. declare module BABYLON.GLTF2.Loader.Extensions {
  70430. /**
  70431. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  70432. */
  70433. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  70434. /**
  70435. * The name of this extension.
  70436. */
  70437. readonly name: string;
  70438. /**
  70439. * Defines whether this extension is enabled.
  70440. */
  70441. enabled: boolean;
  70442. private _loader;
  70443. private _clips;
  70444. private _emitters;
  70445. /** @hidden */
  70446. constructor(loader: GLTFLoader);
  70447. /** @hidden */
  70448. dispose(): void;
  70449. /** @hidden */
  70450. onLoading(): void;
  70451. /** @hidden */
  70452. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  70453. /** @hidden */
  70454. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70455. /** @hidden */
  70456. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  70457. private _loadClipAsync;
  70458. private _loadEmitterAsync;
  70459. private _getEventAction;
  70460. private _loadAnimationEventAsync;
  70461. }
  70462. }
  70463. declare module BABYLON.GLTF2.Loader.Extensions {
  70464. /**
  70465. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  70466. */
  70467. export class MSFT_lod implements IGLTFLoaderExtension {
  70468. /**
  70469. * The name of this extension.
  70470. */
  70471. readonly name: string;
  70472. /**
  70473. * Defines whether this extension is enabled.
  70474. */
  70475. enabled: boolean;
  70476. /**
  70477. * Defines a number that determines the order the extensions are applied.
  70478. */
  70479. order: number;
  70480. /**
  70481. * Maximum number of LODs to load, starting from the lowest LOD.
  70482. */
  70483. maxLODsToLoad: number;
  70484. /**
  70485. * Observable raised when all node LODs of one level are loaded.
  70486. * The event data is the index of the loaded LOD starting from zero.
  70487. * Dispose the loader to cancel the loading of the next level of LODs.
  70488. */
  70489. onNodeLODsLoadedObservable: Observable<number>;
  70490. /**
  70491. * Observable raised when all material LODs of one level are loaded.
  70492. * The event data is the index of the loaded LOD starting from zero.
  70493. * Dispose the loader to cancel the loading of the next level of LODs.
  70494. */
  70495. onMaterialLODsLoadedObservable: Observable<number>;
  70496. private _loader;
  70497. private _nodeIndexLOD;
  70498. private _nodeSignalLODs;
  70499. private _nodePromiseLODs;
  70500. private _materialIndexLOD;
  70501. private _materialSignalLODs;
  70502. private _materialPromiseLODs;
  70503. private _indexLOD;
  70504. private _bufferLODs;
  70505. /** @hidden */
  70506. constructor(loader: GLTFLoader);
  70507. /** @hidden */
  70508. dispose(): void;
  70509. /** @hidden */
  70510. onReady(): void;
  70511. /** @hidden */
  70512. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70513. /** @hidden */
  70514. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  70515. /** @hidden */
  70516. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  70517. /** @hidden */
  70518. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  70519. private _loadBufferLOD;
  70520. /**
  70521. * Gets an array of LOD properties from lowest to highest.
  70522. */
  70523. private _getLODs;
  70524. private _disposeUnusedMaterials;
  70525. }
  70526. }
  70527. declare module BABYLON.GLTF2.Loader.Extensions {
  70528. /** @hidden */
  70529. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  70530. readonly name: string;
  70531. enabled: boolean;
  70532. private _loader;
  70533. constructor(loader: GLTFLoader);
  70534. dispose(): void;
  70535. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70536. }
  70537. }
  70538. declare module BABYLON.GLTF2.Loader.Extensions {
  70539. /** @hidden */
  70540. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  70541. readonly name: string;
  70542. enabled: boolean;
  70543. private _loader;
  70544. constructor(loader: GLTFLoader);
  70545. dispose(): void;
  70546. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70547. }
  70548. }
  70549. declare module BABYLON.GLTF2.Loader.Extensions {
  70550. /**
  70551. * Store glTF extras (if present) in BJS objects' metadata
  70552. */
  70553. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  70554. /**
  70555. * The name of this extension.
  70556. */
  70557. readonly name: string;
  70558. /**
  70559. * Defines whether this extension is enabled.
  70560. */
  70561. enabled: boolean;
  70562. private _loader;
  70563. private _assignExtras;
  70564. /** @hidden */
  70565. constructor(loader: GLTFLoader);
  70566. /** @hidden */
  70567. dispose(): void;
  70568. /** @hidden */
  70569. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70570. /** @hidden */
  70571. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  70572. /** @hidden */
  70573. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  70574. }
  70575. }
  70576. declare module BABYLON {
  70577. /**
  70578. * Class reading and parsing the MTL file bundled with the obj file.
  70579. */
  70580. export class MTLFileLoader {
  70581. /**
  70582. * All material loaded from the mtl will be set here
  70583. */
  70584. materials: StandardMaterial[];
  70585. /**
  70586. * This function will read the mtl file and create each material described inside
  70587. * This function could be improve by adding :
  70588. * -some component missing (Ni, Tf...)
  70589. * -including the specific options available
  70590. *
  70591. * @param scene defines the scene the material will be created in
  70592. * @param data defines the mtl data to parse
  70593. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  70594. */
  70595. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  70596. /**
  70597. * Gets the texture for the material.
  70598. *
  70599. * If the material is imported from input file,
  70600. * We sanitize the url to ensure it takes the textre from aside the material.
  70601. *
  70602. * @param rootUrl The root url to load from
  70603. * @param value The value stored in the mtl
  70604. * @return The Texture
  70605. */
  70606. private static _getTexture;
  70607. }
  70608. /**
  70609. * Options for loading OBJ/MTL files
  70610. */
  70611. type MeshLoadOptions = {
  70612. /**
  70613. * Defines if UVs are optimized by default during load.
  70614. */
  70615. OptimizeWithUV: boolean;
  70616. /**
  70617. * Defines custom scaling of UV coordinates of loaded meshes.
  70618. */
  70619. UVScaling: Vector2;
  70620. /**
  70621. * Invert model on y-axis (does a model scaling inversion)
  70622. */
  70623. InvertY: boolean;
  70624. /**
  70625. * Invert Y-Axis of referenced textures on load
  70626. */
  70627. InvertTextureY: boolean;
  70628. /**
  70629. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  70630. */
  70631. ImportVertexColors: boolean;
  70632. /**
  70633. * Compute the normals for the model, even if normals are present in the file.
  70634. */
  70635. ComputeNormals: boolean;
  70636. /**
  70637. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  70638. */
  70639. SkipMaterials: boolean;
  70640. /**
  70641. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  70642. */
  70643. MaterialLoadingFailsSilently: boolean;
  70644. };
  70645. /**
  70646. * OBJ file type loader.
  70647. * This is a babylon scene loader plugin.
  70648. */
  70649. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  70650. /**
  70651. * Defines if UVs are optimized by default during load.
  70652. */
  70653. static OPTIMIZE_WITH_UV: boolean;
  70654. /**
  70655. * Invert model on y-axis (does a model scaling inversion)
  70656. */
  70657. static INVERT_Y: boolean;
  70658. /**
  70659. * Invert Y-Axis of referenced textures on load
  70660. */
  70661. static INVERT_TEXTURE_Y: boolean;
  70662. /**
  70663. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  70664. */
  70665. static IMPORT_VERTEX_COLORS: boolean;
  70666. /**
  70667. * Compute the normals for the model, even if normals are present in the file.
  70668. */
  70669. static COMPUTE_NORMALS: boolean;
  70670. /**
  70671. * Defines custom scaling of UV coordinates of loaded meshes.
  70672. */
  70673. static UV_SCALING: Vector2;
  70674. /**
  70675. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  70676. */
  70677. static SKIP_MATERIALS: boolean;
  70678. /**
  70679. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  70680. *
  70681. * Defaults to true for backwards compatibility.
  70682. */
  70683. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  70684. /**
  70685. * Defines the name of the plugin.
  70686. */
  70687. name: string;
  70688. /**
  70689. * Defines the extension the plugin is able to load.
  70690. */
  70691. extensions: string;
  70692. /** @hidden */
  70693. obj: RegExp;
  70694. /** @hidden */
  70695. group: RegExp;
  70696. /** @hidden */
  70697. mtllib: RegExp;
  70698. /** @hidden */
  70699. usemtl: RegExp;
  70700. /** @hidden */
  70701. smooth: RegExp;
  70702. /** @hidden */
  70703. vertexPattern: RegExp;
  70704. /** @hidden */
  70705. normalPattern: RegExp;
  70706. /** @hidden */
  70707. uvPattern: RegExp;
  70708. /** @hidden */
  70709. facePattern1: RegExp;
  70710. /** @hidden */
  70711. facePattern2: RegExp;
  70712. /** @hidden */
  70713. facePattern3: RegExp;
  70714. /** @hidden */
  70715. facePattern4: RegExp;
  70716. /** @hidden */
  70717. facePattern5: RegExp;
  70718. private _meshLoadOptions;
  70719. /**
  70720. * Creates loader for .OBJ files
  70721. *
  70722. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  70723. */
  70724. constructor(meshLoadOptions?: MeshLoadOptions);
  70725. private static readonly currentMeshLoadOptions;
  70726. /**
  70727. * Calls synchronously the MTL file attached to this obj.
  70728. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  70729. * Without this function materials are not displayed in the first frame (but displayed after).
  70730. * In consequence it is impossible to get material information in your HTML file
  70731. *
  70732. * @param url The URL of the MTL file
  70733. * @param rootUrl
  70734. * @param onSuccess Callback function to be called when the MTL file is loaded
  70735. * @private
  70736. */
  70737. private _loadMTL;
  70738. /**
  70739. * Instantiates a OBJ file loader plugin.
  70740. * @returns the created plugin
  70741. */
  70742. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  70743. /**
  70744. * If the data string can be loaded directly.
  70745. *
  70746. * @param data string containing the file data
  70747. * @returns if the data can be loaded directly
  70748. */
  70749. canDirectLoad(data: string): boolean;
  70750. /**
  70751. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  70752. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  70753. * @param scene the scene the meshes should be added to
  70754. * @param data the OBJ data to load
  70755. * @param rootUrl root url to load from
  70756. * @param onProgress event that fires when loading progress has occured
  70757. * @param fileName Defines the name of the file to load
  70758. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  70759. */
  70760. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  70761. meshes: AbstractMesh[];
  70762. particleSystems: IParticleSystem[];
  70763. skeletons: Skeleton[];
  70764. animationGroups: AnimationGroup[];
  70765. }>;
  70766. /**
  70767. * Imports all objects from the loaded OBJ data and adds them to the scene
  70768. * @param scene the scene the objects should be added to
  70769. * @param data the OBJ data to load
  70770. * @param rootUrl root url to load from
  70771. * @param onProgress event that fires when loading progress has occured
  70772. * @param fileName Defines the name of the file to load
  70773. * @returns a promise which completes when objects have been loaded to the scene
  70774. */
  70775. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  70776. /**
  70777. * Load into an asset container.
  70778. * @param scene The scene to load into
  70779. * @param data The data to import
  70780. * @param rootUrl The root url for scene and resources
  70781. * @param onProgress The callback when the load progresses
  70782. * @param fileName Defines the name of the file to load
  70783. * @returns The loaded asset container
  70784. */
  70785. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  70786. /**
  70787. * Read the OBJ file and create an Array of meshes.
  70788. * Each mesh contains all information given by the OBJ and the MTL file.
  70789. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  70790. *
  70791. * @param meshesNames
  70792. * @param scene Scene The scene where are displayed the data
  70793. * @param data String The content of the obj file
  70794. * @param rootUrl String The path to the folder
  70795. * @returns Array<AbstractMesh>
  70796. * @private
  70797. */
  70798. private _parseSolid;
  70799. }
  70800. }
  70801. declare module BABYLON {
  70802. /**
  70803. * STL file type loader.
  70804. * This is a babylon scene loader plugin.
  70805. */
  70806. export class STLFileLoader implements ISceneLoaderPlugin {
  70807. /** @hidden */
  70808. solidPattern: RegExp;
  70809. /** @hidden */
  70810. facetsPattern: RegExp;
  70811. /** @hidden */
  70812. normalPattern: RegExp;
  70813. /** @hidden */
  70814. vertexPattern: RegExp;
  70815. /**
  70816. * Defines the name of the plugin.
  70817. */
  70818. name: string;
  70819. /**
  70820. * Defines the extensions the stl loader is able to load.
  70821. * force data to come in as an ArrayBuffer
  70822. * we'll convert to string if it looks like it's an ASCII .stl
  70823. */
  70824. extensions: ISceneLoaderPluginExtensions;
  70825. /**
  70826. * Import meshes into a scene.
  70827. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  70828. * @param scene The scene to import into
  70829. * @param data The data to import
  70830. * @param rootUrl The root url for scene and resources
  70831. * @param meshes The meshes array to import into
  70832. * @param particleSystems The particle systems array to import into
  70833. * @param skeletons The skeletons array to import into
  70834. * @param onError The callback when import fails
  70835. * @returns True if successful or false otherwise
  70836. */
  70837. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  70838. /**
  70839. * Load into a scene.
  70840. * @param scene The scene to load into
  70841. * @param data The data to import
  70842. * @param rootUrl The root url for scene and resources
  70843. * @param onError The callback when import fails
  70844. * @returns true if successful or false otherwise
  70845. */
  70846. load(scene: Scene, data: any, rootUrl: string): boolean;
  70847. /**
  70848. * Load into an asset container.
  70849. * @param scene The scene to load into
  70850. * @param data The data to import
  70851. * @param rootUrl The root url for scene and resources
  70852. * @param onError The callback when import fails
  70853. * @returns The loaded asset container
  70854. */
  70855. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  70856. private _isBinary;
  70857. private _parseBinary;
  70858. private _parseASCII;
  70859. }
  70860. }
  70861. declare module BABYLON {
  70862. /**
  70863. * Class for generating OBJ data from a Babylon scene.
  70864. */
  70865. export class OBJExport {
  70866. /**
  70867. * Exports the geometry of a Mesh array in .OBJ file format (text)
  70868. * @param mesh defines the list of meshes to serialize
  70869. * @param materials defines if materials should be exported
  70870. * @param matlibname defines the name of the associated mtl file
  70871. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  70872. * @returns the OBJ content
  70873. */
  70874. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  70875. /**
  70876. * Exports the material(s) of a mesh in .MTL file format (text)
  70877. * @param mesh defines the mesh to extract the material from
  70878. * @returns the mtl content
  70879. */
  70880. static MTL(mesh: Mesh): string;
  70881. }
  70882. }
  70883. declare module BABYLON {
  70884. /** @hidden */
  70885. export var __IGLTFExporterExtension: number;
  70886. /**
  70887. * Interface for extending the exporter
  70888. * @hidden
  70889. */
  70890. export interface IGLTFExporterExtension {
  70891. /**
  70892. * The name of this extension
  70893. */
  70894. readonly name: string;
  70895. /**
  70896. * Defines whether this extension is enabled
  70897. */
  70898. enabled: boolean;
  70899. /**
  70900. * Defines whether this extension is required
  70901. */
  70902. required: boolean;
  70903. }
  70904. }
  70905. declare module BABYLON.GLTF2.Exporter {
  70906. /** @hidden */
  70907. export var __IGLTFExporterExtensionV2: number;
  70908. /**
  70909. * Interface for a glTF exporter extension
  70910. * @hidden
  70911. */
  70912. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  70913. /**
  70914. * Define this method to modify the default behavior before exporting a texture
  70915. * @param context The context when loading the asset
  70916. * @param babylonTexture The glTF texture info property
  70917. * @param mimeType The mime-type of the generated image
  70918. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  70919. */
  70920. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70921. /**
  70922. * Define this method to modify the default behavior when exporting texture info
  70923. * @param context The context when loading the asset
  70924. * @param meshPrimitive glTF mesh primitive
  70925. * @param babylonSubMesh Babylon submesh
  70926. * @param binaryWriter glTF serializer binary writer instance
  70927. * @returns nullable IMeshPrimitive promise
  70928. */
  70929. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  70930. /**
  70931. * Define this method to modify the default behavior when exporting a node
  70932. * @param context The context when exporting the node
  70933. * @param node glTF node
  70934. * @param babylonNode BabylonJS node
  70935. * @returns nullable INode promise
  70936. */
  70937. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70938. /**
  70939. * Called after the exporter state changes to EXPORTING
  70940. */
  70941. onExporting?(): void;
  70942. }
  70943. }
  70944. declare module BABYLON.GLTF2.Exporter {
  70945. /**
  70946. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  70947. * @hidden
  70948. */
  70949. export class _GLTFMaterialExporter {
  70950. /**
  70951. * Represents the dielectric specular values for R, G and B
  70952. */
  70953. private static readonly _DielectricSpecular;
  70954. /**
  70955. * Allows the maximum specular power to be defined for material calculations
  70956. */
  70957. private static readonly _MaxSpecularPower;
  70958. /**
  70959. * Mapping to store textures
  70960. */
  70961. private _textureMap;
  70962. /**
  70963. * Numeric tolerance value
  70964. */
  70965. private static readonly _Epsilon;
  70966. /**
  70967. * Reference to the glTF Exporter
  70968. */
  70969. private _exporter;
  70970. constructor(exporter: _Exporter);
  70971. /**
  70972. * Specifies if two colors are approximately equal in value
  70973. * @param color1 first color to compare to
  70974. * @param color2 second color to compare to
  70975. * @param epsilon threshold value
  70976. */
  70977. private static FuzzyEquals;
  70978. /**
  70979. * Gets the materials from a Babylon scene and converts them to glTF materials
  70980. * @param scene babylonjs scene
  70981. * @param mimeType texture mime type
  70982. * @param images array of images
  70983. * @param textures array of textures
  70984. * @param materials array of materials
  70985. * @param imageData mapping of texture names to base64 textures
  70986. * @param hasTextureCoords specifies if texture coordinates are present on the material
  70987. */
  70988. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70989. /**
  70990. * Makes a copy of the glTF material without the texture parameters
  70991. * @param originalMaterial original glTF material
  70992. * @returns glTF material without texture parameters
  70993. */
  70994. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  70995. /**
  70996. * Specifies if the material has any texture parameters present
  70997. * @param material glTF Material
  70998. * @returns boolean specifying if texture parameters are present
  70999. */
  71000. _hasTexturesPresent(material: IMaterial): boolean;
  71001. /**
  71002. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  71003. * @param babylonStandardMaterial
  71004. * @returns glTF Metallic Roughness Material representation
  71005. */
  71006. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  71007. /**
  71008. * Computes the metallic factor
  71009. * @param diffuse diffused value
  71010. * @param specular specular value
  71011. * @param oneMinusSpecularStrength one minus the specular strength
  71012. * @returns metallic value
  71013. */
  71014. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  71015. /**
  71016. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  71017. * @param glTFMaterial glTF material
  71018. * @param babylonMaterial Babylon material
  71019. */
  71020. private static _SetAlphaMode;
  71021. /**
  71022. * Converts a Babylon Standard Material to a glTF Material
  71023. * @param babylonStandardMaterial BJS Standard Material
  71024. * @param mimeType mime type to use for the textures
  71025. * @param images array of glTF image interfaces
  71026. * @param textures array of glTF texture interfaces
  71027. * @param materials array of glTF material interfaces
  71028. * @param imageData map of image file name to data
  71029. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  71030. */
  71031. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  71032. /**
  71033. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  71034. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  71035. * @param mimeType mime type to use for the textures
  71036. * @param images array of glTF image interfaces
  71037. * @param textures array of glTF texture interfaces
  71038. * @param materials array of glTF material interfaces
  71039. * @param imageData map of image file name to data
  71040. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  71041. */
  71042. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  71043. /**
  71044. * Converts an image typed array buffer to a base64 image
  71045. * @param buffer typed array buffer
  71046. * @param width width of the image
  71047. * @param height height of the image
  71048. * @param mimeType mimetype of the image
  71049. * @returns base64 image string
  71050. */
  71051. private _createBase64FromCanvasAsync;
  71052. /**
  71053. * Generates a white texture based on the specified width and height
  71054. * @param width width of the texture in pixels
  71055. * @param height height of the texture in pixels
  71056. * @param scene babylonjs scene
  71057. * @returns white texture
  71058. */
  71059. private _createWhiteTexture;
  71060. /**
  71061. * 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
  71062. * @param texture1 first texture to resize
  71063. * @param texture2 second texture to resize
  71064. * @param scene babylonjs scene
  71065. * @returns resized textures or null
  71066. */
  71067. private _resizeTexturesToSameDimensions;
  71068. /**
  71069. * Converts an array of pixels to a Float32Array
  71070. * Throws an error if the pixel format is not supported
  71071. * @param pixels - array buffer containing pixel values
  71072. * @returns Float32 of pixels
  71073. */
  71074. private _convertPixelArrayToFloat32;
  71075. /**
  71076. * Convert Specular Glossiness Textures to Metallic Roughness
  71077. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  71078. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  71079. * @param diffuseTexture texture used to store diffuse information
  71080. * @param specularGlossinessTexture texture used to store specular and glossiness information
  71081. * @param factors specular glossiness material factors
  71082. * @param mimeType the mime type to use for the texture
  71083. * @returns pbr metallic roughness interface or null
  71084. */
  71085. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  71086. /**
  71087. * Converts specular glossiness material properties to metallic roughness
  71088. * @param specularGlossiness interface with specular glossiness material properties
  71089. * @returns interface with metallic roughness material properties
  71090. */
  71091. private _convertSpecularGlossinessToMetallicRoughness;
  71092. /**
  71093. * Calculates the surface reflectance, independent of lighting conditions
  71094. * @param color Color source to calculate brightness from
  71095. * @returns number representing the perceived brightness, or zero if color is undefined
  71096. */
  71097. private _getPerceivedBrightness;
  71098. /**
  71099. * Returns the maximum color component value
  71100. * @param color
  71101. * @returns maximum color component value, or zero if color is null or undefined
  71102. */
  71103. private _getMaxComponent;
  71104. /**
  71105. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  71106. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  71107. * @param mimeType mime type to use for the textures
  71108. * @param images array of glTF image interfaces
  71109. * @param textures array of glTF texture interfaces
  71110. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  71111. * @param imageData map of image file name to data
  71112. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  71113. * @returns glTF PBR Metallic Roughness factors
  71114. */
  71115. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  71116. private _getGLTFTextureSampler;
  71117. private _getGLTFTextureWrapMode;
  71118. private _getGLTFTextureWrapModesSampler;
  71119. /**
  71120. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  71121. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  71122. * @param mimeType mime type to use for the textures
  71123. * @param images array of glTF image interfaces
  71124. * @param textures array of glTF texture interfaces
  71125. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  71126. * @param imageData map of image file name to data
  71127. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  71128. * @returns glTF PBR Metallic Roughness factors
  71129. */
  71130. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  71131. /**
  71132. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  71133. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  71134. * @param mimeType mime type to use for the textures
  71135. * @param images array of glTF image interfaces
  71136. * @param textures array of glTF texture interfaces
  71137. * @param materials array of glTF material interfaces
  71138. * @param imageData map of image file name to data
  71139. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  71140. */
  71141. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  71142. private setMetallicRoughnessPbrMaterial;
  71143. private getPixelsFromTexture;
  71144. /**
  71145. * Extracts a texture from a Babylon texture into file data and glTF data
  71146. * @param babylonTexture Babylon texture to extract
  71147. * @param mimeType Mime Type of the babylonTexture
  71148. * @return glTF texture info, or null if the texture format is not supported
  71149. */
  71150. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  71151. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  71152. /**
  71153. * Builds a texture from base64 string
  71154. * @param base64Texture base64 texture string
  71155. * @param baseTextureName Name to use for the texture
  71156. * @param mimeType image mime type for the texture
  71157. * @param images array of images
  71158. * @param textures array of textures
  71159. * @param imageData map of image data
  71160. * @returns glTF texture info, or null if the texture format is not supported
  71161. */
  71162. private _getTextureInfoFromBase64;
  71163. }
  71164. }
  71165. declare module BABYLON {
  71166. /**
  71167. * Class for holding and downloading glTF file data
  71168. */
  71169. export class GLTFData {
  71170. /**
  71171. * Object which contains the file name as the key and its data as the value
  71172. */
  71173. glTFFiles: {
  71174. [fileName: string]: string | Blob;
  71175. };
  71176. /**
  71177. * Initializes the glTF file object
  71178. */
  71179. constructor();
  71180. /**
  71181. * Downloads the glTF data as files based on their names and data
  71182. */
  71183. downloadFiles(): void;
  71184. }
  71185. }
  71186. declare module BABYLON {
  71187. /**
  71188. * Holds a collection of exporter options and parameters
  71189. */
  71190. export interface IExportOptions {
  71191. /**
  71192. * Function which indicates whether a babylon node should be exported or not
  71193. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  71194. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  71195. */
  71196. shouldExportNode?(node: Node): boolean;
  71197. /**
  71198. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  71199. * @param metadata source metadata to read from
  71200. * @returns the data to store to glTF node extras
  71201. */
  71202. metadataSelector?(metadata: any): any;
  71203. /**
  71204. * The sample rate to bake animation curves
  71205. */
  71206. animationSampleRate?: number;
  71207. /**
  71208. * Begin serialization without waiting for the scene to be ready
  71209. */
  71210. exportWithoutWaitingForScene?: boolean;
  71211. }
  71212. /**
  71213. * Class for generating glTF data from a Babylon scene.
  71214. */
  71215. export class GLTF2Export {
  71216. /**
  71217. * Exports the geometry of the scene to .gltf file format asynchronously
  71218. * @param scene Babylon scene with scene hierarchy information
  71219. * @param filePrefix File prefix to use when generating the glTF file
  71220. * @param options Exporter options
  71221. * @returns Returns an object with a .gltf file and associates texture names
  71222. * as keys and their data and paths as values
  71223. */
  71224. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  71225. private static _PreExportAsync;
  71226. private static _PostExportAsync;
  71227. /**
  71228. * Exports the geometry of the scene to .glb file format asychronously
  71229. * @param scene Babylon scene with scene hierarchy information
  71230. * @param filePrefix File prefix to use when generating glb file
  71231. * @param options Exporter options
  71232. * @returns Returns an object with a .glb filename as key and data as value
  71233. */
  71234. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  71235. }
  71236. }
  71237. declare module BABYLON.GLTF2.Exporter {
  71238. /**
  71239. * @hidden
  71240. */
  71241. export class _GLTFUtilities {
  71242. /**
  71243. * Creates a buffer view based on the supplied arguments
  71244. * @param bufferIndex index value of the specified buffer
  71245. * @param byteOffset byte offset value
  71246. * @param byteLength byte length of the bufferView
  71247. * @param byteStride byte distance between conequential elements
  71248. * @param name name of the buffer view
  71249. * @returns bufferView for glTF
  71250. */
  71251. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  71252. /**
  71253. * Creates an accessor based on the supplied arguments
  71254. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  71255. * @param name The name of the accessor
  71256. * @param type The type of the accessor
  71257. * @param componentType The datatype of components in the attribute
  71258. * @param count The number of attributes referenced by this accessor
  71259. * @param byteOffset The offset relative to the start of the bufferView in bytes
  71260. * @param min Minimum value of each component in this attribute
  71261. * @param max Maximum value of each component in this attribute
  71262. * @returns accessor for glTF
  71263. */
  71264. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  71265. /**
  71266. * Calculates the minimum and maximum values of an array of position floats
  71267. * @param positions Positions array of a mesh
  71268. * @param vertexStart Starting vertex offset to calculate min and max values
  71269. * @param vertexCount Number of vertices to check for min and max values
  71270. * @returns min number array and max number array
  71271. */
  71272. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  71273. min: number[];
  71274. max: number[];
  71275. };
  71276. /**
  71277. * Converts a new right-handed Vector3
  71278. * @param vector vector3 array
  71279. * @returns right-handed Vector3
  71280. */
  71281. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  71282. /**
  71283. * Converts a Vector3 to right-handed
  71284. * @param vector Vector3 to convert to right-handed
  71285. */
  71286. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  71287. /**
  71288. * Converts a three element number array to right-handed
  71289. * @param vector number array to convert to right-handed
  71290. */
  71291. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  71292. /**
  71293. * Converts a new right-handed Vector3
  71294. * @param vector vector3 array
  71295. * @returns right-handed Vector3
  71296. */
  71297. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  71298. /**
  71299. * Converts a Vector3 to right-handed
  71300. * @param vector Vector3 to convert to right-handed
  71301. */
  71302. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  71303. /**
  71304. * Converts a three element number array to right-handed
  71305. * @param vector number array to convert to right-handed
  71306. */
  71307. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  71308. /**
  71309. * Converts a Vector4 to right-handed
  71310. * @param vector Vector4 to convert to right-handed
  71311. */
  71312. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  71313. /**
  71314. * Converts a Vector4 to right-handed
  71315. * @param vector Vector4 to convert to right-handed
  71316. */
  71317. static _GetRightHandedArray4FromRef(vector: number[]): void;
  71318. /**
  71319. * Converts a Quaternion to right-handed
  71320. * @param quaternion Source quaternion to convert to right-handed
  71321. */
  71322. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  71323. /**
  71324. * Converts a Quaternion to right-handed
  71325. * @param quaternion Source quaternion to convert to right-handed
  71326. */
  71327. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  71328. static _NormalizeTangentFromRef(tangent: Vector4): void;
  71329. }
  71330. }
  71331. declare module BABYLON.GLTF2.Exporter {
  71332. /**
  71333. * Converts Babylon Scene into glTF 2.0.
  71334. * @hidden
  71335. */
  71336. export class _Exporter {
  71337. /**
  71338. * Stores the glTF to export
  71339. */
  71340. _glTF: IGLTF;
  71341. /**
  71342. * Stores all generated buffer views, which represents views into the main glTF buffer data
  71343. */
  71344. _bufferViews: IBufferView[];
  71345. /**
  71346. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  71347. */
  71348. _accessors: IAccessor[];
  71349. /**
  71350. * Stores all the generated nodes, which contains transform and/or mesh information per node
  71351. */
  71352. private _nodes;
  71353. /**
  71354. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  71355. */
  71356. private _scenes;
  71357. /**
  71358. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  71359. */
  71360. private _meshes;
  71361. /**
  71362. * Stores all the generated material information, which represents the appearance of each primitive
  71363. */
  71364. _materials: IMaterial[];
  71365. _materialMap: {
  71366. [materialID: number]: number;
  71367. };
  71368. /**
  71369. * Stores all the generated texture information, which is referenced by glTF materials
  71370. */
  71371. _textures: ITexture[];
  71372. /**
  71373. * Stores all the generated image information, which is referenced by glTF textures
  71374. */
  71375. _images: IImage[];
  71376. /**
  71377. * Stores all the texture samplers
  71378. */
  71379. _samplers: ISampler[];
  71380. /**
  71381. * Stores all the generated animation samplers, which is referenced by glTF animations
  71382. */
  71383. /**
  71384. * Stores the animations for glTF models
  71385. */
  71386. private _animations;
  71387. /**
  71388. * Stores the total amount of bytes stored in the glTF buffer
  71389. */
  71390. private _totalByteLength;
  71391. /**
  71392. * Stores a reference to the Babylon scene containing the source geometry and material information
  71393. */
  71394. _babylonScene: Scene;
  71395. /**
  71396. * Stores a map of the image data, where the key is the file name and the value
  71397. * is the image data
  71398. */
  71399. _imageData: {
  71400. [fileName: string]: {
  71401. data: Uint8Array;
  71402. mimeType: ImageMimeType;
  71403. };
  71404. };
  71405. /**
  71406. * Stores a map of the unique id of a node to its index in the node array
  71407. */
  71408. private _nodeMap;
  71409. /**
  71410. * Specifies if the Babylon scene should be converted to right-handed on export
  71411. */
  71412. _convertToRightHandedSystem: boolean;
  71413. /**
  71414. * Baked animation sample rate
  71415. */
  71416. private _animationSampleRate;
  71417. private _options;
  71418. private _localEngine;
  71419. _glTFMaterialExporter: _GLTFMaterialExporter;
  71420. private _extensions;
  71421. private static _ExtensionNames;
  71422. private static _ExtensionFactories;
  71423. private _applyExtensions;
  71424. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  71425. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  71426. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  71427. private _forEachExtensions;
  71428. private _extensionsOnExporting;
  71429. /**
  71430. * Load glTF serializer extensions
  71431. */
  71432. private _loadExtensions;
  71433. /**
  71434. * Creates a glTF Exporter instance, which can accept optional exporter options
  71435. * @param babylonScene Babylon scene object
  71436. * @param options Options to modify the behavior of the exporter
  71437. */
  71438. constructor(babylonScene: Scene, options?: IExportOptions);
  71439. /**
  71440. * Registers a glTF exporter extension
  71441. * @param name Name of the extension to export
  71442. * @param factory The factory function that creates the exporter extension
  71443. */
  71444. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  71445. /**
  71446. * Un-registers an exporter extension
  71447. * @param name The name fo the exporter extension
  71448. * @returns A boolean indicating whether the extension has been un-registered
  71449. */
  71450. static UnregisterExtension(name: string): boolean;
  71451. /**
  71452. * Lazy load a local engine with premultiplied alpha set to false
  71453. */
  71454. _getLocalEngine(): Engine;
  71455. private reorderIndicesBasedOnPrimitiveMode;
  71456. /**
  71457. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  71458. * clock-wise during export to glTF
  71459. * @param submesh BabylonJS submesh
  71460. * @param primitiveMode Primitive mode of the mesh
  71461. * @param sideOrientation the winding order of the submesh
  71462. * @param vertexBufferKind The type of vertex attribute
  71463. * @param meshAttributeArray The vertex attribute data
  71464. * @param byteOffset The offset to the binary data
  71465. * @param binaryWriter The binary data for the glTF file
  71466. */
  71467. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  71468. /**
  71469. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  71470. * clock-wise during export to glTF
  71471. * @param submesh BabylonJS submesh
  71472. * @param primitiveMode Primitive mode of the mesh
  71473. * @param sideOrientation the winding order of the submesh
  71474. * @param vertexBufferKind The type of vertex attribute
  71475. * @param meshAttributeArray The vertex attribute data
  71476. * @param byteOffset The offset to the binary data
  71477. * @param binaryWriter The binary data for the glTF file
  71478. */
  71479. private reorderTriangleFillMode;
  71480. /**
  71481. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  71482. * clock-wise during export to glTF
  71483. * @param submesh BabylonJS submesh
  71484. * @param primitiveMode Primitive mode of the mesh
  71485. * @param sideOrientation the winding order of the submesh
  71486. * @param vertexBufferKind The type of vertex attribute
  71487. * @param meshAttributeArray The vertex attribute data
  71488. * @param byteOffset The offset to the binary data
  71489. * @param binaryWriter The binary data for the glTF file
  71490. */
  71491. private reorderTriangleStripDrawMode;
  71492. /**
  71493. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  71494. * clock-wise during export to glTF
  71495. * @param submesh BabylonJS submesh
  71496. * @param primitiveMode Primitive mode of the mesh
  71497. * @param sideOrientation the winding order of the submesh
  71498. * @param vertexBufferKind The type of vertex attribute
  71499. * @param meshAttributeArray The vertex attribute data
  71500. * @param byteOffset The offset to the binary data
  71501. * @param binaryWriter The binary data for the glTF file
  71502. */
  71503. private reorderTriangleFanMode;
  71504. /**
  71505. * Writes the vertex attribute data to binary
  71506. * @param vertices The vertices to write to the binary writer
  71507. * @param byteOffset The offset into the binary writer to overwrite binary data
  71508. * @param vertexAttributeKind The vertex attribute type
  71509. * @param meshAttributeArray The vertex attribute data
  71510. * @param binaryWriter The writer containing the binary data
  71511. */
  71512. private writeVertexAttributeData;
  71513. /**
  71514. * Writes mesh attribute data to a data buffer
  71515. * Returns the bytelength of the data
  71516. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  71517. * @param meshAttributeArray Array containing the attribute data
  71518. * @param binaryWriter The buffer to write the binary data to
  71519. * @param indices Used to specify the order of the vertex data
  71520. */
  71521. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  71522. /**
  71523. * Generates glTF json data
  71524. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  71525. * @param glTFPrefix Text to use when prefixing a glTF file
  71526. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  71527. * @returns json data as string
  71528. */
  71529. private generateJSON;
  71530. /**
  71531. * Generates data for .gltf and .bin files based on the glTF prefix string
  71532. * @param glTFPrefix Text to use when prefixing a glTF file
  71533. * @returns GLTFData with glTF file data
  71534. */
  71535. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  71536. /**
  71537. * Creates a binary buffer for glTF
  71538. * @returns array buffer for binary data
  71539. */
  71540. private _generateBinaryAsync;
  71541. /**
  71542. * Pads the number to a multiple of 4
  71543. * @param num number to pad
  71544. * @returns padded number
  71545. */
  71546. private _getPadding;
  71547. /**
  71548. * Generates a glb file from the json and binary data
  71549. * Returns an object with the glb file name as the key and data as the value
  71550. * @param glTFPrefix
  71551. * @returns object with glb filename as key and data as value
  71552. */
  71553. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  71554. /**
  71555. * Sets the TRS for each node
  71556. * @param node glTF Node for storing the transformation data
  71557. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  71558. */
  71559. private setNodeTransformation;
  71560. private getVertexBufferFromMesh;
  71561. /**
  71562. * Creates a bufferview based on the vertices type for the Babylon mesh
  71563. * @param kind Indicates the type of vertices data
  71564. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  71565. * @param binaryWriter The buffer to write the bufferview data to
  71566. */
  71567. private createBufferViewKind;
  71568. /**
  71569. * The primitive mode of the Babylon mesh
  71570. * @param babylonMesh The BabylonJS mesh
  71571. */
  71572. private getMeshPrimitiveMode;
  71573. /**
  71574. * Sets the primitive mode of the glTF mesh primitive
  71575. * @param meshPrimitive glTF mesh primitive
  71576. * @param primitiveMode The primitive mode
  71577. */
  71578. private setPrimitiveMode;
  71579. /**
  71580. * Sets the vertex attribute accessor based of the glTF mesh primitive
  71581. * @param meshPrimitive glTF mesh primitive
  71582. * @param attributeKind vertex attribute
  71583. * @returns boolean specifying if uv coordinates are present
  71584. */
  71585. private setAttributeKind;
  71586. /**
  71587. * Sets data for the primitive attributes of each submesh
  71588. * @param mesh glTF Mesh object to store the primitive attribute information
  71589. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  71590. * @param binaryWriter Buffer to write the attribute data to
  71591. */
  71592. private setPrimitiveAttributesAsync;
  71593. /**
  71594. * Creates a glTF scene based on the array of meshes
  71595. * Returns the the total byte offset
  71596. * @param babylonScene Babylon scene to get the mesh data from
  71597. * @param binaryWriter Buffer to write binary data to
  71598. */
  71599. private createSceneAsync;
  71600. /**
  71601. * Creates a mapping of Node unique id to node index and handles animations
  71602. * @param babylonScene Babylon Scene
  71603. * @param nodes Babylon transform nodes
  71604. * @param binaryWriter Buffer to write binary data to
  71605. * @returns Node mapping of unique id to index
  71606. */
  71607. private createNodeMapAndAnimationsAsync;
  71608. /**
  71609. * Creates a glTF node from a Babylon mesh
  71610. * @param babylonMesh Source Babylon mesh
  71611. * @param binaryWriter Buffer for storing geometry data
  71612. * @returns glTF node
  71613. */
  71614. private createNodeAsync;
  71615. }
  71616. /**
  71617. * @hidden
  71618. *
  71619. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  71620. */
  71621. export class _BinaryWriter {
  71622. /**
  71623. * Array buffer which stores all binary data
  71624. */
  71625. private _arrayBuffer;
  71626. /**
  71627. * View of the array buffer
  71628. */
  71629. private _dataView;
  71630. /**
  71631. * byte offset of data in array buffer
  71632. */
  71633. private _byteOffset;
  71634. /**
  71635. * Initialize binary writer with an initial byte length
  71636. * @param byteLength Initial byte length of the array buffer
  71637. */
  71638. constructor(byteLength: number);
  71639. /**
  71640. * Resize the array buffer to the specified byte length
  71641. * @param byteLength
  71642. */
  71643. private resizeBuffer;
  71644. /**
  71645. * Get an array buffer with the length of the byte offset
  71646. * @returns ArrayBuffer resized to the byte offset
  71647. */
  71648. getArrayBuffer(): ArrayBuffer;
  71649. /**
  71650. * Get the byte offset of the array buffer
  71651. * @returns byte offset
  71652. */
  71653. getByteOffset(): number;
  71654. /**
  71655. * Stores an UInt8 in the array buffer
  71656. * @param entry
  71657. * @param byteOffset If defined, specifies where to set the value as an offset.
  71658. */
  71659. setUInt8(entry: number, byteOffset?: number): void;
  71660. /**
  71661. * Gets an UInt32 in the array buffer
  71662. * @param entry
  71663. * @param byteOffset If defined, specifies where to set the value as an offset.
  71664. */
  71665. getUInt32(byteOffset: number): number;
  71666. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  71667. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  71668. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  71669. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  71670. /**
  71671. * Stores a Float32 in the array buffer
  71672. * @param entry
  71673. */
  71674. setFloat32(entry: number, byteOffset?: number): void;
  71675. /**
  71676. * Stores an UInt32 in the array buffer
  71677. * @param entry
  71678. * @param byteOffset If defined, specifies where to set the value as an offset.
  71679. */
  71680. setUInt32(entry: number, byteOffset?: number): void;
  71681. }
  71682. }
  71683. declare module BABYLON.GLTF2.Exporter {
  71684. /**
  71685. * @hidden
  71686. * Interface to store animation data.
  71687. */
  71688. export interface _IAnimationData {
  71689. /**
  71690. * Keyframe data.
  71691. */
  71692. inputs: number[];
  71693. /**
  71694. * Value data.
  71695. */
  71696. outputs: number[][];
  71697. /**
  71698. * Animation interpolation data.
  71699. */
  71700. samplerInterpolation: AnimationSamplerInterpolation;
  71701. /**
  71702. * Minimum keyframe value.
  71703. */
  71704. inputsMin: number;
  71705. /**
  71706. * Maximum keyframe value.
  71707. */
  71708. inputsMax: number;
  71709. }
  71710. /**
  71711. * @hidden
  71712. */
  71713. export interface _IAnimationInfo {
  71714. /**
  71715. * The target channel for the animation
  71716. */
  71717. animationChannelTargetPath: AnimationChannelTargetPath;
  71718. /**
  71719. * The glTF accessor type for the data.
  71720. */
  71721. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  71722. /**
  71723. * Specifies if quaternions should be used.
  71724. */
  71725. useQuaternion: boolean;
  71726. }
  71727. /**
  71728. * @hidden
  71729. * Utility class for generating glTF animation data from BabylonJS.
  71730. */
  71731. export class _GLTFAnimation {
  71732. /**
  71733. * @ignore
  71734. *
  71735. * Creates glTF channel animation from BabylonJS animation.
  71736. * @param babylonTransformNode - BabylonJS mesh.
  71737. * @param animation - animation.
  71738. * @param animationChannelTargetPath - The target animation channel.
  71739. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  71740. * @param useQuaternion - Specifies if quaternions are used.
  71741. * @returns nullable IAnimationData
  71742. */
  71743. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  71744. private static _DeduceAnimationInfo;
  71745. /**
  71746. * @ignore
  71747. * Create node animations from the transform node animations
  71748. * @param babylonNode
  71749. * @param runtimeGLTFAnimation
  71750. * @param idleGLTFAnimations
  71751. * @param nodeMap
  71752. * @param nodes
  71753. * @param binaryWriter
  71754. * @param bufferViews
  71755. * @param accessors
  71756. * @param convertToRightHandedSystem
  71757. */
  71758. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  71759. [key: number]: number;
  71760. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  71761. /**
  71762. * @ignore
  71763. * Create node animations from the animation groups
  71764. * @param babylonScene
  71765. * @param glTFAnimations
  71766. * @param nodeMap
  71767. * @param nodes
  71768. * @param binaryWriter
  71769. * @param bufferViews
  71770. * @param accessors
  71771. * @param convertToRightHandedSystem
  71772. */
  71773. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  71774. [key: number]: number;
  71775. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  71776. private static AddAnimation;
  71777. /**
  71778. * Create a baked animation
  71779. * @param babylonTransformNode BabylonJS mesh
  71780. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  71781. * @param animationChannelTargetPath animation target channel
  71782. * @param minFrame minimum animation frame
  71783. * @param maxFrame maximum animation frame
  71784. * @param fps frames per second of the animation
  71785. * @param inputs input key frames of the animation
  71786. * @param outputs output key frame data of the animation
  71787. * @param convertToRightHandedSystem converts the values to right-handed
  71788. * @param useQuaternion specifies if quaternions should be used
  71789. */
  71790. private static _CreateBakedAnimation;
  71791. private static _ConvertFactorToVector3OrQuaternion;
  71792. private static _SetInterpolatedValue;
  71793. /**
  71794. * Creates linear animation from the animation key frames
  71795. * @param babylonTransformNode BabylonJS mesh
  71796. * @param animation BabylonJS animation
  71797. * @param animationChannelTargetPath The target animation channel
  71798. * @param frameDelta The difference between the last and first frame of the animation
  71799. * @param inputs Array to store the key frame times
  71800. * @param outputs Array to store the key frame data
  71801. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  71802. * @param useQuaternion Specifies if quaternions are used in the animation
  71803. */
  71804. private static _CreateLinearOrStepAnimation;
  71805. /**
  71806. * Creates cubic spline animation from the animation key frames
  71807. * @param babylonTransformNode BabylonJS mesh
  71808. * @param animation BabylonJS animation
  71809. * @param animationChannelTargetPath The target animation channel
  71810. * @param frameDelta The difference between the last and first frame of the animation
  71811. * @param inputs Array to store the key frame times
  71812. * @param outputs Array to store the key frame data
  71813. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  71814. * @param useQuaternion Specifies if quaternions are used in the animation
  71815. */
  71816. private static _CreateCubicSplineAnimation;
  71817. private static _GetBasePositionRotationOrScale;
  71818. /**
  71819. * Adds a key frame value
  71820. * @param keyFrame
  71821. * @param animation
  71822. * @param outputs
  71823. * @param animationChannelTargetPath
  71824. * @param basePositionRotationOrScale
  71825. * @param convertToRightHandedSystem
  71826. * @param useQuaternion
  71827. */
  71828. private static _AddKeyframeValue;
  71829. /**
  71830. * Determine the interpolation based on the key frames
  71831. * @param keyFrames
  71832. * @param animationChannelTargetPath
  71833. * @param useQuaternion
  71834. */
  71835. private static _DeduceInterpolation;
  71836. /**
  71837. * Adds an input tangent or output tangent to the output data
  71838. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  71839. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  71840. * @param outputs The animation data by keyframe
  71841. * @param animationChannelTargetPath The target animation channel
  71842. * @param interpolation The interpolation type
  71843. * @param keyFrame The key frame with the animation data
  71844. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  71845. * @param useQuaternion Specifies if quaternions are used
  71846. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  71847. */
  71848. private static AddSplineTangent;
  71849. /**
  71850. * Get the minimum and maximum key frames' frame values
  71851. * @param keyFrames animation key frames
  71852. * @returns the minimum and maximum key frame value
  71853. */
  71854. private static calculateMinMaxKeyFrames;
  71855. }
  71856. }
  71857. declare module BABYLON.GLTF2.Exporter {
  71858. /** @hidden */
  71859. export var textureTransformPixelShader: {
  71860. name: string;
  71861. shader: string;
  71862. };
  71863. }
  71864. declare module BABYLON.GLTF2.Exporter.Extensions {
  71865. /**
  71866. * @hidden
  71867. */
  71868. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  71869. /** Name of this extension */
  71870. readonly name: string;
  71871. /** Defines whether this extension is enabled */
  71872. enabled: boolean;
  71873. /** Defines whether this extension is required */
  71874. required: boolean;
  71875. /** Reference to the glTF exporter */
  71876. private _exporter;
  71877. constructor(exporter: _Exporter);
  71878. dispose(): void;
  71879. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  71880. /**
  71881. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  71882. * @param babylonTexture
  71883. * @param offset
  71884. * @param rotation
  71885. * @param scale
  71886. * @param scene
  71887. */
  71888. private _textureTransformTextureAsync;
  71889. }
  71890. }
  71891. declare module BABYLON.GLTF2.Exporter.Extensions {
  71892. /**
  71893. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  71894. */
  71895. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  71896. /** The name of this extension. */
  71897. readonly name: string;
  71898. /** Defines whether this extension is enabled. */
  71899. enabled: boolean;
  71900. /** Defines whether this extension is required */
  71901. required: boolean;
  71902. /** Reference to the glTF exporter */
  71903. private _exporter;
  71904. private _lights;
  71905. /** @hidden */
  71906. constructor(exporter: _Exporter);
  71907. /** @hidden */
  71908. dispose(): void;
  71909. /** @hidden */
  71910. onExporting(): void;
  71911. /**
  71912. * Define this method to modify the default behavior when exporting a node
  71913. * @param context The context when exporting the node
  71914. * @param node glTF node
  71915. * @param babylonNode BabylonJS node
  71916. * @returns nullable INode promise
  71917. */
  71918. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  71919. }
  71920. }
  71921. declare module BABYLON {
  71922. /**
  71923. * Class for generating STL data from a Babylon scene.
  71924. */
  71925. export class STLExport {
  71926. /**
  71927. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  71928. * @param meshes list defines the mesh to serialize
  71929. * @param download triggers the automatic download of the file.
  71930. * @param fileName changes the downloads fileName.
  71931. * @param binary changes the STL to a binary type.
  71932. * @param isLittleEndian toggle for binary type exporter.
  71933. * @returns the STL as UTF8 string
  71934. */
  71935. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  71936. }
  71937. }
  71938. declare module "babylonjs-gltf2interface" {
  71939. export = BABYLON.GLTF2;
  71940. }
  71941. /**
  71942. * Module for glTF 2.0 Interface
  71943. */
  71944. declare module BABYLON.GLTF2 {
  71945. /**
  71946. * The datatype of the components in the attribute
  71947. */
  71948. const enum AccessorComponentType {
  71949. /**
  71950. * Byte
  71951. */
  71952. BYTE = 5120,
  71953. /**
  71954. * Unsigned Byte
  71955. */
  71956. UNSIGNED_BYTE = 5121,
  71957. /**
  71958. * Short
  71959. */
  71960. SHORT = 5122,
  71961. /**
  71962. * Unsigned Short
  71963. */
  71964. UNSIGNED_SHORT = 5123,
  71965. /**
  71966. * Unsigned Int
  71967. */
  71968. UNSIGNED_INT = 5125,
  71969. /**
  71970. * Float
  71971. */
  71972. FLOAT = 5126,
  71973. }
  71974. /**
  71975. * Specifies if the attirbute is a scalar, vector, or matrix
  71976. */
  71977. const enum AccessorType {
  71978. /**
  71979. * Scalar
  71980. */
  71981. SCALAR = "SCALAR",
  71982. /**
  71983. * Vector2
  71984. */
  71985. VEC2 = "VEC2",
  71986. /**
  71987. * Vector3
  71988. */
  71989. VEC3 = "VEC3",
  71990. /**
  71991. * Vector4
  71992. */
  71993. VEC4 = "VEC4",
  71994. /**
  71995. * Matrix2x2
  71996. */
  71997. MAT2 = "MAT2",
  71998. /**
  71999. * Matrix3x3
  72000. */
  72001. MAT3 = "MAT3",
  72002. /**
  72003. * Matrix4x4
  72004. */
  72005. MAT4 = "MAT4",
  72006. }
  72007. /**
  72008. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  72009. */
  72010. const enum AnimationChannelTargetPath {
  72011. /**
  72012. * Translation
  72013. */
  72014. TRANSLATION = "translation",
  72015. /**
  72016. * Rotation
  72017. */
  72018. ROTATION = "rotation",
  72019. /**
  72020. * Scale
  72021. */
  72022. SCALE = "scale",
  72023. /**
  72024. * Weights
  72025. */
  72026. WEIGHTS = "weights",
  72027. }
  72028. /**
  72029. * Interpolation algorithm
  72030. */
  72031. const enum AnimationSamplerInterpolation {
  72032. /**
  72033. * The animated values are linearly interpolated between keyframes
  72034. */
  72035. LINEAR = "LINEAR",
  72036. /**
  72037. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  72038. */
  72039. STEP = "STEP",
  72040. /**
  72041. * The animation's interpolation is computed using a cubic spline with specified tangents
  72042. */
  72043. CUBICSPLINE = "CUBICSPLINE",
  72044. }
  72045. /**
  72046. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  72047. */
  72048. const enum CameraType {
  72049. /**
  72050. * A perspective camera containing properties to create a perspective projection matrix
  72051. */
  72052. PERSPECTIVE = "perspective",
  72053. /**
  72054. * An orthographic camera containing properties to create an orthographic projection matrix
  72055. */
  72056. ORTHOGRAPHIC = "orthographic",
  72057. }
  72058. /**
  72059. * The mime-type of the image
  72060. */
  72061. const enum ImageMimeType {
  72062. /**
  72063. * JPEG Mime-type
  72064. */
  72065. JPEG = "image/jpeg",
  72066. /**
  72067. * PNG Mime-type
  72068. */
  72069. PNG = "image/png",
  72070. }
  72071. /**
  72072. * The alpha rendering mode of the material
  72073. */
  72074. const enum MaterialAlphaMode {
  72075. /**
  72076. * The alpha value is ignored and the rendered output is fully opaque
  72077. */
  72078. OPAQUE = "OPAQUE",
  72079. /**
  72080. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  72081. */
  72082. MASK = "MASK",
  72083. /**
  72084. * 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)
  72085. */
  72086. BLEND = "BLEND",
  72087. }
  72088. /**
  72089. * The type of the primitives to render
  72090. */
  72091. const enum MeshPrimitiveMode {
  72092. /**
  72093. * Points
  72094. */
  72095. POINTS = 0,
  72096. /**
  72097. * Lines
  72098. */
  72099. LINES = 1,
  72100. /**
  72101. * Line Loop
  72102. */
  72103. LINE_LOOP = 2,
  72104. /**
  72105. * Line Strip
  72106. */
  72107. LINE_STRIP = 3,
  72108. /**
  72109. * Triangles
  72110. */
  72111. TRIANGLES = 4,
  72112. /**
  72113. * Triangle Strip
  72114. */
  72115. TRIANGLE_STRIP = 5,
  72116. /**
  72117. * Triangle Fan
  72118. */
  72119. TRIANGLE_FAN = 6,
  72120. }
  72121. /**
  72122. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  72123. */
  72124. const enum TextureMagFilter {
  72125. /**
  72126. * Nearest
  72127. */
  72128. NEAREST = 9728,
  72129. /**
  72130. * Linear
  72131. */
  72132. LINEAR = 9729,
  72133. }
  72134. /**
  72135. * Minification filter. All valid values correspond to WebGL enums
  72136. */
  72137. const enum TextureMinFilter {
  72138. /**
  72139. * Nearest
  72140. */
  72141. NEAREST = 9728,
  72142. /**
  72143. * Linear
  72144. */
  72145. LINEAR = 9729,
  72146. /**
  72147. * Nearest Mip-Map Nearest
  72148. */
  72149. NEAREST_MIPMAP_NEAREST = 9984,
  72150. /**
  72151. * Linear Mipmap Nearest
  72152. */
  72153. LINEAR_MIPMAP_NEAREST = 9985,
  72154. /**
  72155. * Nearest Mipmap Linear
  72156. */
  72157. NEAREST_MIPMAP_LINEAR = 9986,
  72158. /**
  72159. * Linear Mipmap Linear
  72160. */
  72161. LINEAR_MIPMAP_LINEAR = 9987,
  72162. }
  72163. /**
  72164. * S (U) wrapping mode. All valid values correspond to WebGL enums
  72165. */
  72166. const enum TextureWrapMode {
  72167. /**
  72168. * Clamp to Edge
  72169. */
  72170. CLAMP_TO_EDGE = 33071,
  72171. /**
  72172. * Mirrored Repeat
  72173. */
  72174. MIRRORED_REPEAT = 33648,
  72175. /**
  72176. * Repeat
  72177. */
  72178. REPEAT = 10497,
  72179. }
  72180. /**
  72181. * glTF Property
  72182. */
  72183. interface IProperty {
  72184. /**
  72185. * Dictionary object with extension-specific objects
  72186. */
  72187. extensions?: {
  72188. [key: string]: any;
  72189. };
  72190. /**
  72191. * Application-Specific data
  72192. */
  72193. extras?: any;
  72194. }
  72195. /**
  72196. * glTF Child of Root Property
  72197. */
  72198. interface IChildRootProperty extends IProperty {
  72199. /**
  72200. * The user-defined name of this object
  72201. */
  72202. name?: string;
  72203. }
  72204. /**
  72205. * Indices of those attributes that deviate from their initialization value
  72206. */
  72207. interface IAccessorSparseIndices extends IProperty {
  72208. /**
  72209. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  72210. */
  72211. bufferView: number;
  72212. /**
  72213. * The offset relative to the start of the bufferView in bytes. Must be aligned
  72214. */
  72215. byteOffset?: number;
  72216. /**
  72217. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  72218. */
  72219. componentType: AccessorComponentType;
  72220. }
  72221. /**
  72222. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  72223. */
  72224. interface IAccessorSparseValues extends IProperty {
  72225. /**
  72226. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  72227. */
  72228. bufferView: number;
  72229. /**
  72230. * The offset relative to the start of the bufferView in bytes. Must be aligned
  72231. */
  72232. byteOffset?: number;
  72233. }
  72234. /**
  72235. * Sparse storage of attributes that deviate from their initialization value
  72236. */
  72237. interface IAccessorSparse extends IProperty {
  72238. /**
  72239. * The number of attributes encoded in this sparse accessor
  72240. */
  72241. count: number;
  72242. /**
  72243. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  72244. */
  72245. indices: IAccessorSparseIndices;
  72246. /**
  72247. * 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
  72248. */
  72249. values: IAccessorSparseValues;
  72250. }
  72251. /**
  72252. * 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
  72253. */
  72254. interface IAccessor extends IChildRootProperty {
  72255. /**
  72256. * The index of the bufferview
  72257. */
  72258. bufferView?: number;
  72259. /**
  72260. * The offset relative to the start of the bufferView in bytes
  72261. */
  72262. byteOffset?: number;
  72263. /**
  72264. * The datatype of components in the attribute
  72265. */
  72266. componentType: AccessorComponentType;
  72267. /**
  72268. * Specifies whether integer data values should be normalized
  72269. */
  72270. normalized?: boolean;
  72271. /**
  72272. * The number of attributes referenced by this accessor
  72273. */
  72274. count: number;
  72275. /**
  72276. * Specifies if the attribute is a scalar, vector, or matrix
  72277. */
  72278. type: AccessorType;
  72279. /**
  72280. * Maximum value of each component in this attribute
  72281. */
  72282. max?: number[];
  72283. /**
  72284. * Minimum value of each component in this attribute
  72285. */
  72286. min?: number[];
  72287. /**
  72288. * Sparse storage of attributes that deviate from their initialization value
  72289. */
  72290. sparse?: IAccessorSparse;
  72291. }
  72292. /**
  72293. * Targets an animation's sampler at a node's property
  72294. */
  72295. interface IAnimationChannel extends IProperty {
  72296. /**
  72297. * The index of a sampler in this animation used to compute the value for the target
  72298. */
  72299. sampler: number;
  72300. /**
  72301. * The index of the node and TRS property to target
  72302. */
  72303. target: IAnimationChannelTarget;
  72304. }
  72305. /**
  72306. * The index of the node and TRS property that an animation channel targets
  72307. */
  72308. interface IAnimationChannelTarget extends IProperty {
  72309. /**
  72310. * The index of the node to target
  72311. */
  72312. node: number;
  72313. /**
  72314. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  72315. */
  72316. path: AnimationChannelTargetPath;
  72317. }
  72318. /**
  72319. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  72320. */
  72321. interface IAnimationSampler extends IProperty {
  72322. /**
  72323. * The index of an accessor containing keyframe input values, e.g., time
  72324. */
  72325. input: number;
  72326. /**
  72327. * Interpolation algorithm
  72328. */
  72329. interpolation?: AnimationSamplerInterpolation;
  72330. /**
  72331. * The index of an accessor, containing keyframe output values
  72332. */
  72333. output: number;
  72334. }
  72335. /**
  72336. * A keyframe animation
  72337. */
  72338. interface IAnimation extends IChildRootProperty {
  72339. /**
  72340. * An array of channels, each of which targets an animation's sampler at a node's property
  72341. */
  72342. channels: IAnimationChannel[];
  72343. /**
  72344. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  72345. */
  72346. samplers: IAnimationSampler[];
  72347. }
  72348. /**
  72349. * Metadata about the glTF asset
  72350. */
  72351. interface IAsset extends IChildRootProperty {
  72352. /**
  72353. * A copyright message suitable for display to credit the content creator
  72354. */
  72355. copyright?: string;
  72356. /**
  72357. * Tool that generated this glTF model. Useful for debugging
  72358. */
  72359. generator?: string;
  72360. /**
  72361. * The glTF version that this asset targets
  72362. */
  72363. version: string;
  72364. /**
  72365. * The minimum glTF version that this asset targets
  72366. */
  72367. minVersion?: string;
  72368. }
  72369. /**
  72370. * A buffer points to binary geometry, animation, or skins
  72371. */
  72372. interface IBuffer extends IChildRootProperty {
  72373. /**
  72374. * 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
  72375. */
  72376. uri?: string;
  72377. /**
  72378. * The length of the buffer in bytes
  72379. */
  72380. byteLength: number;
  72381. }
  72382. /**
  72383. * A view into a buffer generally representing a subset of the buffer
  72384. */
  72385. interface IBufferView extends IChildRootProperty {
  72386. /**
  72387. * The index of the buffer
  72388. */
  72389. buffer: number;
  72390. /**
  72391. * The offset into the buffer in bytes
  72392. */
  72393. byteOffset?: number;
  72394. /**
  72395. * The lenth of the bufferView in bytes
  72396. */
  72397. byteLength: number;
  72398. /**
  72399. * The stride, in bytes
  72400. */
  72401. byteStride?: number;
  72402. }
  72403. /**
  72404. * An orthographic camera containing properties to create an orthographic projection matrix
  72405. */
  72406. interface ICameraOrthographic extends IProperty {
  72407. /**
  72408. * The floating-point horizontal magnification of the view. Must not be zero
  72409. */
  72410. xmag: number;
  72411. /**
  72412. * The floating-point vertical magnification of the view. Must not be zero
  72413. */
  72414. ymag: number;
  72415. /**
  72416. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  72417. */
  72418. zfar: number;
  72419. /**
  72420. * The floating-point distance to the near clipping plane
  72421. */
  72422. znear: number;
  72423. }
  72424. /**
  72425. * A perspective camera containing properties to create a perspective projection matrix
  72426. */
  72427. interface ICameraPerspective extends IProperty {
  72428. /**
  72429. * The floating-point aspect ratio of the field of view
  72430. */
  72431. aspectRatio?: number;
  72432. /**
  72433. * The floating-point vertical field of view in radians
  72434. */
  72435. yfov: number;
  72436. /**
  72437. * The floating-point distance to the far clipping plane
  72438. */
  72439. zfar?: number;
  72440. /**
  72441. * The floating-point distance to the near clipping plane
  72442. */
  72443. znear: number;
  72444. }
  72445. /**
  72446. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  72447. */
  72448. interface ICamera extends IChildRootProperty {
  72449. /**
  72450. * An orthographic camera containing properties to create an orthographic projection matrix
  72451. */
  72452. orthographic?: ICameraOrthographic;
  72453. /**
  72454. * A perspective camera containing properties to create a perspective projection matrix
  72455. */
  72456. perspective?: ICameraPerspective;
  72457. /**
  72458. * Specifies if the camera uses a perspective or orthographic projection
  72459. */
  72460. type: CameraType;
  72461. }
  72462. /**
  72463. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  72464. */
  72465. interface IImage extends IChildRootProperty {
  72466. /**
  72467. * 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
  72468. */
  72469. uri?: string;
  72470. /**
  72471. * The image's MIME type
  72472. */
  72473. mimeType?: ImageMimeType;
  72474. /**
  72475. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  72476. */
  72477. bufferView?: number;
  72478. }
  72479. /**
  72480. * Material Normal Texture Info
  72481. */
  72482. interface IMaterialNormalTextureInfo extends ITextureInfo {
  72483. /**
  72484. * The scalar multiplier applied to each normal vector of the normal texture
  72485. */
  72486. scale?: number;
  72487. }
  72488. /**
  72489. * Material Occlusion Texture Info
  72490. */
  72491. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  72492. /**
  72493. * A scalar multiplier controlling the amount of occlusion applied
  72494. */
  72495. strength?: number;
  72496. }
  72497. /**
  72498. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  72499. */
  72500. interface IMaterialPbrMetallicRoughness {
  72501. /**
  72502. * The material's base color factor
  72503. */
  72504. baseColorFactor?: number[];
  72505. /**
  72506. * The base color texture
  72507. */
  72508. baseColorTexture?: ITextureInfo;
  72509. /**
  72510. * The metalness of the material
  72511. */
  72512. metallicFactor?: number;
  72513. /**
  72514. * The roughness of the material
  72515. */
  72516. roughnessFactor?: number;
  72517. /**
  72518. * The metallic-roughness texture
  72519. */
  72520. metallicRoughnessTexture?: ITextureInfo;
  72521. }
  72522. /**
  72523. * The material appearance of a primitive
  72524. */
  72525. interface IMaterial extends IChildRootProperty {
  72526. /**
  72527. * 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
  72528. */
  72529. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  72530. /**
  72531. * The normal map texture
  72532. */
  72533. normalTexture?: IMaterialNormalTextureInfo;
  72534. /**
  72535. * The occlusion map texture
  72536. */
  72537. occlusionTexture?: IMaterialOcclusionTextureInfo;
  72538. /**
  72539. * The emissive map texture
  72540. */
  72541. emissiveTexture?: ITextureInfo;
  72542. /**
  72543. * 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
  72544. */
  72545. emissiveFactor?: number[];
  72546. /**
  72547. * The alpha rendering mode of the material
  72548. */
  72549. alphaMode?: MaterialAlphaMode;
  72550. /**
  72551. * The alpha cutoff value of the material
  72552. */
  72553. alphaCutoff?: number;
  72554. /**
  72555. * Specifies whether the material is double sided
  72556. */
  72557. doubleSided?: boolean;
  72558. }
  72559. /**
  72560. * Geometry to be rendered with the given material
  72561. */
  72562. interface IMeshPrimitive extends IProperty {
  72563. /**
  72564. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  72565. */
  72566. attributes: {
  72567. [name: string]: number;
  72568. };
  72569. /**
  72570. * The index of the accessor that contains the indices
  72571. */
  72572. indices?: number;
  72573. /**
  72574. * The index of the material to apply to this primitive when rendering
  72575. */
  72576. material?: number;
  72577. /**
  72578. * The type of primitives to render. All valid values correspond to WebGL enums
  72579. */
  72580. mode?: MeshPrimitiveMode;
  72581. /**
  72582. * 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
  72583. */
  72584. targets?: {
  72585. [name: string]: number;
  72586. }[];
  72587. }
  72588. /**
  72589. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  72590. */
  72591. interface IMesh extends IChildRootProperty {
  72592. /**
  72593. * An array of primitives, each defining geometry to be rendered with a material
  72594. */
  72595. primitives: IMeshPrimitive[];
  72596. /**
  72597. * Array of weights to be applied to the Morph Targets
  72598. */
  72599. weights?: number[];
  72600. }
  72601. /**
  72602. * A node in the node hierarchy
  72603. */
  72604. interface INode extends IChildRootProperty {
  72605. /**
  72606. * The index of the camera referenced by this node
  72607. */
  72608. camera?: number;
  72609. /**
  72610. * The indices of this node's children
  72611. */
  72612. children?: number[];
  72613. /**
  72614. * The index of the skin referenced by this node
  72615. */
  72616. skin?: number;
  72617. /**
  72618. * A floating-point 4x4 transformation matrix stored in column-major order
  72619. */
  72620. matrix?: number[];
  72621. /**
  72622. * The index of the mesh in this node
  72623. */
  72624. mesh?: number;
  72625. /**
  72626. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  72627. */
  72628. rotation?: number[];
  72629. /**
  72630. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  72631. */
  72632. scale?: number[];
  72633. /**
  72634. * The node's translation along the x, y, and z axes
  72635. */
  72636. translation?: number[];
  72637. /**
  72638. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  72639. */
  72640. weights?: number[];
  72641. }
  72642. /**
  72643. * Texture sampler properties for filtering and wrapping modes
  72644. */
  72645. interface ISampler extends IChildRootProperty {
  72646. /**
  72647. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  72648. */
  72649. magFilter?: TextureMagFilter;
  72650. /**
  72651. * Minification filter. All valid values correspond to WebGL enums
  72652. */
  72653. minFilter?: TextureMinFilter;
  72654. /**
  72655. * S (U) wrapping mode. All valid values correspond to WebGL enums
  72656. */
  72657. wrapS?: TextureWrapMode;
  72658. /**
  72659. * T (V) wrapping mode. All valid values correspond to WebGL enums
  72660. */
  72661. wrapT?: TextureWrapMode;
  72662. }
  72663. /**
  72664. * The root nodes of a scene
  72665. */
  72666. interface IScene extends IChildRootProperty {
  72667. /**
  72668. * The indices of each root node
  72669. */
  72670. nodes: number[];
  72671. }
  72672. /**
  72673. * Joints and matrices defining a skin
  72674. */
  72675. interface ISkin extends IChildRootProperty {
  72676. /**
  72677. * 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
  72678. */
  72679. inverseBindMatrices?: number;
  72680. /**
  72681. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  72682. */
  72683. skeleton?: number;
  72684. /**
  72685. * 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)
  72686. */
  72687. joints: number[];
  72688. }
  72689. /**
  72690. * A texture and its sampler
  72691. */
  72692. interface ITexture extends IChildRootProperty {
  72693. /**
  72694. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  72695. */
  72696. sampler?: number;
  72697. /**
  72698. * The index of the image used by this texture
  72699. */
  72700. source: number;
  72701. }
  72702. /**
  72703. * Reference to a texture
  72704. */
  72705. interface ITextureInfo extends IProperty {
  72706. /**
  72707. * The index of the texture
  72708. */
  72709. index: number;
  72710. /**
  72711. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  72712. */
  72713. texCoord?: number;
  72714. }
  72715. /**
  72716. * The root object for a glTF asset
  72717. */
  72718. interface IGLTF extends IProperty {
  72719. /**
  72720. * An array of accessors. An accessor is a typed view into a bufferView
  72721. */
  72722. accessors?: IAccessor[];
  72723. /**
  72724. * An array of keyframe animations
  72725. */
  72726. animations?: IAnimation[];
  72727. /**
  72728. * Metadata about the glTF asset
  72729. */
  72730. asset: IAsset;
  72731. /**
  72732. * An array of buffers. A buffer points to binary geometry, animation, or skins
  72733. */
  72734. buffers?: IBuffer[];
  72735. /**
  72736. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  72737. */
  72738. bufferViews?: IBufferView[];
  72739. /**
  72740. * An array of cameras
  72741. */
  72742. cameras?: ICamera[];
  72743. /**
  72744. * Names of glTF extensions used somewhere in this asset
  72745. */
  72746. extensionsUsed?: string[];
  72747. /**
  72748. * Names of glTF extensions required to properly load this asset
  72749. */
  72750. extensionsRequired?: string[];
  72751. /**
  72752. * An array of images. An image defines data used to create a texture
  72753. */
  72754. images?: IImage[];
  72755. /**
  72756. * An array of materials. A material defines the appearance of a primitive
  72757. */
  72758. materials?: IMaterial[];
  72759. /**
  72760. * An array of meshes. A mesh is a set of primitives to be rendered
  72761. */
  72762. meshes?: IMesh[];
  72763. /**
  72764. * An array of nodes
  72765. */
  72766. nodes?: INode[];
  72767. /**
  72768. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  72769. */
  72770. samplers?: ISampler[];
  72771. /**
  72772. * The index of the default scene
  72773. */
  72774. scene?: number;
  72775. /**
  72776. * An array of scenes
  72777. */
  72778. scenes?: IScene[];
  72779. /**
  72780. * An array of skins. A skin is defined by joints and matrices
  72781. */
  72782. skins?: ISkin[];
  72783. /**
  72784. * An array of textures
  72785. */
  72786. textures?: ITexture[];
  72787. }
  72788. /**
  72789. * The glTF validation results
  72790. * @ignore
  72791. */
  72792. interface IGLTFValidationResults {
  72793. info: {
  72794. generator: string;
  72795. hasAnimations: boolean;
  72796. hasDefaultScene: boolean;
  72797. hasMaterials: boolean;
  72798. hasMorphTargets: boolean;
  72799. hasSkins: boolean;
  72800. hasTextures: boolean;
  72801. maxAttributesUsed: number;
  72802. primitivesCount: number
  72803. };
  72804. issues: {
  72805. messages: Array<string>;
  72806. numErrors: number;
  72807. numHints: number;
  72808. numInfos: number;
  72809. numWarnings: number;
  72810. truncated: boolean
  72811. };
  72812. mimeType: string;
  72813. uri: string;
  72814. validatedAt: string;
  72815. validatorVersion: string;
  72816. }
  72817. /**
  72818. * The glTF validation options
  72819. */
  72820. interface IGLTFValidationOptions {
  72821. /** Uri to use */
  72822. uri?: string;
  72823. /** Function used to load external resources */
  72824. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  72825. /** Boolean indicating that we need to validate accessor data */
  72826. validateAccessorData?: boolean;
  72827. /** max number of issues allowed */
  72828. maxIssues?: number;
  72829. /** Ignored issues */
  72830. ignoredIssues?: Array<string>;
  72831. /** Value to override severy settings */
  72832. severityOverrides?: Object;
  72833. }
  72834. /**
  72835. * The glTF validator object
  72836. * @ignore
  72837. */
  72838. interface IGLTFValidator {
  72839. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  72840. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  72841. }
  72842. }
  72843. declare module BABYLON {
  72844. /** @hidden */
  72845. export var cellPixelShader: {
  72846. name: string;
  72847. shader: string;
  72848. };
  72849. }
  72850. declare module BABYLON {
  72851. /** @hidden */
  72852. export var cellVertexShader: {
  72853. name: string;
  72854. shader: string;
  72855. };
  72856. }
  72857. declare module BABYLON {
  72858. export class CellMaterial extends BABYLON.PushMaterial {
  72859. private _diffuseTexture;
  72860. diffuseTexture: BABYLON.BaseTexture;
  72861. diffuseColor: BABYLON.Color3;
  72862. _computeHighLevel: boolean;
  72863. computeHighLevel: boolean;
  72864. private _disableLighting;
  72865. disableLighting: boolean;
  72866. private _maxSimultaneousLights;
  72867. maxSimultaneousLights: number;
  72868. private _renderId;
  72869. constructor(name: string, scene: BABYLON.Scene);
  72870. needAlphaBlending(): boolean;
  72871. needAlphaTesting(): boolean;
  72872. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72873. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72874. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72875. getAnimatables(): BABYLON.IAnimatable[];
  72876. getActiveTextures(): BABYLON.BaseTexture[];
  72877. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72878. dispose(forceDisposeEffect?: boolean): void;
  72879. getClassName(): string;
  72880. clone(name: string): CellMaterial;
  72881. serialize(): any;
  72882. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  72883. }
  72884. }
  72885. declare module BABYLON {
  72886. export class CustomShaderStructure {
  72887. FragmentStore: string;
  72888. VertexStore: string;
  72889. constructor();
  72890. }
  72891. export class ShaderSpecialParts {
  72892. constructor();
  72893. Fragment_Begin: string;
  72894. Fragment_Definitions: string;
  72895. Fragment_MainBegin: string;
  72896. Fragment_Custom_Diffuse: string;
  72897. Fragment_Before_Lights: string;
  72898. Fragment_Before_Fog: string;
  72899. Fragment_Custom_Alpha: string;
  72900. Fragment_Before_FragColor: string;
  72901. Vertex_Begin: string;
  72902. Vertex_Definitions: string;
  72903. Vertex_MainBegin: string;
  72904. Vertex_Before_PositionUpdated: string;
  72905. Vertex_Before_NormalUpdated: string;
  72906. Vertex_MainEnd: string;
  72907. }
  72908. export class CustomMaterial extends BABYLON.StandardMaterial {
  72909. static ShaderIndexer: number;
  72910. CustomParts: ShaderSpecialParts;
  72911. _isCreatedShader: boolean;
  72912. _createdShaderName: string;
  72913. _customUniform: string[];
  72914. _newUniforms: string[];
  72915. _newUniformInstances: any[];
  72916. _newSamplerInstances: BABYLON.Texture[];
  72917. FragmentShader: string;
  72918. VertexShader: string;
  72919. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72920. ReviewUniform(name: string, arr: string[]): string[];
  72921. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  72922. constructor(name: string, scene: BABYLON.Scene);
  72923. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  72924. Fragment_Begin(shaderPart: string): CustomMaterial;
  72925. Fragment_Definitions(shaderPart: string): CustomMaterial;
  72926. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  72927. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  72928. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  72929. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  72930. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  72931. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  72932. Vertex_Begin(shaderPart: string): CustomMaterial;
  72933. Vertex_Definitions(shaderPart: string): CustomMaterial;
  72934. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  72935. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  72936. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  72937. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  72938. }
  72939. }
  72940. declare module BABYLON {
  72941. export class ShaderAlebdoParts {
  72942. constructor();
  72943. Fragment_Begin: string;
  72944. Fragment_Definitions: string;
  72945. Fragment_MainBegin: string;
  72946. Fragment_Custom_Albedo: string;
  72947. Fragment_Before_Lights: string;
  72948. Fragment_Custom_MetallicRoughness: string;
  72949. Fragment_Custom_MicroSurface: string;
  72950. Fragment_Before_Fog: string;
  72951. Fragment_Custom_Alpha: string;
  72952. Fragment_Before_FragColor: string;
  72953. Vertex_Begin: string;
  72954. Vertex_Definitions: string;
  72955. Vertex_MainBegin: string;
  72956. Vertex_Before_PositionUpdated: string;
  72957. Vertex_Before_NormalUpdated: string;
  72958. Vertex_MainEnd: string;
  72959. }
  72960. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  72961. static ShaderIndexer: number;
  72962. CustomParts: ShaderAlebdoParts;
  72963. _isCreatedShader: boolean;
  72964. _createdShaderName: string;
  72965. _customUniform: string[];
  72966. _newUniforms: string[];
  72967. _newUniformInstances: any[];
  72968. _newSamplerInstances: BABYLON.Texture[];
  72969. FragmentShader: string;
  72970. VertexShader: string;
  72971. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72972. ReviewUniform(name: string, arr: string[]): string[];
  72973. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  72974. constructor(name: string, scene: BABYLON.Scene);
  72975. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  72976. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  72977. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  72978. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  72979. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  72980. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  72981. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  72982. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  72983. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  72984. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  72985. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  72986. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  72987. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  72988. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  72989. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  72990. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  72991. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  72992. }
  72993. }
  72994. declare module BABYLON {
  72995. /** @hidden */
  72996. export var firePixelShader: {
  72997. name: string;
  72998. shader: string;
  72999. };
  73000. }
  73001. declare module BABYLON {
  73002. /** @hidden */
  73003. export var fireVertexShader: {
  73004. name: string;
  73005. shader: string;
  73006. };
  73007. }
  73008. declare module BABYLON {
  73009. export class FireMaterial extends BABYLON.PushMaterial {
  73010. private _diffuseTexture;
  73011. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73012. private _distortionTexture;
  73013. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73014. private _opacityTexture;
  73015. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73016. diffuseColor: BABYLON.Color3;
  73017. speed: number;
  73018. private _scaledDiffuse;
  73019. private _renderId;
  73020. private _lastTime;
  73021. constructor(name: string, scene: BABYLON.Scene);
  73022. needAlphaBlending(): boolean;
  73023. needAlphaTesting(): boolean;
  73024. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73025. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73026. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73027. getAnimatables(): BABYLON.IAnimatable[];
  73028. getActiveTextures(): BABYLON.BaseTexture[];
  73029. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73030. getClassName(): string;
  73031. dispose(forceDisposeEffect?: boolean): void;
  73032. clone(name: string): FireMaterial;
  73033. serialize(): any;
  73034. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  73035. }
  73036. }
  73037. declare module BABYLON {
  73038. /** @hidden */
  73039. export var furPixelShader: {
  73040. name: string;
  73041. shader: string;
  73042. };
  73043. }
  73044. declare module BABYLON {
  73045. /** @hidden */
  73046. export var furVertexShader: {
  73047. name: string;
  73048. shader: string;
  73049. };
  73050. }
  73051. declare module BABYLON {
  73052. export class FurMaterial extends BABYLON.PushMaterial {
  73053. private _diffuseTexture;
  73054. diffuseTexture: BABYLON.BaseTexture;
  73055. private _heightTexture;
  73056. heightTexture: BABYLON.BaseTexture;
  73057. diffuseColor: BABYLON.Color3;
  73058. furLength: number;
  73059. furAngle: number;
  73060. furColor: BABYLON.Color3;
  73061. furOffset: number;
  73062. furSpacing: number;
  73063. furGravity: BABYLON.Vector3;
  73064. furSpeed: number;
  73065. furDensity: number;
  73066. furOcclusion: number;
  73067. furTexture: BABYLON.DynamicTexture;
  73068. private _disableLighting;
  73069. disableLighting: boolean;
  73070. private _maxSimultaneousLights;
  73071. maxSimultaneousLights: number;
  73072. highLevelFur: boolean;
  73073. _meshes: BABYLON.AbstractMesh[];
  73074. private _renderId;
  73075. private _furTime;
  73076. constructor(name: string, scene: BABYLON.Scene);
  73077. furTime: number;
  73078. needAlphaBlending(): boolean;
  73079. needAlphaTesting(): boolean;
  73080. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73081. updateFur(): void;
  73082. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73083. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73084. getAnimatables(): BABYLON.IAnimatable[];
  73085. getActiveTextures(): BABYLON.BaseTexture[];
  73086. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73087. dispose(forceDisposeEffect?: boolean): void;
  73088. clone(name: string): FurMaterial;
  73089. serialize(): any;
  73090. getClassName(): string;
  73091. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  73092. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  73093. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  73094. }
  73095. }
  73096. declare module BABYLON {
  73097. /** @hidden */
  73098. export var gradientPixelShader: {
  73099. name: string;
  73100. shader: string;
  73101. };
  73102. }
  73103. declare module BABYLON {
  73104. /** @hidden */
  73105. export var gradientVertexShader: {
  73106. name: string;
  73107. shader: string;
  73108. };
  73109. }
  73110. declare module BABYLON {
  73111. export class GradientMaterial extends BABYLON.PushMaterial {
  73112. private _maxSimultaneousLights;
  73113. maxSimultaneousLights: number;
  73114. topColor: BABYLON.Color3;
  73115. topColorAlpha: number;
  73116. bottomColor: BABYLON.Color3;
  73117. bottomColorAlpha: number;
  73118. offset: number;
  73119. scale: number;
  73120. smoothness: number;
  73121. private _disableLighting;
  73122. disableLighting: boolean;
  73123. private _renderId;
  73124. constructor(name: string, scene: BABYLON.Scene);
  73125. needAlphaBlending(): boolean;
  73126. needAlphaTesting(): boolean;
  73127. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73128. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73129. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73130. getAnimatables(): BABYLON.IAnimatable[];
  73131. dispose(forceDisposeEffect?: boolean): void;
  73132. clone(name: string): GradientMaterial;
  73133. serialize(): any;
  73134. getClassName(): string;
  73135. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  73136. }
  73137. }
  73138. declare module BABYLON {
  73139. /** @hidden */
  73140. export var gridPixelShader: {
  73141. name: string;
  73142. shader: string;
  73143. };
  73144. }
  73145. declare module BABYLON {
  73146. /** @hidden */
  73147. export var gridVertexShader: {
  73148. name: string;
  73149. shader: string;
  73150. };
  73151. }
  73152. declare module BABYLON {
  73153. /**
  73154. * The grid materials allows you to wrap any shape with a grid.
  73155. * Colors are customizable.
  73156. */
  73157. export class GridMaterial extends BABYLON.PushMaterial {
  73158. /**
  73159. * Main color of the grid (e.g. between lines)
  73160. */
  73161. mainColor: BABYLON.Color3;
  73162. /**
  73163. * Color of the grid lines.
  73164. */
  73165. lineColor: BABYLON.Color3;
  73166. /**
  73167. * The scale of the grid compared to unit.
  73168. */
  73169. gridRatio: number;
  73170. /**
  73171. * Allows setting an offset for the grid lines.
  73172. */
  73173. gridOffset: BABYLON.Vector3;
  73174. /**
  73175. * The frequency of thicker lines.
  73176. */
  73177. majorUnitFrequency: number;
  73178. /**
  73179. * The visibility of minor units in the grid.
  73180. */
  73181. minorUnitVisibility: number;
  73182. /**
  73183. * The grid opacity outside of the lines.
  73184. */
  73185. opacity: number;
  73186. /**
  73187. * Determine RBG output is premultiplied by alpha value.
  73188. */
  73189. preMultiplyAlpha: boolean;
  73190. private _opacityTexture;
  73191. opacityTexture: BABYLON.BaseTexture;
  73192. private _gridControl;
  73193. private _renderId;
  73194. /**
  73195. * constructor
  73196. * @param name The name given to the material in order to identify it afterwards.
  73197. * @param scene The scene the material is used in.
  73198. */
  73199. constructor(name: string, scene: BABYLON.Scene);
  73200. /**
  73201. * Returns wehter or not the grid requires alpha blending.
  73202. */
  73203. needAlphaBlending(): boolean;
  73204. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  73205. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73206. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73207. /**
  73208. * Dispose the material and its associated resources.
  73209. * @param forceDisposeEffect will also dispose the used effect when true
  73210. */
  73211. dispose(forceDisposeEffect?: boolean): void;
  73212. clone(name: string): GridMaterial;
  73213. serialize(): any;
  73214. getClassName(): string;
  73215. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  73216. }
  73217. }
  73218. declare module BABYLON {
  73219. /** @hidden */
  73220. export var lavaPixelShader: {
  73221. name: string;
  73222. shader: string;
  73223. };
  73224. }
  73225. declare module BABYLON {
  73226. /** @hidden */
  73227. export var lavaVertexShader: {
  73228. name: string;
  73229. shader: string;
  73230. };
  73231. }
  73232. declare module BABYLON {
  73233. export class LavaMaterial extends BABYLON.PushMaterial {
  73234. private _diffuseTexture;
  73235. diffuseTexture: BABYLON.BaseTexture;
  73236. noiseTexture: BABYLON.BaseTexture;
  73237. fogColor: BABYLON.Color3;
  73238. speed: number;
  73239. movingSpeed: number;
  73240. lowFrequencySpeed: number;
  73241. fogDensity: number;
  73242. private _lastTime;
  73243. diffuseColor: BABYLON.Color3;
  73244. private _disableLighting;
  73245. disableLighting: boolean;
  73246. private _unlit;
  73247. unlit: boolean;
  73248. private _maxSimultaneousLights;
  73249. maxSimultaneousLights: number;
  73250. private _scaledDiffuse;
  73251. private _renderId;
  73252. constructor(name: string, scene: BABYLON.Scene);
  73253. needAlphaBlending(): boolean;
  73254. needAlphaTesting(): boolean;
  73255. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73256. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73257. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73258. getAnimatables(): BABYLON.IAnimatable[];
  73259. getActiveTextures(): BABYLON.BaseTexture[];
  73260. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73261. dispose(forceDisposeEffect?: boolean): void;
  73262. clone(name: string): LavaMaterial;
  73263. serialize(): any;
  73264. getClassName(): string;
  73265. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  73266. }
  73267. }
  73268. declare module BABYLON {
  73269. /** @hidden */
  73270. export var mixPixelShader: {
  73271. name: string;
  73272. shader: string;
  73273. };
  73274. }
  73275. declare module BABYLON {
  73276. /** @hidden */
  73277. export var mixVertexShader: {
  73278. name: string;
  73279. shader: string;
  73280. };
  73281. }
  73282. declare module BABYLON {
  73283. export class MixMaterial extends BABYLON.PushMaterial {
  73284. /**
  73285. * Mix textures
  73286. */
  73287. private _mixTexture1;
  73288. mixTexture1: BABYLON.BaseTexture;
  73289. private _mixTexture2;
  73290. mixTexture2: BABYLON.BaseTexture;
  73291. /**
  73292. * Diffuse textures
  73293. */
  73294. private _diffuseTexture1;
  73295. diffuseTexture1: BABYLON.Texture;
  73296. private _diffuseTexture2;
  73297. diffuseTexture2: BABYLON.Texture;
  73298. private _diffuseTexture3;
  73299. diffuseTexture3: BABYLON.Texture;
  73300. private _diffuseTexture4;
  73301. diffuseTexture4: BABYLON.Texture;
  73302. private _diffuseTexture5;
  73303. diffuseTexture5: BABYLON.Texture;
  73304. private _diffuseTexture6;
  73305. diffuseTexture6: BABYLON.Texture;
  73306. private _diffuseTexture7;
  73307. diffuseTexture7: BABYLON.Texture;
  73308. private _diffuseTexture8;
  73309. diffuseTexture8: BABYLON.Texture;
  73310. /**
  73311. * Uniforms
  73312. */
  73313. diffuseColor: BABYLON.Color3;
  73314. specularColor: BABYLON.Color3;
  73315. specularPower: number;
  73316. private _disableLighting;
  73317. disableLighting: boolean;
  73318. private _maxSimultaneousLights;
  73319. maxSimultaneousLights: number;
  73320. private _renderId;
  73321. constructor(name: string, scene: BABYLON.Scene);
  73322. needAlphaBlending(): boolean;
  73323. needAlphaTesting(): boolean;
  73324. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73325. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73326. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73327. getAnimatables(): BABYLON.IAnimatable[];
  73328. getActiveTextures(): BABYLON.BaseTexture[];
  73329. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73330. dispose(forceDisposeEffect?: boolean): void;
  73331. clone(name: string): MixMaterial;
  73332. serialize(): any;
  73333. getClassName(): string;
  73334. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  73335. }
  73336. }
  73337. declare module BABYLON {
  73338. /** @hidden */
  73339. export var normalPixelShader: {
  73340. name: string;
  73341. shader: string;
  73342. };
  73343. }
  73344. declare module BABYLON {
  73345. /** @hidden */
  73346. export var normalVertexShader: {
  73347. name: string;
  73348. shader: string;
  73349. };
  73350. }
  73351. declare module BABYLON {
  73352. export class NormalMaterial extends BABYLON.PushMaterial {
  73353. private _diffuseTexture;
  73354. diffuseTexture: BABYLON.BaseTexture;
  73355. diffuseColor: BABYLON.Color3;
  73356. private _disableLighting;
  73357. disableLighting: boolean;
  73358. private _maxSimultaneousLights;
  73359. maxSimultaneousLights: number;
  73360. private _renderId;
  73361. constructor(name: string, scene: BABYLON.Scene);
  73362. needAlphaBlending(): boolean;
  73363. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  73364. needAlphaTesting(): boolean;
  73365. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73366. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73367. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73368. getAnimatables(): BABYLON.IAnimatable[];
  73369. getActiveTextures(): BABYLON.BaseTexture[];
  73370. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73371. dispose(forceDisposeEffect?: boolean): void;
  73372. clone(name: string): NormalMaterial;
  73373. serialize(): any;
  73374. getClassName(): string;
  73375. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  73376. }
  73377. }
  73378. declare module BABYLON {
  73379. /** @hidden */
  73380. export var shadowOnlyPixelShader: {
  73381. name: string;
  73382. shader: string;
  73383. };
  73384. }
  73385. declare module BABYLON {
  73386. /** @hidden */
  73387. export var shadowOnlyVertexShader: {
  73388. name: string;
  73389. shader: string;
  73390. };
  73391. }
  73392. declare module BABYLON {
  73393. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  73394. private _renderId;
  73395. private _activeLight;
  73396. constructor(name: string, scene: BABYLON.Scene);
  73397. shadowColor: BABYLON.Color3;
  73398. needAlphaBlending(): boolean;
  73399. needAlphaTesting(): boolean;
  73400. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73401. activeLight: BABYLON.IShadowLight;
  73402. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73403. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73404. clone(name: string): ShadowOnlyMaterial;
  73405. serialize(): any;
  73406. getClassName(): string;
  73407. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  73408. }
  73409. }
  73410. declare module BABYLON {
  73411. /** @hidden */
  73412. export var simplePixelShader: {
  73413. name: string;
  73414. shader: string;
  73415. };
  73416. }
  73417. declare module BABYLON {
  73418. /** @hidden */
  73419. export var simpleVertexShader: {
  73420. name: string;
  73421. shader: string;
  73422. };
  73423. }
  73424. declare module BABYLON {
  73425. export class SimpleMaterial extends BABYLON.PushMaterial {
  73426. private _diffuseTexture;
  73427. diffuseTexture: BABYLON.BaseTexture;
  73428. diffuseColor: BABYLON.Color3;
  73429. private _disableLighting;
  73430. disableLighting: boolean;
  73431. private _maxSimultaneousLights;
  73432. maxSimultaneousLights: number;
  73433. private _renderId;
  73434. constructor(name: string, scene: BABYLON.Scene);
  73435. needAlphaBlending(): boolean;
  73436. needAlphaTesting(): boolean;
  73437. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73438. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73439. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73440. getAnimatables(): BABYLON.IAnimatable[];
  73441. getActiveTextures(): BABYLON.BaseTexture[];
  73442. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73443. dispose(forceDisposeEffect?: boolean): void;
  73444. clone(name: string): SimpleMaterial;
  73445. serialize(): any;
  73446. getClassName(): string;
  73447. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  73448. }
  73449. }
  73450. declare module BABYLON {
  73451. /** @hidden */
  73452. export var skyPixelShader: {
  73453. name: string;
  73454. shader: string;
  73455. };
  73456. }
  73457. declare module BABYLON {
  73458. /** @hidden */
  73459. export var skyVertexShader: {
  73460. name: string;
  73461. shader: string;
  73462. };
  73463. }
  73464. declare module BABYLON {
  73465. /**
  73466. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  73467. * @see https://doc.babylonjs.com/extensions/sky
  73468. */
  73469. export class SkyMaterial extends BABYLON.PushMaterial {
  73470. /**
  73471. * Defines the overall luminance of sky in interval ]0, 1[.
  73472. */
  73473. luminance: number;
  73474. /**
  73475. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  73476. */
  73477. turbidity: number;
  73478. /**
  73479. * Defines the sky appearance (light intensity).
  73480. */
  73481. rayleigh: number;
  73482. /**
  73483. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  73484. */
  73485. mieCoefficient: number;
  73486. /**
  73487. * Defines the amount of haze particles following the Mie scattering theory.
  73488. */
  73489. mieDirectionalG: number;
  73490. /**
  73491. * Defines the distance of the sun according to the active scene camera.
  73492. */
  73493. distance: number;
  73494. /**
  73495. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  73496. * "inclined".
  73497. */
  73498. inclination: number;
  73499. /**
  73500. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  73501. * an object direction and a reference direction.
  73502. */
  73503. azimuth: number;
  73504. /**
  73505. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  73506. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  73507. */
  73508. sunPosition: BABYLON.Vector3;
  73509. /**
  73510. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  73511. * .sunPosition property.
  73512. */
  73513. useSunPosition: boolean;
  73514. /**
  73515. * Defines an offset vector used to get a horizon offset.
  73516. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  73517. */
  73518. cameraOffset: BABYLON.Vector3;
  73519. private _cameraPosition;
  73520. private _renderId;
  73521. /**
  73522. * Instantiates a new sky material.
  73523. * This material allows to create dynamic and texture free
  73524. * effects for skyboxes by taking care of the atmosphere state.
  73525. * @see https://doc.babylonjs.com/extensions/sky
  73526. * @param name Define the name of the material in the scene
  73527. * @param scene Define the scene the material belong to
  73528. */
  73529. constructor(name: string, scene: BABYLON.Scene);
  73530. /**
  73531. * Specifies if the material will require alpha blending
  73532. * @returns a boolean specifying if alpha blending is needed
  73533. */
  73534. needAlphaBlending(): boolean;
  73535. /**
  73536. * Specifies if this material should be rendered in alpha test mode
  73537. * @returns false as the sky material doesn't need alpha testing.
  73538. */
  73539. needAlphaTesting(): boolean;
  73540. /**
  73541. * Get the texture used for alpha test purpose.
  73542. * @returns null as the sky material has no texture.
  73543. */
  73544. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73545. /**
  73546. * Get if the submesh is ready to be used and all its information available.
  73547. * Child classes can use it to update shaders
  73548. * @param mesh defines the mesh to check
  73549. * @param subMesh defines which submesh to check
  73550. * @param useInstances specifies that instances should be used
  73551. * @returns a boolean indicating that the submesh is ready or not
  73552. */
  73553. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73554. /**
  73555. * Binds the submesh to this material by preparing the effect and shader to draw
  73556. * @param world defines the world transformation matrix
  73557. * @param mesh defines the mesh containing the submesh
  73558. * @param subMesh defines the submesh to bind the material to
  73559. */
  73560. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73561. /**
  73562. * Get the list of animatables in the material.
  73563. * @returns the list of animatables object used in the material
  73564. */
  73565. getAnimatables(): BABYLON.IAnimatable[];
  73566. /**
  73567. * Disposes the material
  73568. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  73569. */
  73570. dispose(forceDisposeEffect?: boolean): void;
  73571. /**
  73572. * Makes a duplicate of the material, and gives it a new name
  73573. * @param name defines the new name for the duplicated material
  73574. * @returns the cloned material
  73575. */
  73576. clone(name: string): SkyMaterial;
  73577. /**
  73578. * Serializes this material in a JSON representation
  73579. * @returns the serialized material object
  73580. */
  73581. serialize(): any;
  73582. /**
  73583. * Gets the current class name of the material e.g. "SkyMaterial"
  73584. * Mainly use in serialization.
  73585. * @returns the class name
  73586. */
  73587. getClassName(): string;
  73588. /**
  73589. * Creates a sky material from parsed material data
  73590. * @param source defines the JSON representation of the material
  73591. * @param scene defines the hosting scene
  73592. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73593. * @returns a new sky material
  73594. */
  73595. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  73596. }
  73597. }
  73598. declare module BABYLON {
  73599. /** @hidden */
  73600. export var terrainPixelShader: {
  73601. name: string;
  73602. shader: string;
  73603. };
  73604. }
  73605. declare module BABYLON {
  73606. /** @hidden */
  73607. export var terrainVertexShader: {
  73608. name: string;
  73609. shader: string;
  73610. };
  73611. }
  73612. declare module BABYLON {
  73613. export class TerrainMaterial extends BABYLON.PushMaterial {
  73614. private _mixTexture;
  73615. mixTexture: BABYLON.BaseTexture;
  73616. private _diffuseTexture1;
  73617. diffuseTexture1: BABYLON.Texture;
  73618. private _diffuseTexture2;
  73619. diffuseTexture2: BABYLON.Texture;
  73620. private _diffuseTexture3;
  73621. diffuseTexture3: BABYLON.Texture;
  73622. private _bumpTexture1;
  73623. bumpTexture1: BABYLON.Texture;
  73624. private _bumpTexture2;
  73625. bumpTexture2: BABYLON.Texture;
  73626. private _bumpTexture3;
  73627. bumpTexture3: BABYLON.Texture;
  73628. diffuseColor: BABYLON.Color3;
  73629. specularColor: BABYLON.Color3;
  73630. specularPower: number;
  73631. private _disableLighting;
  73632. disableLighting: boolean;
  73633. private _maxSimultaneousLights;
  73634. maxSimultaneousLights: number;
  73635. private _renderId;
  73636. constructor(name: string, scene: BABYLON.Scene);
  73637. needAlphaBlending(): boolean;
  73638. needAlphaTesting(): boolean;
  73639. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73640. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73641. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73642. getAnimatables(): BABYLON.IAnimatable[];
  73643. getActiveTextures(): BABYLON.BaseTexture[];
  73644. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73645. dispose(forceDisposeEffect?: boolean): void;
  73646. clone(name: string): TerrainMaterial;
  73647. serialize(): any;
  73648. getClassName(): string;
  73649. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  73650. }
  73651. }
  73652. declare module BABYLON {
  73653. /** @hidden */
  73654. export var triplanarPixelShader: {
  73655. name: string;
  73656. shader: string;
  73657. };
  73658. }
  73659. declare module BABYLON {
  73660. /** @hidden */
  73661. export var triplanarVertexShader: {
  73662. name: string;
  73663. shader: string;
  73664. };
  73665. }
  73666. declare module BABYLON {
  73667. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  73668. mixTexture: BABYLON.BaseTexture;
  73669. private _diffuseTextureX;
  73670. diffuseTextureX: BABYLON.BaseTexture;
  73671. private _diffuseTextureY;
  73672. diffuseTextureY: BABYLON.BaseTexture;
  73673. private _diffuseTextureZ;
  73674. diffuseTextureZ: BABYLON.BaseTexture;
  73675. private _normalTextureX;
  73676. normalTextureX: BABYLON.BaseTexture;
  73677. private _normalTextureY;
  73678. normalTextureY: BABYLON.BaseTexture;
  73679. private _normalTextureZ;
  73680. normalTextureZ: BABYLON.BaseTexture;
  73681. tileSize: number;
  73682. diffuseColor: BABYLON.Color3;
  73683. specularColor: BABYLON.Color3;
  73684. specularPower: number;
  73685. private _disableLighting;
  73686. disableLighting: boolean;
  73687. private _maxSimultaneousLights;
  73688. maxSimultaneousLights: number;
  73689. private _renderId;
  73690. constructor(name: string, scene: BABYLON.Scene);
  73691. needAlphaBlending(): boolean;
  73692. needAlphaTesting(): boolean;
  73693. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73694. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73695. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73696. getAnimatables(): BABYLON.IAnimatable[];
  73697. getActiveTextures(): BABYLON.BaseTexture[];
  73698. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73699. dispose(forceDisposeEffect?: boolean): void;
  73700. clone(name: string): TriPlanarMaterial;
  73701. serialize(): any;
  73702. getClassName(): string;
  73703. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  73704. }
  73705. }
  73706. declare module BABYLON {
  73707. /** @hidden */
  73708. export var waterPixelShader: {
  73709. name: string;
  73710. shader: string;
  73711. };
  73712. }
  73713. declare module BABYLON {
  73714. /** @hidden */
  73715. export var waterVertexShader: {
  73716. name: string;
  73717. shader: string;
  73718. };
  73719. }
  73720. declare module BABYLON {
  73721. export class WaterMaterial extends BABYLON.PushMaterial {
  73722. renderTargetSize: BABYLON.Vector2;
  73723. private _bumpTexture;
  73724. bumpTexture: BABYLON.BaseTexture;
  73725. diffuseColor: BABYLON.Color3;
  73726. specularColor: BABYLON.Color3;
  73727. specularPower: number;
  73728. private _disableLighting;
  73729. disableLighting: boolean;
  73730. private _maxSimultaneousLights;
  73731. maxSimultaneousLights: number;
  73732. /**
  73733. * @param {number}: Represents the wind force
  73734. */
  73735. windForce: number;
  73736. /**
  73737. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  73738. */
  73739. windDirection: BABYLON.Vector2;
  73740. /**
  73741. * @param {number}: Wave height, represents the height of the waves
  73742. */
  73743. waveHeight: number;
  73744. /**
  73745. * @param {number}: Bump height, represents the bump height related to the bump map
  73746. */
  73747. bumpHeight: number;
  73748. /**
  73749. * @param {boolean}: Add a smaller moving bump to less steady waves.
  73750. */
  73751. private _bumpSuperimpose;
  73752. bumpSuperimpose: boolean;
  73753. /**
  73754. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  73755. */
  73756. private _fresnelSeparate;
  73757. fresnelSeparate: boolean;
  73758. /**
  73759. * @param {boolean}: bump Waves modify the reflection.
  73760. */
  73761. private _bumpAffectsReflection;
  73762. bumpAffectsReflection: boolean;
  73763. /**
  73764. * @param {number}: The water color blended with the refraction (near)
  73765. */
  73766. waterColor: BABYLON.Color3;
  73767. /**
  73768. * @param {number}: The blend factor related to the water color
  73769. */
  73770. colorBlendFactor: number;
  73771. /**
  73772. * @param {number}: The water color blended with the reflection (far)
  73773. */
  73774. waterColor2: BABYLON.Color3;
  73775. /**
  73776. * @param {number}: The blend factor related to the water color (reflection, far)
  73777. */
  73778. colorBlendFactor2: number;
  73779. /**
  73780. * @param {number}: Represents the maximum length of a wave
  73781. */
  73782. waveLength: number;
  73783. /**
  73784. * @param {number}: Defines the waves speed
  73785. */
  73786. waveSpeed: number;
  73787. /**
  73788. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  73789. * will avoid calculating useless pixels in the pixel shader of the water material.
  73790. */
  73791. disableClipPlane: boolean;
  73792. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  73793. private _mesh;
  73794. private _refractionRTT;
  73795. private _reflectionRTT;
  73796. private _reflectionTransform;
  73797. private _lastTime;
  73798. private _lastDeltaTime;
  73799. private _renderId;
  73800. private _useLogarithmicDepth;
  73801. private _waitingRenderList;
  73802. private _imageProcessingConfiguration;
  73803. private _imageProcessingObserver;
  73804. /**
  73805. * Gets a boolean indicating that current material needs to register RTT
  73806. */
  73807. readonly hasRenderTargetTextures: boolean;
  73808. /**
  73809. * Constructor
  73810. */
  73811. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  73812. useLogarithmicDepth: boolean;
  73813. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  73814. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  73815. addToRenderList(node: any): void;
  73816. enableRenderTargets(enable: boolean): void;
  73817. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  73818. readonly renderTargetsEnabled: boolean;
  73819. needAlphaBlending(): boolean;
  73820. needAlphaTesting(): boolean;
  73821. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73822. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73823. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73824. private _createRenderTargets;
  73825. getAnimatables(): BABYLON.IAnimatable[];
  73826. getActiveTextures(): BABYLON.BaseTexture[];
  73827. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73828. dispose(forceDisposeEffect?: boolean): void;
  73829. clone(name: string): WaterMaterial;
  73830. serialize(): any;
  73831. getClassName(): string;
  73832. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  73833. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  73834. }
  73835. }
  73836. declare module BABYLON {
  73837. /** @hidden */
  73838. export var asciiartPixelShader: {
  73839. name: string;
  73840. shader: string;
  73841. };
  73842. }
  73843. declare module BABYLON {
  73844. /**
  73845. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  73846. *
  73847. * It basically takes care rendering the font front the given font size to a texture.
  73848. * This is used later on in the postprocess.
  73849. */
  73850. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  73851. private _font;
  73852. private _text;
  73853. private _charSize;
  73854. /**
  73855. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  73856. */
  73857. readonly charSize: number;
  73858. /**
  73859. * Create a new instance of the Ascii Art FontTexture class
  73860. * @param name the name of the texture
  73861. * @param font the font to use, use the W3C CSS notation
  73862. * @param text the caracter set to use in the rendering.
  73863. * @param scene the scene that owns the texture
  73864. */
  73865. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  73866. /**
  73867. * Gets the max char width of a font.
  73868. * @param font the font to use, use the W3C CSS notation
  73869. * @return the max char width
  73870. */
  73871. private getFontWidth;
  73872. /**
  73873. * Gets the max char height of a font.
  73874. * @param font the font to use, use the W3C CSS notation
  73875. * @return the max char height
  73876. */
  73877. private getFontHeight;
  73878. /**
  73879. * Clones the current AsciiArtTexture.
  73880. * @return the clone of the texture.
  73881. */
  73882. clone(): AsciiArtFontTexture;
  73883. /**
  73884. * Parses a json object representing the texture and returns an instance of it.
  73885. * @param source the source JSON representation
  73886. * @param scene the scene to create the texture for
  73887. * @return the parsed texture
  73888. */
  73889. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  73890. }
  73891. /**
  73892. * Option available in the Ascii Art Post Process.
  73893. */
  73894. export interface IAsciiArtPostProcessOptions {
  73895. /**
  73896. * The font to use following the w3c font definition.
  73897. */
  73898. font?: string;
  73899. /**
  73900. * The character set to use in the postprocess.
  73901. */
  73902. characterSet?: string;
  73903. /**
  73904. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73905. * This number is defined between 0 and 1;
  73906. */
  73907. mixToTile?: number;
  73908. /**
  73909. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73910. * This number is defined between 0 and 1;
  73911. */
  73912. mixToNormal?: number;
  73913. }
  73914. /**
  73915. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  73916. *
  73917. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73918. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  73919. */
  73920. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  73921. /**
  73922. * The font texture used to render the char in the post process.
  73923. */
  73924. private _asciiArtFontTexture;
  73925. /**
  73926. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73927. * This number is defined between 0 and 1;
  73928. */
  73929. mixToTile: number;
  73930. /**
  73931. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73932. * This number is defined between 0 and 1;
  73933. */
  73934. mixToNormal: number;
  73935. /**
  73936. * Instantiates a new Ascii Art Post Process.
  73937. * @param name the name to give to the postprocess
  73938. * @camera the camera to apply the post process to.
  73939. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  73940. */
  73941. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  73942. }
  73943. }
  73944. declare module BABYLON {
  73945. /** @hidden */
  73946. export var digitalrainPixelShader: {
  73947. name: string;
  73948. shader: string;
  73949. };
  73950. }
  73951. declare module BABYLON {
  73952. /**
  73953. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  73954. *
  73955. * It basically takes care rendering the font front the given font size to a texture.
  73956. * This is used later on in the postprocess.
  73957. */
  73958. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  73959. private _font;
  73960. private _text;
  73961. private _charSize;
  73962. /**
  73963. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  73964. */
  73965. readonly charSize: number;
  73966. /**
  73967. * Create a new instance of the Digital Rain FontTexture class
  73968. * @param name the name of the texture
  73969. * @param font the font to use, use the W3C CSS notation
  73970. * @param text the caracter set to use in the rendering.
  73971. * @param scene the scene that owns the texture
  73972. */
  73973. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  73974. /**
  73975. * Gets the max char width of a font.
  73976. * @param font the font to use, use the W3C CSS notation
  73977. * @return the max char width
  73978. */
  73979. private getFontWidth;
  73980. /**
  73981. * Gets the max char height of a font.
  73982. * @param font the font to use, use the W3C CSS notation
  73983. * @return the max char height
  73984. */
  73985. private getFontHeight;
  73986. /**
  73987. * Clones the current DigitalRainFontTexture.
  73988. * @return the clone of the texture.
  73989. */
  73990. clone(): DigitalRainFontTexture;
  73991. /**
  73992. * Parses a json object representing the texture and returns an instance of it.
  73993. * @param source the source JSON representation
  73994. * @param scene the scene to create the texture for
  73995. * @return the parsed texture
  73996. */
  73997. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  73998. }
  73999. /**
  74000. * Option available in the Digital Rain Post Process.
  74001. */
  74002. export interface IDigitalRainPostProcessOptions {
  74003. /**
  74004. * The font to use following the w3c font definition.
  74005. */
  74006. font?: string;
  74007. /**
  74008. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  74009. * This number is defined between 0 and 1;
  74010. */
  74011. mixToTile?: number;
  74012. /**
  74013. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  74014. * This number is defined between 0 and 1;
  74015. */
  74016. mixToNormal?: number;
  74017. }
  74018. /**
  74019. * DigitalRainPostProcess helps rendering everithing in digital rain.
  74020. *
  74021. * Simmply add it to your scene and let the nerd that lives in you have fun.
  74022. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  74023. */
  74024. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  74025. /**
  74026. * The font texture used to render the char in the post process.
  74027. */
  74028. private _digitalRainFontTexture;
  74029. /**
  74030. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  74031. * This number is defined between 0 and 1;
  74032. */
  74033. mixToTile: number;
  74034. /**
  74035. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  74036. * This number is defined between 0 and 1;
  74037. */
  74038. mixToNormal: number;
  74039. /**
  74040. * Instantiates a new Digital Rain Post Process.
  74041. * @param name the name to give to the postprocess
  74042. * @camera the camera to apply the post process to.
  74043. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  74044. */
  74045. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  74046. }
  74047. }
  74048. declare module BABYLON {
  74049. /** @hidden */
  74050. export var oceanPostProcessPixelShader: {
  74051. name: string;
  74052. shader: string;
  74053. };
  74054. }
  74055. declare module BABYLON {
  74056. /**
  74057. * Option available in the Ocean Post Process.
  74058. */
  74059. export interface IOceanPostProcessOptions {
  74060. /**
  74061. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  74062. */
  74063. reflectionSize?: number | {
  74064. width: number;
  74065. height: number;
  74066. } | {
  74067. ratio: number;
  74068. };
  74069. /**
  74070. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  74071. */
  74072. refractionSize?: number | {
  74073. width: number;
  74074. height: number;
  74075. } | {
  74076. ratio: number;
  74077. };
  74078. }
  74079. /**
  74080. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  74081. *
  74082. * Simmply add it to your scene and let the nerd that lives in you have fun.
  74083. * Example usage:
  74084. * var pp = new OceanPostProcess("myOcean", camera);
  74085. * pp.reflectionEnabled = true;
  74086. * pp.refractionEnabled = true;
  74087. */
  74088. export class OceanPostProcess extends BABYLON.PostProcess {
  74089. /**
  74090. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  74091. */
  74092. /**
  74093. * Sets weither or not the real-time reflection is enabled on the ocean.
  74094. * Is set to true, the reflection mirror texture will be used as reflection texture.
  74095. */
  74096. reflectionEnabled: boolean;
  74097. /**
  74098. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  74099. */
  74100. /**
  74101. * Sets weither or not the real-time refraction is enabled on the ocean.
  74102. * Is set to true, the refraction render target texture will be used as refraction texture.
  74103. */
  74104. refractionEnabled: boolean;
  74105. /**
  74106. * Gets wether or not the post-processes is supported by the running hardware.
  74107. * This requires draw buffer supports.
  74108. */
  74109. readonly isSupported: boolean;
  74110. /**
  74111. * This is the reflection mirror texture used to display reflections on the ocean.
  74112. * By default, render list is empty.
  74113. */
  74114. reflectionTexture: BABYLON.MirrorTexture;
  74115. /**
  74116. * This is the refraction render target texture used to display refraction on the ocean.
  74117. * By default, render list is empty.
  74118. */
  74119. refractionTexture: BABYLON.RenderTargetTexture;
  74120. private _time;
  74121. private _cameraRotation;
  74122. private _cameraViewMatrix;
  74123. private _reflectionEnabled;
  74124. private _refractionEnabled;
  74125. private _geometryRenderer;
  74126. /**
  74127. * Instantiates a new Ocean Post Process.
  74128. * @param name the name to give to the postprocess.
  74129. * @camera the camera to apply the post process to.
  74130. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  74131. */
  74132. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  74133. /**
  74134. * Returns the appropriate defines according to the current configuration.
  74135. */
  74136. private _getDefines;
  74137. /**
  74138. * Computes the current camera rotation as the shader requires a camera rotation.
  74139. */
  74140. private _computeCameraRotation;
  74141. }
  74142. }
  74143. declare module BABYLON {
  74144. /** @hidden */
  74145. export var brickProceduralTexturePixelShader: {
  74146. name: string;
  74147. shader: string;
  74148. };
  74149. }
  74150. declare module BABYLON {
  74151. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  74152. private _numberOfBricksHeight;
  74153. private _numberOfBricksWidth;
  74154. private _jointColor;
  74155. private _brickColor;
  74156. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74157. updateShaderUniforms(): void;
  74158. numberOfBricksHeight: number;
  74159. numberOfBricksWidth: number;
  74160. jointColor: BABYLON.Color3;
  74161. brickColor: BABYLON.Color3;
  74162. /**
  74163. * Serializes this brick procedural texture
  74164. * @returns a serialized brick procedural texture object
  74165. */
  74166. serialize(): any;
  74167. /**
  74168. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  74169. * @param parsedTexture defines parsed texture data
  74170. * @param scene defines the current scene
  74171. * @param rootUrl defines the root URL containing brick procedural texture information
  74172. * @returns a parsed Brick Procedural BABYLON.Texture
  74173. */
  74174. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  74175. }
  74176. }
  74177. declare module BABYLON {
  74178. /** @hidden */
  74179. export var cloudProceduralTexturePixelShader: {
  74180. name: string;
  74181. shader: string;
  74182. };
  74183. }
  74184. declare module BABYLON {
  74185. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  74186. private _skyColor;
  74187. private _cloudColor;
  74188. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74189. updateShaderUniforms(): void;
  74190. skyColor: BABYLON.Color4;
  74191. cloudColor: BABYLON.Color4;
  74192. /**
  74193. * Serializes this cloud procedural texture
  74194. * @returns a serialized cloud procedural texture object
  74195. */
  74196. serialize(): any;
  74197. /**
  74198. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  74199. * @param parsedTexture defines parsed texture data
  74200. * @param scene defines the current scene
  74201. * @param rootUrl defines the root URL containing cloud procedural texture information
  74202. * @returns a parsed Cloud Procedural BABYLON.Texture
  74203. */
  74204. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  74205. }
  74206. }
  74207. declare module BABYLON {
  74208. /** @hidden */
  74209. export var fireProceduralTexturePixelShader: {
  74210. name: string;
  74211. shader: string;
  74212. };
  74213. }
  74214. declare module BABYLON {
  74215. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  74216. private _time;
  74217. private _speed;
  74218. private _autoGenerateTime;
  74219. private _fireColors;
  74220. private _alphaThreshold;
  74221. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74222. updateShaderUniforms(): void;
  74223. render(useCameraPostProcess?: boolean): void;
  74224. static readonly PurpleFireColors: BABYLON.Color3[];
  74225. static readonly GreenFireColors: BABYLON.Color3[];
  74226. static readonly RedFireColors: BABYLON.Color3[];
  74227. static readonly BlueFireColors: BABYLON.Color3[];
  74228. autoGenerateTime: boolean;
  74229. fireColors: BABYLON.Color3[];
  74230. time: number;
  74231. speed: BABYLON.Vector2;
  74232. alphaThreshold: number;
  74233. /**
  74234. * Serializes this fire procedural texture
  74235. * @returns a serialized fire procedural texture object
  74236. */
  74237. serialize(): any;
  74238. /**
  74239. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  74240. * @param parsedTexture defines parsed texture data
  74241. * @param scene defines the current scene
  74242. * @param rootUrl defines the root URL containing fire procedural texture information
  74243. * @returns a parsed Fire Procedural BABYLON.Texture
  74244. */
  74245. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  74246. }
  74247. }
  74248. declare module BABYLON {
  74249. /** @hidden */
  74250. export var grassProceduralTexturePixelShader: {
  74251. name: string;
  74252. shader: string;
  74253. };
  74254. }
  74255. declare module BABYLON {
  74256. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  74257. private _grassColors;
  74258. private _groundColor;
  74259. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74260. updateShaderUniforms(): void;
  74261. grassColors: BABYLON.Color3[];
  74262. groundColor: BABYLON.Color3;
  74263. /**
  74264. * Serializes this grass procedural texture
  74265. * @returns a serialized grass procedural texture object
  74266. */
  74267. serialize(): any;
  74268. /**
  74269. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  74270. * @param parsedTexture defines parsed texture data
  74271. * @param scene defines the current scene
  74272. * @param rootUrl defines the root URL containing grass procedural texture information
  74273. * @returns a parsed Grass Procedural BABYLON.Texture
  74274. */
  74275. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  74276. }
  74277. }
  74278. declare module BABYLON {
  74279. /** @hidden */
  74280. export var marbleProceduralTexturePixelShader: {
  74281. name: string;
  74282. shader: string;
  74283. };
  74284. }
  74285. declare module BABYLON {
  74286. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  74287. private _numberOfTilesHeight;
  74288. private _numberOfTilesWidth;
  74289. private _amplitude;
  74290. private _jointColor;
  74291. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74292. updateShaderUniforms(): void;
  74293. numberOfTilesHeight: number;
  74294. amplitude: number;
  74295. numberOfTilesWidth: number;
  74296. jointColor: BABYLON.Color3;
  74297. /**
  74298. * Serializes this marble procedural texture
  74299. * @returns a serialized marble procedural texture object
  74300. */
  74301. serialize(): any;
  74302. /**
  74303. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  74304. * @param parsedTexture defines parsed texture data
  74305. * @param scene defines the current scene
  74306. * @param rootUrl defines the root URL containing marble procedural texture information
  74307. * @returns a parsed Marble Procedural BABYLON.Texture
  74308. */
  74309. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  74310. }
  74311. }
  74312. declare module BABYLON {
  74313. /** @hidden */
  74314. export var normalMapProceduralTexturePixelShader: {
  74315. name: string;
  74316. shader: string;
  74317. };
  74318. }
  74319. declare module BABYLON {
  74320. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  74321. private _baseTexture;
  74322. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74323. updateShaderUniforms(): void;
  74324. render(useCameraPostProcess?: boolean): void;
  74325. resize(size: any, generateMipMaps: any): void;
  74326. baseTexture: BABYLON.Texture;
  74327. /**
  74328. * Serializes this normal map procedural texture
  74329. * @returns a serialized normal map procedural texture object
  74330. */
  74331. serialize(): any;
  74332. /**
  74333. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  74334. * @param parsedTexture defines parsed texture data
  74335. * @param scene defines the current scene
  74336. * @param rootUrl defines the root URL containing normal map procedural texture information
  74337. * @returns a parsed Normal Map Procedural BABYLON.Texture
  74338. */
  74339. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  74340. }
  74341. }
  74342. declare module BABYLON {
  74343. /** @hidden */
  74344. export var perlinNoiseProceduralTexturePixelShader: {
  74345. name: string;
  74346. shader: string;
  74347. };
  74348. }
  74349. declare module BABYLON {
  74350. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  74351. time: number;
  74352. timeScale: number;
  74353. translationSpeed: number;
  74354. private _currentTranslation;
  74355. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74356. updateShaderUniforms(): void;
  74357. render(useCameraPostProcess?: boolean): void;
  74358. resize(size: any, generateMipMaps: any): void;
  74359. /**
  74360. * Serializes this perlin noise procedural texture
  74361. * @returns a serialized perlin noise procedural texture object
  74362. */
  74363. serialize(): any;
  74364. /**
  74365. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  74366. * @param parsedTexture defines parsed texture data
  74367. * @param scene defines the current scene
  74368. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  74369. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  74370. */
  74371. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  74372. }
  74373. }
  74374. declare module BABYLON {
  74375. /** @hidden */
  74376. export var roadProceduralTexturePixelShader: {
  74377. name: string;
  74378. shader: string;
  74379. };
  74380. }
  74381. declare module BABYLON {
  74382. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  74383. private _roadColor;
  74384. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74385. updateShaderUniforms(): void;
  74386. roadColor: BABYLON.Color3;
  74387. /**
  74388. * Serializes this road procedural texture
  74389. * @returns a serialized road procedural texture object
  74390. */
  74391. serialize(): any;
  74392. /**
  74393. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  74394. * @param parsedTexture defines parsed texture data
  74395. * @param scene defines the current scene
  74396. * @param rootUrl defines the root URL containing road procedural texture information
  74397. * @returns a parsed Road Procedural BABYLON.Texture
  74398. */
  74399. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  74400. }
  74401. }
  74402. declare module BABYLON {
  74403. /** @hidden */
  74404. export var starfieldProceduralTexturePixelShader: {
  74405. name: string;
  74406. shader: string;
  74407. };
  74408. }
  74409. declare module BABYLON {
  74410. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  74411. private _time;
  74412. private _alpha;
  74413. private _beta;
  74414. private _zoom;
  74415. private _formuparam;
  74416. private _stepsize;
  74417. private _tile;
  74418. private _brightness;
  74419. private _darkmatter;
  74420. private _distfading;
  74421. private _saturation;
  74422. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74423. updateShaderUniforms(): void;
  74424. time: number;
  74425. alpha: number;
  74426. beta: number;
  74427. formuparam: number;
  74428. stepsize: number;
  74429. zoom: number;
  74430. tile: number;
  74431. brightness: number;
  74432. darkmatter: number;
  74433. distfading: number;
  74434. saturation: number;
  74435. /**
  74436. * Serializes this starfield procedural texture
  74437. * @returns a serialized starfield procedural texture object
  74438. */
  74439. serialize(): any;
  74440. /**
  74441. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  74442. * @param parsedTexture defines parsed texture data
  74443. * @param scene defines the current scene
  74444. * @param rootUrl defines the root URL containing startfield procedural texture information
  74445. * @returns a parsed Starfield Procedural BABYLON.Texture
  74446. */
  74447. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  74448. }
  74449. }
  74450. declare module BABYLON {
  74451. /** @hidden */
  74452. export var woodProceduralTexturePixelShader: {
  74453. name: string;
  74454. shader: string;
  74455. };
  74456. }
  74457. declare module BABYLON {
  74458. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  74459. private _ampScale;
  74460. private _woodColor;
  74461. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74462. updateShaderUniforms(): void;
  74463. ampScale: number;
  74464. woodColor: BABYLON.Color3;
  74465. /**
  74466. * Serializes this wood procedural texture
  74467. * @returns a serialized wood procedural texture object
  74468. */
  74469. serialize(): any;
  74470. /**
  74471. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  74472. * @param parsedTexture defines parsed texture data
  74473. * @param scene defines the current scene
  74474. * @param rootUrl defines the root URL containing wood procedural texture information
  74475. * @returns a parsed Wood Procedural BABYLON.Texture
  74476. */
  74477. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  74478. }
  74479. }