babylon.d.ts 1.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. */
  8. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  9. /**
  10. * Base class of the scene acting as a container for the different elements composing a scene.
  11. * This class is dynamically extended by the different components of the scene increasing
  12. * flexibility and reducing coupling.
  13. */
  14. abstract class AbstractScene {
  15. /**
  16. * Stores the list of available parsers in the application.
  17. */
  18. private static _BabylonFileParsers;
  19. /**
  20. * Adds a parser in the list of availables ones.
  21. * @param name Defines the name of the parser
  22. * @param parser Defines the parser to add
  23. */
  24. static AddParser(name: string, parser: BabylonFileParser): void;
  25. /**
  26. * Parser json data and populate both a scene and its associated container object
  27. * @param jsonData Defines the data to parse
  28. * @param scene Defines the scene to parse the data for
  29. * @param container Defines the container attached to the parsing sequence
  30. * @param rootUrl Defines the root url of the data
  31. */
  32. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33. /** All of the cameras added to this scene
  34. * @see http://doc.babylonjs.com/babylon101/cameras
  35. */
  36. cameras: Camera[];
  37. /**
  38. * All of the lights added to this scene
  39. * @see http://doc.babylonjs.com/babylon101/lights
  40. */
  41. lights: Light[];
  42. /**
  43. * All of the (abstract) meshes added to this scene
  44. */
  45. meshes: AbstractMesh[];
  46. /**
  47. * The list of skeletons added to the scene
  48. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  49. */
  50. skeletons: Skeleton[];
  51. /**
  52. * All of the particle systems added to this scene
  53. * @see http://doc.babylonjs.com/babylon101/particles
  54. */
  55. particleSystems: IParticleSystem[];
  56. /**
  57. * Gets a list of Animations associated with the scene
  58. */
  59. animations: Animation[];
  60. /**
  61. * All of the animation groups added to this scene
  62. * @see http://doc.babylonjs.com/how_to/group
  63. */
  64. animationGroups: AnimationGroup[];
  65. /**
  66. * All of the multi-materials added to this scene
  67. * @see http://doc.babylonjs.com/how_to/multi_materials
  68. */
  69. multiMaterials: MultiMaterial[];
  70. /**
  71. * All of the materials added to this scene
  72. * @see http://doc.babylonjs.com/babylon101/materials
  73. */
  74. materials: Material[];
  75. /**
  76. * The list of morph target managers added to the scene
  77. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  78. */
  79. morphTargetManagers: MorphTargetManager[];
  80. /**
  81. * The list of geometries used in the scene.
  82. */
  83. geometries: Geometry[];
  84. /**
  85. * All of the tranform nodes added to this scene
  86. * @see http://doc.babylonjs.com/how_to/transformnode
  87. */
  88. transformNodes: TransformNode[];
  89. /**
  90. * ActionManagers available on the scene.
  91. */
  92. actionManagers: ActionManager[];
  93. /**
  94. * Sounds to keep.
  95. */
  96. sounds: Sound[];
  97. /**
  98. * Textures to keep.
  99. */
  100. textures: BaseTexture[];
  101. }
  102. }
  103. declare module BABYLON {
  104. /**
  105. * Set of assets to keep when moving a scene into an asset container.
  106. */
  107. class KeepAssets extends AbstractScene {
  108. }
  109. /**
  110. * Container with a set of assets that can be added or removed from a scene.
  111. */
  112. class AssetContainer extends AbstractScene {
  113. /**
  114. * The scene the AssetContainer belongs to.
  115. */
  116. scene: Scene;
  117. /**
  118. * Instantiates an AssetContainer.
  119. * @param scene The scene the AssetContainer belongs to.
  120. */
  121. constructor(scene: Scene);
  122. /**
  123. * Adds all the assets from the container to the scene.
  124. */
  125. addAllToScene(): void;
  126. /**
  127. * Removes all the assets in the container from the scene
  128. */
  129. removeAllFromScene(): void;
  130. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  131. /**
  132. * Removes all the assets contained in the scene and adds them to the container.
  133. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  134. */
  135. moveAllFromScene(keepAssets?: KeepAssets): void;
  136. /**
  137. * 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.
  138. * @returns the root mesh
  139. */
  140. createRootMesh(): Mesh;
  141. }
  142. }
  143. interface Window {
  144. mozIndexedDB: IDBFactory;
  145. webkitIndexedDB: IDBFactory;
  146. msIndexedDB: IDBFactory;
  147. webkitURL: typeof URL;
  148. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  149. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  150. WebGLRenderingContext: WebGLRenderingContext;
  151. MSGesture: MSGesture;
  152. CANNON: any;
  153. AudioContext: AudioContext;
  154. webkitAudioContext: AudioContext;
  155. PointerEvent: any;
  156. Math: Math;
  157. Uint8Array: Uint8ArrayConstructor;
  158. Float32Array: Float32ArrayConstructor;
  159. mozURL: typeof URL;
  160. msURL: typeof URL;
  161. VRFrameData: any;
  162. DracoDecoderModule: any;
  163. }
  164. interface WebGLRenderingContext {
  165. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  166. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  167. vertexAttribDivisor(index: number, divisor: number): void;
  168. createVertexArray(): any;
  169. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  170. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  171. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  172. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  173. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  174. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  175. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  176. createQuery(): WebGLQuery;
  177. deleteQuery(query: WebGLQuery): void;
  178. beginQuery(target: number, query: WebGLQuery): void;
  179. endQuery(target: number): void;
  180. getQueryParameter(query: WebGLQuery, pname: number): any;
  181. getQuery(target: number, pname: number): any;
  182. MAX_SAMPLES: number;
  183. RGBA8: number;
  184. READ_FRAMEBUFFER: number;
  185. DRAW_FRAMEBUFFER: number;
  186. UNIFORM_BUFFER: number;
  187. HALF_FLOAT_OES: number;
  188. RGBA16F: number;
  189. RGBA32F: number;
  190. R32F: number;
  191. RG32F: number;
  192. RGB32F: number;
  193. R16F: number;
  194. RG16F: number;
  195. RGB16F: number;
  196. RED: number;
  197. RG: number;
  198. R8: number;
  199. RG8: number;
  200. UNSIGNED_INT_24_8: number;
  201. DEPTH24_STENCIL8: number;
  202. drawBuffers(buffers: number[]): void;
  203. readBuffer(src: number): void;
  204. readonly COLOR_ATTACHMENT0: number;
  205. readonly COLOR_ATTACHMENT1: number;
  206. readonly COLOR_ATTACHMENT2: number;
  207. readonly COLOR_ATTACHMENT3: number;
  208. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  209. ANY_SAMPLES_PASSED: number;
  210. QUERY_RESULT_AVAILABLE: number;
  211. QUERY_RESULT: number;
  212. }
  213. interface Document {
  214. mozCancelFullScreen(): void;
  215. msCancelFullScreen(): void;
  216. mozFullScreen: boolean;
  217. msIsFullScreen: boolean;
  218. fullscreen: boolean;
  219. mozPointerLockElement: HTMLElement;
  220. msPointerLockElement: HTMLElement;
  221. webkitPointerLockElement: HTMLElement;
  222. }
  223. interface HTMLCanvasElement {
  224. msRequestPointerLock?(): void;
  225. mozRequestPointerLock?(): void;
  226. webkitRequestPointerLock?(): void;
  227. }
  228. interface CanvasRenderingContext2D {
  229. msImageSmoothingEnabled: boolean;
  230. }
  231. interface WebGLBuffer {
  232. references: number;
  233. capacity: number;
  234. is32Bits: boolean;
  235. }
  236. interface WebGLProgram {
  237. transformFeedback?: WebGLTransformFeedback | null;
  238. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  239. }
  240. interface MouseEvent {
  241. mozMovementX: number;
  242. mozMovementY: number;
  243. webkitMovementX: number;
  244. webkitMovementY: number;
  245. msMovementX: number;
  246. msMovementY: number;
  247. }
  248. interface Navigator {
  249. mozGetVRDevices: (any: any) => any;
  250. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  251. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  252. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  253. webkitGetGamepads(): Gamepad[];
  254. msGetGamepads(): Gamepad[];
  255. webkitGamepads(): Gamepad[];
  256. }
  257. interface HTMLVideoElement {
  258. mozSrcObject: any;
  259. }
  260. interface Screen {
  261. orientation: string;
  262. mozOrientation: string;
  263. }
  264. interface Math {
  265. fround(x: number): number;
  266. imul(a: number, b: number): number;
  267. }
  268. interface EXT_disjoint_timer_query {
  269. QUERY_COUNTER_BITS_EXT: number;
  270. TIME_ELAPSED_EXT: number;
  271. TIMESTAMP_EXT: number;
  272. GPU_DISJOINT_EXT: number;
  273. QUERY_RESULT_EXT: number;
  274. QUERY_RESULT_AVAILABLE_EXT: number;
  275. queryCounterEXT(query: WebGLQuery, target: number): void;
  276. createQueryEXT(): WebGLQuery;
  277. beginQueryEXT(target: number, query: WebGLQuery): void;
  278. endQueryEXT(target: number): void;
  279. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  280. deleteQueryEXT(query: WebGLQuery): void;
  281. }
  282. interface WebGLUniformLocation {
  283. _currentState: any;
  284. }
  285. declare module BABYLON {
  286. /**
  287. * Node is the basic class for all scene objects (Mesh, Light Camera).
  288. */
  289. class Node implements IBehaviorAware<Node> {
  290. /**
  291. * Gets or sets the name of the node
  292. */
  293. name: string;
  294. /**
  295. * Gets or sets the id of the node
  296. */
  297. id: string;
  298. /**
  299. * Gets or sets the unique id of the node
  300. */
  301. uniqueId: number;
  302. /**
  303. * Gets or sets a string used to store user defined state for the node
  304. */
  305. state: string;
  306. /**
  307. * Gets or sets an object used to store user defined information for the node
  308. */
  309. metadata: any;
  310. /**
  311. * Gets or sets a boolean used to define if the node must be serialized
  312. */
  313. doNotSerialize: boolean;
  314. /** @hidden */
  315. _isDisposed: boolean;
  316. /**
  317. * Gets a list of Animations associated with the node
  318. */
  319. animations: Animation[];
  320. private _ranges;
  321. /**
  322. * Callback raised when the node is ready to be used
  323. */
  324. onReady: (node: Node) => void;
  325. private _isEnabled;
  326. private _isReady;
  327. /** @hidden */
  328. _currentRenderId: number;
  329. private _parentRenderId;
  330. protected _childRenderId: number;
  331. /** @hidden */
  332. _waitingParentId: Nullable<string>;
  333. private _scene;
  334. /** @hidden */
  335. _cache: any;
  336. private _parentNode;
  337. private _children;
  338. /**
  339. * Gets a boolean indicating if the node has been disposed
  340. * @returns true if the node was disposed
  341. */
  342. isDisposed(): boolean;
  343. /**
  344. * Gets or sets the parent of the node
  345. */
  346. parent: Nullable<Node>;
  347. private _animationPropertiesOverride;
  348. /**
  349. * Gets or sets the animation properties override
  350. */
  351. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  352. /**
  353. * Gets a string idenfifying the name of the class
  354. * @returns "Node" string
  355. */
  356. getClassName(): string;
  357. /**
  358. * An event triggered when the mesh is disposed
  359. */
  360. onDisposeObservable: Observable<Node>;
  361. private _onDisposeObserver;
  362. /**
  363. * Sets a callback that will be raised when the node will be disposed
  364. */
  365. onDispose: () => void;
  366. /**
  367. * Creates a new Node
  368. * @param {string} name - the name and id to be given to this node
  369. * @param {BABYLON.Scene} the scene this node will be added to
  370. */
  371. constructor(name: string, scene?: Nullable<Scene>);
  372. /**
  373. * Gets the scene of the node
  374. * @returns a {BABYLON.Scene}
  375. */
  376. getScene(): Scene;
  377. /**
  378. * Gets the engine of the node
  379. * @returns a {BABYLON.Engine}
  380. */
  381. getEngine(): Engine;
  382. private _behaviors;
  383. /**
  384. * Attach a behavior to the node
  385. * @see http://doc.babylonjs.com/features/behaviour
  386. * @param behavior defines the behavior to attach
  387. * @returns the current Node
  388. */
  389. addBehavior(behavior: Behavior<Node>): Node;
  390. /**
  391. * Remove an attached behavior
  392. * @see http://doc.babylonjs.com/features/behaviour
  393. * @param behavior defines the behavior to attach
  394. * @returns the current Node
  395. */
  396. removeBehavior(behavior: Behavior<Node>): Node;
  397. /**
  398. * Gets the list of attached behaviors
  399. * @see http://doc.babylonjs.com/features/behaviour
  400. */
  401. readonly behaviors: Behavior<Node>[];
  402. /**
  403. * Gets an attached behavior by name
  404. * @param name defines the name of the behavior to look for
  405. * @see http://doc.babylonjs.com/features/behaviour
  406. * @returns null if behavior was not found else the requested behavior
  407. */
  408. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  409. /**
  410. * Returns the world matrix of the node
  411. * @returns a matrix containing the node's world matrix
  412. */
  413. getWorldMatrix(): Matrix;
  414. /** @hidden */
  415. _getWorldMatrixDeterminant(): number;
  416. /** @hidden */
  417. _initCache(): void;
  418. /** @hidden */
  419. updateCache(force?: boolean): void;
  420. /** @hidden */
  421. _updateCache(ignoreParentClass?: boolean): void;
  422. /** @hidden */
  423. _isSynchronized(): boolean;
  424. /** @hidden */
  425. _markSyncedWithParent(): void;
  426. /** @hidden */
  427. isSynchronizedWithParent(): boolean;
  428. /** @hidden */
  429. isSynchronized(updateCache?: boolean): boolean;
  430. /** @hidden */
  431. hasNewParent(update?: boolean): boolean;
  432. /**
  433. * Is this node ready to be used/rendered
  434. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  435. * @return true if the node is ready
  436. */
  437. isReady(completeCheck?: boolean): boolean;
  438. /**
  439. * Is this node enabled?
  440. * 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
  441. * @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
  442. * @return whether this node (and its parent) is enabled
  443. */
  444. isEnabled(checkAncestors?: boolean): boolean;
  445. /**
  446. * Set the enabled state of this node
  447. * @param value defines the new enabled state
  448. */
  449. setEnabled(value: boolean): void;
  450. /**
  451. * Is this node a descendant of the given node?
  452. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  453. * @param ancestor defines the parent node to inspect
  454. * @returns a boolean indicating if this node is a descendant of the given node
  455. */
  456. isDescendantOf(ancestor: Node): boolean;
  457. /** @hidden */
  458. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  459. /**
  460. * Will return all nodes that have this node as ascendant
  461. * @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
  462. * @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
  463. * @return all children nodes of all types
  464. */
  465. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  466. /**
  467. * Get all child-meshes of this node
  468. * @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
  469. * @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
  470. * @returns an array of {BABYLON.AbstractMesh}
  471. */
  472. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  473. /**
  474. * Get all child-transformNodes of this node
  475. * @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
  476. * @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
  477. * @returns an array of {BABYLON.TransformNode}
  478. */
  479. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  480. /**
  481. * Get all direct children of this node
  482. * @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
  483. * @returns an array of {BABYLON.Node}
  484. */
  485. getChildren(predicate?: (node: Node) => boolean): Node[];
  486. /** @hidden */
  487. _setReady(state: boolean): void;
  488. /**
  489. * Get an animation by name
  490. * @param name defines the name of the animation to look for
  491. * @returns null if not found else the requested animation
  492. */
  493. getAnimationByName(name: string): Nullable<Animation>;
  494. /**
  495. * Creates an animation range for this node
  496. * @param name defines the name of the range
  497. * @param from defines the starting key
  498. * @param to defines the end key
  499. */
  500. createAnimationRange(name: string, from: number, to: number): void;
  501. /**
  502. * Delete a specific animation range
  503. * @param name defines the name of the range to delete
  504. * @param deleteFrames defines if animation frames from the range must be deleted as well
  505. */
  506. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  507. /**
  508. * Get an animation range by name
  509. * @param name defines the name of the animation range to look for
  510. * @returns null if not found else the requested animation range
  511. */
  512. getAnimationRange(name: string): Nullable<AnimationRange>;
  513. /**
  514. * Will start the animation sequence
  515. * @param name defines the range frames for animation sequence
  516. * @param loop defines if the animation should loop (false by default)
  517. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  518. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  519. * @returns the object created for this animation. If range does not exist, it will return null
  520. */
  521. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  522. /**
  523. * Serialize animation ranges into a JSON compatible object
  524. * @returns serialization object
  525. */
  526. serializeAnimationRanges(): any;
  527. /**
  528. * Computes the world matrix of the node
  529. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  530. * @returns the world matrix
  531. */
  532. computeWorldMatrix(force?: boolean): Matrix;
  533. /**
  534. * Releases resources associated with this node.
  535. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  536. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  537. */
  538. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  539. /**
  540. * Parse animation range data from a serialization object and store them into a given node
  541. * @param node defines where to store the animation ranges
  542. * @param parsedNode defines the serialization object to read data from
  543. * @param scene defines the hosting scene
  544. */
  545. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  546. }
  547. }
  548. declare module BABYLON {
  549. /**
  550. * Define an interface for all classes that will hold resources
  551. */
  552. interface IDisposable {
  553. /**
  554. * Releases all held resources
  555. */
  556. dispose(): void;
  557. }
  558. /**
  559. * Interface used to let developers provide their own mesh selection mechanism
  560. */
  561. interface IActiveMeshCandidateProvider {
  562. /**
  563. * Return the list of active meshes
  564. * @param scene defines the current scene
  565. * @returns the list of active meshes
  566. */
  567. getMeshes(scene: Scene): AbstractMesh[];
  568. /**
  569. * Indicates if the meshes have been checked to make sure they are isEnabled()
  570. */
  571. readonly checksIsEnabled: boolean;
  572. }
  573. /**
  574. * This class is used by the onRenderingGroupObservable
  575. */
  576. class RenderingGroupInfo {
  577. /**
  578. * The Scene that being rendered
  579. */
  580. scene: Scene;
  581. /**
  582. * The camera currently used for the rendering pass
  583. */
  584. camera: Nullable<Camera>;
  585. /**
  586. * The ID of the renderingGroup being processed
  587. */
  588. renderingGroupId: number;
  589. /**
  590. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  591. */
  592. renderStage: number;
  593. /**
  594. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  595. * This stage will be fired no matter what
  596. */
  597. static STAGE_PRECLEAR: number;
  598. /**
  599. * Called before opaque object are rendered.
  600. * This stage will be fired only if there's 3D Opaque content to render
  601. */
  602. static STAGE_PREOPAQUE: number;
  603. /**
  604. * Called after the opaque objects are rendered and before the transparent ones
  605. * This stage will be fired only if there's 3D transparent content to render
  606. */
  607. static STAGE_PRETRANSPARENT: number;
  608. /**
  609. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  610. * This stage will be fired no matter what
  611. */
  612. static STAGE_POSTTRANSPARENT: number;
  613. }
  614. /**
  615. * Represents a scene to be rendered by the engine.
  616. * @see http://doc.babylonjs.com/features/scene
  617. */
  618. class Scene extends AbstractScene implements IAnimatable {
  619. private static _FOGMODE_NONE;
  620. private static _FOGMODE_EXP;
  621. private static _FOGMODE_EXP2;
  622. private static _FOGMODE_LINEAR;
  623. private static _uniqueIdCounter;
  624. /**
  625. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  626. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  627. */
  628. static MinDeltaTime: number;
  629. /**
  630. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  631. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  632. */
  633. static MaxDeltaTime: number;
  634. /** The fog is deactivated */
  635. static readonly FOGMODE_NONE: number;
  636. /** The fog density is following an exponential function */
  637. static readonly FOGMODE_EXP: number;
  638. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  639. static readonly FOGMODE_EXP2: number;
  640. /** The fog density is following a linear function. */
  641. static readonly FOGMODE_LINEAR: number;
  642. /**
  643. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  644. */
  645. autoClear: boolean;
  646. /**
  647. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  648. */
  649. autoClearDepthAndStencil: boolean;
  650. /**
  651. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  652. */
  653. clearColor: Color4;
  654. /**
  655. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  656. */
  657. ambientColor: Color3;
  658. /** @hidden */
  659. _environmentBRDFTexture: BaseTexture;
  660. /** @hidden */
  661. protected _environmentTexture: BaseTexture;
  662. /**
  663. * Texture used in all pbr material as the reflection texture.
  664. * As in the majority of the scene they are the same (exception for multi room and so on),
  665. * this is easier to reference from here than from all the materials.
  666. */
  667. /**
  668. * Texture used in all pbr material as the reflection texture.
  669. * As in the majority of the scene they are the same (exception for multi room and so on),
  670. * this is easier to set here than in all the materials.
  671. */
  672. environmentTexture: BaseTexture;
  673. /** @hidden */
  674. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  675. /**
  676. * Default image processing configuration used either in the rendering
  677. * Forward main pass or through the imageProcessingPostProcess if present.
  678. * As in the majority of the scene they are the same (exception for multi camera),
  679. * this is easier to reference from here than from all the materials and post process.
  680. *
  681. * No setter as we it is a shared configuration, you can set the values instead.
  682. */
  683. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  684. private _forceWireframe;
  685. /**
  686. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  687. */
  688. forceWireframe: boolean;
  689. private _forcePointsCloud;
  690. /**
  691. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  692. */
  693. forcePointsCloud: boolean;
  694. /**
  695. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  696. */
  697. forceShowBoundingBoxes: boolean;
  698. /**
  699. * Gets or sets the active clipplane
  700. */
  701. clipPlane: Nullable<Plane>;
  702. /**
  703. * Gets or sets a boolean indicating if animations are enabled
  704. */
  705. animationsEnabled: boolean;
  706. private _animationPropertiesOverride;
  707. /**
  708. * Gets or sets the animation properties override
  709. */
  710. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  711. /**
  712. * Gets or sets a boolean indicating if a constant deltatime has to be used
  713. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  714. */
  715. useConstantAnimationDeltaTime: boolean;
  716. /**
  717. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  718. * Please note that it requires to run a ray cast through the scene on every frame
  719. */
  720. constantlyUpdateMeshUnderPointer: boolean;
  721. /**
  722. * Defines the HTML cursor to use when hovering over interactive elements
  723. */
  724. hoverCursor: string;
  725. /**
  726. * Defines the HTML default cursor to use (empty by default)
  727. */
  728. defaultCursor: string;
  729. /**
  730. * This is used to call preventDefault() on pointer down
  731. * in order to block unwanted artifacts like system double clicks
  732. */
  733. preventDefaultOnPointerDown: boolean;
  734. /**
  735. * Gets or sets user defined metadata
  736. */
  737. metadata: any;
  738. /**
  739. * Gets the name of the plugin used to load this scene (null by default)
  740. */
  741. loadingPluginName: string;
  742. /**
  743. * Use this array to add regular expressions used to disable offline support for specific urls
  744. */
  745. disableOfflineSupportExceptionRules: RegExp[];
  746. private _spritePredicate;
  747. /**
  748. * An event triggered when the scene is disposed.
  749. */
  750. onDisposeObservable: Observable<Scene>;
  751. private _onDisposeObserver;
  752. /** Sets a function to be executed when this scene is disposed. */
  753. onDispose: () => void;
  754. /**
  755. * An event triggered before rendering the scene (right after animations and physics)
  756. */
  757. onBeforeRenderObservable: Observable<Scene>;
  758. private _onBeforeRenderObserver;
  759. /** Sets a function to be executed before rendering this scene */
  760. beforeRender: Nullable<() => void>;
  761. /**
  762. * An event triggered after rendering the scene
  763. */
  764. onAfterRenderObservable: Observable<Scene>;
  765. private _onAfterRenderObserver;
  766. /** Sets a function to be executed after rendering this scene */
  767. afterRender: Nullable<() => void>;
  768. /**
  769. * An event triggered before animating the scene
  770. */
  771. onBeforeAnimationsObservable: Observable<Scene>;
  772. /**
  773. * An event triggered after animations processing
  774. */
  775. onAfterAnimationsObservable: Observable<Scene>;
  776. /**
  777. * An event triggered before draw calls are ready to be sent
  778. */
  779. onBeforeDrawPhaseObservable: Observable<Scene>;
  780. /**
  781. * An event triggered after draw calls have been sent
  782. */
  783. onAfterDrawPhaseObservable: Observable<Scene>;
  784. /**
  785. * An event triggered when physic simulation is about to be run
  786. */
  787. onBeforePhysicsObservable: Observable<Scene>;
  788. /**
  789. * An event triggered when physic simulation has been done
  790. */
  791. onAfterPhysicsObservable: Observable<Scene>;
  792. /**
  793. * An event triggered when the scene is ready
  794. */
  795. onReadyObservable: Observable<Scene>;
  796. /**
  797. * An event triggered before rendering a camera
  798. */
  799. onBeforeCameraRenderObservable: Observable<Camera>;
  800. private _onBeforeCameraRenderObserver;
  801. /** Sets a function to be executed before rendering a camera*/
  802. beforeCameraRender: () => void;
  803. /**
  804. * An event triggered after rendering a camera
  805. */
  806. onAfterCameraRenderObservable: Observable<Camera>;
  807. private _onAfterCameraRenderObserver;
  808. /** Sets a function to be executed after rendering a camera*/
  809. afterCameraRender: () => void;
  810. /**
  811. * An event triggered when active meshes evaluation is about to start
  812. */
  813. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  814. /**
  815. * An event triggered when active meshes evaluation is done
  816. */
  817. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  818. /**
  819. * An event triggered when particles rendering is about to start
  820. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  821. */
  822. onBeforeParticlesRenderingObservable: Observable<Scene>;
  823. /**
  824. * An event triggered when particles rendering is done
  825. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  826. */
  827. onAfterParticlesRenderingObservable: Observable<Scene>;
  828. /**
  829. * An event triggered when sprites rendering is about to start
  830. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  831. */
  832. onBeforeSpritesRenderingObservable: Observable<Scene>;
  833. /**
  834. * An event triggered when sprites rendering is done
  835. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  836. */
  837. onAfterSpritesRenderingObservable: Observable<Scene>;
  838. /**
  839. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  840. */
  841. onDataLoadedObservable: Observable<Scene>;
  842. /**
  843. * An event triggered when a camera is created
  844. */
  845. onNewCameraAddedObservable: Observable<Camera>;
  846. /**
  847. * An event triggered when a camera is removed
  848. */
  849. onCameraRemovedObservable: Observable<Camera>;
  850. /**
  851. * An event triggered when a light is created
  852. */
  853. onNewLightAddedObservable: Observable<Light>;
  854. /**
  855. * An event triggered when a light is removed
  856. */
  857. onLightRemovedObservable: Observable<Light>;
  858. /**
  859. * An event triggered when a geometry is created
  860. */
  861. onNewGeometryAddedObservable: Observable<Geometry>;
  862. /**
  863. * An event triggered when a geometry is removed
  864. */
  865. onGeometryRemovedObservable: Observable<Geometry>;
  866. /**
  867. * An event triggered when a transform node is created
  868. */
  869. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  870. /**
  871. * An event triggered when a transform node is removed
  872. */
  873. onTransformNodeRemovedObservable: Observable<TransformNode>;
  874. /**
  875. * An event triggered when a mesh is created
  876. */
  877. onNewMeshAddedObservable: Observable<AbstractMesh>;
  878. /**
  879. * An event triggered when a mesh is removed
  880. */
  881. onMeshRemovedObservable: Observable<AbstractMesh>;
  882. /**
  883. * An event triggered when render targets are about to be rendered
  884. * Can happen multiple times per frame.
  885. */
  886. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  887. /**
  888. * An event triggered when render targets were rendered.
  889. * Can happen multiple times per frame.
  890. */
  891. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  892. /**
  893. * An event triggered before calculating deterministic simulation step
  894. */
  895. onBeforeStepObservable: Observable<Scene>;
  896. /**
  897. * An event triggered after calculating deterministic simulation step
  898. */
  899. onAfterStepObservable: Observable<Scene>;
  900. /**
  901. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  902. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  903. * 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)
  904. */
  905. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  906. private _registeredForLateAnimationBindings;
  907. /**
  908. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  909. */
  910. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  911. /**
  912. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  913. */
  914. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  915. /**
  916. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  917. */
  918. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  919. private _onPointerMove;
  920. private _onPointerDown;
  921. private _onPointerUp;
  922. /** Deprecated. Use onPointerObservable instead */
  923. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  924. /** Deprecated. Use onPointerObservable instead */
  925. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  926. /** Deprecated. Use onPointerObservable instead */
  927. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  928. /** Deprecated. Use onPointerObservable instead */
  929. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  930. private _gamepadManager;
  931. /**
  932. * Gets the gamepad manager associated with the scene
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  934. */
  935. readonly gamepadManager: GamepadManager;
  936. /**
  937. * 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).
  938. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  939. */
  940. onPrePointerObservable: Observable<PointerInfoPre>;
  941. /**
  942. * Observable event triggered each time an input event is received from the rendering canvas
  943. */
  944. onPointerObservable: Observable<PointerInfo>;
  945. /**
  946. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  947. */
  948. readonly unTranslatedPointer: Vector2;
  949. /** The distance in pixel that you have to move to prevent some events */
  950. static DragMovementThreshold: number;
  951. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  952. static LongPressDelay: number;
  953. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  954. static DoubleClickDelay: number;
  955. /** If you need to check double click without raising a single click at first click, enable this flag */
  956. static ExclusiveDoubleClickMode: boolean;
  957. private _initClickEvent;
  958. private _initActionManager;
  959. private _delayedSimpleClick;
  960. private _delayedSimpleClickTimeout;
  961. private _previousDelayedSimpleClickTimeout;
  962. private _meshPickProceed;
  963. private _previousButtonPressed;
  964. private _currentPickResult;
  965. private _previousPickResult;
  966. private _totalPointersPressed;
  967. private _doubleClickOccured;
  968. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  969. cameraToUseForPointers: Nullable<Camera>;
  970. private _pointerX;
  971. private _pointerY;
  972. private _unTranslatedPointerX;
  973. private _unTranslatedPointerY;
  974. private _startingPointerPosition;
  975. private _previousStartingPointerPosition;
  976. private _startingPointerTime;
  977. private _previousStartingPointerTime;
  978. private _pointerCaptures;
  979. private _timeAccumulator;
  980. private _currentStepId;
  981. private _currentInternalStep;
  982. /** @hidden */
  983. _mirroredCameraPosition: Nullable<Vector3>;
  984. /**
  985. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  986. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  987. */
  988. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  989. /**
  990. * Observable event triggered each time an keyboard event is received from the hosting window
  991. */
  992. onKeyboardObservable: Observable<KeyboardInfo>;
  993. private _onKeyDown;
  994. private _onKeyUp;
  995. private _onCanvasFocusObserver;
  996. private _onCanvasBlurObserver;
  997. private _useRightHandedSystem;
  998. /**
  999. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1000. */
  1001. useRightHandedSystem: boolean;
  1002. /**
  1003. * Sets the step Id used by deterministic lock step
  1004. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1005. * @param newStepId defines the step Id
  1006. */
  1007. setStepId(newStepId: number): void;
  1008. /**
  1009. * Gets the step Id used by deterministic lock step
  1010. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1011. * @returns the step Id
  1012. */
  1013. getStepId(): number;
  1014. /**
  1015. * Gets the internal step used by deterministic lock step
  1016. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1017. * @returns the internal step
  1018. */
  1019. getInternalStep(): number;
  1020. private _fogEnabled;
  1021. /**
  1022. * Gets or sets a boolean indicating if fog is enabled on this scene
  1023. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1024. */
  1025. fogEnabled: boolean;
  1026. private _fogMode;
  1027. /**
  1028. * Gets or sets the fog mode to use
  1029. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1030. */
  1031. fogMode: number;
  1032. /**
  1033. * Gets or sets the fog color to use
  1034. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1035. */
  1036. fogColor: Color3;
  1037. /**
  1038. * Gets or sets the fog density to use
  1039. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1040. */
  1041. fogDensity: number;
  1042. /**
  1043. * Gets or sets the fog start distance to use
  1044. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1045. */
  1046. fogStart: number;
  1047. /**
  1048. * Gets or sets the fog end distance to use
  1049. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1050. */
  1051. fogEnd: number;
  1052. private _shadowsEnabled;
  1053. /**
  1054. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1055. */
  1056. shadowsEnabled: boolean;
  1057. private _lightsEnabled;
  1058. /**
  1059. * Gets or sets a boolean indicating if lights are enabled on this scene
  1060. */
  1061. lightsEnabled: boolean;
  1062. /** All of the active cameras added to this scene. */
  1063. activeCameras: Camera[];
  1064. /** The current active camera */
  1065. activeCamera: Nullable<Camera>;
  1066. private _defaultMaterial;
  1067. /** The default material used on meshes when no material is affected */
  1068. /** The default material used on meshes when no material is affected */
  1069. defaultMaterial: Material;
  1070. private _texturesEnabled;
  1071. /**
  1072. * Gets or sets a boolean indicating if textures are enabled on this scene
  1073. */
  1074. texturesEnabled: boolean;
  1075. /**
  1076. * Gets or sets a boolean indicating if particles are enabled on this scene
  1077. */
  1078. particlesEnabled: boolean;
  1079. /**
  1080. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1081. */
  1082. spritesEnabled: boolean;
  1083. /**
  1084. * All of the sprite managers added to this scene
  1085. * @see http://doc.babylonjs.com/babylon101/sprites
  1086. */
  1087. spriteManagers: SpriteManager[];
  1088. private _skeletonsEnabled;
  1089. /**
  1090. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1091. */
  1092. skeletonsEnabled: boolean;
  1093. /**
  1094. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1095. */
  1096. lensFlaresEnabled: boolean;
  1097. /**
  1098. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1099. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1100. */
  1101. collisionsEnabled: boolean;
  1102. private _workerCollisions;
  1103. /** @hidden */
  1104. collisionCoordinator: ICollisionCoordinator;
  1105. /**
  1106. * Defines the gravity applied to this scene (used only for collisions)
  1107. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1108. */
  1109. gravity: Vector3;
  1110. /**
  1111. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1112. */
  1113. postProcessesEnabled: boolean;
  1114. /**
  1115. * The list of postprocesses added to the scene
  1116. */
  1117. postProcesses: PostProcess[];
  1118. /**
  1119. * Gets the current postprocess manager
  1120. */
  1121. postProcessManager: PostProcessManager;
  1122. private _postProcessRenderPipelineManager;
  1123. /**
  1124. * Gets the postprocess render pipeline manager
  1125. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1126. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1127. */
  1128. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1129. /**
  1130. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1131. */
  1132. renderTargetsEnabled: boolean;
  1133. /**
  1134. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1135. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1136. */
  1137. dumpNextRenderTargets: boolean;
  1138. /**
  1139. * The list of user defined render targets added to the scene
  1140. */
  1141. customRenderTargets: RenderTargetTexture[];
  1142. /**
  1143. * Defines if texture loading must be delayed
  1144. * If true, textures will only be loaded when they need to be rendered
  1145. */
  1146. useDelayedTextureLoading: boolean;
  1147. /**
  1148. * Gets the list of meshes imported to the scene through SceneLoader
  1149. */
  1150. importedMeshesFiles: String[];
  1151. /**
  1152. * Gets or sets a boolean indicating if probes are enabled on this scene
  1153. */
  1154. probesEnabled: boolean;
  1155. /**
  1156. * The list of reflection probes added to the scene
  1157. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1158. */
  1159. reflectionProbes: ReflectionProbe[];
  1160. /**
  1161. * @hidden
  1162. */
  1163. database: Database;
  1164. /**
  1165. * Gets or sets the action manager associated with the scene
  1166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1167. */
  1168. actionManager: ActionManager;
  1169. private _meshesForIntersections;
  1170. /**
  1171. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1172. */
  1173. proceduralTexturesEnabled: boolean;
  1174. /**
  1175. * The list of procedural textures added to the scene
  1176. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1177. */
  1178. proceduralTextures: ProceduralTexture[];
  1179. private _mainSoundTrack;
  1180. /**
  1181. * The list of sound tracks added to the scene
  1182. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1183. */
  1184. soundTracks: SoundTrack[];
  1185. private _audioEnabled;
  1186. private _headphone;
  1187. /**
  1188. * Gets the main soundtrack associated with the scene
  1189. */
  1190. readonly mainSoundTrack: SoundTrack;
  1191. /**
  1192. * Gets or sets the VRExperienceHelper attached to the scene
  1193. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1194. * @ignorenaming
  1195. */
  1196. VRHelper: VRExperienceHelper;
  1197. /**
  1198. * Gets or sets the simplification queue attached to the scene
  1199. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1200. */
  1201. simplificationQueue: SimplificationQueue;
  1202. private _engine;
  1203. private _totalVertices;
  1204. /** @hidden */
  1205. _activeIndices: PerfCounter;
  1206. /** @hidden */
  1207. _activeParticles: PerfCounter;
  1208. /** @hidden */
  1209. _activeBones: PerfCounter;
  1210. private _animationRatio;
  1211. private _animationTimeLast;
  1212. private _animationTime;
  1213. /**
  1214. * Gets or sets a general scale for animation speed
  1215. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1216. */
  1217. animationTimeScale: number;
  1218. /** @hidden */
  1219. _cachedMaterial: Nullable<Material>;
  1220. /** @hidden */
  1221. _cachedEffect: Nullable<Effect>;
  1222. /** @hidden */
  1223. _cachedVisibility: Nullable<number>;
  1224. private _renderId;
  1225. private _executeWhenReadyTimeoutId;
  1226. private _intermediateRendering;
  1227. private _viewUpdateFlag;
  1228. private _projectionUpdateFlag;
  1229. private _alternateViewUpdateFlag;
  1230. private _alternateProjectionUpdateFlag;
  1231. /** @hidden */
  1232. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1233. private _activeRequests;
  1234. private _pendingData;
  1235. private _isDisposed;
  1236. /**
  1237. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1238. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1239. */
  1240. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1241. private _activeMeshes;
  1242. private _processedMaterials;
  1243. private _renderTargets;
  1244. /** @hidden */
  1245. _activeParticleSystems: SmartArray<IParticleSystem>;
  1246. private _activeSkeletons;
  1247. private _softwareSkinnedMeshes;
  1248. private _renderingManager;
  1249. private _physicsEngine;
  1250. /** @hidden */
  1251. _activeAnimatables: Animatable[];
  1252. private _transformMatrix;
  1253. private _sceneUbo;
  1254. private _alternateSceneUbo;
  1255. private _pickWithRayInverseMatrix;
  1256. private _boundingBoxRenderer;
  1257. private _outlineRenderer;
  1258. private _viewMatrix;
  1259. private _projectionMatrix;
  1260. private _alternateViewMatrix;
  1261. private _alternateProjectionMatrix;
  1262. private _alternateTransformMatrix;
  1263. private _useAlternateCameraConfiguration;
  1264. private _alternateRendering;
  1265. /** @hidden */
  1266. _forcedViewPosition: Nullable<Vector3>;
  1267. /** @hidden */
  1268. readonly _isAlternateRenderingEnabled: boolean;
  1269. private _frustumPlanes;
  1270. /**
  1271. * Gets the list of frustum planes (built from the active camera)
  1272. */
  1273. readonly frustumPlanes: Plane[];
  1274. /**
  1275. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1276. * This is useful if there are more lights that the maximum simulteanous authorized
  1277. */
  1278. requireLightSorting: boolean;
  1279. private _selectionOctree;
  1280. private _pointerOverMesh;
  1281. private _pointerOverSprite;
  1282. private _debugLayer;
  1283. private _depthRenderer;
  1284. private _geometryBufferRenderer;
  1285. /**
  1286. * Gets the current geometry buffer associated to the scene.
  1287. */
  1288. /**
  1289. * Sets the current geometry buffer for the scene.
  1290. */
  1291. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1292. private _pickedDownMesh;
  1293. private _pickedUpMesh;
  1294. private _pickedDownSprite;
  1295. private _externalData;
  1296. private _uid;
  1297. /**
  1298. * Backing store of defined scene components.
  1299. */
  1300. _components: ISceneComponent[];
  1301. /**
  1302. * List of components to register on the next registration step.
  1303. */
  1304. private _transientComponents;
  1305. /**
  1306. * Registers the transient components if needed.
  1307. */
  1308. private _registerTransientComponents();
  1309. /**
  1310. * Add a component to the scene.
  1311. * Note that the ccomponent could be registered on th next frame if this is called after
  1312. * the register component stage.
  1313. * @param component Defines the component to add to the scene
  1314. */
  1315. _addComponent(component: ISceneComponent): void;
  1316. /**
  1317. * Gets a component from the scene.
  1318. * @param name defines the name of the component to retrieve
  1319. * @returns the component or null if not present
  1320. */
  1321. _getComponent(name: string): Nullable<ISceneComponent>;
  1322. /**
  1323. * Defines the actions happening during the per mesh ready checks.
  1324. */
  1325. _isReadyForMeshStage: Stage<MeshStageAction>;
  1326. /**
  1327. * Defines the actions happening during the per camera render target step.
  1328. */
  1329. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1330. /**
  1331. * Defines the actions happening just before the active camera is drawing.
  1332. */
  1333. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1334. /**
  1335. * Defines the actions happening just after the active camera is drawing.
  1336. */
  1337. _afterCameraDrawStage: Stage<CameraStageAction>;
  1338. /**
  1339. * Creates a new Scene
  1340. * @param engine defines the engine to use to render this scene
  1341. */
  1342. constructor(engine: Engine);
  1343. /**
  1344. * Gets the debug layer (aka Inspector) associated with the scene
  1345. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1346. */
  1347. readonly debugLayer: DebugLayer;
  1348. /**
  1349. * Gets a boolean indicating if collisions are processed on a web worker
  1350. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1351. */
  1352. workerCollisions: boolean;
  1353. /**
  1354. * Gets the octree used to boost mesh selection (picking)
  1355. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1356. */
  1357. readonly selectionOctree: Octree<AbstractMesh>;
  1358. /**
  1359. * Gets the mesh that is currently under the pointer
  1360. */
  1361. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1362. /**
  1363. * Gets the current on-screen X position of the pointer
  1364. */
  1365. readonly pointerX: number;
  1366. /**
  1367. * Gets the current on-screen Y position of the pointer
  1368. */
  1369. readonly pointerY: number;
  1370. /**
  1371. * Gets the cached material (ie. the latest rendered one)
  1372. * @returns the cached material
  1373. */
  1374. getCachedMaterial(): Nullable<Material>;
  1375. /**
  1376. * Gets the cached effect (ie. the latest rendered one)
  1377. * @returns the cached effect
  1378. */
  1379. getCachedEffect(): Nullable<Effect>;
  1380. /**
  1381. * Gets the cached visibility state (ie. the latest rendered one)
  1382. * @returns the cached visibility state
  1383. */
  1384. getCachedVisibility(): Nullable<number>;
  1385. /**
  1386. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1387. * @param material defines the current material
  1388. * @param effect defines the current effect
  1389. * @param visibility defines the current visibility state
  1390. * @returns true if one parameter is not cached
  1391. */
  1392. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1393. /**
  1394. * Gets the bounding box renderer associated with the scene
  1395. * @returns a BoundingBoxRenderer
  1396. */
  1397. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1398. /**
  1399. * Gets the outline renderer associated with the scene
  1400. * @returns a OutlineRenderer
  1401. */
  1402. getOutlineRenderer(): OutlineRenderer;
  1403. /**
  1404. * Gets the engine associated with the scene
  1405. * @returns an Engine
  1406. */
  1407. getEngine(): Engine;
  1408. /**
  1409. * Gets the total number of vertices rendered per frame
  1410. * @returns the total number of vertices rendered per frame
  1411. */
  1412. getTotalVertices(): number;
  1413. /**
  1414. * Gets the performance counter for total vertices
  1415. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1416. */
  1417. readonly totalVerticesPerfCounter: PerfCounter;
  1418. /**
  1419. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1420. * @returns the total number of active indices rendered per frame
  1421. */
  1422. getActiveIndices(): number;
  1423. /**
  1424. * Gets the performance counter for active indices
  1425. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1426. */
  1427. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1428. /**
  1429. * Gets the total number of active particles rendered per frame
  1430. * @returns the total number of active particles rendered per frame
  1431. */
  1432. getActiveParticles(): number;
  1433. /**
  1434. * Gets the performance counter for active particles
  1435. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1436. */
  1437. readonly activeParticlesPerfCounter: PerfCounter;
  1438. /**
  1439. * Gets the total number of active bones rendered per frame
  1440. * @returns the total number of active bones rendered per frame
  1441. */
  1442. getActiveBones(): number;
  1443. /**
  1444. * Gets the performance counter for active bones
  1445. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1446. */
  1447. readonly activeBonesPerfCounter: PerfCounter;
  1448. /** @hidden */
  1449. getInterFramePerfCounter(): number;
  1450. /** @hidden */
  1451. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1452. /** @hidden */
  1453. getLastFrameDuration(): number;
  1454. /** @hidden */
  1455. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1456. /** @hidden */
  1457. getEvaluateActiveMeshesDuration(): number;
  1458. /** @hidden */
  1459. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1460. /**
  1461. * Gets the array of active meshes
  1462. * @returns an array of AbstractMesh
  1463. */
  1464. getActiveMeshes(): SmartArray<AbstractMesh>;
  1465. /** @hidden */
  1466. getRenderTargetsDuration(): number;
  1467. /** @hidden */
  1468. getRenderDuration(): number;
  1469. /** @hidden */
  1470. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1471. /** @hidden */
  1472. getParticlesDuration(): number;
  1473. /** @hidden */
  1474. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1475. /** @hidden */
  1476. getSpritesDuration(): number;
  1477. /** @hidden */
  1478. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1479. /**
  1480. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1481. * @returns a number
  1482. */
  1483. getAnimationRatio(): number;
  1484. /**
  1485. * Gets an unique Id for the current frame
  1486. * @returns a number
  1487. */
  1488. getRenderId(): number;
  1489. /** Call this function if you want to manually increment the render Id*/
  1490. incrementRenderId(): void;
  1491. private _updatePointerPosition(evt);
  1492. private _createUbo();
  1493. private _createAlternateUbo();
  1494. private _pickSpriteButKeepRay(originalPointerInfo, x, y, predicate?, fastCheck?, camera?);
  1495. private _setRayOnPointerInfo(pointerInfo);
  1496. /**
  1497. * Use this method to simulate a pointer move on a mesh
  1498. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1499. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1500. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1501. * @returns the current scene
  1502. */
  1503. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1504. private _processPointerMove(pickResult, evt);
  1505. private _checkPrePointerObservable(pickResult, evt, type);
  1506. /**
  1507. * Use this method to simulate a pointer down on a mesh
  1508. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1509. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1510. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1511. * @returns the current scene
  1512. */
  1513. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1514. private _processPointerDown(pickResult, evt);
  1515. /**
  1516. * Use this method to simulate a pointer up on a mesh
  1517. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1518. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1519. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1520. * @returns the current scene
  1521. */
  1522. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1523. private _processPointerUp(pickResult, evt, clickInfo);
  1524. /**
  1525. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1526. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1527. * @returns true if the pointer was captured
  1528. */
  1529. isPointerCaptured(pointerId?: number): boolean;
  1530. /**
  1531. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1532. * @param attachUp defines if you want to attach events to pointerup
  1533. * @param attachDown defines if you want to attach events to pointerdown
  1534. * @param attachMove defines if you want to attach events to pointermove
  1535. */
  1536. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1537. /** Detaches all event handlers*/
  1538. detachControl(): void;
  1539. /**
  1540. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1541. * Delay loaded resources are not taking in account
  1542. * @return true if all required resources are ready
  1543. */
  1544. isReady(): boolean;
  1545. /** Resets all cached information relative to material (including effect and visibility) */
  1546. resetCachedMaterial(): void;
  1547. /**
  1548. * Registers a function to be called before every frame render
  1549. * @param func defines the function to register
  1550. */
  1551. registerBeforeRender(func: () => void): void;
  1552. /**
  1553. * Unregisters a function called before every frame render
  1554. * @param func defines the function to unregister
  1555. */
  1556. unregisterBeforeRender(func: () => void): void;
  1557. /**
  1558. * Registers a function to be called after every frame render
  1559. * @param func defines the function to register
  1560. */
  1561. registerAfterRender(func: () => void): void;
  1562. /**
  1563. * Unregisters a function called after every frame render
  1564. * @param func defines the function to unregister
  1565. */
  1566. unregisterAfterRender(func: () => void): void;
  1567. private _executeOnceBeforeRender(func);
  1568. /**
  1569. * The provided function will run before render once and will be disposed afterwards.
  1570. * A timeout delay can be provided so that the function will be executed in N ms.
  1571. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1572. * @param func The function to be executed.
  1573. * @param timeout optional delay in ms
  1574. */
  1575. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1576. /** @hidden */
  1577. _addPendingData(data: any): void;
  1578. /** @hidden */
  1579. _removePendingData(data: any): void;
  1580. /**
  1581. * Returns the number of items waiting to be loaded
  1582. * @returns the number of items waiting to be loaded
  1583. */
  1584. getWaitingItemsCount(): number;
  1585. /**
  1586. * Returns a boolean indicating if the scene is still loading data
  1587. */
  1588. readonly isLoading: boolean;
  1589. /**
  1590. * Registers a function to be executed when the scene is ready
  1591. * @param {Function} func - the function to be executed
  1592. */
  1593. executeWhenReady(func: () => void): void;
  1594. /**
  1595. * Returns a promise that resolves when the scene is ready
  1596. * @returns A promise that resolves when the scene is ready
  1597. */
  1598. whenReadyAsync(): Promise<void>;
  1599. /** @hidden */
  1600. _checkIsReady(): void;
  1601. /**
  1602. * Will start the animation sequence of a given target
  1603. * @param target defines the target
  1604. * @param from defines from which frame should animation start
  1605. * @param to defines until which frame should animation run.
  1606. * @param weight defines the weight to apply to the animation (1.0 by default)
  1607. * @param loop defines if the animation loops
  1608. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1609. * @param onAnimationEnd defines the function to be executed when the animation ends
  1610. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1611. * @returns the animatable object created for this animation
  1612. */
  1613. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1614. /**
  1615. * Will start the animation sequence of a given target
  1616. * @param target defines the target
  1617. * @param from defines from which frame should animation start
  1618. * @param to defines until which frame should animation run.
  1619. * @param loop defines if the animation loops
  1620. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1621. * @param onAnimationEnd defines the function to be executed when the animation ends
  1622. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1623. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1624. * @returns the animatable object created for this animation
  1625. */
  1626. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1627. /**
  1628. * Begin a new animation on a given node
  1629. * @param target defines the target where the animation will take place
  1630. * @param animations defines the list of animations to start
  1631. * @param from defines the initial value
  1632. * @param to defines the final value
  1633. * @param loop defines if you want animation to loop (off by default)
  1634. * @param speedRatio defines the speed ratio to apply to all animations
  1635. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1636. * @returns the list of created animatables
  1637. */
  1638. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1639. /**
  1640. * Begin a new animation on a given node and its hierarchy
  1641. * @param target defines the root node where the animation will take place
  1642. * @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.
  1643. * @param animations defines the list of animations to start
  1644. * @param from defines the initial value
  1645. * @param to defines the final value
  1646. * @param loop defines if you want animation to loop (off by default)
  1647. * @param speedRatio defines the speed ratio to apply to all animations
  1648. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1649. * @returns the list of animatables created for all nodes
  1650. */
  1651. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1652. /**
  1653. * Gets the animatable associated with a specific target
  1654. * @param target defines the target of the animatable
  1655. * @returns the required animatable if found
  1656. */
  1657. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1658. /**
  1659. * Gets all animatables associated with a given target
  1660. * @param target defines the target to look animatables for
  1661. * @returns an array of Animatables
  1662. */
  1663. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1664. /**
  1665. * Gets all animatable attached to the scene
  1666. */
  1667. readonly animatables: Animatable[];
  1668. /**
  1669. * Will stop the animation of the given target
  1670. * @param target - the target
  1671. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1672. */
  1673. stopAnimation(target: any, animationName?: string): void;
  1674. /**
  1675. * Stops and removes all animations that have been applied to the scene
  1676. */
  1677. stopAllAnimations(): void;
  1678. private _animate();
  1679. /** @hidden */
  1680. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1681. private _processLateAnimationBindingsForMatrices(holder);
  1682. private _processLateAnimationBindingsForQuaternions(holder);
  1683. private _processLateAnimationBindings();
  1684. /** @hidden */
  1685. _switchToAlternateCameraConfiguration(active: boolean): void;
  1686. /**
  1687. * Gets the current view matrix
  1688. * @returns a Matrix
  1689. */
  1690. getViewMatrix(): Matrix;
  1691. /**
  1692. * Gets the current projection matrix
  1693. * @returns a Matrix
  1694. */
  1695. getProjectionMatrix(): Matrix;
  1696. /**
  1697. * Gets the current transform matrix
  1698. * @returns a Matrix made of View * Projection
  1699. */
  1700. getTransformMatrix(): Matrix;
  1701. /**
  1702. * Sets the current transform matrix
  1703. * @param view defines the View matrix to use
  1704. * @param projection defines the Projection matrix to use
  1705. */
  1706. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1707. /** @hidden */
  1708. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1709. /**
  1710. * Gets the uniform buffer used to store scene data
  1711. * @returns a UniformBuffer
  1712. */
  1713. getSceneUniformBuffer(): UniformBuffer;
  1714. /**
  1715. * Gets an unique (relatively to the current scene) Id
  1716. * @returns an unique number for the scene
  1717. */
  1718. getUniqueId(): number;
  1719. /**
  1720. * Add a mesh to the list of scene's meshes
  1721. * @param newMesh defines the mesh to add
  1722. * @param recursive if all child meshes should also be added to the scene
  1723. */
  1724. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1725. /**
  1726. * Remove a mesh for the list of scene's meshes
  1727. * @param toRemove defines the mesh to remove
  1728. * @param recursive if all child meshes should also be removed from the scene
  1729. * @returns the index where the mesh was in the mesh list
  1730. */
  1731. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1732. /**
  1733. * Add a transform node to the list of scene's transform nodes
  1734. * @param newTransformNode defines the transform node to add
  1735. */
  1736. addTransformNode(newTransformNode: TransformNode): void;
  1737. /**
  1738. * Remove a transform node for the list of scene's transform nodes
  1739. * @param toRemove defines the transform node to remove
  1740. * @returns the index where the transform node was in the transform node list
  1741. */
  1742. removeTransformNode(toRemove: TransformNode): number;
  1743. /**
  1744. * Remove a skeleton for the list of scene's skeletons
  1745. * @param toRemove defines the skeleton to remove
  1746. * @returns the index where the skeleton was in the skeleton list
  1747. */
  1748. removeSkeleton(toRemove: Skeleton): number;
  1749. /**
  1750. * Remove a morph target for the list of scene's morph targets
  1751. * @param toRemove defines the morph target to remove
  1752. * @returns the index where the morph target was in the morph target list
  1753. */
  1754. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1755. /**
  1756. * Remove a light for the list of scene's lights
  1757. * @param toRemove defines the light to remove
  1758. * @returns the index where the light was in the light list
  1759. */
  1760. removeLight(toRemove: Light): number;
  1761. /**
  1762. * Remove a camera for the list of scene's cameras
  1763. * @param toRemove defines the camera to remove
  1764. * @returns the index where the camera was in the camera list
  1765. */
  1766. removeCamera(toRemove: Camera): number;
  1767. /**
  1768. * Remove a particle system for the list of scene's particle systems
  1769. * @param toRemove defines the particle system to remove
  1770. * @returns the index where the particle system was in the particle system list
  1771. */
  1772. removeParticleSystem(toRemove: IParticleSystem): number;
  1773. /**
  1774. * Remove a animation for the list of scene's animations
  1775. * @param toRemove defines the animation to remove
  1776. * @returns the index where the animation was in the animation list
  1777. */
  1778. removeAnimation(toRemove: Animation): number;
  1779. /**
  1780. * Removes the given animation group from this scene.
  1781. * @param toRemove The animation group to remove
  1782. * @returns The index of the removed animation group
  1783. */
  1784. removeAnimationGroup(toRemove: AnimationGroup): number;
  1785. /**
  1786. * Removes the given multi-material from this scene.
  1787. * @param toRemove The multi-material to remove
  1788. * @returns The index of the removed multi-material
  1789. */
  1790. removeMultiMaterial(toRemove: MultiMaterial): number;
  1791. /**
  1792. * Removes the given material from this scene.
  1793. * @param toRemove The material to remove
  1794. * @returns The index of the removed material
  1795. */
  1796. removeMaterial(toRemove: Material): number;
  1797. /**
  1798. * Removes the given action manager from this scene.
  1799. * @param toRemove The action manager to remove
  1800. * @returns The index of the removed action manager
  1801. */
  1802. removeActionManager(toRemove: ActionManager): number;
  1803. /**
  1804. * Removes the given texture from this scene.
  1805. * @param toRemove The texture to remove
  1806. * @returns The index of the removed texture
  1807. */
  1808. removeTexture(toRemove: BaseTexture): number;
  1809. /**
  1810. * Adds the given light to this scene
  1811. * @param newLight The light to add
  1812. */
  1813. addLight(newLight: Light): void;
  1814. /**
  1815. * Sorts the list list based on light priorities
  1816. */
  1817. sortLightsByPriority(): void;
  1818. /**
  1819. * Adds the given camera to this scene
  1820. * @param newCamera The camera to add
  1821. */
  1822. addCamera(newCamera: Camera): void;
  1823. /**
  1824. * Adds the given skeleton to this scene
  1825. * @param newSkeleton The skeleton to add
  1826. */
  1827. addSkeleton(newSkeleton: Skeleton): void;
  1828. /**
  1829. * Adds the given particle system to this scene
  1830. * @param newParticleSystem The particle system to add
  1831. */
  1832. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1833. /**
  1834. * Adds the given animation to this scene
  1835. * @param newAnimation The animation to add
  1836. */
  1837. addAnimation(newAnimation: Animation): void;
  1838. /**
  1839. * Adds the given animation group to this scene.
  1840. * @param newAnimationGroup The animation group to add
  1841. */
  1842. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1843. /**
  1844. * Adds the given multi-material to this scene
  1845. * @param newMultiMaterial The multi-material to add
  1846. */
  1847. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1848. /**
  1849. * Adds the given material to this scene
  1850. * @param newMaterial The material to add
  1851. */
  1852. addMaterial(newMaterial: Material): void;
  1853. /**
  1854. * Adds the given morph target to this scene
  1855. * @param newMorphTargetManager The morph target to add
  1856. */
  1857. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1858. /**
  1859. * Adds the given geometry to this scene
  1860. * @param newGeometry The geometry to add
  1861. */
  1862. addGeometry(newGeometry: Geometry): void;
  1863. /**
  1864. * Adds the given action manager to this scene
  1865. * @param newActionManager The action manager to add
  1866. */
  1867. addActionManager(newActionManager: ActionManager): void;
  1868. /**
  1869. * Adds the given texture to this scene.
  1870. * @param newTexture The texture to add
  1871. */
  1872. addTexture(newTexture: BaseTexture): void;
  1873. /**
  1874. * Switch active camera
  1875. * @param newCamera defines the new active camera
  1876. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1877. */
  1878. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1879. /**
  1880. * sets the active camera of the scene using its ID
  1881. * @param id defines the camera's ID
  1882. * @return the new active camera or null if none found.
  1883. */
  1884. setActiveCameraByID(id: string): Nullable<Camera>;
  1885. /**
  1886. * sets the active camera of the scene using its name
  1887. * @param name defines the camera's name
  1888. * @returns the new active camera or null if none found.
  1889. */
  1890. setActiveCameraByName(name: string): Nullable<Camera>;
  1891. /**
  1892. * get an animation group using its name
  1893. * @param name defines the material's name
  1894. * @return the animation group or null if none found.
  1895. */
  1896. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1897. /**
  1898. * get a material using its id
  1899. * @param id defines the material's ID
  1900. * @return the material or null if none found.
  1901. */
  1902. getMaterialByID(id: string): Nullable<Material>;
  1903. /**
  1904. * Gets a material using its name
  1905. * @param name defines the material's name
  1906. * @return the material or null if none found.
  1907. */
  1908. getMaterialByName(name: string): Nullable<Material>;
  1909. /**
  1910. * Gets a camera using its id
  1911. * @param id defines the id to look for
  1912. * @returns the camera or null if not found
  1913. */
  1914. getCameraByID(id: string): Nullable<Camera>;
  1915. /**
  1916. * Gets a camera using its unique id
  1917. * @param uniqueId defines the unique id to look for
  1918. * @returns the camera or null if not found
  1919. */
  1920. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1921. /**
  1922. * Gets a camera using its name
  1923. * @param name defines the camera's name
  1924. * @return the camera or null if none found.
  1925. */
  1926. getCameraByName(name: string): Nullable<Camera>;
  1927. /**
  1928. * Gets a bone using its id
  1929. * @param id defines the bone's id
  1930. * @return the bone or null if not found
  1931. */
  1932. getBoneByID(id: string): Nullable<Bone>;
  1933. /**
  1934. * Gets a bone using its id
  1935. * @param name defines the bone's name
  1936. * @return the bone or null if not found
  1937. */
  1938. getBoneByName(name: string): Nullable<Bone>;
  1939. /**
  1940. * Gets a light node using its name
  1941. * @param name defines the the light's name
  1942. * @return the light or null if none found.
  1943. */
  1944. getLightByName(name: string): Nullable<Light>;
  1945. /**
  1946. * Gets a light node using its id
  1947. * @param id defines the light's id
  1948. * @return the light or null if none found.
  1949. */
  1950. getLightByID(id: string): Nullable<Light>;
  1951. /**
  1952. * Gets a light node using its scene-generated unique ID
  1953. * @param uniqueId defines the light's unique id
  1954. * @return the light or null if none found.
  1955. */
  1956. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  1957. /**
  1958. * Gets a particle system by id
  1959. * @param id defines the particle system id
  1960. * @return the corresponding system or null if none found
  1961. */
  1962. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  1963. /**
  1964. * Gets a geometry using its ID
  1965. * @param id defines the geometry's id
  1966. * @return the geometry or null if none found.
  1967. */
  1968. getGeometryByID(id: string): Nullable<Geometry>;
  1969. /**
  1970. * Add a new geometry to this scene
  1971. * @param geometry defines the geometry to be added to the scene.
  1972. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  1973. * @return a boolean defining if the geometry was added or not
  1974. */
  1975. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  1976. /**
  1977. * Removes an existing geometry
  1978. * @param geometry defines the geometry to be removed from the scene
  1979. * @return a boolean defining if the geometry was removed or not
  1980. */
  1981. removeGeometry(geometry: Geometry): boolean;
  1982. /**
  1983. * Gets the list of geometries attached to the scene
  1984. * @returns an array of Geometry
  1985. */
  1986. getGeometries(): Geometry[];
  1987. /**
  1988. * Gets the first added mesh found of a given ID
  1989. * @param id defines the id to search for
  1990. * @return the mesh found or null if not found at all
  1991. */
  1992. getMeshByID(id: string): Nullable<AbstractMesh>;
  1993. /**
  1994. * Gets a list of meshes using their id
  1995. * @param id defines the id to search for
  1996. * @returns a list of meshes
  1997. */
  1998. getMeshesByID(id: string): Array<AbstractMesh>;
  1999. /**
  2000. * Gets the first added transform node found of a given ID
  2001. * @param id defines the id to search for
  2002. * @return the found transform node or null if not found at all.
  2003. */
  2004. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2005. /**
  2006. * Gets a list of transform nodes using their id
  2007. * @param id defines the id to search for
  2008. * @returns a list of transform nodes
  2009. */
  2010. getTransformNodesByID(id: string): Array<TransformNode>;
  2011. /**
  2012. * Gets a mesh with its auto-generated unique id
  2013. * @param uniqueId defines the unique id to search for
  2014. * @return the found mesh or null if not found at all.
  2015. */
  2016. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2017. /**
  2018. * Gets a the last added mesh using a given id
  2019. * @param id defines the id to search for
  2020. * @return the found mesh or null if not found at all.
  2021. */
  2022. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2023. /**
  2024. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2025. * @param id defines the id to search for
  2026. * @return the found node or null if not found at all
  2027. */
  2028. getLastEntryByID(id: string): Nullable<Node>;
  2029. /**
  2030. * Gets a node (Mesh, Camera, Light) using a given id
  2031. * @param id defines the id to search for
  2032. * @return the found node or null if not found at all
  2033. */
  2034. getNodeByID(id: string): Nullable<Node>;
  2035. /**
  2036. * Gets a node (Mesh, Camera, Light) using a given name
  2037. * @param name defines the name to search for
  2038. * @return the found node or null if not found at all.
  2039. */
  2040. getNodeByName(name: string): Nullable<Node>;
  2041. /**
  2042. * Gets a mesh using a given name
  2043. * @param name defines the name to search for
  2044. * @return the found mesh or null if not found at all.
  2045. */
  2046. getMeshByName(name: string): Nullable<AbstractMesh>;
  2047. /**
  2048. * Gets a transform node using a given name
  2049. * @param name defines the name to search for
  2050. * @return the found transform node or null if not found at all.
  2051. */
  2052. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2053. /**
  2054. * Gets a sound using a given name
  2055. * @param name defines the name to search for
  2056. * @return the found sound or null if not found at all.
  2057. */
  2058. getSoundByName(name: string): Nullable<Sound>;
  2059. /**
  2060. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2061. * @param id defines the id to search for
  2062. * @return the found skeleton or null if not found at all.
  2063. */
  2064. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2065. /**
  2066. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2067. * @param id defines the id to search for
  2068. * @return the found skeleton or null if not found at all.
  2069. */
  2070. getSkeletonById(id: string): Nullable<Skeleton>;
  2071. /**
  2072. * Gets a skeleton using a given name
  2073. * @param name defines the name to search for
  2074. * @return the found skeleton or null if not found at all.
  2075. */
  2076. getSkeletonByName(name: string): Nullable<Skeleton>;
  2077. /**
  2078. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2079. * @param id defines the id to search for
  2080. * @return the found morph target manager or null if not found at all.
  2081. */
  2082. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2083. /**
  2084. * Gets a boolean indicating if the given mesh is active
  2085. * @param mesh defines the mesh to look for
  2086. * @returns true if the mesh is in the active list
  2087. */
  2088. isActiveMesh(mesh: AbstractMesh): boolean;
  2089. /**
  2090. * Return a unique id as a string which can serve as an identifier for the scene
  2091. */
  2092. readonly uid: string;
  2093. /**
  2094. * Add an externaly attached data from its key.
  2095. * This method call will fail and return false, if such key already exists.
  2096. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2097. * @param key the unique key that identifies the data
  2098. * @param data the data object to associate to the key for this Engine instance
  2099. * @return true if no such key were already present and the data was added successfully, false otherwise
  2100. */
  2101. addExternalData<T>(key: string, data: T): boolean;
  2102. /**
  2103. * Get an externaly attached data from its key
  2104. * @param key the unique key that identifies the data
  2105. * @return the associated data, if present (can be null), or undefined if not present
  2106. */
  2107. getExternalData<T>(key: string): Nullable<T>;
  2108. /**
  2109. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2110. * @param key the unique key that identifies the data
  2111. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2112. * @return the associated data, can be null if the factory returned null.
  2113. */
  2114. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2115. /**
  2116. * Remove an externaly attached data from the Engine instance
  2117. * @param key the unique key that identifies the data
  2118. * @return true if the data was successfully removed, false if it doesn't exist
  2119. */
  2120. removeExternalData(key: string): boolean;
  2121. private _evaluateSubMesh(subMesh, mesh);
  2122. /**
  2123. * Clear the processed materials smart array preventing retention point in material dispose.
  2124. */
  2125. freeProcessedMaterials(): void;
  2126. /**
  2127. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2128. */
  2129. freeActiveMeshes(): void;
  2130. /**
  2131. * Clear the info related to rendering groups preventing retention points during dispose.
  2132. */
  2133. freeRenderingGroups(): void;
  2134. /** @hidden */
  2135. _isInIntermediateRendering(): boolean;
  2136. private _activeMeshCandidateProvider;
  2137. /**
  2138. * Defines the current active mesh candidate provider
  2139. * @param provider defines the provider to use
  2140. */
  2141. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2142. /**
  2143. * Gets the current active mesh candidate provider
  2144. * @returns the current active mesh candidate provider
  2145. */
  2146. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2147. private _activeMeshesFrozen;
  2148. /**
  2149. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2150. * @returns the current scene
  2151. */
  2152. freezeActiveMeshes(): Scene;
  2153. /**
  2154. * Use this function to restart evaluating active meshes on every frame
  2155. * @returns the current scene
  2156. */
  2157. unfreezeActiveMeshes(): Scene;
  2158. private _evaluateActiveMeshes();
  2159. private _activeMesh(sourceMesh, mesh);
  2160. /**
  2161. * Update the transform matrix to update from the current active camera
  2162. * @param force defines a boolean used to force the update even if cache is up to date
  2163. */
  2164. updateTransformMatrix(force?: boolean): void;
  2165. /**
  2166. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  2167. * @param alternateCamera defines the camera to use
  2168. */
  2169. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2170. private _renderForCamera(camera, rigParent?);
  2171. private _processSubCameras(camera);
  2172. private _checkIntersections();
  2173. /**
  2174. * Render the scene
  2175. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2176. */
  2177. render(updateCameras?: boolean): void;
  2178. private _updateAudioParameters();
  2179. /**
  2180. * Gets or sets if audio support is enabled
  2181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2182. */
  2183. audioEnabled: boolean;
  2184. private _disableAudio();
  2185. private _enableAudio();
  2186. /**
  2187. * Gets or sets if audio will be output to headphones
  2188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2189. */
  2190. headphone: boolean;
  2191. private _switchAudioModeForHeadphones();
  2192. private _switchAudioModeForNormalSpeakers();
  2193. /**
  2194. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2195. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2196. * @returns the created depth renderer
  2197. */
  2198. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2199. /**
  2200. * Disables a depth renderer for a given camera
  2201. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2202. */
  2203. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2204. /**
  2205. * Enables a GeometryBufferRender and associates it with the scene
  2206. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2207. * @returns the GeometryBufferRenderer
  2208. */
  2209. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2210. /**
  2211. * Disables the GeometryBufferRender associated with the scene
  2212. */
  2213. disableGeometryBufferRenderer(): void;
  2214. /**
  2215. * Freeze all materials
  2216. * A frozen material will not be updatable but should be faster to render
  2217. */
  2218. freezeMaterials(): void;
  2219. /**
  2220. * Unfreeze all materials
  2221. * A frozen material will not be updatable but should be faster to render
  2222. */
  2223. unfreezeMaterials(): void;
  2224. /**
  2225. * Releases all held ressources
  2226. */
  2227. dispose(): void;
  2228. /**
  2229. * Gets if the scene is already disposed
  2230. */
  2231. readonly isDisposed: boolean;
  2232. /**
  2233. * Releases sounds & soundtracks
  2234. */
  2235. disposeSounds(): void;
  2236. /**
  2237. * Call this function to reduce memory footprint of the scene.
  2238. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2239. */
  2240. clearCachedVertexData(): void;
  2241. /**
  2242. * This function will remove the local cached buffer data from texture.
  2243. * It will save memory but will prevent the texture from being rebuilt
  2244. */
  2245. cleanCachedTextureBuffer(): void;
  2246. /**
  2247. * Get the world extend vectors with an optional filter
  2248. *
  2249. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2250. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2251. */
  2252. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2253. min: Vector3;
  2254. max: Vector3;
  2255. };
  2256. /**
  2257. * Creates or updates the octree used to boost selection (picking)
  2258. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2259. * @param maxCapacity defines the maximum capacity per leaf
  2260. * @param maxDepth defines the maximum depth of the octree
  2261. * @returns an octree of AbstractMesh
  2262. */
  2263. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2264. /**
  2265. * Creates a ray that can be used to pick in the scene
  2266. * @param x defines the x coordinate of the origin (on-screen)
  2267. * @param y defines the y coordinate of the origin (on-screen)
  2268. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2269. * @param camera defines the camera to use for the picking
  2270. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2271. * @returns a Ray
  2272. */
  2273. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2274. /**
  2275. * Creates a ray that can be used to pick in the scene
  2276. * @param x defines the x coordinate of the origin (on-screen)
  2277. * @param y defines the y coordinate of the origin (on-screen)
  2278. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2279. * @param result defines the ray where to store the picking ray
  2280. * @param camera defines the camera to use for the picking
  2281. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2282. * @returns the current scene
  2283. */
  2284. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2285. /**
  2286. * Creates a ray that can be used to pick in the scene
  2287. * @param x defines the x coordinate of the origin (on-screen)
  2288. * @param y defines the y coordinate of the origin (on-screen)
  2289. * @param camera defines the camera to use for the picking
  2290. * @returns a Ray
  2291. */
  2292. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2293. /**
  2294. * Creates a ray that can be used to pick in the scene
  2295. * @param x defines the x coordinate of the origin (on-screen)
  2296. * @param y defines the y coordinate of the origin (on-screen)
  2297. * @param result defines the ray where to store the picking ray
  2298. * @param camera defines the camera to use for the picking
  2299. * @returns the current scene
  2300. */
  2301. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2302. private _internalPick(rayFunction, predicate?, fastCheck?);
  2303. private _internalMultiPick(rayFunction, predicate?);
  2304. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2305. private _tempPickingRay;
  2306. /** Launch a ray to try to pick a mesh in the scene
  2307. * @param x position on screen
  2308. * @param y position on screen
  2309. * @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
  2310. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2311. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2312. * @returns a PickingInfo
  2313. */
  2314. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2315. /** Launch a ray to try to pick a sprite in the scene
  2316. * @param x position on screen
  2317. * @param y position on screen
  2318. * @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
  2319. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2320. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2321. * @returns a PickingInfo
  2322. */
  2323. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2324. private _cachedRayForTransform;
  2325. /** Use the given ray to pick a mesh in the scene
  2326. * @param ray The ray to use to pick meshes
  2327. * @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
  2328. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2329. * @returns a PickingInfo
  2330. */
  2331. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2332. /**
  2333. * Launch a ray to try to pick a mesh in the scene
  2334. * @param x X position on screen
  2335. * @param y Y position on screen
  2336. * @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
  2337. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2338. * @returns an array of PickingInfo
  2339. */
  2340. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2341. /**
  2342. * Launch a ray to try to pick a mesh in the scene
  2343. * @param ray Ray to use
  2344. * @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
  2345. * @returns an array of PickingInfo
  2346. */
  2347. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2348. /**
  2349. * Force the value of meshUnderPointer
  2350. * @param mesh defines the mesh to use
  2351. */
  2352. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2353. /**
  2354. * Gets the mesh under the pointer
  2355. * @returns a Mesh or null if no mesh is under the pointer
  2356. */
  2357. getPointerOverMesh(): Nullable<AbstractMesh>;
  2358. /**
  2359. * Force the sprite under the pointer
  2360. * @param sprite defines the sprite to use
  2361. */
  2362. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2363. /**
  2364. * Gets the sprite under the pointer
  2365. * @returns a Sprite or null if no sprite is under the pointer
  2366. */
  2367. getPointerOverSprite(): Nullable<Sprite>;
  2368. /**
  2369. * Gets the current physics engine
  2370. * @returns a PhysicsEngine or null if none attached
  2371. */
  2372. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2373. /**
  2374. * Enables physics to the current scene
  2375. * @param gravity defines the scene's gravity for the physics engine
  2376. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2377. * @return a boolean indicating if the physics engine was initialized
  2378. */
  2379. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2380. /**
  2381. * Disables and disposes the physics engine associated with the scene
  2382. */
  2383. disablePhysicsEngine(): void;
  2384. /**
  2385. * Gets a boolean indicating if there is an active physics engine
  2386. * @returns a boolean indicating if there is an active physics engine
  2387. */
  2388. isPhysicsEnabled(): boolean;
  2389. /**
  2390. * Deletes a physics compound impostor
  2391. * @param compound defines the compound to delete
  2392. */
  2393. deleteCompoundImpostor(compound: any): void;
  2394. /** @hidden */
  2395. _rebuildGeometries(): void;
  2396. /** @hidden */
  2397. _rebuildTextures(): void;
  2398. /**
  2399. * Creates a default light for the scene.
  2400. * @param replace Whether to replace the existing lights in the scene.
  2401. */
  2402. createDefaultLight(replace?: boolean): void;
  2403. /**
  2404. * Creates a default camera for the scene.
  2405. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2406. * @param replace Whether to replace the existing active camera in the scene.
  2407. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2408. */
  2409. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2410. /**
  2411. * Creates a default camera and a default light
  2412. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2413. * @param replace defines if the camera and/or light will replace the existing ones
  2414. * @param attachCameraControls defines if attachControl will be called on the new camera
  2415. */
  2416. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2417. /**
  2418. * Creates a new sky box
  2419. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2420. * @param environmentTexture defines the texture to use as environment texture
  2421. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2422. * @param scale defines the overall scale of the skybox
  2423. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2424. * @param setGlobalEnvTexture defines a boolean indicating that scene.environmentTexture must match the current skybox texture (true by default)
  2425. * @returns a new mesh holding the sky box
  2426. */
  2427. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2428. /**
  2429. * Creates a new environment
  2430. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2431. * @param options defines the options you can use to configure the environment
  2432. * @returns the new EnvironmentHelper
  2433. */
  2434. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2435. /**
  2436. * Creates a new VREXperienceHelper
  2437. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2438. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2439. * @returns a new VREXperienceHelper
  2440. */
  2441. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2442. private _getByTags(list, tagsQuery, forEach?);
  2443. /**
  2444. * Get a list of meshes by tags
  2445. * @param tagsQuery defines the tags query to use
  2446. * @param forEach defines a predicate used to filter results
  2447. * @returns an array of Mesh
  2448. */
  2449. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2450. /**
  2451. * Get a list of cameras by tags
  2452. * @param tagsQuery defines the tags query to use
  2453. * @param forEach defines a predicate used to filter results
  2454. * @returns an array of Camera
  2455. */
  2456. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2457. /**
  2458. * Get a list of lights by tags
  2459. * @param tagsQuery defines the tags query to use
  2460. * @param forEach defines a predicate used to filter results
  2461. * @returns an array of Light
  2462. */
  2463. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2464. /**
  2465. * Get a list of materials by tags
  2466. * @param tagsQuery defines the tags query to use
  2467. * @param forEach defines a predicate used to filter results
  2468. * @returns an array of Material
  2469. */
  2470. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2471. /**
  2472. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2473. * This allowed control for front to back rendering or reversly depending of the special needs.
  2474. *
  2475. * @param renderingGroupId The rendering group id corresponding to its index
  2476. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2477. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2478. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2479. */
  2480. 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;
  2481. /**
  2482. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2483. *
  2484. * @param renderingGroupId The rendering group id corresponding to its index
  2485. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2486. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2487. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2488. */
  2489. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2490. /**
  2491. * Will flag all materials as dirty to trigger new shader compilation
  2492. * @param flag defines the flag used to specify which material part must be marked as dirty
  2493. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2494. */
  2495. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2496. /** @hidden */
  2497. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useDatabase?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  2498. /** @hidden */
  2499. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2500. }
  2501. }
  2502. declare module BABYLON {
  2503. /**
  2504. * Groups all the scene component constants in one place to ease maintenance.
  2505. * @hidden
  2506. */
  2507. class SceneComponentConstants {
  2508. static readonly NAME_EFFECTLAYER: string;
  2509. static readonly NAME_LAYER: string;
  2510. static readonly NAME_LENSFLARESYSTEM: string;
  2511. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2512. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2513. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2514. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2515. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2516. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2517. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2518. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2519. }
  2520. /**
  2521. * This represents a scene component.
  2522. *
  2523. * This is used to decouple the dependency the scene is having on the different workloads like
  2524. * layers, post processes...
  2525. */
  2526. interface ISceneComponent {
  2527. /**
  2528. * The name of the component. Each component must have a unique name.
  2529. */
  2530. name: string;
  2531. /**
  2532. * The scene the component belongs to.
  2533. */
  2534. scene: Scene;
  2535. /**
  2536. * Register the component to one instance of a scene.
  2537. */
  2538. register(): void;
  2539. /**
  2540. * Adds all the element from the container to the scene
  2541. * @param container the container holding the elements
  2542. */
  2543. addFromContainer(container: AbstractScene): void;
  2544. /**
  2545. * Removes all the elements in the container from the scene
  2546. * @param container contains the elements to remove
  2547. */
  2548. removeFromContainer(container: AbstractScene): void;
  2549. /**
  2550. * Rebuilds the elements related to this component in case of
  2551. * context lost for instance.
  2552. */
  2553. rebuild(): void;
  2554. /**
  2555. * Serializes the component data to the specified json object
  2556. * @param serializationObject The object to serialize to
  2557. */
  2558. serialize(serializationObject: any): void;
  2559. /**
  2560. * Disposes the component and the associated ressources.
  2561. */
  2562. dispose(): void;
  2563. }
  2564. /**
  2565. * Strong typing of a Mesh related stage step action
  2566. */
  2567. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2568. /**
  2569. * Strong typing of a Camera related stage step action
  2570. */
  2571. type CameraStageAction = (camera: Camera) => void;
  2572. /**
  2573. * Strong typing of a simple stage step action
  2574. */
  2575. type SimpleStageAction = () => void;
  2576. /**
  2577. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2578. * @hidden
  2579. */
  2580. class Stage<T extends Function> extends Array<{
  2581. index: number;
  2582. component: ISceneComponent;
  2583. action: T;
  2584. }> {
  2585. /**
  2586. * Hide ctor from the rest of the world.
  2587. * @param items The items to add.
  2588. */
  2589. private constructor();
  2590. /**
  2591. * Creates a new Stage.
  2592. * @returns A new instance of a Stage
  2593. */
  2594. static Create<T extends Function>(): Stage<T>;
  2595. /**
  2596. * Registers a step in an ordered way in the targeted stage.
  2597. * @param index Defines the position to register the step in
  2598. * @param component Defines the component attached to the step
  2599. * @param action Defines the action to launch during the step
  2600. */
  2601. registerStep(index: number, component: ISceneComponent, action: T): void;
  2602. /**
  2603. * Clears all the steps from the stage.
  2604. */
  2605. clear(): void;
  2606. }
  2607. }
  2608. declare module BABYLON {
  2609. type Nullable<T> = T | null;
  2610. type float = number;
  2611. type double = number;
  2612. type int = number;
  2613. type FloatArray = number[] | Float32Array;
  2614. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2615. /**
  2616. * Alias for types that can be used by a Buffer or VertexBuffer.
  2617. */
  2618. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2619. }
  2620. declare module BABYLON {
  2621. /**
  2622. * The action to be carried out following a trigger
  2623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2624. */
  2625. class Action {
  2626. /** the trigger, with or without parameters, for the action */
  2627. triggerOptions: any;
  2628. /**
  2629. * Trigger for the action
  2630. */
  2631. trigger: number;
  2632. /**
  2633. * Internal only - manager for action
  2634. * @hidden
  2635. */
  2636. _actionManager: ActionManager;
  2637. private _nextActiveAction;
  2638. private _child;
  2639. private _condition?;
  2640. private _triggerParameter;
  2641. /**
  2642. * An event triggered prior to action being executed.
  2643. */
  2644. onBeforeExecuteObservable: Observable<Action>;
  2645. /**
  2646. * Creates a new Action
  2647. * @param triggerOptions the trigger, with or without parameters, for the action
  2648. * @param condition an optional determinant of action
  2649. */
  2650. constructor(
  2651. /** the trigger, with or without parameters, for the action */
  2652. triggerOptions: any, condition?: Condition);
  2653. /**
  2654. * Internal only
  2655. * @hidden
  2656. */
  2657. _prepare(): void;
  2658. /**
  2659. * Gets the trigger parameters
  2660. * @returns the trigger parameters
  2661. */
  2662. getTriggerParameter(): any;
  2663. /**
  2664. * Internal only - executes current action event
  2665. * @hidden
  2666. */
  2667. _executeCurrent(evt?: ActionEvent): void;
  2668. /**
  2669. * Execute placeholder for child classes
  2670. * @param evt optional action event
  2671. */
  2672. execute(evt?: ActionEvent): void;
  2673. /**
  2674. * Skips to next active action
  2675. */
  2676. skipToNextActiveAction(): void;
  2677. /**
  2678. * Adds action to chain of actions, may be a DoNothingAction
  2679. * @param action defines the next action to execute
  2680. * @returns The action passed in
  2681. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2682. */
  2683. then(action: Action): Action;
  2684. /**
  2685. * Internal only
  2686. * @hidden
  2687. */
  2688. _getProperty(propertyPath: string): string;
  2689. /**
  2690. * Internal only
  2691. * @hidden
  2692. */
  2693. _getEffectiveTarget(target: any, propertyPath: string): any;
  2694. /**
  2695. * Serialize placeholder for child classes
  2696. * @param parent of child
  2697. * @returns the serialized object
  2698. */
  2699. serialize(parent: any): any;
  2700. /**
  2701. * Internal only called by serialize
  2702. * @hidden
  2703. */
  2704. protected _serialize(serializedAction: any, parent?: any): any;
  2705. /**
  2706. * Internal only
  2707. * @hidden
  2708. */
  2709. static _SerializeValueAsString: (value: any) => string;
  2710. /**
  2711. * Internal only
  2712. * @hidden
  2713. */
  2714. static _GetTargetProperty: (target: Scene | Node) => {
  2715. name: string;
  2716. targetType: string;
  2717. value: string;
  2718. };
  2719. }
  2720. }
  2721. declare module BABYLON {
  2722. /**
  2723. * ActionEvent is the event being sent when an action is triggered.
  2724. */
  2725. class ActionEvent {
  2726. /** The mesh or sprite that triggered the action */
  2727. source: any;
  2728. /** The X mouse cursor position at the time of the event */
  2729. pointerX: number;
  2730. /** The Y mouse cursor position at the time of the event */
  2731. pointerY: number;
  2732. /** The mesh that is currently pointed at (can be null) */
  2733. meshUnderPointer: Nullable<AbstractMesh>;
  2734. /** the original (browser) event that triggered the ActionEvent */
  2735. sourceEvent: any;
  2736. /** additional data for the event */
  2737. additionalData: any;
  2738. /**
  2739. * Creates a new ActionEvent
  2740. * @param source The mesh or sprite that triggered the action
  2741. * @param pointerX The X mouse cursor position at the time of the event
  2742. * @param pointerY The Y mouse cursor position at the time of the event
  2743. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2744. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2745. * @param additionalData additional data for the event
  2746. */
  2747. constructor(
  2748. /** The mesh or sprite that triggered the action */
  2749. source: any,
  2750. /** The X mouse cursor position at the time of the event */
  2751. pointerX: number,
  2752. /** The Y mouse cursor position at the time of the event */
  2753. pointerY: number,
  2754. /** The mesh that is currently pointed at (can be null) */
  2755. meshUnderPointer: Nullable<AbstractMesh>,
  2756. /** the original (browser) event that triggered the ActionEvent */
  2757. sourceEvent?: any,
  2758. /** additional data for the event */
  2759. additionalData?: any);
  2760. /**
  2761. * Helper function to auto-create an ActionEvent from a source mesh.
  2762. * @param source The source mesh that triggered the event
  2763. * @param evt The original (browser) event
  2764. * @param additionalData additional data for the event
  2765. * @returns the new ActionEvent
  2766. */
  2767. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2768. /**
  2769. * Helper function to auto-create an ActionEvent from a source sprite
  2770. * @param source The source sprite that triggered the event
  2771. * @param scene Scene associated with the sprite
  2772. * @param evt The original (browser) event
  2773. * @param additionalData additional data for the event
  2774. * @returns the new ActionEvent
  2775. */
  2776. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2777. /**
  2778. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2779. * @param scene the scene where the event occurred
  2780. * @param evt The original (browser) event
  2781. * @returns the new ActionEvent
  2782. */
  2783. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2784. /**
  2785. * Helper function to auto-create an ActionEvent from a primitive
  2786. * @param prim defines the target primitive
  2787. * @param pointerPos defines the pointer position
  2788. * @param evt The original (browser) event
  2789. * @param additionalData additional data for the event
  2790. * @returns the new ActionEvent
  2791. */
  2792. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2793. }
  2794. /**
  2795. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2796. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2798. */
  2799. class ActionManager {
  2800. private static _NothingTrigger;
  2801. private static _OnPickTrigger;
  2802. private static _OnLeftPickTrigger;
  2803. private static _OnRightPickTrigger;
  2804. private static _OnCenterPickTrigger;
  2805. private static _OnPickDownTrigger;
  2806. private static _OnDoublePickTrigger;
  2807. private static _OnPickUpTrigger;
  2808. private static _OnLongPressTrigger;
  2809. private static _OnPointerOverTrigger;
  2810. private static _OnPointerOutTrigger;
  2811. private static _OnEveryFrameTrigger;
  2812. private static _OnIntersectionEnterTrigger;
  2813. private static _OnIntersectionExitTrigger;
  2814. private static _OnKeyDownTrigger;
  2815. private static _OnKeyUpTrigger;
  2816. private static _OnPickOutTrigger;
  2817. /**
  2818. * Nothing
  2819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2820. */
  2821. static readonly NothingTrigger: number;
  2822. /**
  2823. * On pick
  2824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2825. */
  2826. static readonly OnPickTrigger: number;
  2827. /**
  2828. * On left pick
  2829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2830. */
  2831. static readonly OnLeftPickTrigger: number;
  2832. /**
  2833. * On right pick
  2834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2835. */
  2836. static readonly OnRightPickTrigger: number;
  2837. /**
  2838. * On center pick
  2839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2840. */
  2841. static readonly OnCenterPickTrigger: number;
  2842. /**
  2843. * On pick down
  2844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2845. */
  2846. static readonly OnPickDownTrigger: number;
  2847. /**
  2848. * On double pick
  2849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2850. */
  2851. static readonly OnDoublePickTrigger: number;
  2852. /**
  2853. * On pick up
  2854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2855. */
  2856. static readonly OnPickUpTrigger: number;
  2857. /**
  2858. * On pick out.
  2859. * This trigger will only be raised if you also declared a OnPickDown
  2860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2861. */
  2862. static readonly OnPickOutTrigger: number;
  2863. /**
  2864. * On long press
  2865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2866. */
  2867. static readonly OnLongPressTrigger: number;
  2868. /**
  2869. * On pointer over
  2870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2871. */
  2872. static readonly OnPointerOverTrigger: number;
  2873. /**
  2874. * On pointer out
  2875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2876. */
  2877. static readonly OnPointerOutTrigger: number;
  2878. /**
  2879. * On every frame
  2880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2881. */
  2882. static readonly OnEveryFrameTrigger: number;
  2883. /**
  2884. * On intersection enter
  2885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2886. */
  2887. static readonly OnIntersectionEnterTrigger: number;
  2888. /**
  2889. * On intersection exit
  2890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2891. */
  2892. static readonly OnIntersectionExitTrigger: number;
  2893. /**
  2894. * On key down
  2895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2896. */
  2897. static readonly OnKeyDownTrigger: number;
  2898. /**
  2899. * On key up
  2900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2901. */
  2902. static readonly OnKeyUpTrigger: number;
  2903. /** Gets the list of active triggers */
  2904. static Triggers: {
  2905. [key: string]: number;
  2906. };
  2907. /** Gets the list of actions */
  2908. actions: Action[];
  2909. /** Gets the cursor to use when hovering items */
  2910. hoverCursor: string;
  2911. private _scene;
  2912. /**
  2913. * Creates a new action manager
  2914. * @param scene defines the hosting scene
  2915. */
  2916. constructor(scene: Scene);
  2917. /**
  2918. * Releases all associated resources
  2919. */
  2920. dispose(): void;
  2921. /**
  2922. * Gets hosting scene
  2923. * @returns the hosting scene
  2924. */
  2925. getScene(): Scene;
  2926. /**
  2927. * Does this action manager handles actions of any of the given triggers
  2928. * @param triggers defines the triggers to be tested
  2929. * @return a boolean indicating whether one (or more) of the triggers is handled
  2930. */
  2931. hasSpecificTriggers(triggers: number[]): boolean;
  2932. /**
  2933. * Does this action manager handles actions of a given trigger
  2934. * @param trigger defines the trigger to be tested
  2935. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2936. * @return whether the trigger is handled
  2937. */
  2938. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2939. /**
  2940. * Does this action manager has pointer triggers
  2941. */
  2942. readonly hasPointerTriggers: boolean;
  2943. /**
  2944. * Does this action manager has pick triggers
  2945. */
  2946. readonly hasPickTriggers: boolean;
  2947. /**
  2948. * Does exist one action manager with at least one trigger
  2949. **/
  2950. static readonly HasTriggers: boolean;
  2951. /**
  2952. * Does exist one action manager with at least one pick trigger
  2953. **/
  2954. static readonly HasPickTriggers: boolean;
  2955. /**
  2956. * Does exist one action manager that handles actions of a given trigger
  2957. * @param trigger defines the trigger to be tested
  2958. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2959. **/
  2960. static HasSpecificTrigger(trigger: number): boolean;
  2961. /**
  2962. * Registers an action to this action manager
  2963. * @param action defines the action to be registered
  2964. * @return the action amended (prepared) after registration
  2965. */
  2966. registerAction(action: Action): Nullable<Action>;
  2967. /**
  2968. * Unregisters an action to this action manager
  2969. * @param action defines the action to be unregistered
  2970. * @return a boolean indicating whether the action has been unregistered
  2971. */
  2972. unregisterAction(action: Action): Boolean;
  2973. /**
  2974. * Process a specific trigger
  2975. * @param trigger defines the trigger to process
  2976. * @param evt defines the event details to be processed
  2977. */
  2978. processTrigger(trigger: number, evt?: ActionEvent): void;
  2979. /** @hidden */
  2980. _getEffectiveTarget(target: any, propertyPath: string): any;
  2981. /** @hidden */
  2982. _getProperty(propertyPath: string): string;
  2983. /**
  2984. * Serialize this manager to a JSON object
  2985. * @param name defines the property name to store this manager
  2986. * @returns a JSON representation of this manager
  2987. */
  2988. serialize(name: string): any;
  2989. /**
  2990. * Creates a new ActionManager from a JSON data
  2991. * @param parsedActions defines the JSON data to read from
  2992. * @param object defines the hosting mesh
  2993. * @param scene defines the hosting scene
  2994. */
  2995. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  2996. /**
  2997. * Get a trigger name by index
  2998. * @param trigger defines the trigger index
  2999. * @returns a trigger name
  3000. */
  3001. static GetTriggerName(trigger: number): string;
  3002. }
  3003. }
  3004. declare module BABYLON {
  3005. /**
  3006. * A Condition applied to an Action
  3007. */
  3008. class Condition {
  3009. /**
  3010. * Internal only - manager for action
  3011. * @hidden
  3012. */
  3013. _actionManager: ActionManager;
  3014. /**
  3015. * Internal only
  3016. * @hidden
  3017. */
  3018. _evaluationId: number;
  3019. /**
  3020. * Internal only
  3021. * @hidden
  3022. */
  3023. _currentResult: boolean;
  3024. /**
  3025. * Creates a new Condition
  3026. * @param actionManager the manager of the action the condition is applied to
  3027. */
  3028. constructor(actionManager: ActionManager);
  3029. /**
  3030. * Check if the current condition is valid
  3031. * @returns a boolean
  3032. */
  3033. isValid(): boolean;
  3034. /**
  3035. * Internal only
  3036. * @hidden
  3037. */
  3038. _getProperty(propertyPath: string): string;
  3039. /**
  3040. * Internal only
  3041. * @hidden
  3042. */
  3043. _getEffectiveTarget(target: any, propertyPath: string): any;
  3044. /**
  3045. * Serialize placeholder for child classes
  3046. * @returns the serialized object
  3047. */
  3048. serialize(): any;
  3049. /**
  3050. * Internal only
  3051. * @hidden
  3052. */
  3053. protected _serialize(serializedCondition: any): any;
  3054. }
  3055. /**
  3056. * Defines specific conditional operators as extensions of Condition
  3057. */
  3058. class ValueCondition extends Condition {
  3059. /** path to specify the property of the target the conditional operator uses */
  3060. propertyPath: string;
  3061. /** the value compared by the conditional operator against the current value of the property */
  3062. value: any;
  3063. /** the conditional operator, default ValueCondition.IsEqual */
  3064. operator: number;
  3065. /**
  3066. * Internal only
  3067. * @hidden
  3068. */
  3069. private static _IsEqual;
  3070. /**
  3071. * Internal only
  3072. * @hidden
  3073. */
  3074. private static _IsDifferent;
  3075. /**
  3076. * Internal only
  3077. * @hidden
  3078. */
  3079. private static _IsGreater;
  3080. /**
  3081. * Internal only
  3082. * @hidden
  3083. */
  3084. private static _IsLesser;
  3085. /**
  3086. * returns the number for IsEqual
  3087. */
  3088. static readonly IsEqual: number;
  3089. /**
  3090. * Returns the number for IsDifferent
  3091. */
  3092. static readonly IsDifferent: number;
  3093. /**
  3094. * Returns the number for IsGreater
  3095. */
  3096. static readonly IsGreater: number;
  3097. /**
  3098. * Returns the number for IsLesser
  3099. */
  3100. static readonly IsLesser: number;
  3101. /**
  3102. * Internal only The action manager for the condition
  3103. * @hidden
  3104. */
  3105. _actionManager: ActionManager;
  3106. /**
  3107. * Internal only
  3108. * @hidden
  3109. */
  3110. private _target;
  3111. /**
  3112. * Internal only
  3113. * @hidden
  3114. */
  3115. private _effectiveTarget;
  3116. /**
  3117. * Internal only
  3118. * @hidden
  3119. */
  3120. private _property;
  3121. /**
  3122. * Creates a new ValueCondition
  3123. * @param actionManager manager for the action the condition applies to
  3124. * @param target for the action
  3125. * @param propertyPath path to specify the property of the target the conditional operator uses
  3126. * @param value the value compared by the conditional operator against the current value of the property
  3127. * @param operator the conditional operator, default ValueCondition.IsEqual
  3128. */
  3129. constructor(actionManager: ActionManager, target: any,
  3130. /** path to specify the property of the target the conditional operator uses */
  3131. propertyPath: string,
  3132. /** the value compared by the conditional operator against the current value of the property */
  3133. value: any,
  3134. /** the conditional operator, default ValueCondition.IsEqual */
  3135. operator?: number);
  3136. /**
  3137. * Compares the given value with the property value for the specified conditional operator
  3138. * @returns the result of the comparison
  3139. */
  3140. isValid(): boolean;
  3141. /**
  3142. * Serialize the ValueCondition into a JSON compatible object
  3143. * @returns serialization object
  3144. */
  3145. serialize(): any;
  3146. /**
  3147. * Gets the name of the conditional operator for the ValueCondition
  3148. * @param operator the conditional operator
  3149. * @returns the name
  3150. */
  3151. static GetOperatorName(operator: number): string;
  3152. }
  3153. /**
  3154. * Defines a predicate condition as an extension of Condition
  3155. */
  3156. class PredicateCondition extends Condition {
  3157. /** defines the predicate function used to validate the condition */
  3158. predicate: () => boolean;
  3159. /**
  3160. * Internal only - manager for action
  3161. * @hidden
  3162. */
  3163. _actionManager: ActionManager;
  3164. /**
  3165. * Creates a new PredicateCondition
  3166. * @param actionManager manager for the action the condition applies to
  3167. * @param predicate defines the predicate function used to validate the condition
  3168. */
  3169. constructor(actionManager: ActionManager,
  3170. /** defines the predicate function used to validate the condition */
  3171. predicate: () => boolean);
  3172. /**
  3173. * @returns the validity of the predicate condition
  3174. */
  3175. isValid(): boolean;
  3176. }
  3177. /**
  3178. * Defines a state condition as an extension of Condition
  3179. */
  3180. class StateCondition extends Condition {
  3181. value: string;
  3182. /**
  3183. * Internal only - manager for action
  3184. * @hidden
  3185. */
  3186. _actionManager: ActionManager;
  3187. /**
  3188. * Internal only
  3189. * @hidden
  3190. */
  3191. private _target;
  3192. /**
  3193. * Creates a new StateCondition
  3194. * @param actionManager manager for the action the condition applies to
  3195. * @param target of the condition
  3196. * @param value to compare with target state
  3197. */
  3198. constructor(actionManager: ActionManager, target: any, value: string);
  3199. /**
  3200. * @returns the validity of the state
  3201. */
  3202. isValid(): boolean;
  3203. /**
  3204. * Serialize the StateCondition into a JSON compatible object
  3205. * @returns serialization object
  3206. */
  3207. serialize(): any;
  3208. }
  3209. }
  3210. declare module BABYLON {
  3211. class SwitchBooleanAction extends Action {
  3212. propertyPath: string;
  3213. private _target;
  3214. private _effectiveTarget;
  3215. private _property;
  3216. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3217. _prepare(): void;
  3218. execute(): void;
  3219. serialize(parent: any): any;
  3220. }
  3221. class SetStateAction extends Action {
  3222. value: string;
  3223. private _target;
  3224. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3225. execute(): void;
  3226. serialize(parent: any): any;
  3227. }
  3228. class SetValueAction extends Action {
  3229. propertyPath: string;
  3230. value: any;
  3231. private _target;
  3232. private _effectiveTarget;
  3233. private _property;
  3234. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3235. _prepare(): void;
  3236. execute(): void;
  3237. serialize(parent: any): any;
  3238. }
  3239. class IncrementValueAction extends Action {
  3240. propertyPath: string;
  3241. value: any;
  3242. private _target;
  3243. private _effectiveTarget;
  3244. private _property;
  3245. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3246. _prepare(): void;
  3247. execute(): void;
  3248. serialize(parent: any): any;
  3249. }
  3250. class PlayAnimationAction extends Action {
  3251. from: number;
  3252. to: number;
  3253. loop: boolean | undefined;
  3254. private _target;
  3255. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3256. _prepare(): void;
  3257. execute(): void;
  3258. serialize(parent: any): any;
  3259. }
  3260. class StopAnimationAction extends Action {
  3261. private _target;
  3262. constructor(triggerOptions: any, target: any, condition?: Condition);
  3263. _prepare(): void;
  3264. execute(): void;
  3265. serialize(parent: any): any;
  3266. }
  3267. class DoNothingAction extends Action {
  3268. constructor(triggerOptions?: any, condition?: Condition);
  3269. execute(): void;
  3270. serialize(parent: any): any;
  3271. }
  3272. class CombineAction extends Action {
  3273. children: Action[];
  3274. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3275. _prepare(): void;
  3276. execute(evt: ActionEvent): void;
  3277. serialize(parent: any): any;
  3278. }
  3279. class ExecuteCodeAction extends Action {
  3280. func: (evt: ActionEvent) => void;
  3281. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3282. execute(evt: ActionEvent): void;
  3283. }
  3284. class SetParentAction extends Action {
  3285. private _parent;
  3286. private _target;
  3287. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3288. _prepare(): void;
  3289. execute(): void;
  3290. serialize(parent: any): any;
  3291. }
  3292. class PlaySoundAction extends Action {
  3293. private _sound;
  3294. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3295. _prepare(): void;
  3296. execute(): void;
  3297. serialize(parent: any): any;
  3298. }
  3299. class StopSoundAction extends Action {
  3300. private _sound;
  3301. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3302. _prepare(): void;
  3303. execute(): void;
  3304. serialize(parent: any): any;
  3305. }
  3306. }
  3307. declare module BABYLON {
  3308. class InterpolateValueAction extends Action {
  3309. propertyPath: string;
  3310. value: any;
  3311. duration: number;
  3312. stopOtherAnimations: boolean | undefined;
  3313. onInterpolationDone: (() => void) | undefined;
  3314. private _target;
  3315. private _effectiveTarget;
  3316. private _property;
  3317. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3318. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3319. _prepare(): void;
  3320. execute(): void;
  3321. serialize(parent: any): any;
  3322. }
  3323. }
  3324. declare module BABYLON {
  3325. class Animatable {
  3326. target: any;
  3327. fromFrame: number;
  3328. toFrame: number;
  3329. loopAnimation: boolean;
  3330. onAnimationEnd: (() => void) | null | undefined;
  3331. private _localDelayOffset;
  3332. private _pausedDelay;
  3333. private _runtimeAnimations;
  3334. private _paused;
  3335. private _scene;
  3336. private _speedRatio;
  3337. private _weight;
  3338. private _syncRoot;
  3339. animationStarted: boolean;
  3340. /**
  3341. * Observer raised when the animation ends
  3342. */
  3343. onAnimationEndObservable: Observable<Animatable>;
  3344. /**
  3345. * Gets the root Animatable used to synchronize and normalize animations
  3346. */
  3347. readonly syncRoot: Animatable;
  3348. /**
  3349. * Gets the current frame of the first RuntimeAnimation
  3350. * Used to synchronize Animatables
  3351. */
  3352. readonly masterFrame: number;
  3353. /**
  3354. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3355. */
  3356. weight: number;
  3357. /**
  3358. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3359. */
  3360. speedRatio: number;
  3361. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3362. /**
  3363. * Synchronize and normalize current Animatable with a source Animatable
  3364. * This is useful when using animation weights and when animations are not of the same length
  3365. * @param root defines the root Animatable to synchronize with
  3366. * @returns the current Animatable
  3367. */
  3368. syncWith(root: Animatable): Animatable;
  3369. getAnimations(): RuntimeAnimation[];
  3370. appendAnimations(target: any, animations: Animation[]): void;
  3371. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3372. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3373. reset(): void;
  3374. enableBlending(blendingSpeed: number): void;
  3375. disableBlending(): void;
  3376. goToFrame(frame: number): void;
  3377. pause(): void;
  3378. restart(): void;
  3379. private _raiseOnAnimationEnd();
  3380. stop(animationName?: string): void;
  3381. /**
  3382. * Wait asynchronously for the animation to end
  3383. * @returns a promise which will be fullfilled when the animation ends
  3384. */
  3385. waitAsync(): Promise<Animatable>;
  3386. /** @hidden */
  3387. _animate(delay: number): boolean;
  3388. }
  3389. }
  3390. declare module BABYLON {
  3391. /**
  3392. * Represents the range of an animation
  3393. */
  3394. class AnimationRange {
  3395. /**The name of the animation range**/
  3396. name: string;
  3397. /**The starting frame of the animation */
  3398. from: number;
  3399. /**The ending frame of the animation*/
  3400. to: number;
  3401. /**
  3402. * Initializes the range of an animation
  3403. * @param name The name of the animation range
  3404. * @param from The starting frame of the animation
  3405. * @param to The ending frame of the animation
  3406. */
  3407. constructor(
  3408. /**The name of the animation range**/
  3409. name: string,
  3410. /**The starting frame of the animation */
  3411. from: number,
  3412. /**The ending frame of the animation*/
  3413. to: number);
  3414. /**
  3415. * Makes a copy of the animation range
  3416. * @returns A copy of the animation range
  3417. */
  3418. clone(): AnimationRange;
  3419. }
  3420. /**
  3421. * Composed of a frame, and an action function
  3422. */
  3423. class AnimationEvent {
  3424. /** The frame for which the event is triggered **/
  3425. frame: number;
  3426. /** The event to perform when triggered **/
  3427. action: () => void;
  3428. /** Specifies if the event should be triggered only once**/
  3429. onlyOnce: boolean | undefined;
  3430. /**
  3431. * Specifies if the animation event is done
  3432. */
  3433. isDone: boolean;
  3434. /**
  3435. * Initializes the animation event
  3436. * @param frame The frame for which the event is triggered
  3437. * @param action The event to perform when triggered
  3438. * @param onlyOnce Specifies if the event should be triggered only once
  3439. */
  3440. constructor(
  3441. /** The frame for which the event is triggered **/
  3442. frame: number,
  3443. /** The event to perform when triggered **/
  3444. action: () => void,
  3445. /** Specifies if the event should be triggered only once**/
  3446. onlyOnce?: boolean | undefined);
  3447. /** @hidden */
  3448. _clone(): AnimationEvent;
  3449. }
  3450. /**
  3451. * A cursor which tracks a point on a path
  3452. */
  3453. class PathCursor {
  3454. private path;
  3455. /**
  3456. * Stores path cursor callbacks for when an onchange event is triggered
  3457. */
  3458. private _onchange;
  3459. /**
  3460. * The value of the path cursor
  3461. */
  3462. value: number;
  3463. /**
  3464. * The animation array of the path cursor
  3465. */
  3466. animations: Animation[];
  3467. /**
  3468. * Initializes the path cursor
  3469. * @param path The path to track
  3470. */
  3471. constructor(path: Path2);
  3472. /**
  3473. * Gets the cursor point on the path
  3474. * @returns A point on the path cursor at the cursor location
  3475. */
  3476. getPoint(): Vector3;
  3477. /**
  3478. * Moves the cursor ahead by the step amount
  3479. * @param step The amount to move the cursor forward
  3480. * @returns This path cursor
  3481. */
  3482. moveAhead(step?: number): PathCursor;
  3483. /**
  3484. * Moves the cursor behind by the step amount
  3485. * @param step The amount to move the cursor back
  3486. * @returns This path cursor
  3487. */
  3488. moveBack(step?: number): PathCursor;
  3489. /**
  3490. * Moves the cursor by the step amount
  3491. * If the step amount is greater than one, an exception is thrown
  3492. * @param step The amount to move the cursor
  3493. * @returns This path cursor
  3494. */
  3495. move(step: number): PathCursor;
  3496. /**
  3497. * Ensures that the value is limited between zero and one
  3498. * @returns This path cursor
  3499. */
  3500. private ensureLimits();
  3501. /**
  3502. * Runs onchange callbacks on change (used by the animation engine)
  3503. * @returns This path cursor
  3504. */
  3505. private raiseOnChange();
  3506. /**
  3507. * Executes a function on change
  3508. * @param f A path cursor onchange callback
  3509. * @returns This path cursor
  3510. */
  3511. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3512. }
  3513. /**
  3514. * Defines an interface which represents an animation key frame
  3515. */
  3516. interface IAnimationKey {
  3517. /**
  3518. * Frame of the key frame
  3519. */
  3520. frame: number;
  3521. /**
  3522. * Value at the specifies key frame
  3523. */
  3524. value: any;
  3525. /**
  3526. * The input tangent for the cubic hermite spline
  3527. */
  3528. inTangent?: any;
  3529. /**
  3530. * The output tangent for the cubic hermite spline
  3531. */
  3532. outTangent?: any;
  3533. /**
  3534. * The animation interpolation type
  3535. */
  3536. interpolation?: AnimationKeyInterpolation;
  3537. }
  3538. /**
  3539. * Enum for the animation key frame interpolation type
  3540. */
  3541. enum AnimationKeyInterpolation {
  3542. /**
  3543. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3544. */
  3545. STEP = 1,
  3546. }
  3547. /**
  3548. * Class used to store any kind of animation
  3549. */
  3550. class Animation {
  3551. /**Name of the animation */
  3552. name: string;
  3553. /**Property to animate */
  3554. targetProperty: string;
  3555. /**The frames per second of the animation */
  3556. framePerSecond: number;
  3557. /**The data type of the animation */
  3558. dataType: number;
  3559. /**The loop mode of the animation */
  3560. loopMode: number | undefined;
  3561. /**Specifies if blending should be enabled */
  3562. enableBlending: boolean | undefined;
  3563. /**
  3564. * Use matrix interpolation instead of using direct key value when animating matrices
  3565. */
  3566. static AllowMatricesInterpolation: boolean;
  3567. /**
  3568. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3569. */
  3570. static AllowMatrixDecomposeForInterpolation: boolean;
  3571. /**
  3572. * Stores the key frames of the animation
  3573. */
  3574. private _keys;
  3575. /**
  3576. * Stores the easing function of the animation
  3577. */
  3578. private _easingFunction;
  3579. /**
  3580. * @hidden Internal use only
  3581. */
  3582. _runtimeAnimations: RuntimeAnimation[];
  3583. /**
  3584. * The set of event that will be linked to this animation
  3585. */
  3586. private _events;
  3587. /**
  3588. * Stores an array of target property paths
  3589. */
  3590. targetPropertyPath: string[];
  3591. /**
  3592. * Stores the blending speed of the animation
  3593. */
  3594. blendingSpeed: number;
  3595. /**
  3596. * Stores the animation ranges for the animation
  3597. */
  3598. private _ranges;
  3599. /**
  3600. * @hidden Internal use
  3601. */
  3602. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3603. /**
  3604. * Sets up an animation
  3605. * @param property The property to animate
  3606. * @param animationType The animation type to apply
  3607. * @param framePerSecond The frames per second of the animation
  3608. * @param easingFunction The easing function used in the animation
  3609. * @returns The created animation
  3610. */
  3611. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3612. /**
  3613. * Create and start an animation on a node
  3614. * @param name defines the name of the global animation that will be run on all nodes
  3615. * @param node defines the root node where the animation will take place
  3616. * @param targetProperty defines property to animate
  3617. * @param framePerSecond defines the number of frame per second yo use
  3618. * @param totalFrame defines the number of frames in total
  3619. * @param from defines the initial value
  3620. * @param to defines the final value
  3621. * @param loopMode defines which loop mode you want to use (off by default)
  3622. * @param easingFunction defines the easing function to use (linear by default)
  3623. * @param onAnimationEnd defines the callback to call when animation end
  3624. * @returns the animatable created for this animation
  3625. */
  3626. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3627. /**
  3628. * Create and start an animation on a node and its descendants
  3629. * @param name defines the name of the global animation that will be run on all nodes
  3630. * @param node defines the root node where the animation will take place
  3631. * @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
  3632. * @param targetProperty defines property to animate
  3633. * @param framePerSecond defines the number of frame per second to use
  3634. * @param totalFrame defines the number of frames in total
  3635. * @param from defines the initial value
  3636. * @param to defines the final value
  3637. * @param loopMode defines which loop mode you want to use (off by default)
  3638. * @param easingFunction defines the easing function to use (linear by default)
  3639. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3640. * @returns the list of animatables created for all nodes
  3641. * @example https://www.babylonjs-playground.com/#MH0VLI
  3642. */
  3643. 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[]>;
  3644. /**
  3645. * Creates a new animation, merges it with the existing animations and starts it
  3646. * @param name Name of the animation
  3647. * @param node Node which contains the scene that begins the animations
  3648. * @param targetProperty Specifies which property to animate
  3649. * @param framePerSecond The frames per second of the animation
  3650. * @param totalFrame The total number of frames
  3651. * @param from The frame at the beginning of the animation
  3652. * @param to The frame at the end of the animation
  3653. * @param loopMode Specifies the loop mode of the animation
  3654. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3655. * @param onAnimationEnd Callback to run once the animation is complete
  3656. * @returns Nullable animation
  3657. */
  3658. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3659. /**
  3660. * Transition property of an host to the target Value
  3661. * @param property The property to transition
  3662. * @param targetValue The target Value of the property
  3663. * @param host The object where the property to animate belongs
  3664. * @param scene Scene used to run the animation
  3665. * @param frameRate Framerate (in frame/s) to use
  3666. * @param transition The transition type we want to use
  3667. * @param duration The duration of the animation, in milliseconds
  3668. * @param onAnimationEnd Callback trigger at the end of the animation
  3669. * @returns Nullable animation
  3670. */
  3671. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3672. /**
  3673. * Return the array of runtime animations currently using this animation
  3674. */
  3675. readonly runtimeAnimations: RuntimeAnimation[];
  3676. /**
  3677. * Specifies if any of the runtime animations are currently running
  3678. */
  3679. readonly hasRunningRuntimeAnimations: boolean;
  3680. /**
  3681. * Initializes the animation
  3682. * @param name Name of the animation
  3683. * @param targetProperty Property to animate
  3684. * @param framePerSecond The frames per second of the animation
  3685. * @param dataType The data type of the animation
  3686. * @param loopMode The loop mode of the animation
  3687. * @param enableBlendings Specifies if blending should be enabled
  3688. */
  3689. constructor(
  3690. /**Name of the animation */
  3691. name: string,
  3692. /**Property to animate */
  3693. targetProperty: string,
  3694. /**The frames per second of the animation */
  3695. framePerSecond: number,
  3696. /**The data type of the animation */
  3697. dataType: number,
  3698. /**The loop mode of the animation */
  3699. loopMode?: number | undefined,
  3700. /**Specifies if blending should be enabled */
  3701. enableBlending?: boolean | undefined);
  3702. /**
  3703. * Converts the animation to a string
  3704. * @param fullDetails support for multiple levels of logging within scene loading
  3705. * @returns String form of the animation
  3706. */
  3707. toString(fullDetails?: boolean): string;
  3708. /**
  3709. * Add an event to this animation
  3710. * @param event Event to add
  3711. */
  3712. addEvent(event: AnimationEvent): void;
  3713. /**
  3714. * Remove all events found at the given frame
  3715. * @param frame The frame to remove events from
  3716. */
  3717. removeEvents(frame: number): void;
  3718. /**
  3719. * Retrieves all the events from the animation
  3720. * @returns Events from the animation
  3721. */
  3722. getEvents(): AnimationEvent[];
  3723. /**
  3724. * Creates an animation range
  3725. * @param name Name of the animation range
  3726. * @param from Starting frame of the animation range
  3727. * @param to Ending frame of the animation
  3728. */
  3729. createRange(name: string, from: number, to: number): void;
  3730. /**
  3731. * Deletes an animation range by name
  3732. * @param name Name of the animation range to delete
  3733. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3734. */
  3735. deleteRange(name: string, deleteFrames?: boolean): void;
  3736. /**
  3737. * Gets the animation range by name, or null if not defined
  3738. * @param name Name of the animation range
  3739. * @returns Nullable animation range
  3740. */
  3741. getRange(name: string): Nullable<AnimationRange>;
  3742. /**
  3743. * Gets the key frames from the animation
  3744. * @returns The key frames of the animation
  3745. */
  3746. getKeys(): Array<IAnimationKey>;
  3747. /**
  3748. * Gets the highest frame rate of the animation
  3749. * @returns Highest frame rate of the animation
  3750. */
  3751. getHighestFrame(): number;
  3752. /**
  3753. * Gets the easing function of the animation
  3754. * @returns Easing function of the animation
  3755. */
  3756. getEasingFunction(): IEasingFunction;
  3757. /**
  3758. * Sets the easing function of the animation
  3759. * @param easingFunction A custom mathematical formula for animation
  3760. */
  3761. setEasingFunction(easingFunction: EasingFunction): void;
  3762. /**
  3763. * Interpolates a scalar linearly
  3764. * @param startValue Start value of the animation curve
  3765. * @param endValue End value of the animation curve
  3766. * @param gradient Scalar amount to interpolate
  3767. * @returns Interpolated scalar value
  3768. */
  3769. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3770. /**
  3771. * Interpolates a scalar cubically
  3772. * @param startValue Start value of the animation curve
  3773. * @param outTangent End tangent of the animation
  3774. * @param endValue End value of the animation curve
  3775. * @param inTangent Start tangent of the animation curve
  3776. * @param gradient Scalar amount to interpolate
  3777. * @returns Interpolated scalar value
  3778. */
  3779. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3780. /**
  3781. * Interpolates a quaternion using a spherical linear interpolation
  3782. * @param startValue Start value of the animation curve
  3783. * @param endValue End value of the animation curve
  3784. * @param gradient Scalar amount to interpolate
  3785. * @returns Interpolated quaternion value
  3786. */
  3787. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3788. /**
  3789. * Interpolates a quaternion cubically
  3790. * @param startValue Start value of the animation curve
  3791. * @param outTangent End tangent of the animation curve
  3792. * @param endValue End value of the animation curve
  3793. * @param inTangent Start tangent of the animation curve
  3794. * @param gradient Scalar amount to interpolate
  3795. * @returns Interpolated quaternion value
  3796. */
  3797. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3798. /**
  3799. * Interpolates a Vector3 linearl
  3800. * @param startValue Start value of the animation curve
  3801. * @param endValue End value of the animation curve
  3802. * @param gradient Scalar amount to interpolate
  3803. * @returns Interpolated scalar value
  3804. */
  3805. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3806. /**
  3807. * Interpolates a Vector3 cubically
  3808. * @param startValue Start value of the animation curve
  3809. * @param outTangent End tangent of the animation
  3810. * @param endValue End value of the animation curve
  3811. * @param inTangent Start tangent of the animation curve
  3812. * @param gradient Scalar amount to interpolate
  3813. * @returns InterpolatedVector3 value
  3814. */
  3815. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3816. /**
  3817. * Interpolates a Vector2 linearly
  3818. * @param startValue Start value of the animation curve
  3819. * @param endValue End value of the animation curve
  3820. * @param gradient Scalar amount to interpolate
  3821. * @returns Interpolated Vector2 value
  3822. */
  3823. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3824. /**
  3825. * Interpolates a Vector2 cubically
  3826. * @param startValue Start value of the animation curve
  3827. * @param outTangent End tangent of the animation
  3828. * @param endValue End value of the animation curve
  3829. * @param inTangent Start tangent of the animation curve
  3830. * @param gradient Scalar amount to interpolate
  3831. * @returns Interpolated Vector2 value
  3832. */
  3833. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3834. /**
  3835. * Interpolates a size linearly
  3836. * @param startValue Start value of the animation curve
  3837. * @param endValue End value of the animation curve
  3838. * @param gradient Scalar amount to interpolate
  3839. * @returns Interpolated Size value
  3840. */
  3841. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3842. /**
  3843. * Interpolates a Color3 linearly
  3844. * @param startValue Start value of the animation curve
  3845. * @param endValue End value of the animation curve
  3846. * @param gradient Scalar amount to interpolate
  3847. * @returns Interpolated Color3 value
  3848. */
  3849. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3850. /**
  3851. * @hidden Internal use only
  3852. */
  3853. _getKeyValue(value: any): any;
  3854. /**
  3855. * @hidden Internal use only
  3856. */
  3857. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  3858. /**
  3859. * Defines the function to use to interpolate matrices
  3860. * @param startValue defines the start matrix
  3861. * @param endValue defines the end matrix
  3862. * @param gradient defines the gradient between both matrices
  3863. * @param result defines an optional target matrix where to store the interpolation
  3864. * @returns the interpolated matrix
  3865. */
  3866. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  3867. /**
  3868. * Makes a copy of the animation
  3869. * @returns Cloned animation
  3870. */
  3871. clone(): Animation;
  3872. /**
  3873. * Sets the key frames of the animation
  3874. * @param values The animation key frames to set
  3875. */
  3876. setKeys(values: Array<IAnimationKey>): void;
  3877. /**
  3878. * Serializes the animation to an object
  3879. * @returns Serialized object
  3880. */
  3881. serialize(): any;
  3882. /**
  3883. * Float animation type
  3884. */
  3885. private static _ANIMATIONTYPE_FLOAT;
  3886. /**
  3887. * Vector3 animation type
  3888. */
  3889. private static _ANIMATIONTYPE_VECTOR3;
  3890. /**
  3891. * Quaternion animation type
  3892. */
  3893. private static _ANIMATIONTYPE_QUATERNION;
  3894. /**
  3895. * Matrix animation type
  3896. */
  3897. private static _ANIMATIONTYPE_MATRIX;
  3898. /**
  3899. * Color3 animation type
  3900. */
  3901. private static _ANIMATIONTYPE_COLOR3;
  3902. /**
  3903. * Vector2 animation type
  3904. */
  3905. private static _ANIMATIONTYPE_VECTOR2;
  3906. /**
  3907. * Size animation type
  3908. */
  3909. private static _ANIMATIONTYPE_SIZE;
  3910. /**
  3911. * Relative Loop Mode
  3912. */
  3913. private static _ANIMATIONLOOPMODE_RELATIVE;
  3914. /**
  3915. * Cycle Loop Mode
  3916. */
  3917. private static _ANIMATIONLOOPMODE_CYCLE;
  3918. /**
  3919. * Constant Loop Mode
  3920. */
  3921. private static _ANIMATIONLOOPMODE_CONSTANT;
  3922. /**
  3923. * Get the float animation type
  3924. */
  3925. static readonly ANIMATIONTYPE_FLOAT: number;
  3926. /**
  3927. * Get the Vector3 animation type
  3928. */
  3929. static readonly ANIMATIONTYPE_VECTOR3: number;
  3930. /**
  3931. * Get the Vectpr2 animation type
  3932. */
  3933. static readonly ANIMATIONTYPE_VECTOR2: number;
  3934. /**
  3935. * Get the Size animation type
  3936. */
  3937. static readonly ANIMATIONTYPE_SIZE: number;
  3938. /**
  3939. * Get the Quaternion animation type
  3940. */
  3941. static readonly ANIMATIONTYPE_QUATERNION: number;
  3942. /**
  3943. * Get the Matrix animation type
  3944. */
  3945. static readonly ANIMATIONTYPE_MATRIX: number;
  3946. /**
  3947. * Get the Color3 animation type
  3948. */
  3949. static readonly ANIMATIONTYPE_COLOR3: number;
  3950. /**
  3951. * Get the Relative Loop Mode
  3952. */
  3953. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  3954. /**
  3955. * Get the Cycle Loop Mode
  3956. */
  3957. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  3958. /**
  3959. * Get the Constant Loop Mode
  3960. */
  3961. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  3962. /** @hidden */
  3963. static _UniversalLerp(left: any, right: any, amount: number): any;
  3964. /**
  3965. * Parses an animation object and creates an animation
  3966. * @param parsedAnimation Parsed animation object
  3967. * @returns Animation object
  3968. */
  3969. static Parse(parsedAnimation: any): Animation;
  3970. /**
  3971. * Appends the serialized animations from the source animations
  3972. * @param source Source containing the animations
  3973. * @param destination Target to store the animations
  3974. */
  3975. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  3976. }
  3977. }
  3978. declare module BABYLON {
  3979. /**
  3980. * This class defines the direct association between an animation and a target
  3981. */
  3982. class TargetedAnimation {
  3983. animation: Animation;
  3984. target: any;
  3985. }
  3986. /**
  3987. * Use this class to create coordinated animations on multiple targets
  3988. */
  3989. class AnimationGroup implements IDisposable {
  3990. name: string;
  3991. private _scene;
  3992. private _targetedAnimations;
  3993. private _animatables;
  3994. private _from;
  3995. private _to;
  3996. private _isStarted;
  3997. private _speedRatio;
  3998. onAnimationEndObservable: Observable<TargetedAnimation>;
  3999. /**
  4000. * This observable will notify when all animations have ended.
  4001. */
  4002. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4003. /**
  4004. * Gets the first frame
  4005. */
  4006. readonly from: number;
  4007. /**
  4008. * Gets the last frame
  4009. */
  4010. readonly to: number;
  4011. /**
  4012. * Define if the animations are started
  4013. */
  4014. readonly isStarted: boolean;
  4015. /**
  4016. * Gets or sets the speed ratio to use for all animations
  4017. */
  4018. /**
  4019. * Gets or sets the speed ratio to use for all animations
  4020. */
  4021. speedRatio: number;
  4022. /**
  4023. * Gets the targeted animations for this animation group
  4024. */
  4025. readonly targetedAnimations: Array<TargetedAnimation>;
  4026. /**
  4027. * returning the list of animatables controlled by this animation group.
  4028. */
  4029. readonly animatables: Array<Animatable>;
  4030. constructor(name: string, scene?: Nullable<Scene>);
  4031. /**
  4032. * Add an animation (with its target) in the group
  4033. * @param animation defines the animation we want to add
  4034. * @param target defines the target of the animation
  4035. * @returns the {BABYLON.TargetedAnimation} object
  4036. */
  4037. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4038. /**
  4039. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4040. * It can add constant keys at begin or end
  4041. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4042. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4043. */
  4044. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4045. /**
  4046. * Start all animations on given targets
  4047. * @param loop defines if animations must loop
  4048. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4049. * @param from defines the from key (optional)
  4050. * @param to defines the to key (optional)
  4051. * @returns the current animation group
  4052. */
  4053. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4054. /**
  4055. * Pause all animations
  4056. */
  4057. pause(): AnimationGroup;
  4058. /**
  4059. * Play all animations to initial state
  4060. * This function will start() the animations if they were not started or will restart() them if they were paused
  4061. * @param loop defines if animations must loop
  4062. */
  4063. play(loop?: boolean): AnimationGroup;
  4064. /**
  4065. * Reset all animations to initial state
  4066. */
  4067. reset(): AnimationGroup;
  4068. /**
  4069. * Restart animations from key 0
  4070. */
  4071. restart(): AnimationGroup;
  4072. /**
  4073. * Stop all animations
  4074. */
  4075. stop(): AnimationGroup;
  4076. /**
  4077. * Set animation weight for all animatables
  4078. * @param weight defines the weight to use
  4079. * @return the animationGroup
  4080. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4081. */
  4082. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4083. /**
  4084. * Synchronize and normalize all animatables with a source animatable
  4085. * @param root defines the root animatable to synchronize with
  4086. * @return the animationGroup
  4087. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4088. */
  4089. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4090. /**
  4091. * Goes to a specific frame in this animation group
  4092. * @param frame the frame number to go to
  4093. * @return the animationGroup
  4094. */
  4095. goToFrame(frame: number): AnimationGroup;
  4096. /**
  4097. * Dispose all associated resources
  4098. */
  4099. dispose(): void;
  4100. private _checkAnimationGroupEnded(animatable);
  4101. }
  4102. }
  4103. declare module BABYLON {
  4104. /**
  4105. * Class used to override all child animations of a given target
  4106. */
  4107. class AnimationPropertiesOverride {
  4108. /**
  4109. * Gets or sets a value indicating if animation blending must be used
  4110. */
  4111. enableBlending: boolean;
  4112. /**
  4113. * Gets or sets the blending speed to use when enableBlending is true
  4114. */
  4115. blendingSpeed: number;
  4116. /**
  4117. * Gets or sets the default loop mode to use
  4118. */
  4119. loopMode: number;
  4120. }
  4121. }
  4122. declare module BABYLON {
  4123. interface IEasingFunction {
  4124. ease(gradient: number): number;
  4125. }
  4126. class EasingFunction implements IEasingFunction {
  4127. private static _EASINGMODE_EASEIN;
  4128. private static _EASINGMODE_EASEOUT;
  4129. private static _EASINGMODE_EASEINOUT;
  4130. static readonly EASINGMODE_EASEIN: number;
  4131. static readonly EASINGMODE_EASEOUT: number;
  4132. static readonly EASINGMODE_EASEINOUT: number;
  4133. private _easingMode;
  4134. setEasingMode(easingMode: number): void;
  4135. getEasingMode(): number;
  4136. easeInCore(gradient: number): number;
  4137. ease(gradient: number): number;
  4138. }
  4139. class CircleEase extends EasingFunction implements IEasingFunction {
  4140. easeInCore(gradient: number): number;
  4141. }
  4142. class BackEase extends EasingFunction implements IEasingFunction {
  4143. amplitude: number;
  4144. constructor(amplitude?: number);
  4145. easeInCore(gradient: number): number;
  4146. }
  4147. class BounceEase extends EasingFunction implements IEasingFunction {
  4148. bounces: number;
  4149. bounciness: number;
  4150. constructor(bounces?: number, bounciness?: number);
  4151. easeInCore(gradient: number): number;
  4152. }
  4153. class CubicEase extends EasingFunction implements IEasingFunction {
  4154. easeInCore(gradient: number): number;
  4155. }
  4156. class ElasticEase extends EasingFunction implements IEasingFunction {
  4157. oscillations: number;
  4158. springiness: number;
  4159. constructor(oscillations?: number, springiness?: number);
  4160. easeInCore(gradient: number): number;
  4161. }
  4162. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4163. exponent: number;
  4164. constructor(exponent?: number);
  4165. easeInCore(gradient: number): number;
  4166. }
  4167. class PowerEase extends EasingFunction implements IEasingFunction {
  4168. power: number;
  4169. constructor(power?: number);
  4170. easeInCore(gradient: number): number;
  4171. }
  4172. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4173. easeInCore(gradient: number): number;
  4174. }
  4175. class QuarticEase extends EasingFunction implements IEasingFunction {
  4176. easeInCore(gradient: number): number;
  4177. }
  4178. class QuinticEase extends EasingFunction implements IEasingFunction {
  4179. easeInCore(gradient: number): number;
  4180. }
  4181. class SineEase extends EasingFunction implements IEasingFunction {
  4182. easeInCore(gradient: number): number;
  4183. }
  4184. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4185. x1: number;
  4186. y1: number;
  4187. x2: number;
  4188. y2: number;
  4189. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4190. easeInCore(gradient: number): number;
  4191. }
  4192. }
  4193. declare module BABYLON {
  4194. /**
  4195. * Defines a runtime animation
  4196. */
  4197. class RuntimeAnimation {
  4198. private _events;
  4199. /**
  4200. * The current frame of the runtime animation
  4201. */
  4202. private _currentFrame;
  4203. /**
  4204. * The animation used by the runtime animation
  4205. */
  4206. private _animation;
  4207. /**
  4208. * The target of the runtime animation
  4209. */
  4210. private _target;
  4211. /**
  4212. * The initiating animatable
  4213. */
  4214. private _host;
  4215. /**
  4216. * The original value of the runtime animation
  4217. */
  4218. private _originalValue;
  4219. /**
  4220. * The original blend value of the runtime animation
  4221. */
  4222. private _originalBlendValue;
  4223. /**
  4224. * The offsets cache of the runtime animation
  4225. */
  4226. private _offsetsCache;
  4227. /**
  4228. * The high limits cache of the runtime animation
  4229. */
  4230. private _highLimitsCache;
  4231. /**
  4232. * Specifies if the runtime animation has been stopped
  4233. */
  4234. private _stopped;
  4235. /**
  4236. * The blending factor of the runtime animation
  4237. */
  4238. private _blendingFactor;
  4239. /**
  4240. * The BabylonJS scene
  4241. */
  4242. private _scene;
  4243. /**
  4244. * The current value of the runtime animation
  4245. */
  4246. private _currentValue;
  4247. /** @hidden */
  4248. _workValue: any;
  4249. /**
  4250. * The active target of the runtime animation
  4251. */
  4252. private _activeTarget;
  4253. /**
  4254. * The target path of the runtime animation
  4255. */
  4256. private _targetPath;
  4257. /**
  4258. * The weight of the runtime animation
  4259. */
  4260. private _weight;
  4261. /**
  4262. * The ratio offset of the runtime animation
  4263. */
  4264. private _ratioOffset;
  4265. /**
  4266. * The previous delay of the runtime animation
  4267. */
  4268. private _previousDelay;
  4269. /**
  4270. * The previous ratio of the runtime animation
  4271. */
  4272. private _previousRatio;
  4273. /**
  4274. * Gets the current frame of the runtime animation
  4275. */
  4276. readonly currentFrame: number;
  4277. /**
  4278. * Gets the weight of the runtime animation
  4279. */
  4280. readonly weight: number;
  4281. /**
  4282. * Gets the current value of the runtime animation
  4283. */
  4284. readonly currentValue: any;
  4285. /**
  4286. * Gets the target path of the runtime animation
  4287. */
  4288. readonly targetPath: string;
  4289. /**
  4290. * Gets the actual target of the runtime animation
  4291. */
  4292. readonly target: any;
  4293. /**
  4294. * Create a new RuntimeAnimation object
  4295. * @param target defines the target of the animation
  4296. * @param animation defines the source animation object
  4297. * @param scene defines the hosting scene
  4298. * @param host defines the initiating Animatable
  4299. */
  4300. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4301. /**
  4302. * Gets the animation from the runtime animation
  4303. */
  4304. readonly animation: Animation;
  4305. /**
  4306. * Resets the runtime animation to the beginning
  4307. * @param restoreOriginal defines whether to restore the target property to the original value
  4308. */
  4309. reset(restoreOriginal?: boolean): void;
  4310. /**
  4311. * Specifies if the runtime animation is stopped
  4312. * @returns Boolean specifying if the runtime animation is stopped
  4313. */
  4314. isStopped(): boolean;
  4315. /**
  4316. * Disposes of the runtime animation
  4317. */
  4318. dispose(): void;
  4319. /**
  4320. * Interpolates the animation from the current frame
  4321. * @param currentFrame The frame to interpolate the animation to
  4322. * @param repeatCount The number of times that the animation should loop
  4323. * @param loopMode The type of looping mode to use
  4324. * @param offsetValue Animation offset value
  4325. * @param highLimitValue The high limit value
  4326. * @returns The interpolated value
  4327. */
  4328. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4329. /**
  4330. * Apply the interpolated value to the target
  4331. * @param currentValue defines the value computed by the animation
  4332. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4333. */
  4334. setValue(currentValue: any, weight?: number): void;
  4335. private _setValue(target, currentValue, weight, targetIndex?);
  4336. /**
  4337. * Gets the loop pmode of the runtime animation
  4338. * @returns Loop Mode
  4339. */
  4340. private _getCorrectLoopMode();
  4341. /**
  4342. * Move the current animation to a given frame
  4343. * @param frame defines the frame to move to
  4344. */
  4345. goToFrame(frame: number): void;
  4346. /**
  4347. * @hidden Internal use only
  4348. */
  4349. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4350. /**
  4351. * Execute the current animation
  4352. * @param delay defines the delay to add to the current frame
  4353. * @param from defines the lower bound of the animation range
  4354. * @param to defines the upper bound of the animation range
  4355. * @param loop defines if the current animation must loop
  4356. * @param speedRatio defines the current speed ratio
  4357. * @param weight defines the weight of the animation (default is -1 so no weight)
  4358. * @returns a boolean indicating if the animation has ended
  4359. */
  4360. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4361. }
  4362. }
  4363. declare module BABYLON {
  4364. /**
  4365. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4367. */
  4368. class Analyser {
  4369. /**
  4370. * Gets or sets the smoothing
  4371. * @ignorenaming
  4372. */
  4373. SMOOTHING: number;
  4374. /**
  4375. * Gets or sets the FFT table size
  4376. * @ignorenaming
  4377. */
  4378. FFT_SIZE: number;
  4379. /**
  4380. * Gets or sets the bar graph amplitude
  4381. * @ignorenaming
  4382. */
  4383. BARGRAPHAMPLITUDE: number;
  4384. /**
  4385. * Gets or sets the position of the debug canvas
  4386. * @ignorenaming
  4387. */
  4388. DEBUGCANVASPOS: {
  4389. x: number;
  4390. y: number;
  4391. };
  4392. /**
  4393. * Gets or sets the debug canvas size
  4394. * @ignorenaming
  4395. */
  4396. DEBUGCANVASSIZE: {
  4397. width: number;
  4398. height: number;
  4399. };
  4400. private _byteFreqs;
  4401. private _byteTime;
  4402. private _floatFreqs;
  4403. private _webAudioAnalyser;
  4404. private _debugCanvas;
  4405. private _debugCanvasContext;
  4406. private _scene;
  4407. private _registerFunc;
  4408. private _audioEngine;
  4409. /**
  4410. * Creates a new analyser
  4411. * @param scene defines hosting scene
  4412. */
  4413. constructor(scene: Scene);
  4414. /**
  4415. * Get the number of data values you will have to play with for the visualization
  4416. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4417. * @returns a number
  4418. */
  4419. getFrequencyBinCount(): number;
  4420. /**
  4421. * Gets the current frequency data as a byte array
  4422. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4423. * @returns a Uint8Array
  4424. */
  4425. getByteFrequencyData(): Uint8Array;
  4426. /**
  4427. * Gets the current waveform as a byte array
  4428. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4429. * @returns a Uint8Array
  4430. */
  4431. getByteTimeDomainData(): Uint8Array;
  4432. /**
  4433. * Gets the current frequency data as a float array
  4434. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4435. * @returns a Float32Array
  4436. */
  4437. getFloatFrequencyData(): Float32Array;
  4438. /**
  4439. * Renders the debug canvas
  4440. */
  4441. drawDebugCanvas(): void;
  4442. /**
  4443. * Stops rendering the debug canvas and removes it
  4444. */
  4445. stopDebugCanvas(): void;
  4446. /**
  4447. * Connects two audio nodes
  4448. * @param inputAudioNode defines first node to connect
  4449. * @param outputAudioNode defines second node to connect
  4450. */
  4451. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4452. /**
  4453. * Releases all associated resources
  4454. */
  4455. dispose(): void;
  4456. }
  4457. }
  4458. declare module BABYLON {
  4459. class AudioEngine {
  4460. private _audioContext;
  4461. private _audioContextInitialized;
  4462. canUseWebAudio: boolean;
  4463. masterGain: GainNode;
  4464. private _connectedAnalyser;
  4465. WarnedWebAudioUnsupported: boolean;
  4466. unlocked: boolean;
  4467. onAudioUnlocked: () => any;
  4468. isMP3supported: boolean;
  4469. isOGGsupported: boolean;
  4470. readonly audioContext: Nullable<AudioContext>;
  4471. constructor();
  4472. private _unlockiOSaudio();
  4473. private _initializeAudioContext();
  4474. dispose(): void;
  4475. getGlobalVolume(): number;
  4476. setGlobalVolume(newVolume: number): void;
  4477. connectToAnalyser(analyser: Analyser): void;
  4478. }
  4479. }
  4480. declare module BABYLON {
  4481. class Sound {
  4482. name: string;
  4483. autoplay: boolean;
  4484. loop: boolean;
  4485. useCustomAttenuation: boolean;
  4486. soundTrackId: number;
  4487. spatialSound: boolean;
  4488. refDistance: number;
  4489. rolloffFactor: number;
  4490. maxDistance: number;
  4491. distanceModel: string;
  4492. private _panningModel;
  4493. onended: () => any;
  4494. private _playbackRate;
  4495. private _streaming;
  4496. private _startTime;
  4497. private _startOffset;
  4498. private _position;
  4499. private _localDirection;
  4500. private _volume;
  4501. private _isReadyToPlay;
  4502. isPlaying: boolean;
  4503. isPaused: boolean;
  4504. private _isDirectional;
  4505. private _readyToPlayCallback;
  4506. private _audioBuffer;
  4507. private _soundSource;
  4508. private _streamingSource;
  4509. private _soundPanner;
  4510. private _soundGain;
  4511. private _inputAudioNode;
  4512. private _ouputAudioNode;
  4513. private _coneInnerAngle;
  4514. private _coneOuterAngle;
  4515. private _coneOuterGain;
  4516. private _scene;
  4517. private _connectedMesh;
  4518. private _customAttenuationFunction;
  4519. private _registerFunc;
  4520. private _isOutputConnected;
  4521. private _htmlAudioElement;
  4522. private _urlType;
  4523. /**
  4524. * Create a sound and attach it to a scene
  4525. * @param name Name of your sound
  4526. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4527. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4528. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4529. */
  4530. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4531. dispose(): void;
  4532. isReady(): boolean;
  4533. private _soundLoaded(audioData);
  4534. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4535. updateOptions(options: any): void;
  4536. private _createSpatialParameters();
  4537. private _updateSpatialParameters();
  4538. switchPanningModelToHRTF(): void;
  4539. switchPanningModelToEqualPower(): void;
  4540. private _switchPanningModel();
  4541. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4542. /**
  4543. * Transform this sound into a directional source
  4544. * @param coneInnerAngle Size of the inner cone in degree
  4545. * @param coneOuterAngle Size of the outer cone in degree
  4546. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4547. */
  4548. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4549. setPosition(newPosition: Vector3): void;
  4550. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4551. private _updateDirection();
  4552. updateDistanceFromListener(): void;
  4553. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4554. /**
  4555. * Play the sound
  4556. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4557. * @param offset (optional) Start the sound setting it at a specific time
  4558. */
  4559. play(time?: number, offset?: number): void;
  4560. private _onended();
  4561. /**
  4562. * Stop the sound
  4563. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4564. */
  4565. stop(time?: number): void;
  4566. pause(): void;
  4567. setVolume(newVolume: number, time?: number): void;
  4568. setPlaybackRate(newPlaybackRate: number): void;
  4569. getVolume(): number;
  4570. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4571. detachFromMesh(): void;
  4572. private _onRegisterAfterWorldMatrixUpdate(node);
  4573. clone(): Nullable<Sound>;
  4574. getAudioBuffer(): AudioBuffer | null;
  4575. serialize(): any;
  4576. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4577. }
  4578. }
  4579. declare module BABYLON {
  4580. class SoundTrack {
  4581. private _outputAudioNode;
  4582. private _scene;
  4583. id: number;
  4584. soundCollection: Array<Sound>;
  4585. private _isMainTrack;
  4586. private _connectedAnalyser;
  4587. private _options;
  4588. private _isInitialized;
  4589. constructor(scene: Scene, options?: any);
  4590. private _initializeSoundTrackAudioGraph();
  4591. dispose(): void;
  4592. AddSound(sound: Sound): void;
  4593. RemoveSound(sound: Sound): void;
  4594. setVolume(newVolume: number): void;
  4595. switchPanningModelToHRTF(): void;
  4596. switchPanningModelToEqualPower(): void;
  4597. connectToAnalyser(analyser: Analyser): void;
  4598. }
  4599. }
  4600. declare module BABYLON {
  4601. /**
  4602. * Interface used to define a behavior
  4603. */
  4604. interface Behavior<T> {
  4605. /** gets or sets behavior's name */
  4606. name: string;
  4607. /**
  4608. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4609. */
  4610. init(): void;
  4611. /**
  4612. * Called when the behavior is attached to a target
  4613. * @param target defines the target where the behavior is attached to
  4614. */
  4615. attach(target: T): void;
  4616. /**
  4617. * Called when the behavior is detached from its target
  4618. */
  4619. detach(): void;
  4620. }
  4621. /**
  4622. * Interface implemented by classes supporting behaviors
  4623. */
  4624. interface IBehaviorAware<T> {
  4625. /**
  4626. * Attach a behavior
  4627. * @param behavior defines the behavior to attach
  4628. * @returns the current host
  4629. */
  4630. addBehavior(behavior: Behavior<T>): T;
  4631. /**
  4632. * Remove a behavior from the current object
  4633. * @param behavior defines the behavior to detach
  4634. * @returns the current host
  4635. */
  4636. removeBehavior(behavior: Behavior<T>): T;
  4637. /**
  4638. * Gets a behavior using its name to search
  4639. * @param name defines the name to search
  4640. * @returns the behavior or null if not found
  4641. */
  4642. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4643. }
  4644. }
  4645. declare module BABYLON {
  4646. /**
  4647. * Class used to store bone information
  4648. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4649. */
  4650. class Bone extends Node {
  4651. /**
  4652. * defines the bone name
  4653. */
  4654. name: string;
  4655. private static _tmpVecs;
  4656. private static _tmpQuat;
  4657. private static _tmpMats;
  4658. /**
  4659. * Gets the list of child bones
  4660. */
  4661. children: Bone[];
  4662. /** Gets the animations associated with this bone */
  4663. animations: Animation[];
  4664. /**
  4665. * Gets or sets bone length
  4666. */
  4667. length: number;
  4668. /**
  4669. * @hidden Internal only
  4670. * Set this value to map this bone to a different index in the transform matrices
  4671. * Set this value to -1 to exclude the bone from the transform matrices
  4672. */
  4673. _index: Nullable<number>;
  4674. private _skeleton;
  4675. private _localMatrix;
  4676. private _restPose;
  4677. private _baseMatrix;
  4678. private _absoluteTransform;
  4679. private _invertedAbsoluteTransform;
  4680. private _parent;
  4681. private _scalingDeterminant;
  4682. private _worldTransform;
  4683. private _localScaling;
  4684. private _localRotation;
  4685. private _localPosition;
  4686. private _needToDecompose;
  4687. private _needToCompose;
  4688. /** @hidden */
  4689. /** @hidden */
  4690. _matrix: Matrix;
  4691. /**
  4692. * Create a new bone
  4693. * @param name defines the bone name
  4694. * @param skeleton defines the parent skeleton
  4695. * @param parentBone defines the parent (can be null if the bone is the root)
  4696. * @param localMatrix defines the local matrix
  4697. * @param restPose defines the rest pose matrix
  4698. * @param baseMatrix defines the base matrix
  4699. * @param index defines index of the bone in the hiearchy
  4700. */
  4701. constructor(
  4702. /**
  4703. * defines the bone name
  4704. */
  4705. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4706. /**
  4707. * Gets the parent skeleton
  4708. * @returns a skeleton
  4709. */
  4710. getSkeleton(): Skeleton;
  4711. /**
  4712. * Gets parent bone
  4713. * @returns a bone or null if the bone is the root of the bone hierarchy
  4714. */
  4715. getParent(): Nullable<Bone>;
  4716. /**
  4717. * Sets the parent bone
  4718. * @param parent defines the parent (can be null if the bone is the root)
  4719. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4720. */
  4721. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4722. /**
  4723. * Gets the local matrix
  4724. * @returns a matrix
  4725. */
  4726. getLocalMatrix(): Matrix;
  4727. /**
  4728. * Gets the base matrix (initial matrix which remains unchanged)
  4729. * @returns a matrix
  4730. */
  4731. getBaseMatrix(): Matrix;
  4732. /**
  4733. * Gets the rest pose matrix
  4734. * @returns a matrix
  4735. */
  4736. getRestPose(): Matrix;
  4737. /**
  4738. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4739. */
  4740. getWorldMatrix(): Matrix;
  4741. /**
  4742. * Sets the local matrix to rest pose matrix
  4743. */
  4744. returnToRest(): void;
  4745. /**
  4746. * Gets the inverse of the absolute transform matrix.
  4747. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4748. * @returns a matrix
  4749. */
  4750. getInvertedAbsoluteTransform(): Matrix;
  4751. /**
  4752. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4753. * @returns a matrix
  4754. */
  4755. getAbsoluteTransform(): Matrix;
  4756. /** Gets or sets current position (in local space) */
  4757. position: Vector3;
  4758. /** Gets or sets current rotation (in local space) */
  4759. rotation: Vector3;
  4760. /** Gets or sets current rotation quaternion (in local space) */
  4761. rotationQuaternion: Quaternion;
  4762. /** Gets or sets current scaling (in local space) */
  4763. scaling: Vector3;
  4764. /**
  4765. * Gets the animation properties override
  4766. */
  4767. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4768. private _decompose();
  4769. private _compose();
  4770. /**
  4771. * Update the base and local matrices
  4772. * @param matrix defines the new base or local matrix
  4773. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4774. * @param updateLocalMatrix defines if the local matrix should be updated
  4775. */
  4776. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4777. /** @hidden */
  4778. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  4779. /**
  4780. * Flag the bone as dirty (Forcing it to update everything)
  4781. */
  4782. markAsDirty(): void;
  4783. private _markAsDirtyAndCompose();
  4784. private _markAsDirtyAndDecompose();
  4785. /**
  4786. * Copy an animation range from another bone
  4787. * @param source defines the source bone
  4788. * @param rangeName defines the range name to copy
  4789. * @param frameOffset defines the frame offset
  4790. * @param rescaleAsRequired defines if rescaling must be applied if required
  4791. * @param skelDimensionsRatio defines the scaling ratio
  4792. * @returns true if operation was successful
  4793. */
  4794. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4795. /**
  4796. * Translate the bone in local or world space
  4797. * @param vec The amount to translate the bone
  4798. * @param space The space that the translation is in
  4799. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4800. */
  4801. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4802. /**
  4803. * Set the postion of the bone in local or world space
  4804. * @param position The position to set the bone
  4805. * @param space The space that the position is in
  4806. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4807. */
  4808. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4809. /**
  4810. * Set the absolute position of the bone (world space)
  4811. * @param position The position to set the bone
  4812. * @param mesh The mesh that this bone is attached to
  4813. */
  4814. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4815. /**
  4816. * Scale the bone on the x, y and z axes (in local space)
  4817. * @param x The amount to scale the bone on the x axis
  4818. * @param y The amount to scale the bone on the y axis
  4819. * @param z The amount to scale the bone on the z axis
  4820. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4821. */
  4822. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4823. /**
  4824. * Set the bone scaling in local space
  4825. * @param scale defines the scaling vector
  4826. */
  4827. setScale(scale: Vector3): void;
  4828. /**
  4829. * Gets the current scaling in local space
  4830. * @returns the current scaling vector
  4831. */
  4832. getScale(): Vector3;
  4833. /**
  4834. * Gets the current scaling in local space and stores it in a target vector
  4835. * @param result defines the target vector
  4836. */
  4837. getScaleToRef(result: Vector3): void;
  4838. /**
  4839. * Set the yaw, pitch, and roll of the bone in local or world space
  4840. * @param yaw The rotation of the bone on the y axis
  4841. * @param pitch The rotation of the bone on the x axis
  4842. * @param roll The rotation of the bone on the z axis
  4843. * @param space The space that the axes of rotation are in
  4844. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4845. */
  4846. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4847. /**
  4848. * Add a rotation to the bone on an axis in local or world space
  4849. * @param axis The axis to rotate the bone on
  4850. * @param amount The amount to rotate the bone
  4851. * @param space The space that the axis is in
  4852. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4853. */
  4854. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4855. /**
  4856. * Set the rotation of the bone to a particular axis angle in local or world space
  4857. * @param axis The axis to rotate the bone on
  4858. * @param angle The angle that the bone should be rotated to
  4859. * @param space The space that the axis is in
  4860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4861. */
  4862. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4863. /**
  4864. * Set the euler rotation of the bone in local of world space
  4865. * @param rotation The euler rotation that the bone should be set to
  4866. * @param space The space that the rotation is in
  4867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4868. */
  4869. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4870. /**
  4871. * Set the quaternion rotation of the bone in local of world space
  4872. * @param quat The quaternion rotation that the bone should be set to
  4873. * @param space The space that the rotation is in
  4874. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4875. */
  4876. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  4877. /**
  4878. * Set the rotation matrix of the bone in local of world space
  4879. * @param rotMat The rotation matrix that the bone should be set to
  4880. * @param space The space that the rotation is in
  4881. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4882. */
  4883. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  4884. private _rotateWithMatrix(rmat, space?, mesh?);
  4885. private _getNegativeRotationToRef(rotMatInv, mesh?);
  4886. /**
  4887. * Get the position of the bone in local or world space
  4888. * @param space The space that the returned position is in
  4889. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4890. * @returns The position of the bone
  4891. */
  4892. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4893. /**
  4894. * Copy the position of the bone to a vector3 in local or world space
  4895. * @param space The space that the returned position is in
  4896. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4897. * @param result The vector3 to copy the position to
  4898. */
  4899. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  4900. /**
  4901. * Get the absolute position of the bone (world space)
  4902. * @param mesh The mesh that this bone is attached to
  4903. * @returns The absolute position of the bone
  4904. */
  4905. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  4906. /**
  4907. * Copy the absolute position of the bone (world space) to the result param
  4908. * @param mesh The mesh that this bone is attached to
  4909. * @param result The vector3 to copy the absolute position to
  4910. */
  4911. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  4912. /**
  4913. * Compute the absolute transforms of this bone and its children
  4914. */
  4915. computeAbsoluteTransforms(): void;
  4916. /**
  4917. * Get the world direction from an axis that is in the local space of the bone
  4918. * @param localAxis The local direction that is used to compute the world direction
  4919. * @param mesh The mesh that this bone is attached to
  4920. * @returns The world direction
  4921. */
  4922. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4923. /**
  4924. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  4925. * @param localAxis The local direction that is used to compute the world direction
  4926. * @param mesh The mesh that this bone is attached to
  4927. * @param result The vector3 that the world direction will be copied to
  4928. */
  4929. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4930. /**
  4931. * Get the euler rotation of the bone in local or world space
  4932. * @param space The space that the rotation should be in
  4933. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4934. * @returns The euler rotation
  4935. */
  4936. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4937. /**
  4938. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  4939. * @param space The space that the rotation should be in
  4940. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4941. * @param result The vector3 that the rotation should be copied to
  4942. */
  4943. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4944. /**
  4945. * Get the quaternion rotation of the bone in either local or world space
  4946. * @param space The space that the rotation should be in
  4947. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4948. * @returns The quaternion rotation
  4949. */
  4950. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4951. /**
  4952. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  4953. * @param space The space that the rotation should be in
  4954. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4955. * @param result The quaternion that the rotation should be copied to
  4956. */
  4957. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4958. /**
  4959. * Get the rotation matrix of the bone in local or world space
  4960. * @param space The space that the rotation should be in
  4961. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4962. * @returns The rotation matrix
  4963. */
  4964. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4965. /**
  4966. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  4967. * @param space The space that the rotation should be in
  4968. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4969. * @param result The quaternion that the rotation should be copied to
  4970. */
  4971. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4972. /**
  4973. * Get the world position of a point that is in the local space of the bone
  4974. * @param position The local position
  4975. * @param mesh The mesh that this bone is attached to
  4976. * @returns The world position
  4977. */
  4978. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4979. /**
  4980. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  4981. * @param position The local position
  4982. * @param mesh The mesh that this bone is attached to
  4983. * @param result The vector3 that the world position should be copied to
  4984. */
  4985. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4986. /**
  4987. * Get the local position of a point that is in world space
  4988. * @param position The world position
  4989. * @param mesh The mesh that this bone is attached to
  4990. * @returns The local position
  4991. */
  4992. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4993. /**
  4994. * Get the local position of a point that is in world space and copy it to the result param
  4995. * @param position The world position
  4996. * @param mesh The mesh that this bone is attached to
  4997. * @param result The vector3 that the local position should be copied to
  4998. */
  4999. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5000. }
  5001. }
  5002. declare module BABYLON {
  5003. /**
  5004. * Class used to apply inverse kinematics to bones
  5005. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5006. */
  5007. class BoneIKController {
  5008. private static _tmpVecs;
  5009. private static _tmpQuat;
  5010. private static _tmpMats;
  5011. /**
  5012. * Gets or sets the target mesh
  5013. */
  5014. targetMesh: AbstractMesh;
  5015. /** Gets or sets the mesh used as pole */
  5016. poleTargetMesh: AbstractMesh;
  5017. /**
  5018. * Gets or sets the bone used as pole
  5019. */
  5020. poleTargetBone: Nullable<Bone>;
  5021. /**
  5022. * Gets or sets the target position
  5023. */
  5024. targetPosition: Vector3;
  5025. /**
  5026. * Gets or sets the pole target position
  5027. */
  5028. poleTargetPosition: Vector3;
  5029. /**
  5030. * Gets or sets the pole target local offset
  5031. */
  5032. poleTargetLocalOffset: Vector3;
  5033. /**
  5034. * Gets or sets the pole angle
  5035. */
  5036. poleAngle: number;
  5037. /**
  5038. * Gets or sets the mesh associated with the controller
  5039. */
  5040. mesh: AbstractMesh;
  5041. /**
  5042. * 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)
  5043. */
  5044. slerpAmount: number;
  5045. private _bone1Quat;
  5046. private _bone1Mat;
  5047. private _bone2Ang;
  5048. private _bone1;
  5049. private _bone2;
  5050. private _bone1Length;
  5051. private _bone2Length;
  5052. private _maxAngle;
  5053. private _maxReach;
  5054. private _rightHandedSystem;
  5055. private _bendAxis;
  5056. private _slerping;
  5057. private _adjustRoll;
  5058. /**
  5059. * Gets or sets maximum allowed angle
  5060. */
  5061. maxAngle: number;
  5062. /**
  5063. * Creates a new BoneIKController
  5064. * @param mesh defines the mesh to control
  5065. * @param bone defines the bone to control
  5066. * @param options defines options to set up the controller
  5067. */
  5068. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5069. targetMesh?: AbstractMesh;
  5070. poleTargetMesh?: AbstractMesh;
  5071. poleTargetBone?: Bone;
  5072. poleTargetLocalOffset?: Vector3;
  5073. poleAngle?: number;
  5074. bendAxis?: Vector3;
  5075. maxAngle?: number;
  5076. slerpAmount?: number;
  5077. });
  5078. private _setMaxAngle(ang);
  5079. /**
  5080. * Force the controller to update the bones
  5081. */
  5082. update(): void;
  5083. }
  5084. }
  5085. declare module BABYLON {
  5086. /**
  5087. * Class used to make a bone look toward a point in space
  5088. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5089. */
  5090. class BoneLookController {
  5091. private static _tmpVecs;
  5092. private static _tmpQuat;
  5093. private static _tmpMats;
  5094. /**
  5095. * The target Vector3 that the bone will look at
  5096. */
  5097. target: Vector3;
  5098. /**
  5099. * The mesh that the bone is attached to
  5100. */
  5101. mesh: AbstractMesh;
  5102. /**
  5103. * The bone that will be looking to the target
  5104. */
  5105. bone: Bone;
  5106. /**
  5107. * The up axis of the coordinate system that is used when the bone is rotated
  5108. */
  5109. upAxis: Vector3;
  5110. /**
  5111. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5112. */
  5113. upAxisSpace: Space;
  5114. /**
  5115. * Used to make an adjustment to the yaw of the bone
  5116. */
  5117. adjustYaw: number;
  5118. /**
  5119. * Used to make an adjustment to the pitch of the bone
  5120. */
  5121. adjustPitch: number;
  5122. /**
  5123. * Used to make an adjustment to the roll of the bone
  5124. */
  5125. adjustRoll: number;
  5126. /**
  5127. * 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)
  5128. */
  5129. slerpAmount: number;
  5130. private _minYaw;
  5131. private _maxYaw;
  5132. private _minPitch;
  5133. private _maxPitch;
  5134. private _minYawSin;
  5135. private _minYawCos;
  5136. private _maxYawSin;
  5137. private _maxYawCos;
  5138. private _midYawConstraint;
  5139. private _minPitchTan;
  5140. private _maxPitchTan;
  5141. private _boneQuat;
  5142. private _slerping;
  5143. private _transformYawPitch;
  5144. private _transformYawPitchInv;
  5145. private _firstFrameSkipped;
  5146. private _yawRange;
  5147. private _fowardAxis;
  5148. /**
  5149. * Gets or sets the minimum yaw angle that the bone can look to
  5150. */
  5151. minYaw: number;
  5152. /**
  5153. * Gets or sets the maximum yaw angle that the bone can look to
  5154. */
  5155. maxYaw: number;
  5156. /**
  5157. * Gets or sets the minimum pitch angle that the bone can look to
  5158. */
  5159. minPitch: number;
  5160. /**
  5161. * Gets or sets the maximum pitch angle that the bone can look to
  5162. */
  5163. maxPitch: number;
  5164. /**
  5165. * Create a BoneLookController
  5166. * @param mesh the mesh that the bone belongs to
  5167. * @param bone the bone that will be looking to the target
  5168. * @param target the target Vector3 to look at
  5169. * @param settings optional settings:
  5170. * * maxYaw: the maximum angle the bone will yaw to
  5171. * * minYaw: the minimum angle the bone will yaw to
  5172. * * maxPitch: the maximum angle the bone will pitch to
  5173. * * minPitch: the minimum angle the bone will yaw to
  5174. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5175. * * upAxis: the up axis of the coordinate system
  5176. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5177. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5178. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5179. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5180. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5181. * * adjustRoll: used to make an adjustment to the roll of the bone
  5182. **/
  5183. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5184. maxYaw?: number;
  5185. minYaw?: number;
  5186. maxPitch?: number;
  5187. minPitch?: number;
  5188. slerpAmount?: number;
  5189. upAxis?: Vector3;
  5190. upAxisSpace?: Space;
  5191. yawAxis?: Vector3;
  5192. pitchAxis?: Vector3;
  5193. adjustYaw?: number;
  5194. adjustPitch?: number;
  5195. adjustRoll?: number;
  5196. });
  5197. /**
  5198. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5199. */
  5200. update(): void;
  5201. private _getAngleDiff(ang1, ang2);
  5202. private _getAngleBetween(ang1, ang2);
  5203. private _isAngleBetween(ang, ang1, ang2);
  5204. }
  5205. }
  5206. declare module BABYLON {
  5207. /**
  5208. * Class used to handle skinning animations
  5209. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5210. */
  5211. class Skeleton implements IAnimatable {
  5212. /** defines the skeleton name */
  5213. name: string;
  5214. /** defines the skeleton Id */
  5215. id: string;
  5216. /**
  5217. * Gets the list of child bones
  5218. */
  5219. bones: Bone[];
  5220. /**
  5221. * Gets an estimate of the dimension of the skeleton at rest
  5222. */
  5223. dimensionsAtRest: Vector3;
  5224. /**
  5225. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5226. */
  5227. needInitialSkinMatrix: boolean;
  5228. /**
  5229. * Gets the list of animations attached to this skeleton
  5230. */
  5231. animations: Array<Animation>;
  5232. private _scene;
  5233. private _isDirty;
  5234. private _transformMatrices;
  5235. private _meshesWithPoseMatrix;
  5236. private _animatables;
  5237. private _identity;
  5238. private _synchronizedWithMesh;
  5239. private _ranges;
  5240. private _lastAbsoluteTransformsUpdateId;
  5241. /**
  5242. * Specifies if the skeleton should be serialized
  5243. */
  5244. doNotSerialize: boolean;
  5245. private _animationPropertiesOverride;
  5246. /**
  5247. * Gets or sets the animation properties override
  5248. */
  5249. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5250. /**
  5251. * An observable triggered before computing the skeleton's matrices
  5252. */
  5253. onBeforeComputeObservable: Observable<Skeleton>;
  5254. /**
  5255. * Creates a new skeleton
  5256. * @param name defines the skeleton name
  5257. * @param id defines the skeleton Id
  5258. * @param scene defines the hosting scene
  5259. */
  5260. constructor(
  5261. /** defines the skeleton name */
  5262. name: string,
  5263. /** defines the skeleton Id */
  5264. id: string, scene: Scene);
  5265. /**
  5266. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5267. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5268. * @returns a Float32Array containing matrices data
  5269. */
  5270. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5271. /**
  5272. * Gets the current hosting scene
  5273. * @returns a scene object
  5274. */
  5275. getScene(): Scene;
  5276. /**
  5277. * Gets a string representing the current skeleton data
  5278. * @param fullDetails defines a boolean indicating if we want a verbose version
  5279. * @returns a string representing the current skeleton data
  5280. */
  5281. toString(fullDetails?: boolean): string;
  5282. /**
  5283. * Get bone's index searching by name
  5284. * @param name defines bone's name to search for
  5285. * @return the indice of the bone. Returns -1 if not found
  5286. */
  5287. getBoneIndexByName(name: string): number;
  5288. /**
  5289. * Creater a new animation range
  5290. * @param name defines the name of the range
  5291. * @param from defines the start key
  5292. * @param to defines the end key
  5293. */
  5294. createAnimationRange(name: string, from: number, to: number): void;
  5295. /**
  5296. * Delete a specific animation range
  5297. * @param name defines the name of the range
  5298. * @param deleteFrames defines if frames must be removed as well
  5299. */
  5300. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5301. /**
  5302. * Gets a specific animation range
  5303. * @param name defines the name of the range to look for
  5304. * @returns the requested animation range or null if not found
  5305. */
  5306. getAnimationRange(name: string): Nullable<AnimationRange>;
  5307. /**
  5308. * Gets the list of all animation ranges defined on this skeleton
  5309. * @returns an array
  5310. */
  5311. getAnimationRanges(): Nullable<AnimationRange>[];
  5312. /**
  5313. * Copy animation range from a source skeleton.
  5314. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5315. * @param source defines the source skeleton
  5316. * @param name defines the name of the range to copy
  5317. * @param rescaleAsRequired defines if rescaling must be applied if required
  5318. * @returns true if operation was successful
  5319. */
  5320. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5321. /**
  5322. * Forces the skeleton to go to rest pose
  5323. */
  5324. returnToRest(): void;
  5325. private _getHighestAnimationFrame();
  5326. /**
  5327. * Begin a specific animation range
  5328. * @param name defines the name of the range to start
  5329. * @param loop defines if looping must be turned on (false by default)
  5330. * @param speedRatio defines the speed ratio to apply (1 by default)
  5331. * @param onAnimationEnd defines a callback which will be called when animation will end
  5332. * @returns a new animatable
  5333. */
  5334. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5335. /** @hidden */
  5336. _markAsDirty(): void;
  5337. /** @hidden */
  5338. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5339. /** @hidden */
  5340. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5341. /** @hidden */
  5342. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5343. /**
  5344. * Build all resources required to render a skeleton
  5345. */
  5346. prepare(): void;
  5347. /**
  5348. * Gets the list of animatables currently running for this skeleton
  5349. * @returns an array of animatables
  5350. */
  5351. getAnimatables(): IAnimatable[];
  5352. /**
  5353. * Clone the current skeleton
  5354. * @param name defines the name of the new skeleton
  5355. * @param id defines the id of the enw skeleton
  5356. * @returns the new skeleton
  5357. */
  5358. clone(name: string, id: string): Skeleton;
  5359. /**
  5360. * Enable animation blending for this skeleton
  5361. * @param blendingSpeed defines the blending speed to apply
  5362. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5363. */
  5364. enableBlending(blendingSpeed?: number): void;
  5365. /**
  5366. * Releases all resources associated with the current skeleton
  5367. */
  5368. dispose(): void;
  5369. /**
  5370. * Serialize the skeleton in a JSON object
  5371. * @returns a JSON object
  5372. */
  5373. serialize(): any;
  5374. /**
  5375. * Creates a new skeleton from serialized data
  5376. * @param parsedSkeleton defines the serialized data
  5377. * @param scene defines the hosting scene
  5378. * @returns a new skeleton
  5379. */
  5380. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5381. /**
  5382. * Compute all node absolute transforms
  5383. * @param forceUpdate defines if computation must be done even if cache is up to date
  5384. */
  5385. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5386. /**
  5387. * Gets the root pose matrix
  5388. * @returns a matrix
  5389. */
  5390. getPoseMatrix(): Nullable<Matrix>;
  5391. /**
  5392. * Sorts bones per internal index
  5393. */
  5394. sortBones(): void;
  5395. private _sortBones(index, bones, visited);
  5396. }
  5397. }
  5398. declare module BABYLON {
  5399. class Collider {
  5400. /** Define if a collision was found */
  5401. collisionFound: boolean;
  5402. /**
  5403. * Define last intersection point in local space
  5404. */
  5405. intersectionPoint: Vector3;
  5406. /**
  5407. * Define last collided mesh
  5408. */
  5409. collidedMesh: Nullable<AbstractMesh>;
  5410. private _collisionPoint;
  5411. private _planeIntersectionPoint;
  5412. private _tempVector;
  5413. private _tempVector2;
  5414. private _tempVector3;
  5415. private _tempVector4;
  5416. private _edge;
  5417. private _baseToVertex;
  5418. private _destinationPoint;
  5419. private _slidePlaneNormal;
  5420. private _displacementVector;
  5421. _radius: Vector3;
  5422. _retry: number;
  5423. private _velocity;
  5424. private _basePoint;
  5425. private _epsilon;
  5426. _velocityWorldLength: number;
  5427. _basePointWorld: Vector3;
  5428. private _velocityWorld;
  5429. private _normalizedVelocity;
  5430. _initialVelocity: Vector3;
  5431. _initialPosition: Vector3;
  5432. private _nearestDistance;
  5433. private _collisionMask;
  5434. collisionMask: number;
  5435. /**
  5436. * Gets the plane normal used to compute the sliding response (in local space)
  5437. */
  5438. readonly slidePlaneNormal: Vector3;
  5439. _initialize(source: Vector3, dir: Vector3, e: number): void;
  5440. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  5441. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  5442. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  5443. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  5444. _getResponse(pos: Vector3, vel: Vector3): void;
  5445. }
  5446. }
  5447. declare module BABYLON {
  5448. var CollisionWorker: string;
  5449. interface ICollisionCoordinator {
  5450. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5451. init(scene: Scene): void;
  5452. destroy(): void;
  5453. onMeshAdded(mesh: AbstractMesh): void;
  5454. onMeshUpdated(mesh: AbstractMesh): void;
  5455. onMeshRemoved(mesh: AbstractMesh): void;
  5456. onGeometryAdded(geometry: Geometry): void;
  5457. onGeometryUpdated(geometry: Geometry): void;
  5458. onGeometryDeleted(geometry: Geometry): void;
  5459. }
  5460. interface SerializedMesh {
  5461. id: string;
  5462. name: string;
  5463. uniqueId: number;
  5464. geometryId: Nullable<string>;
  5465. sphereCenter: Array<number>;
  5466. sphereRadius: number;
  5467. boxMinimum: Array<number>;
  5468. boxMaximum: Array<number>;
  5469. worldMatrixFromCache: any;
  5470. subMeshes: Array<SerializedSubMesh>;
  5471. checkCollisions: boolean;
  5472. }
  5473. interface SerializedSubMesh {
  5474. position: number;
  5475. verticesStart: number;
  5476. verticesCount: number;
  5477. indexStart: number;
  5478. indexCount: number;
  5479. hasMaterial: boolean;
  5480. sphereCenter: Array<number>;
  5481. sphereRadius: number;
  5482. boxMinimum: Array<number>;
  5483. boxMaximum: Array<number>;
  5484. }
  5485. /**
  5486. * Interface describing the value associated with a geometry
  5487. */
  5488. interface SerializedGeometry {
  5489. /**
  5490. * Defines the unique ID of the geometry
  5491. */
  5492. id: string;
  5493. /**
  5494. * Defines the array containing the positions
  5495. */
  5496. positions: Float32Array;
  5497. /**
  5498. * Defines the array containing the indices
  5499. */
  5500. indices: Uint32Array;
  5501. /**
  5502. * Defines the array containing the normals
  5503. */
  5504. normals: Float32Array;
  5505. }
  5506. interface BabylonMessage {
  5507. taskType: WorkerTaskType;
  5508. payload: InitPayload | CollidePayload | UpdatePayload;
  5509. }
  5510. interface SerializedColliderToWorker {
  5511. position: Array<number>;
  5512. velocity: Array<number>;
  5513. radius: Array<number>;
  5514. }
  5515. /** Defines supported task for worker process */
  5516. enum WorkerTaskType {
  5517. /** Initialization */
  5518. INIT = 0,
  5519. /** Update of geometry */
  5520. UPDATE = 1,
  5521. /** Evaluate collision */
  5522. COLLIDE = 2,
  5523. }
  5524. interface WorkerReply {
  5525. error: WorkerReplyType;
  5526. taskType: WorkerTaskType;
  5527. payload?: any;
  5528. }
  5529. interface CollisionReplyPayload {
  5530. newPosition: Array<number>;
  5531. collisionId: number;
  5532. collidedMeshUniqueId: number;
  5533. }
  5534. interface InitPayload {
  5535. }
  5536. interface CollidePayload {
  5537. collisionId: number;
  5538. collider: SerializedColliderToWorker;
  5539. maximumRetry: number;
  5540. excludedMeshUniqueId: Nullable<number>;
  5541. }
  5542. interface UpdatePayload {
  5543. updatedMeshes: {
  5544. [n: number]: SerializedMesh;
  5545. };
  5546. updatedGeometries: {
  5547. [s: string]: SerializedGeometry;
  5548. };
  5549. removedMeshes: Array<number>;
  5550. removedGeometries: Array<string>;
  5551. }
  5552. /** Defines kind of replies returned by worker */
  5553. enum WorkerReplyType {
  5554. /** Success */
  5555. SUCCESS = 0,
  5556. /** Unkown error */
  5557. UNKNOWN_ERROR = 1,
  5558. }
  5559. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5560. private _scene;
  5561. private _scaledPosition;
  5562. private _scaledVelocity;
  5563. private _collisionsCallbackArray;
  5564. private _init;
  5565. private _runningUpdated;
  5566. private _worker;
  5567. private _addUpdateMeshesList;
  5568. private _addUpdateGeometriesList;
  5569. private _toRemoveMeshesArray;
  5570. private _toRemoveGeometryArray;
  5571. constructor();
  5572. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5573. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5574. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5575. init(scene: Scene): void;
  5576. destroy(): void;
  5577. onMeshAdded(mesh: AbstractMesh): void;
  5578. onMeshUpdated: (transformNode: TransformNode) => void;
  5579. onMeshRemoved(mesh: AbstractMesh): void;
  5580. onGeometryAdded(geometry: Geometry): void;
  5581. onGeometryUpdated: (geometry: Geometry) => void;
  5582. onGeometryDeleted(geometry: Geometry): void;
  5583. private _afterRender;
  5584. private _onMessageFromWorker;
  5585. }
  5586. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5587. private _scene;
  5588. private _scaledPosition;
  5589. private _scaledVelocity;
  5590. private _finalPosition;
  5591. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5592. init(scene: Scene): void;
  5593. destroy(): void;
  5594. onMeshAdded(mesh: AbstractMesh): void;
  5595. onMeshUpdated(mesh: AbstractMesh): void;
  5596. onMeshRemoved(mesh: AbstractMesh): void;
  5597. onGeometryAdded(geometry: Geometry): void;
  5598. onGeometryUpdated(geometry: Geometry): void;
  5599. onGeometryDeleted(geometry: Geometry): void;
  5600. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5601. }
  5602. }
  5603. declare function importScripts(...urls: string[]): void;
  5604. declare const safePostMessage: any;
  5605. declare module BABYLON {
  5606. var WorkerIncluded: boolean;
  5607. class CollisionCache {
  5608. private _meshes;
  5609. private _geometries;
  5610. getMeshes(): {
  5611. [n: number]: SerializedMesh;
  5612. };
  5613. getGeometries(): {
  5614. [s: number]: SerializedGeometry;
  5615. };
  5616. getMesh(id: any): SerializedMesh;
  5617. addMesh(mesh: SerializedMesh): void;
  5618. removeMesh(uniqueId: number): void;
  5619. getGeometry(id: string): SerializedGeometry;
  5620. addGeometry(geometry: SerializedGeometry): void;
  5621. removeGeometry(id: string): void;
  5622. }
  5623. class CollideWorker {
  5624. collider: Collider;
  5625. private _collisionCache;
  5626. private finalPosition;
  5627. private collisionsScalingMatrix;
  5628. private collisionTranformationMatrix;
  5629. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5630. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5631. private checkCollision(mesh);
  5632. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5633. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5634. private checkSubmeshCollision(subMesh);
  5635. }
  5636. interface ICollisionDetector {
  5637. onInit(payload: InitPayload): void;
  5638. onUpdate(payload: UpdatePayload): void;
  5639. onCollision(payload: CollidePayload): void;
  5640. }
  5641. class CollisionDetectorTransferable implements ICollisionDetector {
  5642. private _collisionCache;
  5643. onInit(payload: InitPayload): void;
  5644. onUpdate(payload: UpdatePayload): void;
  5645. onCollision(payload: CollidePayload): void;
  5646. }
  5647. }
  5648. declare module BABYLON {
  5649. class IntersectionInfo {
  5650. bu: Nullable<number>;
  5651. bv: Nullable<number>;
  5652. distance: number;
  5653. faceId: number;
  5654. subMeshId: number;
  5655. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5656. }
  5657. /**
  5658. * Information about the result of picking within a scene
  5659. * See https://doc.babylonjs.com/babylon101/picking_collisions
  5660. */
  5661. class PickingInfo {
  5662. /**
  5663. * If the pick collided with an object
  5664. */
  5665. hit: boolean;
  5666. /**
  5667. * Distance away where the pick collided
  5668. */
  5669. distance: number;
  5670. /**
  5671. * The location of pick collision
  5672. */
  5673. pickedPoint: Nullable<Vector3>;
  5674. /**
  5675. * The mesh corrisponding the the pick collision
  5676. */
  5677. pickedMesh: Nullable<AbstractMesh>;
  5678. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  5679. bu: number;
  5680. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  5681. bv: number;
  5682. /** The id of the face on the mesh that was picked */
  5683. faceId: number;
  5684. /** Id of the the submesh that was picked */
  5685. subMeshId: number;
  5686. /** If a sprite was picked, this will be the sprite the pick collided with */
  5687. pickedSprite: Nullable<Sprite>;
  5688. /**
  5689. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  5690. */
  5691. originMesh: Nullable<AbstractMesh>;
  5692. /**
  5693. * The ray that was used to perform the picking.
  5694. */
  5695. ray: Nullable<Ray>;
  5696. /**
  5697. * Gets the normal corrispodning to the face the pick collided with
  5698. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  5699. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  5700. * @returns The normal corrispodning to the face the pick collided with
  5701. */
  5702. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5703. /**
  5704. * Gets the texture coordinates of where the pick occured
  5705. * @returns the vector containing the coordnates of the texture
  5706. */
  5707. getTextureCoordinates(): Nullable<Vector2>;
  5708. }
  5709. }
  5710. declare module BABYLON {
  5711. class BoundingBox implements ICullable {
  5712. vectors: Vector3[];
  5713. center: Vector3;
  5714. centerWorld: Vector3;
  5715. extendSize: Vector3;
  5716. extendSizeWorld: Vector3;
  5717. directions: Vector3[];
  5718. vectorsWorld: Vector3[];
  5719. minimumWorld: Vector3;
  5720. maximumWorld: Vector3;
  5721. minimum: Vector3;
  5722. maximum: Vector3;
  5723. private _worldMatrix;
  5724. /**
  5725. * Creates a new bounding box
  5726. * @param min defines the minimum vector (in local space)
  5727. * @param max defines the maximum vector (in local space)
  5728. */
  5729. constructor(min: Vector3, max: Vector3);
  5730. /**
  5731. * Recreates the entire bounding box from scratch
  5732. * @param min defines the new minimum vector (in local space)
  5733. * @param max defines the new maximum vector (in local space)
  5734. */
  5735. reConstruct(min: Vector3, max: Vector3): void;
  5736. getWorldMatrix(): Matrix;
  5737. setWorldMatrix(matrix: Matrix): BoundingBox;
  5738. _update(world: Matrix): void;
  5739. isInFrustum(frustumPlanes: Plane[]): boolean;
  5740. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5741. intersectsPoint(point: Vector3): boolean;
  5742. intersectsSphere(sphere: BoundingSphere): boolean;
  5743. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  5744. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  5745. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  5746. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5747. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5748. }
  5749. }
  5750. declare module BABYLON {
  5751. interface ICullable {
  5752. isInFrustum(frustumPlanes: Plane[]): boolean;
  5753. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5754. }
  5755. class BoundingInfo implements ICullable {
  5756. minimum: Vector3;
  5757. maximum: Vector3;
  5758. boundingBox: BoundingBox;
  5759. boundingSphere: BoundingSphere;
  5760. private _isLocked;
  5761. constructor(minimum: Vector3, maximum: Vector3);
  5762. isLocked: boolean;
  5763. update(world: Matrix): void;
  5764. /**
  5765. * Recreate the bounding info to be centered around a specific point given a specific extend.
  5766. * @param center New center of the bounding info
  5767. * @param extend New extend of the bounding info
  5768. */
  5769. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  5770. isInFrustum(frustumPlanes: Plane[]): boolean;
  5771. /**
  5772. * Gets the world distance between the min and max points of the bounding box
  5773. */
  5774. readonly diagonalLength: number;
  5775. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5776. _checkCollision(collider: Collider): boolean;
  5777. intersectsPoint(point: Vector3): boolean;
  5778. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  5779. }
  5780. }
  5781. declare module BABYLON {
  5782. class BoundingSphere {
  5783. center: Vector3;
  5784. radius: number;
  5785. centerWorld: Vector3;
  5786. radiusWorld: number;
  5787. minimum: Vector3;
  5788. maximum: Vector3;
  5789. private _tempRadiusVector;
  5790. /**
  5791. * Creates a new bounding sphere
  5792. * @param min defines the minimum vector (in local space)
  5793. * @param max defines the maximum vector (in local space)
  5794. */
  5795. constructor(min: Vector3, max: Vector3);
  5796. /**
  5797. * Recreates the entire bounding sphere from scratch
  5798. * @param min defines the new minimum vector (in local space)
  5799. * @param max defines the new maximum vector (in local space)
  5800. */
  5801. reConstruct(min: Vector3, max: Vector3): void;
  5802. _update(world: Matrix): void;
  5803. isInFrustum(frustumPlanes: Plane[]): boolean;
  5804. intersectsPoint(point: Vector3): boolean;
  5805. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  5806. }
  5807. }
  5808. declare module BABYLON {
  5809. class Ray {
  5810. origin: Vector3;
  5811. direction: Vector3;
  5812. length: number;
  5813. private _edge1;
  5814. private _edge2;
  5815. private _pvec;
  5816. private _tvec;
  5817. private _qvec;
  5818. private _tmpRay;
  5819. constructor(origin: Vector3, direction: Vector3, length?: number);
  5820. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  5821. intersectsBox(box: BoundingBox): boolean;
  5822. intersectsSphere(sphere: BoundingSphere): boolean;
  5823. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  5824. intersectsPlane(plane: Plane): Nullable<number>;
  5825. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  5826. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  5827. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  5828. private static smallnum;
  5829. private static rayl;
  5830. /**
  5831. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  5832. * @param sega the first point of the segment to test the intersection against
  5833. * @param segb the second point of the segment to test the intersection against
  5834. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  5835. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  5836. */
  5837. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  5838. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5839. static Zero(): Ray;
  5840. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5841. /**
  5842. * 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
  5843. * transformed to the given world matrix.
  5844. * @param origin The origin point
  5845. * @param end The end point
  5846. * @param world a matrix to transform the ray to. Default is the identity matrix.
  5847. */
  5848. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  5849. static Transform(ray: Ray, matrix: Matrix): Ray;
  5850. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  5851. }
  5852. }
  5853. declare module BABYLON {
  5854. class ArcRotateCamera extends TargetCamera {
  5855. alpha: number;
  5856. beta: number;
  5857. radius: number;
  5858. protected _target: Vector3;
  5859. protected _targetHost: Nullable<AbstractMesh>;
  5860. target: Vector3;
  5861. inertialAlphaOffset: number;
  5862. inertialBetaOffset: number;
  5863. inertialRadiusOffset: number;
  5864. lowerAlphaLimit: Nullable<number>;
  5865. upperAlphaLimit: Nullable<number>;
  5866. lowerBetaLimit: number;
  5867. upperBetaLimit: number;
  5868. lowerRadiusLimit: Nullable<number>;
  5869. upperRadiusLimit: Nullable<number>;
  5870. inertialPanningX: number;
  5871. inertialPanningY: number;
  5872. pinchToPanMaxDistance: number;
  5873. panningDistanceLimit: Nullable<number>;
  5874. panningOriginTarget: Vector3;
  5875. panningInertia: number;
  5876. angularSensibilityX: number;
  5877. angularSensibilityY: number;
  5878. pinchPrecision: number;
  5879. pinchDeltaPercentage: number;
  5880. panningSensibility: number;
  5881. keysUp: number[];
  5882. keysDown: number[];
  5883. keysLeft: number[];
  5884. keysRight: number[];
  5885. wheelPrecision: number;
  5886. wheelDeltaPercentage: number;
  5887. zoomOnFactor: number;
  5888. targetScreenOffset: Vector2;
  5889. allowUpsideDown: boolean;
  5890. _viewMatrix: Matrix;
  5891. _useCtrlForPanning: boolean;
  5892. _panningMouseButton: number;
  5893. inputs: ArcRotateCameraInputsManager;
  5894. _reset: () => void;
  5895. panningAxis: Vector3;
  5896. protected _localDirection: Vector3;
  5897. protected _transformedDirection: Vector3;
  5898. private _bouncingBehavior;
  5899. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5900. useBouncingBehavior: boolean;
  5901. private _framingBehavior;
  5902. readonly framingBehavior: Nullable<FramingBehavior>;
  5903. useFramingBehavior: boolean;
  5904. private _autoRotationBehavior;
  5905. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5906. useAutoRotationBehavior: boolean;
  5907. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5908. onCollide: (collidedMesh: AbstractMesh) => void;
  5909. checkCollisions: boolean;
  5910. collisionRadius: Vector3;
  5911. protected _collider: Collider;
  5912. protected _previousPosition: Vector3;
  5913. protected _collisionVelocity: Vector3;
  5914. protected _newPosition: Vector3;
  5915. protected _previousAlpha: number;
  5916. protected _previousBeta: number;
  5917. protected _previousRadius: number;
  5918. protected _collisionTriggered: boolean;
  5919. protected _targetBoundingCenter: Nullable<Vector3>;
  5920. private _computationVector;
  5921. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5922. _initCache(): void;
  5923. _updateCache(ignoreParentClass?: boolean): void;
  5924. protected _getTargetPosition(): Vector3;
  5925. /**
  5926. * Store current camera state (fov, position, etc..)
  5927. */
  5928. private _storedAlpha;
  5929. private _storedBeta;
  5930. private _storedRadius;
  5931. private _storedTarget;
  5932. storeState(): Camera;
  5933. /**
  5934. * Restored camera state. You must call storeState() first
  5935. */
  5936. _restoreStateValues(): boolean;
  5937. _isSynchronizedViewMatrix(): boolean;
  5938. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5939. detachControl(element: HTMLElement): void;
  5940. _checkInputs(): void;
  5941. protected _checkLimits(): void;
  5942. rebuildAnglesAndRadius(): void;
  5943. setPosition(position: Vector3): void;
  5944. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5945. _getViewMatrix(): Matrix;
  5946. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5947. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5948. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5949. min: Vector3;
  5950. max: Vector3;
  5951. distance: number;
  5952. }, doNotUpdateMaxZ?: boolean): void;
  5953. /**
  5954. * @override
  5955. * Override Camera.createRigCamera
  5956. */
  5957. createRigCamera(name: string, cameraIndex: number): Camera;
  5958. /**
  5959. * @override
  5960. * Override Camera._updateRigCameras
  5961. */
  5962. _updateRigCameras(): void;
  5963. dispose(): void;
  5964. getClassName(): string;
  5965. }
  5966. }
  5967. declare module BABYLON {
  5968. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5969. constructor(camera: ArcRotateCamera);
  5970. addMouseWheel(): ArcRotateCameraInputsManager;
  5971. addPointers(): ArcRotateCameraInputsManager;
  5972. addKeyboard(): ArcRotateCameraInputsManager;
  5973. addGamepad(): ArcRotateCameraInputsManager;
  5974. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5975. }
  5976. }
  5977. declare module BABYLON {
  5978. class Camera extends Node {
  5979. inputs: CameraInputsManager<Camera>;
  5980. private static _PERSPECTIVE_CAMERA;
  5981. private static _ORTHOGRAPHIC_CAMERA;
  5982. private static _FOVMODE_VERTICAL_FIXED;
  5983. private static _FOVMODE_HORIZONTAL_FIXED;
  5984. private static _RIG_MODE_NONE;
  5985. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5986. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5987. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5988. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5989. private static _RIG_MODE_VR;
  5990. private static _RIG_MODE_WEBVR;
  5991. static readonly PERSPECTIVE_CAMERA: number;
  5992. static readonly ORTHOGRAPHIC_CAMERA: number;
  5993. /**
  5994. * This is the default FOV mode for perspective cameras.
  5995. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5996. *
  5997. */
  5998. static readonly FOVMODE_VERTICAL_FIXED: number;
  5999. /**
  6000. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  6001. *
  6002. */
  6003. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  6004. static readonly RIG_MODE_NONE: number;
  6005. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  6006. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  6007. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  6008. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  6009. static readonly RIG_MODE_VR: number;
  6010. static readonly RIG_MODE_WEBVR: number;
  6011. static ForceAttachControlToAlwaysPreventDefault: boolean;
  6012. static UseAlternateWebVRRendering: boolean;
  6013. position: Vector3;
  6014. /**
  6015. * The vector the camera should consider as up.
  6016. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  6017. */
  6018. upVector: Vector3;
  6019. orthoLeft: Nullable<number>;
  6020. orthoRight: Nullable<number>;
  6021. orthoBottom: Nullable<number>;
  6022. orthoTop: Nullable<number>;
  6023. /**
  6024. * FOV is set in Radians. (default is 0.8)
  6025. */
  6026. fov: number;
  6027. minZ: number;
  6028. maxZ: number;
  6029. inertia: number;
  6030. mode: number;
  6031. isIntermediate: boolean;
  6032. viewport: Viewport;
  6033. /**
  6034. * Restricts the camera to viewing objects with the same layerMask.
  6035. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  6036. */
  6037. layerMask: number;
  6038. /**
  6039. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  6040. */
  6041. fovMode: number;
  6042. cameraRigMode: number;
  6043. interaxialDistance: number;
  6044. isStereoscopicSideBySide: boolean;
  6045. _cameraRigParams: any;
  6046. _rigCameras: Camera[];
  6047. _rigPostProcess: Nullable<PostProcess>;
  6048. protected _webvrViewMatrix: Matrix;
  6049. _skipRendering: boolean;
  6050. _alternateCamera: Camera;
  6051. customRenderTargets: RenderTargetTexture[];
  6052. onViewMatrixChangedObservable: Observable<Camera>;
  6053. onProjectionMatrixChangedObservable: Observable<Camera>;
  6054. onAfterCheckInputsObservable: Observable<Camera>;
  6055. onRestoreStateObservable: Observable<Camera>;
  6056. private _computedViewMatrix;
  6057. _projectionMatrix: Matrix;
  6058. private _doNotComputeProjectionMatrix;
  6059. private _worldMatrix;
  6060. _postProcesses: Nullable<PostProcess>[];
  6061. private _transformMatrix;
  6062. _activeMeshes: SmartArray<AbstractMesh>;
  6063. protected _globalPosition: Vector3;
  6064. private _frustumPlanes;
  6065. private _refreshFrustumPlanes;
  6066. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6067. private _storedFov;
  6068. private _stateStored;
  6069. /**
  6070. * Store current camera state (fov, position, etc..)
  6071. */
  6072. storeState(): Camera;
  6073. /**
  6074. * Restores the camera state values if it has been stored. You must call storeState() first
  6075. */
  6076. protected _restoreStateValues(): boolean;
  6077. /**
  6078. * Restored camera state. You must call storeState() first
  6079. */
  6080. restoreState(): boolean;
  6081. getClassName(): string;
  6082. /**
  6083. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  6084. */
  6085. toString(fullDetails?: boolean): string;
  6086. readonly globalPosition: Vector3;
  6087. getActiveMeshes(): SmartArray<AbstractMesh>;
  6088. isActiveMesh(mesh: Mesh): boolean;
  6089. /**
  6090. * Is this camera ready to be used/rendered
  6091. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  6092. * @return true if the camera is ready
  6093. */
  6094. isReady(completeCheck?: boolean): boolean;
  6095. _initCache(): void;
  6096. _updateCache(ignoreParentClass?: boolean): void;
  6097. _isSynchronized(): boolean;
  6098. _isSynchronizedViewMatrix(): boolean;
  6099. _isSynchronizedProjectionMatrix(): boolean;
  6100. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6101. detachControl(element: HTMLElement): void;
  6102. update(): void;
  6103. _checkInputs(): void;
  6104. readonly rigCameras: Camera[];
  6105. readonly rigPostProcess: Nullable<PostProcess>;
  6106. /**
  6107. * Internal, gets the first post proces.
  6108. * @returns the first post process to be run on this camera.
  6109. */
  6110. _getFirstPostProcess(): Nullable<PostProcess>;
  6111. private _cascadePostProcessesToRigCams();
  6112. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  6113. detachPostProcess(postProcess: PostProcess): void;
  6114. getWorldMatrix(): Matrix;
  6115. _getViewMatrix(): Matrix;
  6116. getViewMatrix(force?: boolean): Matrix;
  6117. freezeProjectionMatrix(projection?: Matrix): void;
  6118. unfreezeProjectionMatrix(): void;
  6119. getProjectionMatrix(force?: boolean): Matrix;
  6120. getTranformationMatrix(): Matrix;
  6121. private updateFrustumPlanes();
  6122. isInFrustum(target: ICullable): boolean;
  6123. isCompletelyInFrustum(target: ICullable): boolean;
  6124. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  6125. /**
  6126. * Releases resources associated with this node.
  6127. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  6128. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  6129. */
  6130. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  6131. readonly leftCamera: Nullable<FreeCamera>;
  6132. readonly rightCamera: Nullable<FreeCamera>;
  6133. getLeftTarget(): Nullable<Vector3>;
  6134. getRightTarget(): Nullable<Vector3>;
  6135. setCameraRigMode(mode: number, rigParams: any): void;
  6136. private _getVRProjectionMatrix();
  6137. protected _updateCameraRotationMatrix(): void;
  6138. protected _updateWebVRCameraRotationMatrix(): void;
  6139. /**
  6140. * This function MUST be overwritten by the different WebVR cameras available.
  6141. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6142. */
  6143. protected _getWebVRProjectionMatrix(): Matrix;
  6144. /**
  6145. * This function MUST be overwritten by the different WebVR cameras available.
  6146. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6147. */
  6148. protected _getWebVRViewMatrix(): Matrix;
  6149. setCameraRigParameter(name: string, value: any): void;
  6150. /**
  6151. * needs to be overridden by children so sub has required properties to be copied
  6152. */
  6153. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6154. /**
  6155. * May need to be overridden by children
  6156. */
  6157. _updateRigCameras(): void;
  6158. _setupInputs(): void;
  6159. serialize(): any;
  6160. clone(name: string): Camera;
  6161. getDirection(localAxis: Vector3): Vector3;
  6162. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  6163. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  6164. computeWorldMatrix(): Matrix;
  6165. static Parse(parsedCamera: any, scene: Scene): Camera;
  6166. }
  6167. }
  6168. declare module BABYLON {
  6169. var CameraInputTypes: {};
  6170. interface ICameraInput<TCamera extends Camera> {
  6171. camera: Nullable<TCamera>;
  6172. getClassName(): string;
  6173. getSimpleName(): string;
  6174. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  6175. detachControl: (element: Nullable<HTMLElement>) => void;
  6176. checkInputs?: () => void;
  6177. }
  6178. interface CameraInputsMap<TCamera extends Camera> {
  6179. [name: string]: ICameraInput<TCamera>;
  6180. [idx: number]: ICameraInput<TCamera>;
  6181. }
  6182. class CameraInputsManager<TCamera extends Camera> {
  6183. attached: CameraInputsMap<TCamera>;
  6184. attachedElement: Nullable<HTMLElement>;
  6185. noPreventDefault: boolean;
  6186. camera: TCamera;
  6187. checkInputs: () => void;
  6188. constructor(camera: TCamera);
  6189. /**
  6190. * Add an input method to a camera.
  6191. * builtin inputs example: camera.inputs.addGamepad();
  6192. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  6193. * @param input camera input method
  6194. */
  6195. add(input: ICameraInput<TCamera>): void;
  6196. /**
  6197. * Remove a specific input method from a camera
  6198. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6199. * @param inputToRemove camera input method
  6200. */
  6201. remove(inputToRemove: ICameraInput<TCamera>): void;
  6202. removeByType(inputType: string): void;
  6203. private _addCheckInputs(fn);
  6204. attachInput(input: ICameraInput<TCamera>): void;
  6205. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6206. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6207. rebuildInputCheck(): void;
  6208. /**
  6209. * Remove all attached input methods from a camera
  6210. */
  6211. clear(): void;
  6212. serialize(serializedCamera: any): void;
  6213. parse(parsedCamera: any): void;
  6214. }
  6215. }
  6216. declare module BABYLON {
  6217. /**
  6218. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  6219. * being tilted forward or back and left or right.
  6220. */
  6221. class DeviceOrientationCamera extends FreeCamera {
  6222. private _initialQuaternion;
  6223. private _quaternionCache;
  6224. /**
  6225. * Creates a new device orientation camera
  6226. * @param name The name of the camera
  6227. * @param position The start position camera
  6228. * @param scene The scene the camera belongs to
  6229. */
  6230. constructor(name: string, position: Vector3, scene: Scene);
  6231. /**
  6232. * Gets the current instance class name ("DeviceOrientationCamera").
  6233. * This helps avoiding instanceof at run time.
  6234. * @returns the class name
  6235. */
  6236. getClassName(): string;
  6237. /**
  6238. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6239. */
  6240. _checkInputs(): void;
  6241. /**
  6242. * Reset the camera to its default orientation on the specified axis only.
  6243. * @param axis The axis to reset
  6244. */
  6245. resetToCurrentRotation(axis?: Axis): void;
  6246. }
  6247. }
  6248. declare module BABYLON {
  6249. class FollowCamera extends TargetCamera {
  6250. radius: number;
  6251. rotationOffset: number;
  6252. heightOffset: number;
  6253. cameraAcceleration: number;
  6254. maxCameraSpeed: number;
  6255. lockedTarget: Nullable<AbstractMesh>;
  6256. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6257. private getRadians(degrees);
  6258. private follow(cameraTarget);
  6259. _checkInputs(): void;
  6260. getClassName(): string;
  6261. }
  6262. class ArcFollowCamera extends TargetCamera {
  6263. alpha: number;
  6264. beta: number;
  6265. radius: number;
  6266. target: Nullable<AbstractMesh>;
  6267. private _cartesianCoordinates;
  6268. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6269. private follow();
  6270. _checkInputs(): void;
  6271. getClassName(): string;
  6272. }
  6273. }
  6274. declare module BABYLON {
  6275. class FreeCamera extends TargetCamera {
  6276. ellipsoid: Vector3;
  6277. ellipsoidOffset: Vector3;
  6278. checkCollisions: boolean;
  6279. applyGravity: boolean;
  6280. inputs: FreeCameraInputsManager;
  6281. /**
  6282. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6283. * Higher values reduce sensitivity.
  6284. */
  6285. /**
  6286. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6287. * Higher values reduce sensitivity.
  6288. */
  6289. angularSensibility: number;
  6290. keysUp: number[];
  6291. keysDown: number[];
  6292. keysLeft: number[];
  6293. keysRight: number[];
  6294. onCollide: (collidedMesh: AbstractMesh) => void;
  6295. private _collider;
  6296. private _needMoveForGravity;
  6297. private _oldPosition;
  6298. private _diffPosition;
  6299. private _newPosition;
  6300. _localDirection: Vector3;
  6301. _transformedDirection: Vector3;
  6302. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6303. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6304. detachControl(element: HTMLElement): void;
  6305. private _collisionMask;
  6306. collisionMask: number;
  6307. _collideWithWorld(displacement: Vector3): void;
  6308. private _onCollisionPositionChange;
  6309. _checkInputs(): void;
  6310. _decideIfNeedsToMove(): boolean;
  6311. _updatePosition(): void;
  6312. dispose(): void;
  6313. getClassName(): string;
  6314. }
  6315. }
  6316. declare module BABYLON {
  6317. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6318. constructor(camera: FreeCamera);
  6319. addKeyboard(): FreeCameraInputsManager;
  6320. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6321. addGamepad(): FreeCameraInputsManager;
  6322. addDeviceOrientation(): FreeCameraInputsManager;
  6323. addTouch(): FreeCameraInputsManager;
  6324. addVirtualJoystick(): FreeCameraInputsManager;
  6325. }
  6326. }
  6327. declare module BABYLON {
  6328. class GamepadCamera extends UniversalCamera {
  6329. gamepadAngularSensibility: number;
  6330. gamepadMoveSensibility: number;
  6331. constructor(name: string, position: Vector3, scene: Scene);
  6332. getClassName(): string;
  6333. }
  6334. }
  6335. declare module BABYLON {
  6336. /**
  6337. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  6338. */
  6339. class AnaglyphFreeCamera extends FreeCamera {
  6340. /**
  6341. * Creates a new AnaglyphFreeCamera
  6342. * @param name defines camera name
  6343. * @param position defines initial position
  6344. * @param interaxialDistance defines distance between each color axis
  6345. * @param scene defines the hosting scene
  6346. */
  6347. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6348. /**
  6349. * Gets camera class name
  6350. * @returns AnaglyphFreeCamera
  6351. */
  6352. getClassName(): string;
  6353. }
  6354. /**
  6355. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  6356. */
  6357. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  6358. /**
  6359. * Creates a new AnaglyphArcRotateCamera
  6360. * @param name defines camera name
  6361. * @param alpha defines alpha angle (in radians)
  6362. * @param beta defines beta angle (in radians)
  6363. * @param radius defines radius
  6364. * @param target defines camera target
  6365. * @param interaxialDistance defines distance between each color axis
  6366. * @param scene defines the hosting scene
  6367. */
  6368. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  6369. /**
  6370. * Gets camera class name
  6371. * @returns AnaglyphArcRotateCamera
  6372. */
  6373. getClassName(): string;
  6374. }
  6375. /**
  6376. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  6377. */
  6378. class AnaglyphGamepadCamera extends GamepadCamera {
  6379. /**
  6380. * Creates a new AnaglyphGamepadCamera
  6381. * @param name defines camera name
  6382. * @param position defines initial position
  6383. * @param interaxialDistance defines distance between each color axis
  6384. * @param scene defines the hosting scene
  6385. */
  6386. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6387. /**
  6388. * Gets camera class name
  6389. * @returns AnaglyphGamepadCamera
  6390. */
  6391. getClassName(): string;
  6392. }
  6393. /**
  6394. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  6395. */
  6396. class AnaglyphUniversalCamera extends UniversalCamera {
  6397. /**
  6398. * Creates a new AnaglyphUniversalCamera
  6399. * @param name defines camera name
  6400. * @param position defines initial position
  6401. * @param interaxialDistance defines distance between each color axis
  6402. * @param scene defines the hosting scene
  6403. */
  6404. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6405. /**
  6406. * Gets camera class name
  6407. * @returns AnaglyphUniversalCamera
  6408. */
  6409. getClassName(): string;
  6410. }
  6411. /**
  6412. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  6413. */
  6414. class StereoscopicFreeCamera extends FreeCamera {
  6415. /**
  6416. * Creates a new StereoscopicFreeCamera
  6417. * @param name defines camera name
  6418. * @param position defines initial position
  6419. * @param interaxialDistance defines distance between each color axis
  6420. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6421. * @param scene defines the hosting scene
  6422. */
  6423. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6424. /**
  6425. * Gets camera class name
  6426. * @returns StereoscopicFreeCamera
  6427. */
  6428. getClassName(): string;
  6429. }
  6430. /**
  6431. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  6432. */
  6433. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  6434. /**
  6435. * Creates a new StereoscopicArcRotateCamera
  6436. * @param name defines camera name
  6437. * @param alpha defines alpha angle (in radians)
  6438. * @param beta defines beta angle (in radians)
  6439. * @param radius defines radius
  6440. * @param target defines camera target
  6441. * @param interaxialDistance defines distance between each color axis
  6442. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6443. * @param scene defines the hosting scene
  6444. */
  6445. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6446. /**
  6447. * Gets camera class name
  6448. * @returns StereoscopicArcRotateCamera
  6449. */
  6450. getClassName(): string;
  6451. }
  6452. /**
  6453. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  6454. */
  6455. class StereoscopicGamepadCamera extends GamepadCamera {
  6456. /**
  6457. * Creates a new StereoscopicGamepadCamera
  6458. * @param name defines camera name
  6459. * @param position defines initial position
  6460. * @param interaxialDistance defines distance between each color axis
  6461. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6462. * @param scene defines the hosting scene
  6463. */
  6464. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6465. /**
  6466. * Gets camera class name
  6467. * @returns StereoscopicGamepadCamera
  6468. */
  6469. getClassName(): string;
  6470. }
  6471. /**
  6472. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  6473. */
  6474. class StereoscopicUniversalCamera extends UniversalCamera {
  6475. /**
  6476. * Creates a new StereoscopicUniversalCamera
  6477. * @param name defines camera name
  6478. * @param position defines initial position
  6479. * @param interaxialDistance defines distance between each color axis
  6480. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6481. * @param scene defines the hosting scene
  6482. */
  6483. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6484. /**
  6485. * Gets camera class name
  6486. * @returns StereoscopicUniversalCamera
  6487. */
  6488. getClassName(): string;
  6489. }
  6490. }
  6491. declare module BABYLON {
  6492. class TargetCamera extends Camera {
  6493. cameraDirection: Vector3;
  6494. cameraRotation: Vector2;
  6495. rotation: Vector3;
  6496. rotationQuaternion: Quaternion;
  6497. speed: number;
  6498. noRotationConstraint: boolean;
  6499. lockedTarget: any;
  6500. _currentTarget: Vector3;
  6501. _viewMatrix: Matrix;
  6502. _camMatrix: Matrix;
  6503. _cameraTransformMatrix: Matrix;
  6504. _cameraRotationMatrix: Matrix;
  6505. private _rigCamTransformMatrix;
  6506. _referencePoint: Vector3;
  6507. private _currentUpVector;
  6508. _transformedReferencePoint: Vector3;
  6509. protected _globalCurrentTarget: Vector3;
  6510. protected _globalCurrentUpVector: Vector3;
  6511. _reset: () => void;
  6512. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6513. getFrontPosition(distance: number): Vector3;
  6514. _getLockedTargetPosition(): Nullable<Vector3>;
  6515. /**
  6516. * Store current camera state (fov, position, etc..)
  6517. */
  6518. private _storedPosition;
  6519. private _storedRotation;
  6520. private _storedRotationQuaternion;
  6521. storeState(): Camera;
  6522. /**
  6523. * Restored camera state. You must call storeState() first
  6524. */
  6525. _restoreStateValues(): boolean;
  6526. _initCache(): void;
  6527. _updateCache(ignoreParentClass?: boolean): void;
  6528. _isSynchronizedViewMatrix(): boolean;
  6529. _computeLocalCameraSpeed(): number;
  6530. setTarget(target: Vector3): void;
  6531. /**
  6532. * Return the current target position of the camera. This value is expressed in local space.
  6533. */
  6534. getTarget(): Vector3;
  6535. _decideIfNeedsToMove(): boolean;
  6536. _updatePosition(): void;
  6537. _checkInputs(): void;
  6538. protected _updateCameraRotationMatrix(): void;
  6539. _getViewMatrix(): Matrix;
  6540. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6541. /**
  6542. * @override
  6543. * Override Camera.createRigCamera
  6544. */
  6545. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6546. /**
  6547. * @override
  6548. * Override Camera._updateRigCameras
  6549. */
  6550. _updateRigCameras(): void;
  6551. private _getRigCamPosition(halfSpace, result);
  6552. getClassName(): string;
  6553. }
  6554. }
  6555. declare module BABYLON {
  6556. class TouchCamera extends FreeCamera {
  6557. touchAngularSensibility: number;
  6558. touchMoveSensibility: number;
  6559. constructor(name: string, position: Vector3, scene: Scene);
  6560. getClassName(): string;
  6561. _setupInputs(): void;
  6562. }
  6563. }
  6564. declare module BABYLON {
  6565. class UniversalCamera extends TouchCamera {
  6566. gamepadAngularSensibility: number;
  6567. gamepadMoveSensibility: number;
  6568. constructor(name: string, position: Vector3, scene: Scene);
  6569. getClassName(): string;
  6570. }
  6571. }
  6572. declare module BABYLON {
  6573. class VirtualJoysticksCamera extends FreeCamera {
  6574. constructor(name: string, position: Vector3, scene: Scene);
  6575. getClassName(): string;
  6576. }
  6577. }
  6578. interface VRDisplay extends EventTarget {
  6579. /**
  6580. * Dictionary of capabilities describing the VRDisplay.
  6581. */
  6582. readonly capabilities: VRDisplayCapabilities;
  6583. /**
  6584. * z-depth defining the far plane of the eye view frustum
  6585. * enables mapping of values in the render target depth
  6586. * attachment to scene coordinates. Initially set to 10000.0.
  6587. */
  6588. depthFar: number;
  6589. /**
  6590. * z-depth defining the near plane of the eye view frustum
  6591. * enables mapping of values in the render target depth
  6592. * attachment to scene coordinates. Initially set to 0.01.
  6593. */
  6594. depthNear: number;
  6595. /**
  6596. * An identifier for this distinct VRDisplay. Used as an
  6597. * association point in the Gamepad API.
  6598. */
  6599. readonly displayId: number;
  6600. /**
  6601. * A display name, a user-readable name identifying it.
  6602. */
  6603. readonly displayName: string;
  6604. readonly isConnected: boolean;
  6605. readonly isPresenting: boolean;
  6606. /**
  6607. * If this VRDisplay supports room-scale experiences, the optional
  6608. * stage attribute contains details on the room-scale parameters.
  6609. */
  6610. readonly stageParameters: VRStageParameters | null;
  6611. /**
  6612. * Passing the value returned by `requestAnimationFrame` to
  6613. * `cancelAnimationFrame` will unregister the callback.
  6614. */
  6615. cancelAnimationFrame(handle: number): void;
  6616. /**
  6617. * Stops presenting to the VRDisplay.
  6618. */
  6619. exitPresent(): Promise<void>;
  6620. getEyeParameters(whichEye: string): VREyeParameters;
  6621. /**
  6622. * Populates the passed VRFrameData with the information required to render
  6623. * the current frame.
  6624. */
  6625. getFrameData(frameData: VRFrameData): boolean;
  6626. /**
  6627. * Get the layers currently being presented.
  6628. */
  6629. getLayers(): VRLayer[];
  6630. /**
  6631. * Return a VRPose containing the future predicted pose of the VRDisplay
  6632. * when the current frame will be presented. The value returned will not
  6633. * change until JavaScript has returned control to the browser.
  6634. *
  6635. * The VRPose will contain the position, orientation, velocity,
  6636. * and acceleration of each of these properties.
  6637. */
  6638. getPose(): VRPose;
  6639. /**
  6640. * Return the current instantaneous pose of the VRDisplay, with no
  6641. * prediction applied.
  6642. */
  6643. getImmediatePose(): VRPose;
  6644. /**
  6645. * The callback passed to `requestAnimationFrame` will be called
  6646. * any time a new frame should be rendered. When the VRDisplay is
  6647. * presenting the callback will be called at the native refresh
  6648. * rate of the HMD. When not presenting this function acts
  6649. * identically to how window.requestAnimationFrame acts. Content should
  6650. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6651. * asynchronously from other displays and at differing refresh rates.
  6652. */
  6653. requestAnimationFrame(callback: FrameRequestCallback): number;
  6654. /**
  6655. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6656. * Repeat calls while already presenting will update the VRLayers being displayed.
  6657. */
  6658. requestPresent(layers: VRLayer[]): Promise<void>;
  6659. /**
  6660. * Reset the pose for this display, treating its current position and
  6661. * orientation as the "origin/zero" values. VRPose.position,
  6662. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6663. * updated when calling resetPose(). This should be called in only
  6664. * sitting-space experiences.
  6665. */
  6666. resetPose(): void;
  6667. /**
  6668. * The VRLayer provided to the VRDisplay will be captured and presented
  6669. * in the HMD. Calling this function has the same effect on the source
  6670. * canvas as any other operation that uses its source image, and canvases
  6671. * created without preserveDrawingBuffer set to true will be cleared.
  6672. */
  6673. submitFrame(pose?: VRPose): void;
  6674. }
  6675. declare var VRDisplay: {
  6676. prototype: VRDisplay;
  6677. new (): VRDisplay;
  6678. };
  6679. interface VRLayer {
  6680. leftBounds?: number[] | null;
  6681. rightBounds?: number[] | null;
  6682. source?: HTMLCanvasElement | null;
  6683. }
  6684. interface VRDisplayCapabilities {
  6685. readonly canPresent: boolean;
  6686. readonly hasExternalDisplay: boolean;
  6687. readonly hasOrientation: boolean;
  6688. readonly hasPosition: boolean;
  6689. readonly maxLayers: number;
  6690. }
  6691. interface VREyeParameters {
  6692. /** @deprecated */
  6693. readonly fieldOfView: VRFieldOfView;
  6694. readonly offset: Float32Array;
  6695. readonly renderHeight: number;
  6696. readonly renderWidth: number;
  6697. }
  6698. interface VRFieldOfView {
  6699. readonly downDegrees: number;
  6700. readonly leftDegrees: number;
  6701. readonly rightDegrees: number;
  6702. readonly upDegrees: number;
  6703. }
  6704. interface VRFrameData {
  6705. readonly leftProjectionMatrix: Float32Array;
  6706. readonly leftViewMatrix: Float32Array;
  6707. readonly pose: VRPose;
  6708. readonly rightProjectionMatrix: Float32Array;
  6709. readonly rightViewMatrix: Float32Array;
  6710. readonly timestamp: number;
  6711. }
  6712. interface VRPose {
  6713. readonly angularAcceleration: Float32Array | null;
  6714. readonly angularVelocity: Float32Array | null;
  6715. readonly linearAcceleration: Float32Array | null;
  6716. readonly linearVelocity: Float32Array | null;
  6717. readonly orientation: Float32Array | null;
  6718. readonly position: Float32Array | null;
  6719. readonly timestamp: number;
  6720. }
  6721. interface VRStageParameters {
  6722. sittingToStandingTransform?: Float32Array;
  6723. sizeX?: number;
  6724. sizeY?: number;
  6725. }
  6726. interface Navigator {
  6727. getVRDisplays(): Promise<VRDisplay[]>;
  6728. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6729. }
  6730. interface Window {
  6731. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6732. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6733. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6734. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6735. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6736. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6737. }
  6738. interface Gamepad {
  6739. readonly displayId: number;
  6740. }
  6741. /**
  6742. * Module Debug contains the (visual) components to debug a scene correctly
  6743. */
  6744. declare module BABYLON.Debug {
  6745. /**
  6746. * The Axes viewer will show 3 axes in a specific point in space
  6747. */
  6748. class AxesViewer {
  6749. private _xline;
  6750. private _yline;
  6751. private _zline;
  6752. private _xmesh;
  6753. private _ymesh;
  6754. private _zmesh;
  6755. /**
  6756. * Gets the hosting scene
  6757. */
  6758. scene: Nullable<Scene>;
  6759. /**
  6760. * Gets or sets a number used to scale line length
  6761. */
  6762. scaleLines: number;
  6763. /**
  6764. * Creates a new AxesViewer
  6765. * @param scene defines the hosting scene
  6766. * @param scaleLines defines a number used to scale line length (1 by default)
  6767. */
  6768. constructor(scene: Scene, scaleLines?: number);
  6769. /**
  6770. * Force the viewer to update
  6771. * @param position defines the position of the viewer
  6772. * @param xaxis defines the x axis of the viewer
  6773. * @param yaxis defines the y axis of the viewer
  6774. * @param zaxis defines the z axis of the viewer
  6775. */
  6776. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  6777. /** Releases resources */
  6778. dispose(): void;
  6779. }
  6780. }
  6781. declare module BABYLON.Debug {
  6782. /**
  6783. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  6784. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  6785. */
  6786. class BoneAxesViewer extends AxesViewer {
  6787. /**
  6788. * Gets or sets the target mesh where to display the axes viewer
  6789. */
  6790. mesh: Nullable<Mesh>;
  6791. /**
  6792. * Gets or sets the target bone where to display the axes viewer
  6793. */
  6794. bone: Nullable<Bone>;
  6795. /** Gets current position */
  6796. pos: Vector3;
  6797. /** Gets direction of X axis */
  6798. xaxis: Vector3;
  6799. /** Gets direction of Y axis */
  6800. yaxis: Vector3;
  6801. /** Gets direction of Z axis */
  6802. zaxis: Vector3;
  6803. /**
  6804. * Creates a new BoneAxesViewer
  6805. * @param scene defines the hosting scene
  6806. * @param bone defines the target bone
  6807. * @param mesh defines the target mesh
  6808. * @param scaleLines defines a scaling factor for line length (1 by default)
  6809. */
  6810. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  6811. /**
  6812. * Force the viewer to update
  6813. */
  6814. update(): void;
  6815. /** Releases resources */
  6816. dispose(): void;
  6817. }
  6818. }
  6819. declare module BABYLON {
  6820. class DebugLayer {
  6821. private _scene;
  6822. static InspectorURL: string;
  6823. private _inspector;
  6824. private BJSINSPECTOR;
  6825. onPropertyChangedObservable: BABYLON.Observable<{
  6826. object: any;
  6827. property: string;
  6828. value: any;
  6829. initialValue: any;
  6830. }>;
  6831. constructor(scene: Scene);
  6832. /** Creates the inspector window. */
  6833. private _createInspector(config?);
  6834. isVisible(): boolean;
  6835. hide(): void;
  6836. /**
  6837. *
  6838. * Launch the debugLayer.
  6839. *
  6840. * initialTab:
  6841. * | Value | Tab Name |
  6842. * | --- | --- |
  6843. * | 0 | Scene |
  6844. * | 1 | Console |
  6845. * | 2 | Stats |
  6846. * | 3 | Textures |
  6847. * | 4 | Mesh |
  6848. * | 5 | Light |
  6849. * | 6 | Material |
  6850. * | 7 | GLTF |
  6851. * | 8 | GUI |
  6852. * | 9 | Physics |
  6853. * | 10 | Camera |
  6854. * | 11 | Audio |
  6855. *
  6856. */
  6857. show(config?: {
  6858. popup?: boolean;
  6859. initialTab?: number;
  6860. parentElement?: HTMLElement;
  6861. newColors?: {
  6862. backgroundColor?: string;
  6863. backgroundColorLighter?: string;
  6864. backgroundColorLighter2?: string;
  6865. backgroundColorLighter3?: string;
  6866. color?: string;
  6867. colorTop?: string;
  6868. colorBot?: string;
  6869. };
  6870. }): void;
  6871. /**
  6872. * Gets the active tab
  6873. * @return the index of the active tab or -1 if the inspector is hidden
  6874. */
  6875. getActiveTab(): number;
  6876. }
  6877. }
  6878. declare module BABYLON.Debug {
  6879. /**
  6880. * Used to show the physics impostor around the specific mesh
  6881. */
  6882. class PhysicsViewer {
  6883. /** @hidden */
  6884. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  6885. /** @hidden */
  6886. protected _meshes: Array<Nullable<AbstractMesh>>;
  6887. /** @hidden */
  6888. protected _scene: Nullable<Scene>;
  6889. /** @hidden */
  6890. protected _numMeshes: number;
  6891. /** @hidden */
  6892. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  6893. private _renderFunction;
  6894. private _debugBoxMesh;
  6895. private _debugSphereMesh;
  6896. private _debugMaterial;
  6897. /**
  6898. * Creates a new PhysicsViewer
  6899. * @param scene defines the hosting scene
  6900. */
  6901. constructor(scene: Scene);
  6902. /** @hidden */
  6903. protected _updateDebugMeshes(): void;
  6904. /**
  6905. * Renders a specified physic impostor
  6906. * @param impostor defines the impostor to render
  6907. */
  6908. showImpostor(impostor: PhysicsImpostor): void;
  6909. /**
  6910. * Hides a specified physic impostor
  6911. * @param impostor defines the impostor to hide
  6912. */
  6913. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  6914. private _getDebugMaterial(scene);
  6915. private _getDebugBoxMesh(scene);
  6916. private _getDebugSphereMesh(scene);
  6917. private _getDebugMesh(impostor, scene);
  6918. /** Releases all resources */
  6919. dispose(): void;
  6920. }
  6921. }
  6922. declare module BABYLON {
  6923. class RayHelper {
  6924. ray: Nullable<Ray>;
  6925. private _renderPoints;
  6926. private _renderLine;
  6927. private _renderFunction;
  6928. private _scene;
  6929. private _updateToMeshFunction;
  6930. private _attachedToMesh;
  6931. private _meshSpaceDirection;
  6932. private _meshSpaceOrigin;
  6933. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  6934. constructor(ray: Ray);
  6935. show(scene: Scene, color?: Color3): void;
  6936. hide(): void;
  6937. private _render();
  6938. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  6939. detachFromMesh(): void;
  6940. private _updateToMesh();
  6941. dispose(): void;
  6942. }
  6943. }
  6944. declare module BABYLON.Debug {
  6945. /**
  6946. * Class used to render a debug view of a given skeleton
  6947. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  6948. */
  6949. class SkeletonViewer {
  6950. /** defines the skeleton to render */
  6951. skeleton: Skeleton;
  6952. /** defines the mesh attached to the skeleton */
  6953. mesh: AbstractMesh;
  6954. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  6955. autoUpdateBonesMatrices: boolean;
  6956. /** defines the rendering group id to use with the viewer */
  6957. renderingGroupId: number;
  6958. /** Gets or sets the color used to render the skeleton */
  6959. color: Color3;
  6960. private _scene;
  6961. private _debugLines;
  6962. private _debugMesh;
  6963. private _isEnabled;
  6964. private _renderFunction;
  6965. /**
  6966. * Creates a new SkeletonViewer
  6967. * @param skeleton defines the skeleton to render
  6968. * @param mesh defines the mesh attached to the skeleton
  6969. * @param scene defines the hosting scene
  6970. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  6971. * @param renderingGroupId defines the rendering group id to use with the viewer
  6972. */
  6973. constructor(
  6974. /** defines the skeleton to render */
  6975. skeleton: Skeleton,
  6976. /** defines the mesh attached to the skeleton */
  6977. mesh: AbstractMesh, scene: Scene,
  6978. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  6979. autoUpdateBonesMatrices?: boolean,
  6980. /** defines the rendering group id to use with the viewer */
  6981. renderingGroupId?: number);
  6982. /** Gets or sets a boolean indicating if the viewer is enabled */
  6983. isEnabled: boolean;
  6984. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  6985. private _getLinesForBonesWithLength(bones, meshMat);
  6986. private _getLinesForBonesNoLength(bones, meshMat);
  6987. /** Update the viewer to sync with current skeleton state */
  6988. update(): void;
  6989. /** Release associated resources */
  6990. dispose(): void;
  6991. }
  6992. }
  6993. declare module BABYLON {
  6994. /**
  6995. * Interface for attribute information associated with buffer instanciation
  6996. */
  6997. class InstancingAttributeInfo {
  6998. /**
  6999. * Index/offset of the attribute in the vertex shader
  7000. */
  7001. index: number;
  7002. /**
  7003. * size of the attribute, 1, 2, 3 or 4
  7004. */
  7005. attributeSize: number;
  7006. /**
  7007. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  7008. * default is FLOAT
  7009. */
  7010. attribyteType: number;
  7011. /**
  7012. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  7013. */
  7014. normalized: boolean;
  7015. /**
  7016. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  7017. */
  7018. offset: number;
  7019. /**
  7020. * Name of the GLSL attribute, for debugging purpose only
  7021. */
  7022. attributeName: string;
  7023. }
  7024. /**
  7025. * Define options used to create a render target texture
  7026. */
  7027. class RenderTargetCreationOptions {
  7028. /**
  7029. * Specifies is mipmaps must be generated
  7030. */
  7031. generateMipMaps?: boolean;
  7032. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  7033. generateDepthBuffer?: boolean;
  7034. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  7035. generateStencilBuffer?: boolean;
  7036. /** Defines texture type (int by default) */
  7037. type?: number;
  7038. /** Defines sampling mode (trilinear by default) */
  7039. samplingMode?: number;
  7040. /** Defines format (RGBA by default) */
  7041. format?: number;
  7042. }
  7043. /**
  7044. * Define options used to create a depth texture
  7045. */
  7046. class DepthTextureCreationOptions {
  7047. /** Specifies whether or not a stencil should be allocated in the texture */
  7048. generateStencil?: boolean;
  7049. /** Specifies whether or not bilinear filtering is enable on the texture */
  7050. bilinearFiltering?: boolean;
  7051. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7052. comparisonFunction?: number;
  7053. /** Specifies if the created texture is a cube texture */
  7054. isCube?: boolean;
  7055. }
  7056. /**
  7057. * Class used to describe the capabilities of the engine relatively to the current browser
  7058. */
  7059. class EngineCapabilities {
  7060. /** Maximum textures units per fragment shader */
  7061. maxTexturesImageUnits: number;
  7062. /** Maximum texture units per vertex shader */
  7063. maxVertexTextureImageUnits: number;
  7064. /** Maximum textures units in the entire pipeline */
  7065. maxCombinedTexturesImageUnits: number;
  7066. /** Maximum texture size */
  7067. maxTextureSize: number;
  7068. /** Maximum cube texture size */
  7069. maxCubemapTextureSize: number;
  7070. /** Maximum render texture size */
  7071. maxRenderTextureSize: number;
  7072. /** Maximum number of vertex attributes */
  7073. maxVertexAttribs: number;
  7074. /** Maximum number of varyings */
  7075. maxVaryingVectors: number;
  7076. /** Maximum number of uniforms per vertex shader */
  7077. maxVertexUniformVectors: number;
  7078. /** Maximum number of uniforms per fragment shader */
  7079. maxFragmentUniformVectors: number;
  7080. /** Defines if standard derivates (dx/dy) are supported */
  7081. standardDerivatives: boolean;
  7082. /** Defines if s3tc texture compression is supported */
  7083. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  7084. /** Defines if pvrtc texture compression is supported */
  7085. pvrtc: any;
  7086. /** Defines if etc1 texture compression is supported */
  7087. etc1: any;
  7088. /** Defines if etc2 texture compression is supported */
  7089. etc2: any;
  7090. /** Defines if astc texture compression is supported */
  7091. astc: any;
  7092. /** Defines if float textures are supported */
  7093. textureFloat: boolean;
  7094. /** Defines if vertex array objects are supported */
  7095. vertexArrayObject: boolean;
  7096. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  7097. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  7098. /** Gets the maximum level of anisotropy supported */
  7099. maxAnisotropy: number;
  7100. /** Defines if instancing is supported */
  7101. instancedArrays: boolean;
  7102. /** Defines if 32 bits indices are supported */
  7103. uintIndices: boolean;
  7104. /** Defines if high precision shaders are supported */
  7105. highPrecisionShaderSupported: boolean;
  7106. /** Defines if depth reading in the fragment shader is supported */
  7107. fragmentDepthSupported: boolean;
  7108. /** Defines if float texture linear filtering is supported*/
  7109. textureFloatLinearFiltering: boolean;
  7110. /** Defines if rendering to float textures is supported */
  7111. textureFloatRender: boolean;
  7112. /** Defines if half float textures are supported*/
  7113. textureHalfFloat: boolean;
  7114. /** Defines if half float texture linear filtering is supported*/
  7115. textureHalfFloatLinearFiltering: boolean;
  7116. /** Defines if rendering to half float textures is supported */
  7117. textureHalfFloatRender: boolean;
  7118. /** Defines if textureLOD shader command is supported */
  7119. textureLOD: boolean;
  7120. /** Defines if draw buffers extension is supported */
  7121. drawBuffersExtension: boolean;
  7122. /** Defines if depth textures are supported */
  7123. depthTextureExtension: boolean;
  7124. /** Defines if float color buffer are supported */
  7125. colorBufferFloat: boolean;
  7126. /** Gets disjoint timer query extension (null if not supported) */
  7127. timerQuery: EXT_disjoint_timer_query;
  7128. /** Defines if timestamp can be used with timer query */
  7129. canUseTimestampForTimerQuery: boolean;
  7130. }
  7131. /** Interface defining initialization parameters for Engine class */
  7132. interface EngineOptions extends WebGLContextAttributes {
  7133. /**
  7134. * Defines if the engine should no exceed a specified device ratio
  7135. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  7136. */
  7137. limitDeviceRatio?: number;
  7138. /**
  7139. * Defines if webvr should be enabled automatically
  7140. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7141. */
  7142. autoEnableWebVR?: boolean;
  7143. /**
  7144. * Defines if webgl2 should be turned off even if supported
  7145. * @see http://doc.babylonjs.com/features/webgl2
  7146. */
  7147. disableWebGL2Support?: boolean;
  7148. /**
  7149. * Defines if webaudio should be initialized as well
  7150. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7151. */
  7152. audioEngine?: boolean;
  7153. /**
  7154. * Defines if animations should run using a deterministic lock step
  7155. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7156. */
  7157. deterministicLockstep?: boolean;
  7158. /** Defines the maximum steps to use with deterministic lock step mode */
  7159. lockstepMaxSteps?: number;
  7160. /**
  7161. * Defines that engine should ignore context lost events
  7162. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  7163. */
  7164. doNotHandleContextLost?: boolean;
  7165. }
  7166. /**
  7167. * Defines the interface used by display changed events
  7168. */
  7169. interface IDisplayChangedEventArgs {
  7170. /** Gets the vrDisplay object (if any) */
  7171. vrDisplay: Nullable<any>;
  7172. /** Gets a boolean indicating if webVR is supported */
  7173. vrSupported: boolean;
  7174. }
  7175. /**
  7176. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  7177. */
  7178. class Engine {
  7179. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  7180. static ExceptionList: ({
  7181. key: string;
  7182. capture: string;
  7183. captureConstraint: number;
  7184. targets: string[];
  7185. } | {
  7186. key: string;
  7187. capture: null;
  7188. captureConstraint: null;
  7189. targets: string[];
  7190. })[];
  7191. /** Gets the list of created engines */
  7192. static Instances: Engine[];
  7193. /**
  7194. * Gets the latest created engine
  7195. */
  7196. static readonly LastCreatedEngine: Nullable<Engine>;
  7197. /**
  7198. * Gets the latest created scene
  7199. */
  7200. static readonly LastCreatedScene: Nullable<Scene>;
  7201. /**
  7202. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  7203. * @param flag defines which part of the materials must be marked as dirty
  7204. * @param predicate defines a predicate used to filter which materials should be affected
  7205. */
  7206. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  7207. private static _ALPHA_DISABLE;
  7208. private static _ALPHA_ADD;
  7209. private static _ALPHA_COMBINE;
  7210. private static _ALPHA_SUBTRACT;
  7211. private static _ALPHA_MULTIPLY;
  7212. private static _ALPHA_MAXIMIZED;
  7213. private static _ALPHA_ONEONE;
  7214. private static _ALPHA_PREMULTIPLIED;
  7215. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  7216. private static _ALPHA_INTERPOLATE;
  7217. private static _ALPHA_SCREENMODE;
  7218. private static _DELAYLOADSTATE_NONE;
  7219. private static _DELAYLOADSTATE_LOADED;
  7220. private static _DELAYLOADSTATE_LOADING;
  7221. private static _DELAYLOADSTATE_NOTLOADED;
  7222. private static _TEXTUREFORMAT_ALPHA;
  7223. private static _TEXTUREFORMAT_LUMINANCE;
  7224. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  7225. private static _TEXTUREFORMAT_RGB;
  7226. private static _TEXTUREFORMAT_RGBA;
  7227. private static _TEXTUREFORMAT_R;
  7228. private static _TEXTUREFORMAT_RG;
  7229. private static _TEXTURETYPE_UNSIGNED_INT;
  7230. private static _TEXTURETYPE_FLOAT;
  7231. private static _TEXTURETYPE_HALF_FLOAT;
  7232. private static _NEVER;
  7233. private static _ALWAYS;
  7234. private static _LESS;
  7235. private static _EQUAL;
  7236. private static _LEQUAL;
  7237. private static _GREATER;
  7238. private static _GEQUAL;
  7239. private static _NOTEQUAL;
  7240. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7241. static readonly NEVER: number;
  7242. /** 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 */
  7243. static readonly ALWAYS: number;
  7244. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7245. static readonly LESS: number;
  7246. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7247. static readonly EQUAL: number;
  7248. /** 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 */
  7249. static readonly LEQUAL: number;
  7250. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7251. static readonly GREATER: number;
  7252. /** 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 */
  7253. static readonly GEQUAL: number;
  7254. /** 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 */
  7255. static readonly NOTEQUAL: number;
  7256. private static _KEEP;
  7257. private static _REPLACE;
  7258. private static _INCR;
  7259. private static _DECR;
  7260. private static _INVERT;
  7261. private static _INCR_WRAP;
  7262. private static _DECR_WRAP;
  7263. /** Passed to stencilOperation to specify that stencil value must be kept */
  7264. static readonly KEEP: number;
  7265. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7266. static readonly REPLACE: number;
  7267. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7268. static readonly INCR: number;
  7269. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7270. static readonly DECR: number;
  7271. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7272. static readonly INVERT: number;
  7273. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7274. static readonly INCR_WRAP: number;
  7275. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7276. static readonly DECR_WRAP: number;
  7277. /** Defines that alpha blending is disabled */
  7278. static readonly ALPHA_DISABLE: number;
  7279. /** Defines that alpha blending to SRC + DEST */
  7280. static readonly ALPHA_ONEONE: number;
  7281. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7282. static readonly ALPHA_ADD: number;
  7283. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7284. static readonly ALPHA_COMBINE: number;
  7285. /** Defines that alpha blending to DEST - SRC * DEST */
  7286. static readonly ALPHA_SUBTRACT: number;
  7287. /** Defines that alpha blending to SRC * DEST */
  7288. static readonly ALPHA_MULTIPLY: number;
  7289. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7290. static readonly ALPHA_MAXIMIZED: number;
  7291. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7292. static readonly ALPHA_PREMULTIPLIED: number;
  7293. /**
  7294. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7295. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7296. */
  7297. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7298. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7299. static readonly ALPHA_INTERPOLATE: number;
  7300. /**
  7301. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7302. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7303. */
  7304. static readonly ALPHA_SCREENMODE: number;
  7305. /** Defines that the ressource is not delayed*/
  7306. static readonly DELAYLOADSTATE_NONE: number;
  7307. /** Defines that the ressource was successfully delay loaded */
  7308. static readonly DELAYLOADSTATE_LOADED: number;
  7309. /** Defines that the ressource is currently delay loading */
  7310. static readonly DELAYLOADSTATE_LOADING: number;
  7311. /** Defines that the ressource is delayed and has not started loading */
  7312. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7313. /** ALPHA */
  7314. static readonly TEXTUREFORMAT_ALPHA: number;
  7315. /** LUMINANCE */
  7316. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7317. /**
  7318. * R
  7319. */
  7320. static readonly TEXTUREFORMAT_R: number;
  7321. /**
  7322. * RG
  7323. */
  7324. static readonly TEXTUREFORMAT_RG: number;
  7325. /** LUMINANCE_ALPHA */
  7326. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7327. /** RGB */
  7328. static readonly TEXTUREFORMAT_RGB: number;
  7329. /** RGBA */
  7330. static readonly TEXTUREFORMAT_RGBA: number;
  7331. /** UNSIGNED_INT */
  7332. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7333. /** FLOAT */
  7334. static readonly TEXTURETYPE_FLOAT: number;
  7335. /** HALF_FLOAT */
  7336. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7337. private static _SCALEMODE_FLOOR;
  7338. private static _SCALEMODE_NEAREST;
  7339. private static _SCALEMODE_CEILING;
  7340. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7341. static readonly SCALEMODE_FLOOR: number;
  7342. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7343. static readonly SCALEMODE_NEAREST: number;
  7344. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7345. static readonly SCALEMODE_CEILING: number;
  7346. /**
  7347. * Returns the current version of the framework
  7348. */
  7349. static readonly Version: string;
  7350. /**
  7351. * Gets or sets the epsilon value used by collision engine
  7352. */
  7353. static CollisionsEpsilon: number;
  7354. /**
  7355. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7356. */
  7357. static CodeRepository: string;
  7358. /**
  7359. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7360. */
  7361. static ShadersRepository: string;
  7362. /**
  7363. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7364. */
  7365. forcePOTTextures: boolean;
  7366. /**
  7367. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7368. */
  7369. isFullscreen: boolean;
  7370. /**
  7371. * Gets a boolean indicating if the pointer is currently locked
  7372. */
  7373. isPointerLock: boolean;
  7374. /**
  7375. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7376. */
  7377. cullBackFaces: boolean;
  7378. /**
  7379. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7380. */
  7381. renderEvenInBackground: boolean;
  7382. /**
  7383. * Gets or sets a boolean indicating that cache can be kept between frames
  7384. */
  7385. preventCacheWipeBetweenFrames: boolean;
  7386. /**
  7387. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7388. **/
  7389. enableOfflineSupport: boolean;
  7390. /**
  7391. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date)
  7392. **/
  7393. disableManifestCheck: boolean;
  7394. /**
  7395. * Gets the list of created scenes
  7396. */
  7397. scenes: Scene[];
  7398. /**
  7399. * Gets the list of created postprocesses
  7400. */
  7401. postProcesses: PostProcess[];
  7402. /**
  7403. * Observable event triggered each time the rendering canvas is resized
  7404. */
  7405. onResizeObservable: Observable<Engine>;
  7406. /**
  7407. * Observable event triggered each time the canvas loses focus
  7408. */
  7409. onCanvasBlurObservable: Observable<Engine>;
  7410. /**
  7411. * Observable event triggered each time the canvas gains focus
  7412. */
  7413. onCanvasFocusObservable: Observable<Engine>;
  7414. /**
  7415. * Observable event triggered each time the canvas receives pointerout event
  7416. */
  7417. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7418. /**
  7419. * Observable event triggered before each texture is initialized
  7420. */
  7421. onBeforeTextureInitObservable: Observable<Texture>;
  7422. private _vrDisplay;
  7423. private _vrSupported;
  7424. private _oldSize;
  7425. private _oldHardwareScaleFactor;
  7426. private _vrExclusivePointerMode;
  7427. private _webVRInitPromise;
  7428. /**
  7429. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7430. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7431. */
  7432. readonly isInVRExclusivePointerMode: boolean;
  7433. /**
  7434. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7435. */
  7436. disableUniformBuffers: boolean;
  7437. /** @hidden */
  7438. _uniformBuffers: UniformBuffer[];
  7439. /**
  7440. * Gets a boolean indicating that the engine supports uniform buffers
  7441. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7442. */
  7443. readonly supportsUniformBuffers: boolean;
  7444. /**
  7445. * Observable raised when the engine begins a new frame
  7446. */
  7447. onBeginFrameObservable: Observable<Engine>;
  7448. /**
  7449. * Observable raised when the engine ends the current frame
  7450. */
  7451. onEndFrameObservable: Observable<Engine>;
  7452. /**
  7453. * Observable raised when the engine is about to compile a shader
  7454. */
  7455. onBeforeShaderCompilationObservable: Observable<Engine>;
  7456. /**
  7457. * Observable raised when the engine has jsut compiled a shader
  7458. */
  7459. onAfterShaderCompilationObservable: Observable<Engine>;
  7460. private _gl;
  7461. private _renderingCanvas;
  7462. private _windowIsBackground;
  7463. private _webGLVersion;
  7464. /**
  7465. * Gets a boolean indicating that only power of 2 textures are supported
  7466. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7467. */
  7468. readonly needPOTTextures: boolean;
  7469. /** @hidden */
  7470. _badOS: boolean;
  7471. /** @hidden */
  7472. _badDesktopOS: boolean;
  7473. /**
  7474. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7475. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7476. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7477. */
  7478. disableTextureBindingOptimization: boolean;
  7479. /**
  7480. * Gets the audio engine
  7481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7482. * @ignorenaming
  7483. */
  7484. static audioEngine: AudioEngine;
  7485. private _onFocus;
  7486. private _onBlur;
  7487. private _onCanvasPointerOut;
  7488. private _onCanvasBlur;
  7489. private _onCanvasFocus;
  7490. private _onFullscreenChange;
  7491. private _onPointerLockChange;
  7492. private _onVRDisplayPointerRestricted;
  7493. private _onVRDisplayPointerUnrestricted;
  7494. private _onVrDisplayConnect;
  7495. private _onVrDisplayDisconnect;
  7496. private _onVrDisplayPresentChange;
  7497. /**
  7498. * Observable signaled when VR display mode changes
  7499. */
  7500. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7501. /**
  7502. * Observable signaled when VR request present is complete
  7503. */
  7504. onVRRequestPresentComplete: Observable<boolean>;
  7505. /**
  7506. * Observable signaled when VR request present starts
  7507. */
  7508. onVRRequestPresentStart: Observable<Engine>;
  7509. private _hardwareScalingLevel;
  7510. /** @hidden */
  7511. protected _caps: EngineCapabilities;
  7512. private _pointerLockRequested;
  7513. private _isStencilEnable;
  7514. private _colorWrite;
  7515. private _loadingScreen;
  7516. /** @hidden */
  7517. _drawCalls: PerfCounter;
  7518. /** @hidden */
  7519. _textureCollisions: PerfCounter;
  7520. private _glVersion;
  7521. private _glRenderer;
  7522. private _glVendor;
  7523. private _videoTextureSupported;
  7524. private _renderingQueueLaunched;
  7525. private _activeRenderLoops;
  7526. private _deterministicLockstep;
  7527. private _lockstepMaxSteps;
  7528. /**
  7529. * Observable signaled when a context lost event is raised
  7530. */
  7531. onContextLostObservable: Observable<Engine>;
  7532. /**
  7533. * Observable signaled when a context restored event is raised
  7534. */
  7535. onContextRestoredObservable: Observable<Engine>;
  7536. private _onContextLost;
  7537. private _onContextRestored;
  7538. private _contextWasLost;
  7539. private _doNotHandleContextLost;
  7540. /**
  7541. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7542. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7543. */
  7544. doNotHandleContextLost: boolean;
  7545. private _performanceMonitor;
  7546. private _fps;
  7547. private _deltaTime;
  7548. /**
  7549. * Turn this value on if you want to pause FPS computation when in background
  7550. */
  7551. disablePerformanceMonitorInBackground: boolean;
  7552. /**
  7553. * Gets the performance monitor attached to this engine
  7554. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7555. */
  7556. readonly performanceMonitor: PerformanceMonitor;
  7557. /** @hidden */
  7558. protected _depthCullingState: _DepthCullingState;
  7559. /** @hidden */
  7560. protected _stencilState: _StencilState;
  7561. /** @hidden */
  7562. protected _alphaState: _AlphaState;
  7563. /** @hidden */
  7564. protected _alphaMode: number;
  7565. protected _internalTexturesCache: InternalTexture[];
  7566. /** @hidden */
  7567. protected _activeChannel: number;
  7568. private _currentTextureChannel;
  7569. /** @hidden */
  7570. protected _boundTexturesCache: {
  7571. [key: string]: Nullable<InternalTexture>;
  7572. };
  7573. /** @hidden */
  7574. protected _currentEffect: Nullable<Effect>;
  7575. /** @hidden */
  7576. protected _currentProgram: Nullable<WebGLProgram>;
  7577. private _compiledEffects;
  7578. private _vertexAttribArraysEnabled;
  7579. /** @hidden */
  7580. protected _cachedViewport: Nullable<Viewport>;
  7581. private _cachedVertexArrayObject;
  7582. /** @hidden */
  7583. protected _cachedVertexBuffers: any;
  7584. /** @hidden */
  7585. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7586. /** @hidden */
  7587. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7588. /** @hidden */
  7589. protected _currentRenderTarget: Nullable<InternalTexture>;
  7590. private _uintIndicesCurrentlySet;
  7591. private _currentBoundBuffer;
  7592. /** @hidden */
  7593. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7594. private _currentBufferPointers;
  7595. private _currentInstanceLocations;
  7596. private _currentInstanceBuffers;
  7597. private _textureUnits;
  7598. private _firstBoundInternalTextureTracker;
  7599. private _lastBoundInternalTextureTracker;
  7600. private _workingCanvas;
  7601. private _workingContext;
  7602. private _rescalePostProcess;
  7603. private _dummyFramebuffer;
  7604. private _externalData;
  7605. private _bindedRenderFunction;
  7606. private _vaoRecordInProgress;
  7607. private _mustWipeVertexAttributes;
  7608. private _emptyTexture;
  7609. private _emptyCubeTexture;
  7610. private _emptyTexture3D;
  7611. private _frameHandler;
  7612. private _nextFreeTextureSlots;
  7613. private _maxSimultaneousTextures;
  7614. private _activeRequests;
  7615. private _texturesSupported;
  7616. private _textureFormatInUse;
  7617. /**
  7618. * Gets the list of texture formats supported
  7619. */
  7620. readonly texturesSupported: Array<string>;
  7621. /**
  7622. * Gets the list of texture formats in use
  7623. */
  7624. readonly textureFormatInUse: Nullable<string>;
  7625. /**
  7626. * Gets the current viewport
  7627. */
  7628. readonly currentViewport: Nullable<Viewport>;
  7629. /**
  7630. * Gets the default empty texture
  7631. */
  7632. readonly emptyTexture: InternalTexture;
  7633. /**
  7634. * Gets the default empty 3D texture
  7635. */
  7636. readonly emptyTexture3D: InternalTexture;
  7637. /**
  7638. * Gets the default empty cube texture
  7639. */
  7640. readonly emptyCubeTexture: InternalTexture;
  7641. /**
  7642. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  7643. */
  7644. readonly premultipliedAlpha: boolean;
  7645. /**
  7646. * Creates a new engine
  7647. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  7648. * @param antialias defines enable antialiasing (default: false)
  7649. * @param options defines further options to be sent to the getContext() function
  7650. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7651. */
  7652. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7653. private _rebuildInternalTextures();
  7654. private _rebuildEffects();
  7655. private _rebuildBuffers();
  7656. private _initGLContext();
  7657. /**
  7658. * Gets version of the current webGL context
  7659. */
  7660. readonly webGLVersion: number;
  7661. /**
  7662. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7663. */
  7664. readonly isStencilEnable: boolean;
  7665. private _prepareWorkingCanvas();
  7666. /**
  7667. * Reset the texture cache to empty state
  7668. */
  7669. resetTextureCache(): void;
  7670. /**
  7671. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7672. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7673. * @returns true if engine is in deterministic lock step mode
  7674. */
  7675. isDeterministicLockStep(): boolean;
  7676. /**
  7677. * Gets the max steps when engine is running in deterministic lock step
  7678. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7679. * @returns the max steps
  7680. */
  7681. getLockstepMaxSteps(): number;
  7682. /**
  7683. * Gets an object containing information about the current webGL context
  7684. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7685. */
  7686. getGlInfo(): {
  7687. vendor: string;
  7688. renderer: string;
  7689. version: string;
  7690. };
  7691. /**
  7692. * Gets current aspect ratio
  7693. * @param camera defines the camera to use to get the aspect ratio
  7694. * @param useScreen defines if screen size must be used (or the current render target if any)
  7695. * @returns a number defining the aspect ratio
  7696. */
  7697. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7698. /**
  7699. * Gets current screen aspect ratio
  7700. * @returns a number defining the aspect ratio
  7701. */
  7702. getScreenAspectRatio(): number;
  7703. /**
  7704. * Gets the current render width
  7705. * @param useScreen defines if screen size must be used (or the current render target if any)
  7706. * @returns a number defining the current render width
  7707. */
  7708. getRenderWidth(useScreen?: boolean): number;
  7709. /**
  7710. * Gets the current render height
  7711. * @param useScreen defines if screen size must be used (or the current render target if any)
  7712. * @returns a number defining the current render height
  7713. */
  7714. getRenderHeight(useScreen?: boolean): number;
  7715. /**
  7716. * Gets the HTML canvas attached with the current webGL context
  7717. * @returns a HTML canvas
  7718. */
  7719. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7720. /**
  7721. * Gets the client rect of the HTML canvas attached with the current webGL context
  7722. * @returns a client rectanglee
  7723. */
  7724. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7725. /**
  7726. * Defines the hardware scaling level.
  7727. * By default the hardware scaling level is computed from the window device ratio.
  7728. * 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.
  7729. * @param level defines the level to use
  7730. */
  7731. setHardwareScalingLevel(level: number): void;
  7732. /**
  7733. * Gets the current hardware scaling level.
  7734. * By default the hardware scaling level is computed from the window device ratio.
  7735. * 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.
  7736. * @returns a number indicating the current hardware scaling level
  7737. */
  7738. getHardwareScalingLevel(): number;
  7739. /**
  7740. * Gets the list of loaded textures
  7741. * @returns an array containing all loaded textures
  7742. */
  7743. getLoadedTexturesCache(): InternalTexture[];
  7744. /**
  7745. * Gets the object containing all engine capabilities
  7746. * @returns the EngineCapabilities object
  7747. */
  7748. getCaps(): EngineCapabilities;
  7749. /** @hidden */
  7750. readonly drawCalls: number;
  7751. /** @hidden */
  7752. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7753. /**
  7754. * Gets the current depth function
  7755. * @returns a number defining the depth function
  7756. */
  7757. getDepthFunction(): Nullable<number>;
  7758. /**
  7759. * Sets the current depth function
  7760. * @param depthFunc defines the function to use
  7761. */
  7762. setDepthFunction(depthFunc: number): void;
  7763. /**
  7764. * Sets the current depth function to GREATER
  7765. */
  7766. setDepthFunctionToGreater(): void;
  7767. /**
  7768. * Sets the current depth function to GEQUAL
  7769. */
  7770. setDepthFunctionToGreaterOrEqual(): void;
  7771. /**
  7772. * Sets the current depth function to LESS
  7773. */
  7774. setDepthFunctionToLess(): void;
  7775. /**
  7776. * Sets the current depth function to LEQUAL
  7777. */
  7778. setDepthFunctionToLessOrEqual(): void;
  7779. /**
  7780. * Gets a boolean indicating if stencil buffer is enabled
  7781. * @returns the current stencil buffer state
  7782. */
  7783. getStencilBuffer(): boolean;
  7784. /**
  7785. * Enable or disable the stencil buffer
  7786. * @param enable defines if the stencil buffer must be enabled or disabled
  7787. */
  7788. setStencilBuffer(enable: boolean): void;
  7789. /**
  7790. * Gets the current stencil mask
  7791. * @returns a number defining the new stencil mask to use
  7792. */
  7793. getStencilMask(): number;
  7794. /**
  7795. * Sets the current stencil mask
  7796. * @param mask defines the new stencil mask to use
  7797. */
  7798. setStencilMask(mask: number): void;
  7799. /**
  7800. * Gets the current stencil function
  7801. * @returns a number defining the stencil function to use
  7802. */
  7803. getStencilFunction(): number;
  7804. /**
  7805. * Gets the current stencil reference value
  7806. * @returns a number defining the stencil reference value to use
  7807. */
  7808. getStencilFunctionReference(): number;
  7809. /**
  7810. * Gets the current stencil mask
  7811. * @returns a number defining the stencil mask to use
  7812. */
  7813. getStencilFunctionMask(): number;
  7814. /**
  7815. * Sets the current stencil function
  7816. * @param stencilFunc defines the new stencil function to use
  7817. */
  7818. setStencilFunction(stencilFunc: number): void;
  7819. /**
  7820. * Sets the current stencil reference
  7821. * @param reference defines the new stencil reference to use
  7822. */
  7823. setStencilFunctionReference(reference: number): void;
  7824. /**
  7825. * Sets the current stencil mask
  7826. * @param mask defines the new stencil mask to use
  7827. */
  7828. setStencilFunctionMask(mask: number): void;
  7829. /**
  7830. * Gets the current stencil operation when stencil fails
  7831. * @returns a number defining stencil operation to use when stencil fails
  7832. */
  7833. getStencilOperationFail(): number;
  7834. /**
  7835. * Gets the current stencil operation when depth fails
  7836. * @returns a number defining stencil operation to use when depth fails
  7837. */
  7838. getStencilOperationDepthFail(): number;
  7839. /**
  7840. * Gets the current stencil operation when stencil passes
  7841. * @returns a number defining stencil operation to use when stencil passes
  7842. */
  7843. getStencilOperationPass(): number;
  7844. /**
  7845. * Sets the stencil operation to use when stencil fails
  7846. * @param operation defines the stencil operation to use when stencil fails
  7847. */
  7848. setStencilOperationFail(operation: number): void;
  7849. /**
  7850. * Sets the stencil operation to use when depth fails
  7851. * @param operation defines the stencil operation to use when depth fails
  7852. */
  7853. setStencilOperationDepthFail(operation: number): void;
  7854. /**
  7855. * Sets the stencil operation to use when stencil passes
  7856. * @param operation defines the stencil operation to use when stencil passes
  7857. */
  7858. setStencilOperationPass(operation: number): void;
  7859. /**
  7860. * Sets a boolean indicating if the dithering state is enabled or disabled
  7861. * @param value defines the dithering state
  7862. */
  7863. setDitheringState(value: boolean): void;
  7864. /**
  7865. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7866. * @param value defines the rasterizer state
  7867. */
  7868. setRasterizerState(value: boolean): void;
  7869. /**
  7870. * stop executing a render loop function and remove it from the execution array
  7871. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7872. */
  7873. stopRenderLoop(renderFunction?: () => void): void;
  7874. /** @hidden */
  7875. _renderLoop(): void;
  7876. /**
  7877. * Register and execute a render loop. The engine can have more than one render function
  7878. * @param renderFunction defines the function to continuously execute
  7879. */
  7880. runRenderLoop(renderFunction: () => void): void;
  7881. /**
  7882. * Toggle full screen mode
  7883. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7884. * @param options defines an option object to be sent to the requestFullscreen function
  7885. */
  7886. switchFullscreen(requestPointerLock: boolean): void;
  7887. /**
  7888. * Clear the current render buffer or the current render target (if any is set up)
  7889. * @param color defines the color to use
  7890. * @param backBuffer defines if the back buffer must be cleared
  7891. * @param depth defines if the depth buffer must be cleared
  7892. * @param stencil defines if the stencil buffer must be cleared
  7893. */
  7894. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7895. /**
  7896. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7897. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7898. * @param y defines the y-coordinate of the corner of the clear rectangle
  7899. * @param width defines the width of the clear rectangle
  7900. * @param height defines the height of the clear rectangle
  7901. * @param clearColor defines the clear color
  7902. */
  7903. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7904. private _viewportCached;
  7905. /** @hidden */
  7906. _viewport(x: number, y: number, width: number, height: number): void;
  7907. /**
  7908. * Set the WebGL's viewport
  7909. * @param viewport defines the viewport element to be used
  7910. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7911. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7912. */
  7913. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7914. /**
  7915. * Directly set the WebGL Viewport
  7916. * @param x defines the x coordinate of the viewport (in screen space)
  7917. * @param y defines the y coordinate of the viewport (in screen space)
  7918. * @param width defines the width of the viewport (in screen space)
  7919. * @param height defines the height of the viewport (in screen space)
  7920. * @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
  7921. */
  7922. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  7923. /**
  7924. * Begin a new frame
  7925. */
  7926. beginFrame(): void;
  7927. /**
  7928. * Enf the current frame
  7929. */
  7930. endFrame(): void;
  7931. /**
  7932. * Resize the view according to the canvas' size
  7933. */
  7934. resize(): void;
  7935. /**
  7936. * Force a specific size of the canvas
  7937. * @param width defines the new canvas' width
  7938. * @param height defines the new canvas' height
  7939. */
  7940. setSize(width: number, height: number): void;
  7941. /**
  7942. * Gets a boolean indicating if a webVR device was detected
  7943. * @returns true if a webVR device was detected
  7944. */
  7945. isVRDevicePresent(): boolean;
  7946. /**
  7947. * Gets the current webVR device
  7948. * @returns the current webVR device (or null)
  7949. */
  7950. getVRDevice(): any;
  7951. /**
  7952. * Initializes a webVR display and starts listening to display change events
  7953. * The onVRDisplayChangedObservable will be notified upon these changes
  7954. * @returns The onVRDisplayChangedObservable
  7955. */
  7956. initWebVR(): Observable<IDisplayChangedEventArgs>;
  7957. /**
  7958. * Initializes a webVR display and starts listening to display change events
  7959. * The onVRDisplayChangedObservable will be notified upon these changes
  7960. * @returns A promise containing a VRDisplay and if vr is supported
  7961. */
  7962. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  7963. /**
  7964. * Call this function to switch to webVR mode
  7965. * Will do nothing if webVR is not supported or if there is no webVR device
  7966. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7967. */
  7968. enableVR(): void;
  7969. /**
  7970. * Call this function to leave webVR mode
  7971. * Will do nothing if webVR is not supported or if there is no webVR device
  7972. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7973. */
  7974. disableVR(): void;
  7975. private _onVRFullScreenTriggered;
  7976. private _getVRDisplaysAsync();
  7977. /**
  7978. * Binds the frame buffer to the specified texture.
  7979. * @param texture The texture to render to or null for the default canvas
  7980. * @param faceIndex The face of the texture to render to in case of cube texture
  7981. * @param requiredWidth The width of the target to render to
  7982. * @param requiredHeight The height of the target to render to
  7983. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  7984. * @param depthStencilTexture The depth stencil texture to use to render
  7985. * @param lodLevel defines le lod level to bind to the frame buffer
  7986. */
  7987. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  7988. private bindUnboundFramebuffer(framebuffer);
  7989. /**
  7990. * Unbind the current render target texture from the webGL context
  7991. * @param texture defines the render target texture to unbind
  7992. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7993. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7994. */
  7995. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7996. /**
  7997. * Unbind a list of render target textures from the webGL context
  7998. * This is used only when drawBuffer extension or webGL2 are active
  7999. * @param textures defines the render target textures to unbind
  8000. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8001. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8002. */
  8003. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8004. /**
  8005. * Force the mipmap generation for the given render target texture
  8006. * @param texture defines the render target texture to use
  8007. */
  8008. generateMipMapsForCubemap(texture: InternalTexture): void;
  8009. /**
  8010. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  8011. */
  8012. flushFramebuffer(): void;
  8013. /**
  8014. * Unbind the current render target and bind the default framebuffer
  8015. */
  8016. restoreDefaultFramebuffer(): void;
  8017. /**
  8018. * Create an uniform buffer
  8019. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8020. * @param elements defines the content of the uniform buffer
  8021. * @returns the webGL uniform buffer
  8022. */
  8023. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  8024. /**
  8025. * Create a dynamic uniform buffer
  8026. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8027. * @param elements defines the content of the uniform buffer
  8028. * @returns the webGL uniform buffer
  8029. */
  8030. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  8031. /**
  8032. * Update an existing uniform buffer
  8033. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8034. * @param uniformBuffer defines the target uniform buffer
  8035. * @param elements defines the content to update
  8036. * @param offset defines the offset in the uniform buffer where update should start
  8037. * @param count defines the size of the data to update
  8038. */
  8039. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8040. private _resetVertexBufferBinding();
  8041. /**
  8042. * Creates a vertex buffer
  8043. * @param data the data for the vertex buffer
  8044. * @returns the new WebGL static buffer
  8045. */
  8046. createVertexBuffer(data: DataArray): WebGLBuffer;
  8047. /**
  8048. * Creates a dynamic vertex buffer
  8049. * @param data the data for the dynamic vertex buffer
  8050. * @returns the new WebGL dynamic buffer
  8051. */
  8052. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  8053. /**
  8054. * Update a dynamic index buffer
  8055. * @param indexBuffer defines the target index buffer
  8056. * @param indices defines the data to update
  8057. * @param offset defines the offset in the target index buffer where update should start
  8058. */
  8059. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8060. /**
  8061. * Updates a dynamic vertex buffer.
  8062. * @param vertexBuffer the vertex buffer to update
  8063. * @param data the data used to update the vertex buffer
  8064. * @param byteOffset the byte offset of the data
  8065. * @param byteLength the byte length of the data
  8066. */
  8067. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  8068. private _resetIndexBufferBinding();
  8069. /**
  8070. * Creates a new index buffer
  8071. * @param indices defines the content of the index buffer
  8072. * @param updatable defines if the index buffer must be updatable
  8073. * @returns a new webGL buffer
  8074. */
  8075. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  8076. /**
  8077. * Bind a webGL buffer to the webGL context
  8078. * @param buffer defines the buffer to bind
  8079. */
  8080. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  8081. /**
  8082. * Bind an uniform buffer to the current webGL context
  8083. * @param buffer defines the buffer to bind
  8084. */
  8085. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  8086. /**
  8087. * Bind a buffer to the current webGL context at a given location
  8088. * @param buffer defines the buffer to bind
  8089. * @param location defines the index where to bind the buffer
  8090. */
  8091. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  8092. /**
  8093. * Bind a specific block at a given index in a specific shader program
  8094. * @param shaderProgram defines the shader program
  8095. * @param blockName defines the block name
  8096. * @param index defines the index where to bind the block
  8097. */
  8098. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  8099. private bindIndexBuffer(buffer);
  8100. private bindBuffer(buffer, target);
  8101. /**
  8102. * update the bound buffer with the given data
  8103. * @param data defines the data to update
  8104. */
  8105. updateArrayBuffer(data: Float32Array): void;
  8106. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  8107. private _bindIndexBufferWithCache(indexBuffer);
  8108. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  8109. /**
  8110. * Records a vertex array object
  8111. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8112. * @param vertexBuffers defines the list of vertex buffers to store
  8113. * @param indexBuffer defines the index buffer to store
  8114. * @param effect defines the effect to store
  8115. * @returns the new vertex array object
  8116. */
  8117. recordVertexArrayObject(vertexBuffers: {
  8118. [key: string]: VertexBuffer;
  8119. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  8120. /**
  8121. * Bind a specific vertex array object
  8122. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8123. * @param vertexArrayObject defines the vertex array object to bind
  8124. * @param indexBuffer defines the index buffer to bind
  8125. */
  8126. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  8127. /**
  8128. * Bind webGl buffers directly to the webGL context
  8129. * @param vertexBuffer defines the vertex buffer to bind
  8130. * @param indexBuffer defines the index buffer to bind
  8131. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  8132. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  8133. * @param effect defines the effect associated with the vertex buffer
  8134. */
  8135. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  8136. private _unbindVertexArrayObject();
  8137. /**
  8138. * Bind a list of vertex buffers to the webGL context
  8139. * @param vertexBuffers defines the list of vertex buffers to bind
  8140. * @param indexBuffer defines the index buffer to bind
  8141. * @param effect defines the effect associated with the vertex buffers
  8142. */
  8143. bindBuffers(vertexBuffers: {
  8144. [key: string]: Nullable<VertexBuffer>;
  8145. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  8146. /**
  8147. * Unbind all instance attributes
  8148. */
  8149. unbindInstanceAttributes(): void;
  8150. /**
  8151. * Release and free the memory of a vertex array object
  8152. * @param vao defines the vertex array object to delete
  8153. */
  8154. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  8155. /** @hidden */
  8156. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8157. /**
  8158. * Creates a webGL buffer to use with instanciation
  8159. * @param capacity defines the size of the buffer
  8160. * @returns the webGL buffer
  8161. */
  8162. createInstancesBuffer(capacity: number): WebGLBuffer;
  8163. /**
  8164. * Delete a webGL buffer used with instanciation
  8165. * @param buffer defines the webGL buffer to delete
  8166. */
  8167. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  8168. /**
  8169. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  8170. * @param instancesBuffer defines the webGL buffer to update and bind
  8171. * @param data defines the data to store in the buffer
  8172. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  8173. */
  8174. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  8175. /**
  8176. * Apply all cached states (depth, culling, stencil and alpha)
  8177. */
  8178. applyStates(): void;
  8179. /**
  8180. * Send a draw order
  8181. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8182. * @param indexStart defines the starting index
  8183. * @param indexCount defines the number of index to draw
  8184. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8185. */
  8186. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8187. /**
  8188. * Draw a list of points
  8189. * @param verticesStart defines the index of first vertex to draw
  8190. * @param verticesCount defines the count of vertices to draw
  8191. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8192. */
  8193. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8194. /**
  8195. * Draw a list of unindexed primitives
  8196. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8197. * @param verticesStart defines the index of first vertex to draw
  8198. * @param verticesCount defines the count of vertices to draw
  8199. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8200. */
  8201. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8202. /**
  8203. * Draw a list of indexed primitives
  8204. * @param fillMode defines the primitive to use
  8205. * @param indexStart defines the starting index
  8206. * @param indexCount defines the number of index to draw
  8207. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8208. */
  8209. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8210. /**
  8211. * Draw a list of unindexed primitives
  8212. * @param fillMode defines the primitive to use
  8213. * @param verticesStart defines the index of first vertex to draw
  8214. * @param verticesCount defines the count of vertices to draw
  8215. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8216. */
  8217. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8218. private _drawMode(fillMode);
  8219. /** @hidden */
  8220. _releaseEffect(effect: Effect): void;
  8221. /** @hidden */
  8222. _deleteProgram(program: WebGLProgram): void;
  8223. /**
  8224. * Create a new effect (used to store vertex/fragment shaders)
  8225. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8226. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8227. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8228. * @param samplers defines an array of string used to represent textures
  8229. * @param defines defines the string containing the defines to use to compile the shaders
  8230. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8231. * @param onCompiled defines a function to call when the effect creation is successful
  8232. * @param onError defines a function to call when the effect creation has failed
  8233. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8234. * @returns the new Effect
  8235. */
  8236. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  8237. /**
  8238. * Create an effect to use with particle systems.
  8239. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  8240. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  8241. * @param uniformsNames defines a list of attribute names
  8242. * @param samplers defines an array of string used to represent textures
  8243. * @param defines defines the string containing the defines to use to compile the shaders
  8244. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8245. * @param onCompiled defines a function to call when the effect creation is successful
  8246. * @param onError defines a function to call when the effect creation has failed
  8247. * @returns the new Effect
  8248. */
  8249. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  8250. /**
  8251. * Directly creates a webGL program
  8252. * @param vertexCode defines the vertex shader code to use
  8253. * @param fragmentCode defines the fragment shader code to use
  8254. * @param context defines the webGL context to use (if not set, the current one will be used)
  8255. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8256. * @returns the new webGL program
  8257. */
  8258. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8259. /**
  8260. * Creates a webGL program
  8261. * @param vertexCode defines the vertex shader code to use
  8262. * @param fragmentCode defines the fragment shader code to use
  8263. * @param defines defines the string containing the defines to use to compile the shaders
  8264. * @param context defines the webGL context to use (if not set, the current one will be used)
  8265. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8266. * @returns the new webGL program
  8267. */
  8268. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8269. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  8270. /**
  8271. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8272. * @param shaderProgram defines the webGL program to use
  8273. * @param uniformsNames defines the list of uniform names
  8274. * @returns an array of webGL uniform locations
  8275. */
  8276. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8277. /**
  8278. * Gets the lsit of active attributes for a given webGL program
  8279. * @param shaderProgram defines the webGL program to use
  8280. * @param attributesNames defines the list of attribute names to get
  8281. * @returns an array of indices indicating the offset of each attribute
  8282. */
  8283. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8284. /**
  8285. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8286. * @param effect defines the effect to activate
  8287. */
  8288. enableEffect(effect: Nullable<Effect>): void;
  8289. /**
  8290. * Set the value of an uniform to an array of int32
  8291. * @param uniform defines the webGL uniform location where to store the value
  8292. * @param array defines the array of int32 to store
  8293. */
  8294. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8295. /**
  8296. * Set the value of an uniform to an array of int32 (stored as vec2)
  8297. * @param uniform defines the webGL uniform location where to store the value
  8298. * @param array defines the array of int32 to store
  8299. */
  8300. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8301. /**
  8302. * Set the value of an uniform to an array of int32 (stored as vec3)
  8303. * @param uniform defines the webGL uniform location where to store the value
  8304. * @param array defines the array of int32 to store
  8305. */
  8306. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8307. /**
  8308. * Set the value of an uniform to an array of int32 (stored as vec4)
  8309. * @param uniform defines the webGL uniform location where to store the value
  8310. * @param array defines the array of int32 to store
  8311. */
  8312. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8313. /**
  8314. * Set the value of an uniform to an array of float32
  8315. * @param uniform defines the webGL uniform location where to store the value
  8316. * @param array defines the array of float32 to store
  8317. */
  8318. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8319. /**
  8320. * Set the value of an uniform to an array of float32 (stored as vec2)
  8321. * @param uniform defines the webGL uniform location where to store the value
  8322. * @param array defines the array of float32 to store
  8323. */
  8324. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8325. /**
  8326. * Set the value of an uniform to an array of float32 (stored as vec3)
  8327. * @param uniform defines the webGL uniform location where to store the value
  8328. * @param array defines the array of float32 to store
  8329. */
  8330. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8331. /**
  8332. * Set the value of an uniform to an array of float32 (stored as vec4)
  8333. * @param uniform defines the webGL uniform location where to store the value
  8334. * @param array defines the array of float32 to store
  8335. */
  8336. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8337. /**
  8338. * Set the value of an uniform to an array of number
  8339. * @param uniform defines the webGL uniform location where to store the value
  8340. * @param array defines the array of number to store
  8341. */
  8342. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8343. /**
  8344. * Set the value of an uniform to an array of number (stored as vec2)
  8345. * @param uniform defines the webGL uniform location where to store the value
  8346. * @param array defines the array of number to store
  8347. */
  8348. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8349. /**
  8350. * Set the value of an uniform to an array of number (stored as vec3)
  8351. * @param uniform defines the webGL uniform location where to store the value
  8352. * @param array defines the array of number to store
  8353. */
  8354. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8355. /**
  8356. * Set the value of an uniform to an array of number (stored as vec4)
  8357. * @param uniform defines the webGL uniform location where to store the value
  8358. * @param array defines the array of number to store
  8359. */
  8360. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8361. /**
  8362. * Set the value of an uniform to an array of float32 (stored as matrices)
  8363. * @param uniform defines the webGL uniform location where to store the value
  8364. * @param matrices defines the array of float32 to store
  8365. */
  8366. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8367. /**
  8368. * Set the value of an uniform to a matrix
  8369. * @param uniform defines the webGL uniform location where to store the value
  8370. * @param matrix defines the matrix to store
  8371. */
  8372. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8373. /**
  8374. * Set the value of an uniform to a matrix (3x3)
  8375. * @param uniform defines the webGL uniform location where to store the value
  8376. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8377. */
  8378. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8379. /**
  8380. * Set the value of an uniform to a matrix (2x2)
  8381. * @param uniform defines the webGL uniform location where to store the value
  8382. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8383. */
  8384. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8385. /**
  8386. * Set the value of an uniform to a number (int)
  8387. * @param uniform defines the webGL uniform location where to store the value
  8388. * @param value defines the int number to store
  8389. */
  8390. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8391. /**
  8392. * Set the value of an uniform to a number (float)
  8393. * @param uniform defines the webGL uniform location where to store the value
  8394. * @param value defines the float number to store
  8395. */
  8396. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8397. /**
  8398. * Set the value of an uniform to a vec2
  8399. * @param uniform defines the webGL uniform location where to store the value
  8400. * @param x defines the 1st component of the value
  8401. * @param y defines the 2nd component of the value
  8402. */
  8403. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8404. /**
  8405. * Set the value of an uniform to a vec3
  8406. * @param uniform defines the webGL uniform location where to store the value
  8407. * @param x defines the 1st component of the value
  8408. * @param y defines the 2nd component of the value
  8409. * @param z defines the 3rd component of the value
  8410. */
  8411. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8412. /**
  8413. * Set the value of an uniform to a boolean
  8414. * @param uniform defines the webGL uniform location where to store the value
  8415. * @param bool defines the boolean to store
  8416. */
  8417. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8418. /**
  8419. * Set the value of an uniform to a vec4
  8420. * @param uniform defines the webGL uniform location where to store the value
  8421. * @param x defines the 1st component of the value
  8422. * @param y defines the 2nd component of the value
  8423. * @param z defines the 3rd component of the value
  8424. * @param w defines the 4th component of the value
  8425. */
  8426. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8427. /**
  8428. * Set the value of an uniform to a Color3
  8429. * @param uniform defines the webGL uniform location where to store the value
  8430. * @param color3 defines the color to store
  8431. */
  8432. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8433. /**
  8434. * Set the value of an uniform to a Color3 and an alpha value
  8435. * @param uniform defines the webGL uniform location where to store the value
  8436. * @param color3 defines the color to store
  8437. * @param alpha defines the alpha component to store
  8438. */
  8439. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8440. /**
  8441. * Sets a Color4 on a uniform variable
  8442. * @param uniform defines the uniform location
  8443. * @param color4 defines the value to be set
  8444. */
  8445. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8446. /**
  8447. * Set various states to the webGL context
  8448. * @param culling defines backface culling state
  8449. * @param zOffset defines the value to apply to zOffset (0 by default)
  8450. * @param force defines if states must be applied even if cache is up to date
  8451. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8452. */
  8453. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8454. /**
  8455. * Set the z offset to apply to current rendering
  8456. * @param value defines the offset to apply
  8457. */
  8458. setZOffset(value: number): void;
  8459. /**
  8460. * Gets the current value of the zOffset
  8461. * @returns the current zOffset state
  8462. */
  8463. getZOffset(): number;
  8464. /**
  8465. * Enable or disable depth buffering
  8466. * @param enable defines the state to set
  8467. */
  8468. setDepthBuffer(enable: boolean): void;
  8469. /**
  8470. * Gets a boolean indicating if depth writing is enabled
  8471. * @returns the current depth writing state
  8472. */
  8473. getDepthWrite(): boolean;
  8474. /**
  8475. * Enable or disable depth writing
  8476. * @param enable defines the state to set
  8477. */
  8478. setDepthWrite(enable: boolean): void;
  8479. /**
  8480. * Enable or disable color writing
  8481. * @param enable defines the state to set
  8482. */
  8483. setColorWrite(enable: boolean): void;
  8484. /**
  8485. * Gets a boolean indicating if color writing is enabled
  8486. * @returns the current color writing state
  8487. */
  8488. getColorWrite(): boolean;
  8489. /**
  8490. * Sets alpha constants used by some alpha blending modes
  8491. * @param r defines the red component
  8492. * @param g defines the green component
  8493. * @param b defines the blue component
  8494. * @param a defines the alpha component
  8495. */
  8496. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8497. /**
  8498. * Sets the current alpha mode
  8499. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8500. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8501. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8502. */
  8503. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8504. /**
  8505. * Gets the current alpha mode
  8506. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8507. * @returns the current alpha mode
  8508. */
  8509. getAlphaMode(): number;
  8510. /**
  8511. * Clears the list of texture accessible through engine.
  8512. * This can help preventing texture load conflict due to name collision.
  8513. */
  8514. clearInternalTexturesCache(): void;
  8515. /**
  8516. * Force the entire cache to be cleared
  8517. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8518. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8519. */
  8520. wipeCaches(bruteForce?: boolean): void;
  8521. /**
  8522. * Set the compressed texture format to use, based on the formats you have, and the formats
  8523. * supported by the hardware / browser.
  8524. *
  8525. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8526. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8527. * to API arguments needed to compressed textures. This puts the burden on the container
  8528. * generator to house the arcane code for determining these for current & future formats.
  8529. *
  8530. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8531. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8532. *
  8533. * Note: The result of this call is not taken into account when a texture is base64.
  8534. *
  8535. * @param formatsAvailable defines the list of those format families you have created
  8536. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8537. *
  8538. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8539. * @returns The extension selected.
  8540. */
  8541. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8542. /** @hidden */
  8543. _createTexture(): WebGLTexture;
  8544. /**
  8545. * Usually called from BABYLON.Texture.ts.
  8546. * Passed information to create a WebGLTexture
  8547. * @param urlArg defines a value which contains one of the following:
  8548. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8549. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8550. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8551. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8552. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8553. * @param scene needed for loading to the correct scene
  8554. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8555. * @param onLoad optional callback to be called upon successful completion
  8556. * @param onError optional callback to be called upon failure
  8557. * @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
  8558. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8559. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8560. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8561. */
  8562. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  8563. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  8564. /**
  8565. * Update a raw texture
  8566. * @param texture defines the texture to update
  8567. * @param data defines the data to store in the texture
  8568. * @param format defines the format of the data
  8569. * @param invertY defines if data must be stored with Y axis inverted
  8570. * @param compression defines the compression used (null by default)
  8571. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8572. */
  8573. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8574. /**
  8575. * Creates a raw texture
  8576. * @param data defines the data to store in the texture
  8577. * @param width defines the width of the texture
  8578. * @param height defines the height of the texture
  8579. * @param format defines the format of the data
  8580. * @param generateMipMaps defines if the engine should generate the mip levels
  8581. * @param invertY defines if data must be stored with Y axis inverted
  8582. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8583. * @param compression defines the compression used (null by default)
  8584. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8585. * @returns the raw texture inside an InternalTexture
  8586. */
  8587. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8588. private _unpackFlipYCached;
  8589. /** @hidden */
  8590. _unpackFlipY(value: boolean): void;
  8591. /**
  8592. * Creates a dynamic texture
  8593. * @param width defines the width of the texture
  8594. * @param height defines the height of the texture
  8595. * @param generateMipMaps defines if the engine should generate the mip levels
  8596. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8597. * @returns the dynamic texture inside an InternalTexture
  8598. */
  8599. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8600. /**
  8601. * Update the sampling mode of a given texture
  8602. * @param samplingMode defines the required sampling mode
  8603. * @param texture defines the texture to update
  8604. */
  8605. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8606. /**
  8607. * Update the content of a dynamic texture
  8608. * @param texture defines the texture to update
  8609. * @param canvas defines the canvas containing the source
  8610. * @param invertY defines if data must be stored with Y axis inverted
  8611. * @param premulAlpha defines if alpha is stored as premultiplied
  8612. * @param format defines the format of the data
  8613. */
  8614. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8615. /**
  8616. * Update a video texture
  8617. * @param texture defines the texture to update
  8618. * @param video defines the video element to use
  8619. * @param invertY defines if data must be stored with Y axis inverted
  8620. */
  8621. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8622. /**
  8623. * Updates a depth texture Comparison Mode and Function.
  8624. * If the comparison Function is equal to 0, the mode will be set to none.
  8625. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8626. * @param texture The texture to set the comparison function for
  8627. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8628. */
  8629. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8630. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  8631. /**
  8632. * Creates a depth stencil texture.
  8633. * This is only available in WebGL 2 or with the depth texture extension available.
  8634. * @param size The size of face edge in the texture.
  8635. * @param options The options defining the texture.
  8636. * @returns The texture
  8637. */
  8638. createDepthStencilTexture(size: number | {
  8639. width: number;
  8640. height: number;
  8641. }, options: DepthTextureCreationOptions): InternalTexture;
  8642. /**
  8643. * Creates a depth stencil texture.
  8644. * This is only available in WebGL 2 or with the depth texture extension available.
  8645. * @param size The size of face edge in the texture.
  8646. * @param options The options defining the texture.
  8647. * @returns The texture
  8648. */
  8649. private _createDepthStencilTexture(size, options);
  8650. /**
  8651. * Creates a depth stencil cube texture.
  8652. * This is only available in WebGL 2.
  8653. * @param size The size of face edge in the cube texture.
  8654. * @param options The options defining the cube texture.
  8655. * @returns The cube texture
  8656. */
  8657. private _createDepthStencilCubeTexture(size, options);
  8658. /**
  8659. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8660. * @param renderTarget The render target to set the frame buffer for
  8661. */
  8662. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8663. /**
  8664. * Creates a new render target texture
  8665. * @param size defines the size of the texture
  8666. * @param options defines the options used to create the texture
  8667. * @returns a new render target texture stored in an InternalTexture
  8668. */
  8669. createRenderTargetTexture(size: number | {
  8670. width: number;
  8671. height: number;
  8672. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8673. /**
  8674. * Create a multi render target texture
  8675. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8676. * @param size defines the size of the texture
  8677. * @param options defines the creation options
  8678. * @returns the cube texture as an InternalTexture
  8679. */
  8680. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8681. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  8682. /**
  8683. * Updates the sample count of a render target texture
  8684. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8685. * @param texture defines the texture to update
  8686. * @param samples defines the sample count to set
  8687. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8688. */
  8689. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8690. /**
  8691. * Update the sample count for a given multiple render target texture
  8692. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8693. * @param textures defines the textures to update
  8694. * @param samples defines the sample count to set
  8695. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8696. */
  8697. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8698. /** @hidden */
  8699. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  8700. /** @hidden */
  8701. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  8702. /** @hidden */
  8703. _uploadImageToTexture(texture: InternalTexture, faceIndex: number, lod: number, image: HTMLImageElement): void;
  8704. /**
  8705. * Creates a new render target cube texture
  8706. * @param size defines the size of the texture
  8707. * @param options defines the options used to create the texture
  8708. * @returns a new render target cube texture stored in an InternalTexture
  8709. */
  8710. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8711. /**
  8712. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8713. * @param rootUrl defines the url where the file to load is located
  8714. * @param scene defines the current scene
  8715. * @param lodScale defines scale to apply to the mip map selection
  8716. * @param lodOffset defines offset to apply to the mip map selection
  8717. * @param onLoad defines an optional callback raised when the texture is loaded
  8718. * @param onError defines an optional callback raised if there is an issue to load the texture
  8719. * @param format defines the format of the data
  8720. * @param forcedExtension defines the extension to use to pick the right loader
  8721. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8722. * @returns the cube texture as an InternalTexture
  8723. */
  8724. 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;
  8725. /**
  8726. * Creates a cube texture
  8727. * @param rootUrl defines the url where the files to load is located
  8728. * @param scene defines the current scene
  8729. * @param files defines the list of files to load (1 per face)
  8730. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8731. * @param onLoad defines an optional callback raised when the texture is loaded
  8732. * @param onError defines an optional callback raised if there is an issue to load the texture
  8733. * @param format defines the format of the data
  8734. * @param forcedExtension defines the extension to use to pick the right loader
  8735. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8736. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8737. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8738. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8739. * @returns the cube texture as an InternalTexture
  8740. */
  8741. 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;
  8742. private setCubeMapTextureParams(gl, loadMipmap);
  8743. /**
  8744. * Update a raw cube texture
  8745. * @param texture defines the texture to udpdate
  8746. * @param data defines the data to store
  8747. * @param format defines the data format
  8748. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8749. * @param invertY defines if data must be stored with Y axis inverted
  8750. * @param compression defines the compression used (null by default)
  8751. * @param level defines which level of the texture to update
  8752. */
  8753. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8754. /**
  8755. * Creates a new raw cube texture
  8756. * @param data defines the array of data to use to create each face
  8757. * @param size defines the size of the textures
  8758. * @param format defines the format of the data
  8759. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8760. * @param generateMipMaps defines if the engine should generate the mip levels
  8761. * @param invertY defines if data must be stored with Y axis inverted
  8762. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8763. * @param compression defines the compression used (null by default)
  8764. * @returns the cube texture as an InternalTexture
  8765. */
  8766. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8767. /**
  8768. * Creates a new raw cube texture from a specified url
  8769. * @param url defines the url where the data is located
  8770. * @param scene defines the current scene
  8771. * @param size defines the size of the textures
  8772. * @param format defines the format of the data
  8773. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8774. * @param noMipmap defines if the engine should avoid generating the mip levels
  8775. * @param callback defines a callback used to extract texture data from loaded data
  8776. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8777. * @param onLoad defines a callback called when texture is loaded
  8778. * @param onError defines a callback called if there is an error
  8779. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8780. * @param invertY defines if data must be stored with Y axis inverted
  8781. * @returns the cube texture as an InternalTexture
  8782. */
  8783. 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;
  8784. /**
  8785. * Update a raw 3D texture
  8786. * @param texture defines the texture to update
  8787. * @param data defines the data to store
  8788. * @param format defines the data format
  8789. * @param invertY defines if data must be stored with Y axis inverted
  8790. * @param compression defines the used compression (can be null)
  8791. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  8792. */
  8793. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  8794. /**
  8795. * Creates a new raw 3D texture
  8796. * @param data defines the data used to create the texture
  8797. * @param width defines the width of the texture
  8798. * @param height defines the height of the texture
  8799. * @param depth defines the depth of the texture
  8800. * @param format defines the format of the texture
  8801. * @param generateMipMaps defines if the engine must generate mip levels
  8802. * @param invertY defines if data must be stored with Y axis inverted
  8803. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8804. * @param compression defines the compressed used (can be null)
  8805. * @param textureType defines the compressed used (can be null)
  8806. * @returns a new raw 3D texture (stored in an InternalTexture)
  8807. */
  8808. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  8809. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  8810. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  8811. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  8812. /** @hidden */
  8813. _releaseFramebufferObjects(texture: InternalTexture): void;
  8814. /** @hidden */
  8815. _releaseTexture(texture: InternalTexture): void;
  8816. private setProgram(program);
  8817. private _boundUniforms;
  8818. /**
  8819. * Binds an effect to the webGL context
  8820. * @param effect defines the effect to bind
  8821. */
  8822. bindSamplers(effect: Effect): void;
  8823. private _moveBoundTextureOnTop(internalTexture);
  8824. private _getCorrectTextureChannel(channel, internalTexture);
  8825. private _linkTrackers(previous, next);
  8826. private _removeDesignatedSlot(internalTexture);
  8827. private _activateCurrentTexture();
  8828. /** @hidden */
  8829. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  8830. /** @hidden */
  8831. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  8832. /**
  8833. * Sets a texture to the webGL context from a postprocess
  8834. * @param channel defines the channel to use
  8835. * @param postProcess defines the source postprocess
  8836. */
  8837. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8838. /**
  8839. * Binds the output of the passed in post process to the texture channel specified
  8840. * @param channel The channel the texture should be bound to
  8841. * @param postProcess The post process which's output should be bound
  8842. */
  8843. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8844. /**
  8845. * Unbind all textures from the webGL context
  8846. */
  8847. unbindAllTextures(): void;
  8848. /**
  8849. * Sets a texture to the according uniform.
  8850. * @param channel The texture channel
  8851. * @param uniform The uniform to set
  8852. * @param texture The texture to apply
  8853. */
  8854. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8855. /**
  8856. * Sets a depth stencil texture from a render target to the according uniform.
  8857. * @param channel The texture channel
  8858. * @param uniform The uniform to set
  8859. * @param texture The render target texture containing the depth stencil texture to apply
  8860. */
  8861. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8862. private _bindSamplerUniformToChannel(sourceSlot, destination);
  8863. private _getTextureWrapMode(mode);
  8864. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  8865. /**
  8866. * Sets an array of texture to the webGL context
  8867. * @param channel defines the channel where the texture array must be set
  8868. * @param uniform defines the associated uniform location
  8869. * @param textures defines the array of textures to bind
  8870. */
  8871. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8872. /** @hidden */
  8873. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  8874. private _setTextureParameterFloat(target, parameter, value, texture);
  8875. private _setTextureParameterInteger(target, parameter, value, texture?);
  8876. /**
  8877. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8878. * @param x defines the x coordinate of the rectangle where pixels must be read
  8879. * @param y defines the y coordinate of the rectangle where pixels must be read
  8880. * @param width defines the width of the rectangle where pixels must be read
  8881. * @param height defines the height of the rectangle where pixels must be read
  8882. * @returns a Uint8Array containing RGBA colors
  8883. */
  8884. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8885. /**
  8886. * Add an externaly attached data from its key.
  8887. * This method call will fail and return false, if such key already exists.
  8888. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8889. * @param key the unique key that identifies the data
  8890. * @param data the data object to associate to the key for this Engine instance
  8891. * @return true if no such key were already present and the data was added successfully, false otherwise
  8892. */
  8893. addExternalData<T>(key: string, data: T): boolean;
  8894. /**
  8895. * Get an externaly attached data from its key
  8896. * @param key the unique key that identifies the data
  8897. * @return the associated data, if present (can be null), or undefined if not present
  8898. */
  8899. getExternalData<T>(key: string): T;
  8900. /**
  8901. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8902. * @param key the unique key that identifies the data
  8903. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8904. * @return the associated data, can be null if the factory returned null.
  8905. */
  8906. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8907. /**
  8908. * Remove an externaly attached data from the Engine instance
  8909. * @param key the unique key that identifies the data
  8910. * @return true if the data was successfully removed, false if it doesn't exist
  8911. */
  8912. removeExternalData(key: string): boolean;
  8913. /**
  8914. * Unbind all vertex attributes from the webGL context
  8915. */
  8916. unbindAllAttributes(): void;
  8917. /**
  8918. * 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
  8919. */
  8920. releaseEffects(): void;
  8921. /**
  8922. * Dispose and release all associated resources
  8923. */
  8924. dispose(): void;
  8925. /**
  8926. * Display the loading screen
  8927. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8928. */
  8929. displayLoadingUI(): void;
  8930. /**
  8931. * Hide the loading screen
  8932. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8933. */
  8934. hideLoadingUI(): void;
  8935. /**
  8936. * Gets the current loading screen object
  8937. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8938. */
  8939. /**
  8940. * Sets the current loading screen object
  8941. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8942. */
  8943. loadingScreen: ILoadingScreen;
  8944. /**
  8945. * Sets the current loading screen text
  8946. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8947. */
  8948. loadingUIText: string;
  8949. /**
  8950. * Sets the current loading screen background color
  8951. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8952. */
  8953. loadingUIBackgroundColor: string;
  8954. /**
  8955. * Attach a new callback raised when context lost event is fired
  8956. * @param callback defines the callback to call
  8957. */
  8958. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8959. /**
  8960. * Attach a new callback raised when context restored event is fired
  8961. * @param callback defines the callback to call
  8962. */
  8963. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8964. /**
  8965. * Gets the source code of the vertex shader associated with a specific webGL program
  8966. * @param program defines the program to use
  8967. * @returns a string containing the source code of the vertex shader associated with the program
  8968. */
  8969. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  8970. /**
  8971. * Gets the source code of the fragment shader associated with a specific webGL program
  8972. * @param program defines the program to use
  8973. * @returns a string containing the source code of the fragment shader associated with the program
  8974. */
  8975. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  8976. /**
  8977. * Get the current error code of the webGL context
  8978. * @returns the error code
  8979. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8980. */
  8981. getError(): number;
  8982. /**
  8983. * Gets the current framerate
  8984. * @returns a number representing the framerate
  8985. */
  8986. getFps(): number;
  8987. /**
  8988. * Gets the time spent between current and previous frame
  8989. * @returns a number representing the delta time in ms
  8990. */
  8991. getDeltaTime(): number;
  8992. private _measureFps();
  8993. /** @hidden */
  8994. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number): ArrayBufferView;
  8995. private _canRenderToFloatFramebuffer();
  8996. private _canRenderToHalfFloatFramebuffer();
  8997. private _canRenderToFramebuffer(type);
  8998. /** @hidden */
  8999. _getWebGLTextureType(type: number): number;
  9000. private _getInternalFormat(format);
  9001. /** @hidden */
  9002. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  9003. /** @hidden */
  9004. _getRGBAMultiSampleBufferFormat(type: number): number;
  9005. /**
  9006. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  9007. * @return the new query
  9008. */
  9009. createQuery(): WebGLQuery;
  9010. /**
  9011. * Delete and release a webGL query
  9012. * @param query defines the query to delete
  9013. * @return the current engine
  9014. */
  9015. deleteQuery(query: WebGLQuery): Engine;
  9016. /**
  9017. * Check if a given query has resolved and got its value
  9018. * @param query defines the query to check
  9019. * @returns true if the query got its value
  9020. */
  9021. isQueryResultAvailable(query: WebGLQuery): boolean;
  9022. /**
  9023. * Gets the value of a given query
  9024. * @param query defines the query to check
  9025. * @returns the value of the query
  9026. */
  9027. getQueryResult(query: WebGLQuery): number;
  9028. /**
  9029. * Initiates an occlusion query
  9030. * @param algorithmType defines the algorithm to use
  9031. * @param query defines the query to use
  9032. * @returns the current engine
  9033. * @see http://doc.babylonjs.com/features/occlusionquery
  9034. */
  9035. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  9036. /**
  9037. * Ends an occlusion query
  9038. * @see http://doc.babylonjs.com/features/occlusionquery
  9039. * @param algorithmType defines the algorithm to use
  9040. * @returns the current engine
  9041. */
  9042. endOcclusionQuery(algorithmType: number): Engine;
  9043. private _createTimeQuery();
  9044. private _deleteTimeQuery(query);
  9045. private _getTimeQueryResult(query);
  9046. private _getTimeQueryAvailability(query);
  9047. private _currentNonTimestampToken;
  9048. /**
  9049. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  9050. * Please note that only one query can be issued at a time
  9051. * @returns a time token used to track the time span
  9052. */
  9053. startTimeQuery(): Nullable<_TimeToken>;
  9054. /**
  9055. * Ends a time query
  9056. * @param token defines the token used to measure the time span
  9057. * @returns the time spent (in ns)
  9058. */
  9059. endTimeQuery(token: _TimeToken): int;
  9060. private getGlAlgorithmType(algorithmType);
  9061. /**
  9062. * Creates a webGL transform feedback object
  9063. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  9064. * @returns the webGL transform feedback object
  9065. */
  9066. createTransformFeedback(): WebGLTransformFeedback;
  9067. /**
  9068. * Delete a webGL transform feedback object
  9069. * @param value defines the webGL transform feedback object to delete
  9070. */
  9071. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  9072. /**
  9073. * Bind a webGL transform feedback object to the webgl context
  9074. * @param value defines the webGL transform feedback object to bind
  9075. */
  9076. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  9077. /**
  9078. * Begins a transform feedback operation
  9079. * @param usePoints defines if points or triangles must be used
  9080. */
  9081. beginTransformFeedback(usePoints?: boolean): void;
  9082. /**
  9083. * Ends a transform feedback operation
  9084. */
  9085. endTransformFeedback(): void;
  9086. /**
  9087. * Specify the varyings to use with transform feedback
  9088. * @param program defines the associated webGL program
  9089. * @param value defines the list of strings representing the varying names
  9090. */
  9091. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  9092. /**
  9093. * Bind a webGL buffer for a transform feedback operation
  9094. * @param value defines the webGL buffer to bind
  9095. */
  9096. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  9097. /** @hidden */
  9098. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, database?: Database, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  9099. /** @hidden */
  9100. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  9101. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  9102. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  9103. /**
  9104. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  9105. * @returns true if the engine can be created
  9106. * @ignorenaming
  9107. */
  9108. static isSupported(): boolean;
  9109. }
  9110. }
  9111. declare module BABYLON {
  9112. class NullEngineOptions {
  9113. renderWidth: number;
  9114. renderHeight: number;
  9115. textureSize: number;
  9116. deterministicLockstep: boolean;
  9117. lockstepMaxSteps: number;
  9118. }
  9119. /**
  9120. * The null engine class provides support for headless version of babylon.js.
  9121. * This can be used in server side scenario or for testing purposes
  9122. */
  9123. class NullEngine extends Engine {
  9124. private _options;
  9125. isDeterministicLockStep(): boolean;
  9126. getLockstepMaxSteps(): number;
  9127. getHardwareScalingLevel(): number;
  9128. constructor(options?: NullEngineOptions);
  9129. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9130. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  9131. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  9132. getRenderWidth(useScreen?: boolean): number;
  9133. getRenderHeight(useScreen?: boolean): number;
  9134. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  9135. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  9136. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  9137. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  9138. bindSamplers(effect: Effect): void;
  9139. enableEffect(effect: Effect): void;
  9140. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  9141. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  9142. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  9143. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  9144. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  9145. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  9146. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  9147. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  9148. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  9149. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  9150. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  9151. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  9152. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  9153. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  9154. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  9155. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9156. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9157. setFloat(uniform: WebGLUniformLocation, value: number): void;
  9158. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  9159. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  9160. setBool(uniform: WebGLUniformLocation, bool: number): void;
  9161. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  9162. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  9163. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  9164. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  9165. bindBuffers(vertexBuffers: {
  9166. [key: string]: VertexBuffer;
  9167. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  9168. wipeCaches(bruteForce?: boolean): void;
  9169. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  9170. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  9171. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  9172. _createTexture(): WebGLTexture;
  9173. _releaseTexture(texture: InternalTexture): void;
  9174. 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;
  9175. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  9176. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  9177. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  9178. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  9179. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9180. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  9181. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  9182. /**
  9183. * Updates a dynamic vertex buffer.
  9184. * @param vertexBuffer the vertex buffer to update
  9185. * @param data the data used to update the vertex buffer
  9186. * @param byteOffset the byte offset of the data (optional)
  9187. * @param byteLength the byte length of the data (optional)
  9188. */
  9189. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  9190. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  9191. _bindTexture(channel: number, texture: InternalTexture): void;
  9192. _releaseBuffer(buffer: WebGLBuffer): boolean;
  9193. releaseEffects(): void;
  9194. }
  9195. }
  9196. interface WebGLRenderingContext {
  9197. readonly RASTERIZER_DISCARD: number;
  9198. readonly DEPTH_COMPONENT24: number;
  9199. readonly TEXTURE_3D: number;
  9200. readonly TEXTURE_2D_ARRAY: number;
  9201. readonly TEXTURE_COMPARE_FUNC: number;
  9202. readonly TEXTURE_COMPARE_MODE: number;
  9203. readonly COMPARE_REF_TO_TEXTURE: number;
  9204. readonly TEXTURE_WRAP_R: number;
  9205. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  9206. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  9207. 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;
  9208. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  9209. readonly TRANSFORM_FEEDBACK: number;
  9210. readonly INTERLEAVED_ATTRIBS: number;
  9211. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  9212. createTransformFeedback(): WebGLTransformFeedback;
  9213. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  9214. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  9215. beginTransformFeedback(primitiveMode: number): void;
  9216. endTransformFeedback(): void;
  9217. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  9218. }
  9219. interface ImageBitmap {
  9220. readonly width: number;
  9221. readonly height: number;
  9222. close(): void;
  9223. }
  9224. interface WebGLQuery extends WebGLObject {
  9225. }
  9226. declare var WebGLQuery: {
  9227. prototype: WebGLQuery;
  9228. new (): WebGLQuery;
  9229. };
  9230. interface WebGLSampler extends WebGLObject {
  9231. }
  9232. declare var WebGLSampler: {
  9233. prototype: WebGLSampler;
  9234. new (): WebGLSampler;
  9235. };
  9236. interface WebGLSync extends WebGLObject {
  9237. }
  9238. declare var WebGLSync: {
  9239. prototype: WebGLSync;
  9240. new (): WebGLSync;
  9241. };
  9242. interface WebGLTransformFeedback extends WebGLObject {
  9243. }
  9244. declare var WebGLTransformFeedback: {
  9245. prototype: WebGLTransformFeedback;
  9246. new (): WebGLTransformFeedback;
  9247. };
  9248. interface WebGLVertexArrayObject extends WebGLObject {
  9249. }
  9250. declare var WebGLVertexArrayObject: {
  9251. prototype: WebGLVertexArrayObject;
  9252. new (): WebGLVertexArrayObject;
  9253. };
  9254. declare module BABYLON {
  9255. class KeyboardEventTypes {
  9256. static _KEYDOWN: number;
  9257. static _KEYUP: number;
  9258. static readonly KEYDOWN: number;
  9259. static readonly KEYUP: number;
  9260. }
  9261. class KeyboardInfo {
  9262. type: number;
  9263. event: KeyboardEvent;
  9264. constructor(type: number, event: KeyboardEvent);
  9265. }
  9266. /**
  9267. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9268. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9269. */
  9270. class KeyboardInfoPre extends KeyboardInfo {
  9271. constructor(type: number, event: KeyboardEvent);
  9272. skipOnPointerObservable: boolean;
  9273. }
  9274. }
  9275. declare module BABYLON {
  9276. class PointerEventTypes {
  9277. static _POINTERDOWN: number;
  9278. static _POINTERUP: number;
  9279. static _POINTERMOVE: number;
  9280. static _POINTERWHEEL: number;
  9281. static _POINTERPICK: number;
  9282. static _POINTERTAP: number;
  9283. static _POINTERDOUBLETAP: number;
  9284. static readonly POINTERDOWN: number;
  9285. static readonly POINTERUP: number;
  9286. static readonly POINTERMOVE: number;
  9287. static readonly POINTERWHEEL: number;
  9288. static readonly POINTERPICK: number;
  9289. static readonly POINTERTAP: number;
  9290. static readonly POINTERDOUBLETAP: number;
  9291. }
  9292. class PointerInfoBase {
  9293. type: number;
  9294. event: PointerEvent | MouseWheelEvent;
  9295. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9296. }
  9297. /**
  9298. * This class is used to store pointer related info for the onPrePointerObservable event.
  9299. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9300. */
  9301. class PointerInfoPre extends PointerInfoBase {
  9302. /**
  9303. * Ray from a pointer if availible (eg. 6dof controller)
  9304. */
  9305. ray: Nullable<Ray>;
  9306. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9307. localPosition: Vector2;
  9308. skipOnPointerObservable: boolean;
  9309. }
  9310. /**
  9311. * This type contains all the data related to a pointer event in Babylon.js.
  9312. * 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.
  9313. */
  9314. class PointerInfo extends PointerInfoBase {
  9315. pickInfo: Nullable<PickingInfo>;
  9316. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9317. }
  9318. }
  9319. declare module BABYLON {
  9320. class StickValues {
  9321. x: number;
  9322. y: number;
  9323. constructor(x: number, y: number);
  9324. }
  9325. interface GamepadButtonChanges {
  9326. changed: boolean;
  9327. pressChanged: boolean;
  9328. touchChanged: boolean;
  9329. valueChanged: boolean;
  9330. }
  9331. class Gamepad {
  9332. id: string;
  9333. index: number;
  9334. browserGamepad: any;
  9335. type: number;
  9336. private _leftStick;
  9337. private _rightStick;
  9338. _isConnected: boolean;
  9339. private _leftStickAxisX;
  9340. private _leftStickAxisY;
  9341. private _rightStickAxisX;
  9342. private _rightStickAxisY;
  9343. private _onleftstickchanged;
  9344. private _onrightstickchanged;
  9345. static GAMEPAD: number;
  9346. static GENERIC: number;
  9347. static XBOX: number;
  9348. static POSE_ENABLED: number;
  9349. protected _invertLeftStickY: boolean;
  9350. readonly isConnected: boolean;
  9351. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9352. onleftstickchanged(callback: (values: StickValues) => void): void;
  9353. onrightstickchanged(callback: (values: StickValues) => void): void;
  9354. leftStick: StickValues;
  9355. rightStick: StickValues;
  9356. update(): void;
  9357. dispose(): void;
  9358. }
  9359. class GenericPad extends Gamepad {
  9360. private _buttons;
  9361. private _onbuttondown;
  9362. private _onbuttonup;
  9363. onButtonDownObservable: Observable<number>;
  9364. onButtonUpObservable: Observable<number>;
  9365. onbuttondown(callback: (buttonPressed: number) => void): void;
  9366. onbuttonup(callback: (buttonReleased: number) => void): void;
  9367. constructor(id: string, index: number, browserGamepad: any);
  9368. private _setButtonValue(newValue, currentValue, buttonIndex);
  9369. update(): void;
  9370. dispose(): void;
  9371. }
  9372. }
  9373. declare module BABYLON {
  9374. class GamepadManager {
  9375. private _scene;
  9376. private _babylonGamepads;
  9377. private _oneGamepadConnected;
  9378. _isMonitoring: boolean;
  9379. private _gamepadEventSupported;
  9380. private _gamepadSupport;
  9381. onGamepadConnectedObservable: Observable<Gamepad>;
  9382. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9383. private _onGamepadConnectedEvent;
  9384. private _onGamepadDisconnectedEvent;
  9385. constructor(_scene?: Scene | undefined);
  9386. readonly gamepads: Gamepad[];
  9387. getGamepadByType(type?: number): Nullable<Gamepad>;
  9388. dispose(): void;
  9389. private _addNewGamepad(gamepad);
  9390. private _startMonitoringGamepads();
  9391. private _stopMonitoringGamepads();
  9392. _checkGamepadsStatus(): void;
  9393. private _updateGamepadObjects();
  9394. }
  9395. }
  9396. declare module BABYLON {
  9397. /**
  9398. * Defines supported buttons for XBox360 compatible gamepads
  9399. */
  9400. enum Xbox360Button {
  9401. /** A */
  9402. A = 0,
  9403. /** B */
  9404. B = 1,
  9405. /** X */
  9406. X = 2,
  9407. /** Y */
  9408. Y = 3,
  9409. /** Start */
  9410. Start = 4,
  9411. /** Back */
  9412. Back = 5,
  9413. /** Left button */
  9414. LB = 6,
  9415. /** Right button */
  9416. RB = 7,
  9417. /** Left stick */
  9418. LeftStick = 8,
  9419. /** Right stick */
  9420. RightStick = 9,
  9421. }
  9422. /** Defines values for XBox360 DPad */
  9423. enum Xbox360Dpad {
  9424. /** Up */
  9425. Up = 0,
  9426. /** Down */
  9427. Down = 1,
  9428. /** Left */
  9429. Left = 2,
  9430. /** Right */
  9431. Right = 3,
  9432. }
  9433. /**
  9434. * Defines a XBox360 gamepad
  9435. */
  9436. class Xbox360Pad extends Gamepad {
  9437. private _leftTrigger;
  9438. private _rightTrigger;
  9439. private _onlefttriggerchanged;
  9440. private _onrighttriggerchanged;
  9441. private _onbuttondown;
  9442. private _onbuttonup;
  9443. private _ondpaddown;
  9444. private _ondpadup;
  9445. /** Observable raised when a button is pressed */
  9446. onButtonDownObservable: Observable<Xbox360Button>;
  9447. /** Observable raised when a button is released */
  9448. onButtonUpObservable: Observable<Xbox360Button>;
  9449. /** Observable raised when a pad is pressed */
  9450. onPadDownObservable: Observable<Xbox360Dpad>;
  9451. /** Observable raised when a pad is released */
  9452. onPadUpObservable: Observable<Xbox360Dpad>;
  9453. private _buttonA;
  9454. private _buttonB;
  9455. private _buttonX;
  9456. private _buttonY;
  9457. private _buttonBack;
  9458. private _buttonStart;
  9459. private _buttonLB;
  9460. private _buttonRB;
  9461. private _buttonLeftStick;
  9462. private _buttonRightStick;
  9463. private _dPadUp;
  9464. private _dPadDown;
  9465. private _dPadLeft;
  9466. private _dPadRight;
  9467. private _isXboxOnePad;
  9468. /**
  9469. * Creates a new XBox360 gamepad object
  9470. * @param id defines the id of this gamepad
  9471. * @param index defines its index
  9472. * @param gamepad defines the internal HTML gamepad object
  9473. * @param xboxOne defines if it is a XBox One gamepad
  9474. */
  9475. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9476. /**
  9477. * Defines the callback to call when left trigger is pressed
  9478. * @param callback defines the callback to use
  9479. */
  9480. onlefttriggerchanged(callback: (value: number) => void): void;
  9481. /**
  9482. * Defines the callback to call when right trigger is pressed
  9483. * @param callback defines the callback to use
  9484. */
  9485. onrighttriggerchanged(callback: (value: number) => void): void;
  9486. /**
  9487. * Gets or sets left trigger value
  9488. */
  9489. leftTrigger: number;
  9490. /**
  9491. * Gets or sets right trigger value
  9492. */
  9493. rightTrigger: number;
  9494. /**
  9495. * Defines the callback to call when a button is pressed
  9496. * @param callback defines the callback to use
  9497. */
  9498. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9499. /**
  9500. * Defines the callback to call when a button is released
  9501. * @param callback defines the callback to use
  9502. */
  9503. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9504. /**
  9505. * Defines the callback to call when a pad is pressed
  9506. * @param callback defines the callback to use
  9507. */
  9508. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9509. /**
  9510. * Defines the callback to call when a pad is released
  9511. * @param callback defines the callback to use
  9512. */
  9513. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9514. private _setButtonValue(newValue, currentValue, buttonType);
  9515. private _setDPadValue(newValue, currentValue, buttonType);
  9516. /** Gets or sets value of A button */
  9517. buttonA: number;
  9518. /** Gets or sets value of B button */
  9519. buttonB: number;
  9520. /** Gets or sets value of X button */
  9521. buttonX: number;
  9522. /** Gets or sets value of Y button */
  9523. buttonY: number;
  9524. /** Gets or sets value of Start button */
  9525. buttonStart: number;
  9526. /** Gets or sets value of Back button */
  9527. buttonBack: number;
  9528. /** Gets or sets value of Left button */
  9529. buttonLB: number;
  9530. /** Gets or sets value of Right button */
  9531. buttonRB: number;
  9532. /** Gets or sets value of left stick */
  9533. buttonLeftStick: number;
  9534. /** Gets or sets value of right stick */
  9535. buttonRightStick: number;
  9536. /** Gets or sets value of DPad up */
  9537. dPadUp: number;
  9538. /** Gets or sets value of DPad down */
  9539. dPadDown: number;
  9540. /** Gets or sets value of DPad left */
  9541. dPadLeft: number;
  9542. /** Gets or sets value of DPad right */
  9543. dPadRight: number;
  9544. /**
  9545. * Force the gamepad to synchronize with device values
  9546. */
  9547. update(): void;
  9548. dispose(): void;
  9549. }
  9550. }
  9551. declare module BABYLON {
  9552. /**
  9553. * Single axis drag gizmo
  9554. */
  9555. class AxisDragGizmo extends Gizmo {
  9556. private _dragBehavior;
  9557. private _pointerObserver;
  9558. /**
  9559. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9560. */
  9561. snapDistance: number;
  9562. /**
  9563. * Event that fires each time the gizmo snaps to a new location.
  9564. * * snapDistance is the the change in distance
  9565. */
  9566. onSnapObservable: Observable<{
  9567. snapDistance: number;
  9568. }>;
  9569. /**
  9570. * Creates an AxisDragGizmo
  9571. * @param gizmoLayer The utility layer the gizmo will be added to
  9572. * @param dragAxis The axis which the gizmo will be able to drag on
  9573. * @param color The color of the gizmo
  9574. */
  9575. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9576. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9577. /**
  9578. * Disposes of the gizmo
  9579. */
  9580. dispose(): void;
  9581. }
  9582. }
  9583. declare module BABYLON {
  9584. /**
  9585. * Single axis scale gizmo
  9586. */
  9587. class AxisScaleGizmo extends Gizmo {
  9588. private _dragBehavior;
  9589. private _pointerObserver;
  9590. /**
  9591. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9592. */
  9593. snapDistance: number;
  9594. /**
  9595. * Event that fires each time the gizmo snaps to a new location.
  9596. * * snapDistance is the the change in distance
  9597. */
  9598. onSnapObservable: Observable<{
  9599. snapDistance: number;
  9600. }>;
  9601. /**
  9602. * Creates an AxisScaleGizmo
  9603. * @param gizmoLayer The utility layer the gizmo will be added to
  9604. * @param dragAxis The axis which the gizmo will be able to scale on
  9605. * @param color The color of the gizmo
  9606. */
  9607. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9608. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9609. /**
  9610. * Disposes of the gizmo
  9611. */
  9612. dispose(): void;
  9613. }
  9614. }
  9615. declare module BABYLON {
  9616. /**
  9617. * Bounding box gizmo
  9618. */
  9619. class BoundingBoxGizmo extends Gizmo {
  9620. private _lineBoundingBox;
  9621. private _rotateSpheresParent;
  9622. private _scaleBoxesParent;
  9623. private _boundingDimensions;
  9624. private _renderObserver;
  9625. private _pointerObserver;
  9626. private _scaleDragSpeed;
  9627. private _tmpQuaternion;
  9628. private _tmpVector;
  9629. /**
  9630. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  9631. */
  9632. rotationSphereSize: number;
  9633. /**
  9634. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  9635. */
  9636. scaleBoxSize: number;
  9637. /**
  9638. * 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)
  9639. */
  9640. fixedDragMeshScreenSize: boolean;
  9641. /**
  9642. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  9643. */
  9644. fixedDragMeshScreenSizeDistanceFactor: number;
  9645. /**
  9646. * Fired when a rotation sphere or scale box is dragged
  9647. */
  9648. onDragStartObservable: Observable<{}>;
  9649. /**
  9650. * Fired when a rotation sphere or scale box drag is started
  9651. */
  9652. onDragObservable: Observable<{}>;
  9653. /**
  9654. * Fired when a rotation sphere or scale box drag is needed
  9655. */
  9656. onDragEndObservable: Observable<{}>;
  9657. /**
  9658. * Creates an BoundingBoxGizmo
  9659. * @param gizmoLayer The utility layer the gizmo will be added to
  9660. * @param color The color of the gizmo
  9661. */
  9662. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9663. private _selectNode(selectedMesh);
  9664. private _updateBoundingBox();
  9665. /**
  9666. * Enables rotation on the specified axis and disables rotation on the others
  9667. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  9668. */
  9669. setEnabledRotationAxis(axis: string): void;
  9670. /**
  9671. * Disposes of the gizmo
  9672. */
  9673. dispose(): void;
  9674. }
  9675. }
  9676. declare module BABYLON {
  9677. /**
  9678. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  9679. */
  9680. class Gizmo implements IDisposable {
  9681. /** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer;
  9682. /**
  9683. * The root mesh of the gizmo
  9684. */
  9685. protected _rootMesh: Mesh;
  9686. private _attachedMesh;
  9687. /**
  9688. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  9689. * * When set, interactions will be enabled
  9690. */
  9691. attachedMesh: Nullable<AbstractMesh>;
  9692. /**
  9693. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  9694. */
  9695. updateGizmoRotationToMatchAttachedMesh: boolean;
  9696. /**
  9697. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  9698. */
  9699. updateGizmoPositionToMatchAttachedMesh: boolean;
  9700. /**
  9701. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  9702. */
  9703. protected _updateScale: boolean;
  9704. protected _interactionsEnabled: boolean;
  9705. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9706. private _beforeRenderObserver;
  9707. /**
  9708. * Creates a gizmo
  9709. * @param gizmoLayer The utility layer the gizmo will be added to
  9710. */
  9711. constructor(/** The utility layer the gizmo will be added to */ gizmoLayer?: UtilityLayerRenderer);
  9712. /**
  9713. * Disposes of the gizmo
  9714. */
  9715. dispose(): void;
  9716. }
  9717. }
  9718. declare module BABYLON {
  9719. /**
  9720. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  9721. */
  9722. class GizmoManager implements IDisposable {
  9723. private scene;
  9724. private _gizmoLayer;
  9725. private _gizmoSet;
  9726. private _pointerObserver;
  9727. /**
  9728. * Instatiates a gizmo manager
  9729. * @param scene the scene to overlay the gizmos on top of
  9730. * @param options If only a single gizmo should exist at one time
  9731. */
  9732. constructor(scene: Scene, options?: {
  9733. singleGizmo?: boolean;
  9734. });
  9735. /**
  9736. * Disposes of the gizmo manager
  9737. */
  9738. dispose(): void;
  9739. private _clearGizmos();
  9740. }
  9741. }
  9742. declare module BABYLON {
  9743. /**
  9744. * Single plane rotation gizmo
  9745. */
  9746. class PlaneRotationGizmo extends Gizmo {
  9747. private _dragBehavior;
  9748. private _pointerObserver;
  9749. /**
  9750. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  9751. */
  9752. snapDistance: number;
  9753. /**
  9754. * Event that fires each time the gizmo snaps to a new location.
  9755. * * snapDistance is the the change in distance
  9756. */
  9757. onSnapObservable: Observable<{
  9758. snapDistance: number;
  9759. }>;
  9760. /**
  9761. * Creates a PlaneRotationGizmo
  9762. * @param gizmoLayer The utility layer the gizmo will be added to
  9763. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  9764. * @param color The color of the gizmo
  9765. */
  9766. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9767. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9768. /**
  9769. * Disposes of the gizmo
  9770. */
  9771. dispose(): void;
  9772. }
  9773. }
  9774. declare module BABYLON {
  9775. /**
  9776. * Gizmo that enables dragging a mesh along 3 axis
  9777. */
  9778. class PositionGizmo extends Gizmo {
  9779. private _xDrag;
  9780. private _yDrag;
  9781. private _zDrag;
  9782. attachedMesh: Nullable<AbstractMesh>;
  9783. /**
  9784. * Creates a PositionGizmo
  9785. * @param gizmoLayer The utility layer the gizmo will be added to
  9786. */
  9787. constructor(gizmoLayer?: UtilityLayerRenderer);
  9788. updateGizmoRotationToMatchAttachedMesh: boolean;
  9789. /**
  9790. * Disposes of the gizmo
  9791. */
  9792. dispose(): void;
  9793. }
  9794. }
  9795. declare module BABYLON {
  9796. /**
  9797. * Gizmo that enables rotating a mesh along 3 axis
  9798. */
  9799. class RotationGizmo extends Gizmo {
  9800. private _xDrag;
  9801. private _yDrag;
  9802. private _zDrag;
  9803. attachedMesh: Nullable<AbstractMesh>;
  9804. /**
  9805. * Creates a RotationGizmo
  9806. * @param gizmoLayer The utility layer the gizmo will be added to
  9807. */
  9808. constructor(gizmoLayer?: UtilityLayerRenderer);
  9809. updateGizmoRotationToMatchAttachedMesh: boolean;
  9810. /**
  9811. * Disposes of the gizmo
  9812. */
  9813. dispose(): void;
  9814. }
  9815. }
  9816. declare module BABYLON {
  9817. /**
  9818. * Gizmo that enables scaling a mesh along 3 axis
  9819. */
  9820. class ScaleGizmo extends Gizmo {
  9821. private _xDrag;
  9822. private _yDrag;
  9823. private _zDrag;
  9824. attachedMesh: Nullable<AbstractMesh>;
  9825. /**
  9826. * Creates a ScaleGizmo
  9827. * @param gizmoLayer The utility layer the gizmo will be added to
  9828. */
  9829. constructor(gizmoLayer?: UtilityLayerRenderer);
  9830. updateGizmoRotationToMatchAttachedMesh: boolean;
  9831. /**
  9832. * Disposes of the gizmo
  9833. */
  9834. dispose(): void;
  9835. }
  9836. }
  9837. declare module BABYLON {
  9838. /**
  9839. * Represents the different options available during the creation of
  9840. * a Environment helper.
  9841. *
  9842. * This can control the default ground, skybox and image processing setup of your scene.
  9843. */
  9844. interface IEnvironmentHelperOptions {
  9845. /**
  9846. * Specifies wether or not to create a ground.
  9847. * True by default.
  9848. */
  9849. createGround: boolean;
  9850. /**
  9851. * Specifies the ground size.
  9852. * 15 by default.
  9853. */
  9854. groundSize: number;
  9855. /**
  9856. * The texture used on the ground for the main color.
  9857. * Comes from the BabylonJS CDN by default.
  9858. *
  9859. * Remarks: Can be either a texture or a url.
  9860. */
  9861. groundTexture: string | BaseTexture;
  9862. /**
  9863. * The color mixed in the ground texture by default.
  9864. * BabylonJS clearColor by default.
  9865. */
  9866. groundColor: Color3;
  9867. /**
  9868. * Specifies the ground opacity.
  9869. * 1 by default.
  9870. */
  9871. groundOpacity: number;
  9872. /**
  9873. * Enables the ground to receive shadows.
  9874. * True by default.
  9875. */
  9876. enableGroundShadow: boolean;
  9877. /**
  9878. * Helps preventing the shadow to be fully black on the ground.
  9879. * 0.5 by default.
  9880. */
  9881. groundShadowLevel: number;
  9882. /**
  9883. * Creates a mirror texture attach to the ground.
  9884. * false by default.
  9885. */
  9886. enableGroundMirror: boolean;
  9887. /**
  9888. * Specifies the ground mirror size ratio.
  9889. * 0.3 by default as the default kernel is 64.
  9890. */
  9891. groundMirrorSizeRatio: number;
  9892. /**
  9893. * Specifies the ground mirror blur kernel size.
  9894. * 64 by default.
  9895. */
  9896. groundMirrorBlurKernel: number;
  9897. /**
  9898. * Specifies the ground mirror visibility amount.
  9899. * 1 by default
  9900. */
  9901. groundMirrorAmount: number;
  9902. /**
  9903. * Specifies the ground mirror reflectance weight.
  9904. * This uses the standard weight of the background material to setup the fresnel effect
  9905. * of the mirror.
  9906. * 1 by default.
  9907. */
  9908. groundMirrorFresnelWeight: number;
  9909. /**
  9910. * Specifies the ground mirror Falloff distance.
  9911. * This can helps reducing the size of the reflection.
  9912. * 0 by Default.
  9913. */
  9914. groundMirrorFallOffDistance: number;
  9915. /**
  9916. * Specifies the ground mirror texture type.
  9917. * Unsigned Int by Default.
  9918. */
  9919. groundMirrorTextureType: number;
  9920. /**
  9921. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  9922. * the shown objects.
  9923. */
  9924. groundYBias: number;
  9925. /**
  9926. * Specifies wether or not to create a skybox.
  9927. * True by default.
  9928. */
  9929. createSkybox: boolean;
  9930. /**
  9931. * Specifies the skybox size.
  9932. * 20 by default.
  9933. */
  9934. skyboxSize: number;
  9935. /**
  9936. * The texture used on the skybox for the main color.
  9937. * Comes from the BabylonJS CDN by default.
  9938. *
  9939. * Remarks: Can be either a texture or a url.
  9940. */
  9941. skyboxTexture: string | BaseTexture;
  9942. /**
  9943. * The color mixed in the skybox texture by default.
  9944. * BabylonJS clearColor by default.
  9945. */
  9946. skyboxColor: Color3;
  9947. /**
  9948. * The background rotation around the Y axis of the scene.
  9949. * This helps aligning the key lights of your scene with the background.
  9950. * 0 by default.
  9951. */
  9952. backgroundYRotation: number;
  9953. /**
  9954. * Compute automatically the size of the elements to best fit with the scene.
  9955. */
  9956. sizeAuto: boolean;
  9957. /**
  9958. * Default position of the rootMesh if autoSize is not true.
  9959. */
  9960. rootPosition: Vector3;
  9961. /**
  9962. * Sets up the image processing in the scene.
  9963. * true by default.
  9964. */
  9965. setupImageProcessing: boolean;
  9966. /**
  9967. * The texture used as your environment texture in the scene.
  9968. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  9969. *
  9970. * Remarks: Can be either a texture or a url.
  9971. */
  9972. environmentTexture: string | BaseTexture;
  9973. /**
  9974. * The value of the exposure to apply to the scene.
  9975. * 0.6 by default if setupImageProcessing is true.
  9976. */
  9977. cameraExposure: number;
  9978. /**
  9979. * The value of the contrast to apply to the scene.
  9980. * 1.6 by default if setupImageProcessing is true.
  9981. */
  9982. cameraContrast: number;
  9983. /**
  9984. * Specifies wether or not tonemapping should be enabled in the scene.
  9985. * true by default if setupImageProcessing is true.
  9986. */
  9987. toneMappingEnabled: boolean;
  9988. }
  9989. /**
  9990. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  9991. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  9992. * It also helps with the default setup of your imageProcessing configuration.
  9993. */
  9994. class EnvironmentHelper {
  9995. /**
  9996. * Default ground texture URL.
  9997. */
  9998. private static _groundTextureCDNUrl;
  9999. /**
  10000. * Default skybox texture URL.
  10001. */
  10002. private static _skyboxTextureCDNUrl;
  10003. /**
  10004. * Default environment texture URL.
  10005. */
  10006. private static _environmentTextureCDNUrl;
  10007. /**
  10008. * Creates the default options for the helper.
  10009. */
  10010. private static _getDefaultOptions();
  10011. private _rootMesh;
  10012. /**
  10013. * Gets the root mesh created by the helper.
  10014. */
  10015. readonly rootMesh: Mesh;
  10016. private _skybox;
  10017. /**
  10018. * Gets the skybox created by the helper.
  10019. */
  10020. readonly skybox: Nullable<Mesh>;
  10021. private _skyboxTexture;
  10022. /**
  10023. * Gets the skybox texture created by the helper.
  10024. */
  10025. readonly skyboxTexture: Nullable<BaseTexture>;
  10026. private _skyboxMaterial;
  10027. /**
  10028. * Gets the skybox material created by the helper.
  10029. */
  10030. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  10031. private _ground;
  10032. /**
  10033. * Gets the ground mesh created by the helper.
  10034. */
  10035. readonly ground: Nullable<Mesh>;
  10036. private _groundTexture;
  10037. /**
  10038. * Gets the ground texture created by the helper.
  10039. */
  10040. readonly groundTexture: Nullable<BaseTexture>;
  10041. private _groundMirror;
  10042. /**
  10043. * Gets the ground mirror created by the helper.
  10044. */
  10045. readonly groundMirror: Nullable<MirrorTexture>;
  10046. /**
  10047. * Gets the ground mirror render list to helps pushing the meshes
  10048. * you wish in the ground reflection.
  10049. */
  10050. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  10051. private _groundMaterial;
  10052. /**
  10053. * Gets the ground material created by the helper.
  10054. */
  10055. readonly groundMaterial: Nullable<BackgroundMaterial>;
  10056. /**
  10057. * Stores the creation options.
  10058. */
  10059. private readonly _scene;
  10060. private _options;
  10061. /**
  10062. * This observable will be notified with any error during the creation of the environment,
  10063. * mainly texture creation errors.
  10064. */
  10065. onErrorObservable: Observable<{
  10066. message?: string;
  10067. exception?: any;
  10068. }>;
  10069. /**
  10070. * constructor
  10071. * @param options
  10072. * @param scene The scene to add the material to
  10073. */
  10074. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  10075. /**
  10076. * Updates the background according to the new options
  10077. * @param options
  10078. */
  10079. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  10080. /**
  10081. * Sets the primary color of all the available elements.
  10082. * @param color the main color to affect to the ground and the background
  10083. */
  10084. setMainColor(color: Color3): void;
  10085. /**
  10086. * Setup the image processing according to the specified options.
  10087. */
  10088. private _setupImageProcessing();
  10089. /**
  10090. * Setup the environment texture according to the specified options.
  10091. */
  10092. private _setupEnvironmentTexture();
  10093. /**
  10094. * Setup the background according to the specified options.
  10095. */
  10096. private _setupBackground();
  10097. /**
  10098. * Get the scene sizes according to the setup.
  10099. */
  10100. private _getSceneSize();
  10101. /**
  10102. * Setup the ground according to the specified options.
  10103. */
  10104. private _setupGround(sceneSize);
  10105. /**
  10106. * Setup the ground material according to the specified options.
  10107. */
  10108. private _setupGroundMaterial();
  10109. /**
  10110. * Setup the ground diffuse texture according to the specified options.
  10111. */
  10112. private _setupGroundDiffuseTexture();
  10113. /**
  10114. * Setup the ground mirror texture according to the specified options.
  10115. */
  10116. private _setupGroundMirrorTexture(sceneSize);
  10117. /**
  10118. * Setup the ground to receive the mirror texture.
  10119. */
  10120. private _setupMirrorInGroundMaterial();
  10121. /**
  10122. * Setup the skybox according to the specified options.
  10123. */
  10124. private _setupSkybox(sceneSize);
  10125. /**
  10126. * Setup the skybox material according to the specified options.
  10127. */
  10128. private _setupSkyboxMaterial();
  10129. /**
  10130. * Setup the skybox reflection texture according to the specified options.
  10131. */
  10132. private _setupSkyboxReflectionTexture();
  10133. private _errorHandler;
  10134. /**
  10135. * Dispose all the elements created by the Helper.
  10136. */
  10137. dispose(): void;
  10138. }
  10139. }
  10140. declare module BABYLON {
  10141. /**
  10142. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  10143. * As a subclass of Node, this allow parenting to the camera with different locations in the scene.
  10144. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  10145. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10146. */
  10147. class PhotoDome extends Node {
  10148. private _useDirectMapping;
  10149. /**
  10150. * The texture being displayed on the sphere
  10151. */
  10152. protected _photoTexture: Texture;
  10153. /**
  10154. * Gets or sets the texture being displayed on the sphere
  10155. */
  10156. photoTexture: Texture;
  10157. /**
  10158. * The skybox material
  10159. */
  10160. protected _material: BackgroundMaterial;
  10161. /**
  10162. * The surface used for the skybox
  10163. */
  10164. protected _mesh: Mesh;
  10165. /**
  10166. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10167. * Also see the options.resolution property.
  10168. */
  10169. fovMultiplier: number;
  10170. /**
  10171. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10172. * @param name Element's name, child elements will append suffixes for their own names.
  10173. * @param urlsOfPhoto define the url of the photo to display
  10174. * @param options An object containing optional or exposed sub element properties
  10175. */
  10176. constructor(name: string, urlOfPhoto: string, options: {
  10177. resolution?: number;
  10178. size?: number;
  10179. useDirectMapping?: boolean;
  10180. }, scene: Scene);
  10181. /**
  10182. * Releases resources associated with this node.
  10183. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10184. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10185. */
  10186. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10187. }
  10188. }
  10189. declare module BABYLON {
  10190. /**
  10191. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10192. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  10193. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10194. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10195. */
  10196. class VideoDome extends Node {
  10197. private _useDirectMapping;
  10198. /**
  10199. * The video texture being displayed on the sphere
  10200. */
  10201. protected _videoTexture: VideoTexture;
  10202. /**
  10203. * Gets the video texture being displayed on the sphere
  10204. */
  10205. readonly videoTexture: VideoTexture;
  10206. /**
  10207. * The skybox material
  10208. */
  10209. protected _material: BackgroundMaterial;
  10210. /**
  10211. * The surface used for the skybox
  10212. */
  10213. protected _mesh: Mesh;
  10214. /**
  10215. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10216. * Also see the options.resolution property.
  10217. */
  10218. fovMultiplier: number;
  10219. /**
  10220. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10221. * @param name Element's name, child elements will append suffixes for their own names.
  10222. * @param urlsOrVideo defines the url(s) or the video element to use
  10223. * @param options An object containing optional or exposed sub element properties
  10224. */
  10225. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10226. resolution?: number;
  10227. clickToPlay?: boolean;
  10228. autoPlay?: boolean;
  10229. loop?: boolean;
  10230. size?: number;
  10231. poster?: string;
  10232. useDirectMapping?: boolean;
  10233. }, scene: Scene);
  10234. /**
  10235. * Releases resources associated with this node.
  10236. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10237. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10238. */
  10239. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10240. }
  10241. }
  10242. declare module BABYLON {
  10243. /**
  10244. * This class can be used to get instrumentation data from a Babylon engine
  10245. */
  10246. class EngineInstrumentation implements IDisposable {
  10247. engine: Engine;
  10248. private _captureGPUFrameTime;
  10249. private _gpuFrameTimeToken;
  10250. private _gpuFrameTime;
  10251. private _captureShaderCompilationTime;
  10252. private _shaderCompilationTime;
  10253. private _onBeginFrameObserver;
  10254. private _onEndFrameObserver;
  10255. private _onBeforeShaderCompilationObserver;
  10256. private _onAfterShaderCompilationObserver;
  10257. /**
  10258. * Gets the perf counter used for GPU frame time
  10259. */
  10260. readonly gpuFrameTimeCounter: PerfCounter;
  10261. /**
  10262. * Gets the GPU frame time capture status
  10263. */
  10264. /**
  10265. * Enable or disable the GPU frame time capture
  10266. */
  10267. captureGPUFrameTime: boolean;
  10268. /**
  10269. * Gets the perf counter used for shader compilation time
  10270. */
  10271. readonly shaderCompilationTimeCounter: PerfCounter;
  10272. /**
  10273. * Gets the shader compilation time capture status
  10274. */
  10275. /**
  10276. * Enable or disable the shader compilation time capture
  10277. */
  10278. captureShaderCompilationTime: boolean;
  10279. constructor(engine: Engine);
  10280. dispose(): void;
  10281. }
  10282. }
  10283. declare module BABYLON {
  10284. /**
  10285. * This class can be used to get instrumentation data from a Babylon engine
  10286. */
  10287. class SceneInstrumentation implements IDisposable {
  10288. scene: Scene;
  10289. private _captureActiveMeshesEvaluationTime;
  10290. private _activeMeshesEvaluationTime;
  10291. private _captureRenderTargetsRenderTime;
  10292. private _renderTargetsRenderTime;
  10293. private _captureFrameTime;
  10294. private _frameTime;
  10295. private _captureRenderTime;
  10296. private _renderTime;
  10297. private _captureInterFrameTime;
  10298. private _interFrameTime;
  10299. private _captureParticlesRenderTime;
  10300. private _particlesRenderTime;
  10301. private _captureSpritesRenderTime;
  10302. private _spritesRenderTime;
  10303. private _capturePhysicsTime;
  10304. private _physicsTime;
  10305. private _captureAnimationsTime;
  10306. private _animationsTime;
  10307. private _captureCameraRenderTime;
  10308. private _cameraRenderTime;
  10309. private _onBeforeActiveMeshesEvaluationObserver;
  10310. private _onAfterActiveMeshesEvaluationObserver;
  10311. private _onBeforeRenderTargetsRenderObserver;
  10312. private _onAfterRenderTargetsRenderObserver;
  10313. private _onAfterRenderObserver;
  10314. private _onBeforeDrawPhaseObserver;
  10315. private _onAfterDrawPhaseObserver;
  10316. private _onBeforeAnimationsObserver;
  10317. private _onBeforeParticlesRenderingObserver;
  10318. private _onAfterParticlesRenderingObserver;
  10319. private _onBeforeSpritesRenderingObserver;
  10320. private _onAfterSpritesRenderingObserver;
  10321. private _onBeforePhysicsObserver;
  10322. private _onAfterPhysicsObserver;
  10323. private _onAfterAnimationsObserver;
  10324. private _onBeforeCameraRenderObserver;
  10325. private _onAfterCameraRenderObserver;
  10326. /**
  10327. * Gets the perf counter used for active meshes evaluation time
  10328. */
  10329. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10330. /**
  10331. * Gets the active meshes evaluation time capture status
  10332. */
  10333. /**
  10334. * Enable or disable the active meshes evaluation time capture
  10335. */
  10336. captureActiveMeshesEvaluationTime: boolean;
  10337. /**
  10338. * Gets the perf counter used for render targets render time
  10339. */
  10340. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10341. /**
  10342. * Gets the render targets render time capture status
  10343. */
  10344. /**
  10345. * Enable or disable the render targets render time capture
  10346. */
  10347. captureRenderTargetsRenderTime: boolean;
  10348. /**
  10349. * Gets the perf counter used for particles render time
  10350. */
  10351. readonly particlesRenderTimeCounter: PerfCounter;
  10352. /**
  10353. * Gets the particles render time capture status
  10354. */
  10355. /**
  10356. * Enable or disable the particles render time capture
  10357. */
  10358. captureParticlesRenderTime: boolean;
  10359. /**
  10360. * Gets the perf counter used for sprites render time
  10361. */
  10362. readonly spritesRenderTimeCounter: PerfCounter;
  10363. /**
  10364. * Gets the sprites render time capture status
  10365. */
  10366. /**
  10367. * Enable or disable the sprites render time capture
  10368. */
  10369. captureSpritesRenderTime: boolean;
  10370. /**
  10371. * Gets the perf counter used for physics time
  10372. */
  10373. readonly physicsTimeCounter: PerfCounter;
  10374. /**
  10375. * Gets the physics time capture status
  10376. */
  10377. /**
  10378. * Enable or disable the physics time capture
  10379. */
  10380. capturePhysicsTime: boolean;
  10381. /**
  10382. * Gets the perf counter used for animations time
  10383. */
  10384. readonly animationsTimeCounter: PerfCounter;
  10385. /**
  10386. * Gets the animations time capture status
  10387. */
  10388. /**
  10389. * Enable or disable the animations time capture
  10390. */
  10391. captureAnimationsTime: boolean;
  10392. /**
  10393. * Gets the perf counter used for frame time capture
  10394. */
  10395. readonly frameTimeCounter: PerfCounter;
  10396. /**
  10397. * Gets the frame time capture status
  10398. */
  10399. /**
  10400. * Enable or disable the frame time capture
  10401. */
  10402. captureFrameTime: boolean;
  10403. /**
  10404. * Gets the perf counter used for inter-frames time capture
  10405. */
  10406. readonly interFrameTimeCounter: PerfCounter;
  10407. /**
  10408. * Gets the inter-frames time capture status
  10409. */
  10410. /**
  10411. * Enable or disable the inter-frames time capture
  10412. */
  10413. captureInterFrameTime: boolean;
  10414. /**
  10415. * Gets the perf counter used for render time capture
  10416. */
  10417. readonly renderTimeCounter: PerfCounter;
  10418. /**
  10419. * Gets the render time capture status
  10420. */
  10421. /**
  10422. * Enable or disable the render time capture
  10423. */
  10424. captureRenderTime: boolean;
  10425. /**
  10426. * Gets the perf counter used for camera render time capture
  10427. */
  10428. readonly cameraRenderTimeCounter: PerfCounter;
  10429. /**
  10430. * Gets the camera render time capture status
  10431. */
  10432. /**
  10433. * Enable or disable the camera render time capture
  10434. */
  10435. captureCameraRenderTime: boolean;
  10436. /**
  10437. * Gets the perf counter used for draw calls
  10438. */
  10439. readonly drawCallsCounter: PerfCounter;
  10440. /**
  10441. * Gets the perf counter used for texture collisions
  10442. */
  10443. readonly textureCollisionsCounter: PerfCounter;
  10444. constructor(scene: Scene);
  10445. dispose(): void;
  10446. }
  10447. }
  10448. declare module BABYLON {
  10449. /**
  10450. * @hidden
  10451. **/
  10452. class _TimeToken {
  10453. _startTimeQuery: Nullable<WebGLQuery>;
  10454. _endTimeQuery: Nullable<WebGLQuery>;
  10455. _timeElapsedQuery: Nullable<WebGLQuery>;
  10456. _timeElapsedQueryEnded: boolean;
  10457. }
  10458. }
  10459. declare module BABYLON {
  10460. /**
  10461. * Effect layer options. This helps customizing the behaviour
  10462. * of the effect layer.
  10463. */
  10464. interface IEffectLayerOptions {
  10465. /**
  10466. * Multiplication factor apply to the canvas size to compute the render target size
  10467. * used to generated the objects (the smaller the faster).
  10468. */
  10469. mainTextureRatio: number;
  10470. /**
  10471. * Enforces a fixed size texture to ensure effect stability across devices.
  10472. */
  10473. mainTextureFixedSize?: number;
  10474. /**
  10475. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10476. */
  10477. alphaBlendingMode: number;
  10478. /**
  10479. * The camera attached to the layer.
  10480. */
  10481. camera: Nullable<Camera>;
  10482. }
  10483. /**
  10484. * The effect layer Helps adding post process effect blended with the main pass.
  10485. *
  10486. * This can be for instance use to generate glow or higlight effects on the scene.
  10487. *
  10488. * The effect layer class can not be used directly and is intented to inherited from to be
  10489. * customized per effects.
  10490. */
  10491. abstract class EffectLayer {
  10492. private _vertexBuffers;
  10493. private _indexBuffer;
  10494. private _cachedDefines;
  10495. private _effectLayerMapGenerationEffect;
  10496. private _effectLayerOptions;
  10497. private _mergeEffect;
  10498. protected _scene: Scene;
  10499. protected _engine: Engine;
  10500. protected _maxSize: number;
  10501. protected _mainTextureDesiredSize: ISize;
  10502. protected _mainTexture: RenderTargetTexture;
  10503. protected _shouldRender: boolean;
  10504. protected _postProcesses: PostProcess[];
  10505. protected _textures: BaseTexture[];
  10506. protected _emissiveTextureAndColor: {
  10507. texture: Nullable<BaseTexture>;
  10508. color: Color4;
  10509. };
  10510. /**
  10511. * The name of the layer
  10512. */
  10513. name: string;
  10514. /**
  10515. * The clear color of the texture used to generate the glow map.
  10516. */
  10517. neutralColor: Color4;
  10518. /**
  10519. * Specifies wether the highlight layer is enabled or not.
  10520. */
  10521. isEnabled: boolean;
  10522. /**
  10523. * Gets the camera attached to the layer.
  10524. */
  10525. readonly camera: Nullable<Camera>;
  10526. /**
  10527. * An event triggered when the effect layer has been disposed.
  10528. */
  10529. onDisposeObservable: Observable<EffectLayer>;
  10530. /**
  10531. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  10532. */
  10533. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  10534. /**
  10535. * An event triggered when the generated texture is being merged in the scene.
  10536. */
  10537. onBeforeComposeObservable: Observable<EffectLayer>;
  10538. /**
  10539. * An event triggered when the generated texture has been merged in the scene.
  10540. */
  10541. onAfterComposeObservable: Observable<EffectLayer>;
  10542. /**
  10543. * An event triggered when the efffect layer changes its size.
  10544. */
  10545. onSizeChangedObservable: Observable<EffectLayer>;
  10546. /**
  10547. * Instantiates a new effect Layer and references it in the scene.
  10548. * @param name The name of the layer
  10549. * @param scene The scene to use the layer in
  10550. */
  10551. constructor(
  10552. /** The Friendly of the effect in the scene */
  10553. name: string, scene: Scene);
  10554. /**
  10555. * Get the effect name of the layer.
  10556. * @return The effect name
  10557. */
  10558. abstract getEffectName(): string;
  10559. /**
  10560. * Checks for the readiness of the element composing the layer.
  10561. * @param subMesh the mesh to check for
  10562. * @param useInstances specify wether or not to use instances to render the mesh
  10563. * @return true if ready otherwise, false
  10564. */
  10565. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10566. /**
  10567. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10568. * @returns true if the effect requires stencil during the main canvas render pass.
  10569. */
  10570. abstract needStencil(): boolean;
  10571. /**
  10572. * Create the merge effect. This is the shader use to blit the information back
  10573. * to the main canvas at the end of the scene rendering.
  10574. * @returns The effect containing the shader used to merge the effect on the main canvas
  10575. */
  10576. protected abstract _createMergeEffect(): Effect;
  10577. /**
  10578. * Creates the render target textures and post processes used in the effect layer.
  10579. */
  10580. protected abstract _createTextureAndPostProcesses(): void;
  10581. /**
  10582. * Implementation specific of rendering the generating effect on the main canvas.
  10583. * @param effect The effect used to render through
  10584. */
  10585. protected abstract _internalRender(effect: Effect): void;
  10586. /**
  10587. * Sets the required values for both the emissive texture and and the main color.
  10588. */
  10589. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10590. /**
  10591. * Free any resources and references associated to a mesh.
  10592. * Internal use
  10593. * @param mesh The mesh to free.
  10594. */
  10595. abstract _disposeMesh(mesh: Mesh): void;
  10596. /**
  10597. * Serializes this layer (Glow or Highlight for example)
  10598. * @returns a serialized layer object
  10599. */
  10600. abstract serialize?(): any;
  10601. /**
  10602. * Initializes the effect layer with the required options.
  10603. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10604. */
  10605. protected _init(options: Partial<IEffectLayerOptions>): void;
  10606. /**
  10607. * Generates the index buffer of the full screen quad blending to the main canvas.
  10608. */
  10609. private _generateIndexBuffer();
  10610. /**
  10611. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10612. */
  10613. private _genrateVertexBuffer();
  10614. /**
  10615. * Sets the main texture desired size which is the closest power of two
  10616. * of the engine canvas size.
  10617. */
  10618. private _setMainTextureSize();
  10619. /**
  10620. * Creates the main texture for the effect layer.
  10621. */
  10622. protected _createMainTexture(): void;
  10623. /**
  10624. * Checks for the readiness of the element composing the layer.
  10625. * @param subMesh the mesh to check for
  10626. * @param useInstances specify wether or not to use instances to render the mesh
  10627. * @param emissiveTexture the associated emissive texture used to generate the glow
  10628. * @return true if ready otherwise, false
  10629. */
  10630. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10631. /**
  10632. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10633. */
  10634. render(): void;
  10635. /**
  10636. * Determine if a given mesh will be used in the current effect.
  10637. * @param mesh mesh to test
  10638. * @returns true if the mesh will be used
  10639. */
  10640. hasMesh(mesh: AbstractMesh): boolean;
  10641. /**
  10642. * Returns true if the layer contains information to display, otherwise false.
  10643. * @returns true if the glow layer should be rendered
  10644. */
  10645. shouldRender(): boolean;
  10646. /**
  10647. * Returns true if the mesh should render, otherwise false.
  10648. * @param mesh The mesh to render
  10649. * @returns true if it should render otherwise false
  10650. */
  10651. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10652. /**
  10653. * Returns true if the mesh should render, otherwise false.
  10654. * @param mesh The mesh to render
  10655. * @returns true if it should render otherwise false
  10656. */
  10657. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10658. /**
  10659. * Renders the submesh passed in parameter to the generation map.
  10660. */
  10661. protected _renderSubMesh(subMesh: SubMesh): void;
  10662. /**
  10663. * Rebuild the required buffers.
  10664. * @hidden Internal use only.
  10665. */
  10666. _rebuild(): void;
  10667. /**
  10668. * Dispose only the render target textures and post process.
  10669. */
  10670. private _disposeTextureAndPostProcesses();
  10671. /**
  10672. * Dispose the highlight layer and free resources.
  10673. */
  10674. dispose(): void;
  10675. /**
  10676. * Gets the class name of the effect layer
  10677. * @returns the string with the class name of the effect layer
  10678. */
  10679. getClassName(): string;
  10680. /**
  10681. * Creates an effect layer from parsed effect layer data
  10682. * @param parsedEffectLayer defines effect layer data
  10683. * @param scene defines the current scene
  10684. * @param rootUrl defines the root URL containing the effect layer information
  10685. * @returns a parsed effect Layer
  10686. */
  10687. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10688. }
  10689. }
  10690. declare module BABYLON {
  10691. interface AbstractScene {
  10692. /**
  10693. * The list of effect layers (highlights/glow) added to the scene
  10694. * @see http://doc.babylonjs.com/how_to/highlight_layer
  10695. * @see http://doc.babylonjs.com/how_to/glow_layer
  10696. */
  10697. effectLayers: Array<EffectLayer>;
  10698. /**
  10699. * Removes the given effect layer from this scene.
  10700. * @param toRemove defines the effect layer to remove
  10701. * @returns the index of the removed effect layer
  10702. */
  10703. removeEffectLayer(toRemove: EffectLayer): number;
  10704. /**
  10705. * Adds the given effect layer to this scene
  10706. * @param newEffectLayer defines the effect layer to add
  10707. */
  10708. addEffectLayer(newEffectLayer: EffectLayer): void;
  10709. }
  10710. /**
  10711. * Defines the layer scene component responsible to manage any effect layers
  10712. * in a given scene.
  10713. */
  10714. class EffectLayerSceneComponent implements ISceneComponent {
  10715. /**
  10716. * The component name helpfull to identify the component in the list of scene components.
  10717. */
  10718. readonly name: string;
  10719. /**
  10720. * The scene the component belongs to.
  10721. */
  10722. scene: Scene;
  10723. private _engine;
  10724. private _effectLayers;
  10725. private _renderEffects;
  10726. private _needStencil;
  10727. private _previousStencilState;
  10728. /**
  10729. * Creates a new instance of the component for the given scene
  10730. * @param scene Defines the scene to register the component in
  10731. */
  10732. constructor(scene: Scene);
  10733. /**
  10734. * Registers the component in a given scene
  10735. */
  10736. register(): void;
  10737. /**
  10738. * Rebuilds the elements related to this component in case of
  10739. * context lost for instance.
  10740. */
  10741. rebuild(): void;
  10742. /**
  10743. * Serializes the component data to the specified json object
  10744. * @param serializationObject The object to serialize to
  10745. */
  10746. serialize(serializationObject: any): void;
  10747. /**
  10748. * Adds all the element from the container to the scene
  10749. * @param container the container holding the elements
  10750. */
  10751. addFromContainer(container: AbstractScene): void;
  10752. /**
  10753. * Removes all the elements in the container from the scene
  10754. * @param container contains the elements to remove
  10755. */
  10756. removeFromContainer(container: AbstractScene): void;
  10757. /**
  10758. * Disposes the component and the associated ressources.
  10759. */
  10760. dispose(): void;
  10761. private _isReadyForMesh(mesh, hardwareInstancedRendering);
  10762. private _renderMainTexture(camera);
  10763. private _setStencil(camera);
  10764. private _setStencilBack(camera);
  10765. private _draw(camera);
  10766. }
  10767. }
  10768. declare module BABYLON {
  10769. interface AbstractScene {
  10770. /**
  10771. * Return a the first highlight layer of the scene with a given name.
  10772. * @param name The name of the highlight layer to look for.
  10773. * @return The highlight layer if found otherwise null.
  10774. */
  10775. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  10776. }
  10777. /**
  10778. * Glow layer options. This helps customizing the behaviour
  10779. * of the glow layer.
  10780. */
  10781. interface IGlowLayerOptions {
  10782. /**
  10783. * Multiplication factor apply to the canvas size to compute the render target size
  10784. * used to generated the glowing objects (the smaller the faster).
  10785. */
  10786. mainTextureRatio: number;
  10787. /**
  10788. * Enforces a fixed size texture to ensure resize independant blur.
  10789. */
  10790. mainTextureFixedSize?: number;
  10791. /**
  10792. * How big is the kernel of the blur texture.
  10793. */
  10794. blurKernelSize: number;
  10795. /**
  10796. * The camera attached to the layer.
  10797. */
  10798. camera: Nullable<Camera>;
  10799. /**
  10800. * Enable MSAA by chosing the number of samples.
  10801. */
  10802. mainTextureSamples?: number;
  10803. }
  10804. /**
  10805. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  10806. *
  10807. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10808. * glowy meshes to your scene.
  10809. *
  10810. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  10811. */
  10812. class GlowLayer extends EffectLayer {
  10813. /**
  10814. * Effect Name of the layer.
  10815. */
  10816. static readonly EffectName: string;
  10817. /**
  10818. * The default blur kernel size used for the glow.
  10819. */
  10820. static DefaultBlurKernelSize: number;
  10821. /**
  10822. * The default texture size ratio used for the glow.
  10823. */
  10824. static DefaultTextureRatio: number;
  10825. /**
  10826. * Gets the kernel size of the blur.
  10827. */
  10828. /**
  10829. * Sets the kernel size of the blur.
  10830. */
  10831. blurKernelSize: number;
  10832. /**
  10833. * Gets the glow intensity.
  10834. */
  10835. /**
  10836. * Sets the glow intensity.
  10837. */
  10838. intensity: number;
  10839. private _options;
  10840. private _intensity;
  10841. private _horizontalBlurPostprocess1;
  10842. private _verticalBlurPostprocess1;
  10843. private _horizontalBlurPostprocess2;
  10844. private _verticalBlurPostprocess2;
  10845. private _blurTexture1;
  10846. private _blurTexture2;
  10847. private _postProcesses1;
  10848. private _postProcesses2;
  10849. private _includedOnlyMeshes;
  10850. private _excludedMeshes;
  10851. /**
  10852. * Callback used to let the user override the color selection on a per mesh basis
  10853. */
  10854. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  10855. /**
  10856. * Callback used to let the user override the texture selection on a per mesh basis
  10857. */
  10858. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  10859. /**
  10860. * Instantiates a new glow Layer and references it to the scene.
  10861. * @param name The name of the layer
  10862. * @param scene The scene to use the layer in
  10863. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  10864. */
  10865. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  10866. /**
  10867. * Get the effect name of the layer.
  10868. * @return The effect name
  10869. */
  10870. getEffectName(): string;
  10871. /**
  10872. * Create the merge effect. This is the shader use to blit the information back
  10873. * to the main canvas at the end of the scene rendering.
  10874. */
  10875. protected _createMergeEffect(): Effect;
  10876. /**
  10877. * Creates the render target textures and post processes used in the glow layer.
  10878. */
  10879. protected _createTextureAndPostProcesses(): void;
  10880. /**
  10881. * Checks for the readiness of the element composing the layer.
  10882. * @param subMesh the mesh to check for
  10883. * @param useInstances specify wether or not to use instances to render the mesh
  10884. * @param emissiveTexture the associated emissive texture used to generate the glow
  10885. * @return true if ready otherwise, false
  10886. */
  10887. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10888. /**
  10889. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10890. */
  10891. needStencil(): boolean;
  10892. /**
  10893. * Implementation specific of rendering the generating effect on the main canvas.
  10894. * @param effect The effect used to render through
  10895. */
  10896. protected _internalRender(effect: Effect): void;
  10897. /**
  10898. * Sets the required values for both the emissive texture and and the main color.
  10899. */
  10900. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10901. /**
  10902. * Returns true if the mesh should render, otherwise false.
  10903. * @param mesh The mesh to render
  10904. * @returns true if it should render otherwise false
  10905. */
  10906. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10907. /**
  10908. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  10909. * @param mesh The mesh to exclude from the glow layer
  10910. */
  10911. addExcludedMesh(mesh: Mesh): void;
  10912. /**
  10913. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  10914. * @param mesh The mesh to remove
  10915. */
  10916. removeExcludedMesh(mesh: Mesh): void;
  10917. /**
  10918. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  10919. * @param mesh The mesh to include in the glow layer
  10920. */
  10921. addIncludedOnlyMesh(mesh: Mesh): void;
  10922. /**
  10923. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  10924. * @param mesh The mesh to remove
  10925. */
  10926. removeIncludedOnlyMesh(mesh: Mesh): void;
  10927. /**
  10928. * Determine if a given mesh will be used in the glow layer
  10929. * @param mesh The mesh to test
  10930. * @returns true if the mesh will be highlighted by the current glow layer
  10931. */
  10932. hasMesh(mesh: AbstractMesh): boolean;
  10933. /**
  10934. * Free any resources and references associated to a mesh.
  10935. * Internal use
  10936. * @param mesh The mesh to free.
  10937. */
  10938. _disposeMesh(mesh: Mesh): void;
  10939. /**
  10940. * Gets the class name of the effect layer
  10941. * @returns the string with the class name of the effect layer
  10942. */
  10943. getClassName(): string;
  10944. /**
  10945. * Serializes this glow layer
  10946. * @returns a serialized glow layer object
  10947. */
  10948. serialize(): any;
  10949. /**
  10950. * Creates a Glow Layer from parsed glow layer data
  10951. * @param parsedGlowLayer defines glow layer data
  10952. * @param scene defines the current scene
  10953. * @param rootUrl defines the root URL containing the glow layer information
  10954. * @returns a parsed Glow Layer
  10955. */
  10956. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  10957. }
  10958. }
  10959. declare module BABYLON {
  10960. interface AbstractScene {
  10961. /**
  10962. * Return a the first highlight layer of the scene with a given name.
  10963. * @param name The name of the highlight layer to look for.
  10964. * @return The highlight layer if found otherwise null.
  10965. */
  10966. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  10967. }
  10968. /**
  10969. * Highlight layer options. This helps customizing the behaviour
  10970. * of the highlight layer.
  10971. */
  10972. interface IHighlightLayerOptions {
  10973. /**
  10974. * Multiplication factor apply to the canvas size to compute the render target size
  10975. * used to generated the glowing objects (the smaller the faster).
  10976. */
  10977. mainTextureRatio: number;
  10978. /**
  10979. * Enforces a fixed size texture to ensure resize independant blur.
  10980. */
  10981. mainTextureFixedSize?: number;
  10982. /**
  10983. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  10984. * of the picture to blur (the smaller the faster).
  10985. */
  10986. blurTextureSizeRatio: number;
  10987. /**
  10988. * How big in texel of the blur texture is the vertical blur.
  10989. */
  10990. blurVerticalSize: number;
  10991. /**
  10992. * How big in texel of the blur texture is the horizontal blur.
  10993. */
  10994. blurHorizontalSize: number;
  10995. /**
  10996. * Alpha blending mode used to apply the blur. Default is combine.
  10997. */
  10998. alphaBlendingMode: number;
  10999. /**
  11000. * The camera attached to the layer.
  11001. */
  11002. camera: Nullable<Camera>;
  11003. /**
  11004. * Should we display highlight as a solid stroke?
  11005. */
  11006. isStroke?: boolean;
  11007. }
  11008. /**
  11009. * The highlight layer Helps adding a glow effect around a mesh.
  11010. *
  11011. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11012. * glowy meshes to your scene.
  11013. *
  11014. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11015. */
  11016. class HighlightLayer extends EffectLayer {
  11017. name: string;
  11018. /**
  11019. * Effect Name of the highlight layer.
  11020. */
  11021. static readonly EffectName: string;
  11022. /**
  11023. * The neutral color used during the preparation of the glow effect.
  11024. * This is black by default as the blend operation is a blend operation.
  11025. */
  11026. static NeutralColor: Color4;
  11027. /**
  11028. * Stencil value used for glowing meshes.
  11029. */
  11030. static GlowingMeshStencilReference: number;
  11031. /**
  11032. * Stencil value used for the other meshes in the scene.
  11033. */
  11034. static NormalMeshStencilReference: number;
  11035. /**
  11036. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11037. */
  11038. innerGlow: boolean;
  11039. /**
  11040. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11041. */
  11042. outerGlow: boolean;
  11043. /**
  11044. * Gets the horizontal size of the blur.
  11045. */
  11046. /**
  11047. * Specifies the horizontal size of the blur.
  11048. */
  11049. blurHorizontalSize: number;
  11050. /**
  11051. * Gets the vertical size of the blur.
  11052. */
  11053. /**
  11054. * Specifies the vertical size of the blur.
  11055. */
  11056. blurVerticalSize: number;
  11057. /**
  11058. * An event triggered when the highlight layer is being blurred.
  11059. */
  11060. onBeforeBlurObservable: Observable<HighlightLayer>;
  11061. /**
  11062. * An event triggered when the highlight layer has been blurred.
  11063. */
  11064. onAfterBlurObservable: Observable<HighlightLayer>;
  11065. private _instanceGlowingMeshStencilReference;
  11066. private _options;
  11067. private _downSamplePostprocess;
  11068. private _horizontalBlurPostprocess;
  11069. private _verticalBlurPostprocess;
  11070. private _blurTexture;
  11071. private _meshes;
  11072. private _excludedMeshes;
  11073. /**
  11074. * Instantiates a new highlight Layer and references it to the scene..
  11075. * @param name The name of the layer
  11076. * @param scene The scene to use the layer in
  11077. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11078. */
  11079. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11080. /**
  11081. * Get the effect name of the layer.
  11082. * @return The effect name
  11083. */
  11084. getEffectName(): string;
  11085. /**
  11086. * Create the merge effect. This is the shader use to blit the information back
  11087. * to the main canvas at the end of the scene rendering.
  11088. */
  11089. protected _createMergeEffect(): Effect;
  11090. /**
  11091. * Creates the render target textures and post processes used in the highlight layer.
  11092. */
  11093. protected _createTextureAndPostProcesses(): void;
  11094. /**
  11095. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11096. */
  11097. needStencil(): boolean;
  11098. /**
  11099. * Checks for the readiness of the element composing the layer.
  11100. * @param subMesh the mesh to check for
  11101. * @param useInstances specify wether or not to use instances to render the mesh
  11102. * @param emissiveTexture the associated emissive texture used to generate the glow
  11103. * @return true if ready otherwise, false
  11104. */
  11105. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11106. /**
  11107. * Implementation specific of rendering the generating effect on the main canvas.
  11108. * @param effect The effect used to render through
  11109. */
  11110. protected _internalRender(effect: Effect): void;
  11111. /**
  11112. * Returns true if the layer contains information to display, otherwise false.
  11113. */
  11114. shouldRender(): boolean;
  11115. /**
  11116. * Returns true if the mesh should render, otherwise false.
  11117. * @param mesh The mesh to render
  11118. * @returns true if it should render otherwise false
  11119. */
  11120. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11121. /**
  11122. * Sets the required values for both the emissive texture and and the main color.
  11123. */
  11124. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11125. /**
  11126. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11127. * @param mesh The mesh to exclude from the highlight layer
  11128. */
  11129. addExcludedMesh(mesh: Mesh): void;
  11130. /**
  11131. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11132. * @param mesh The mesh to highlight
  11133. */
  11134. removeExcludedMesh(mesh: Mesh): void;
  11135. /**
  11136. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11137. * @param mesh mesh to test
  11138. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11139. */
  11140. hasMesh(mesh: AbstractMesh): boolean;
  11141. /**
  11142. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11143. * @param mesh The mesh to highlight
  11144. * @param color The color of the highlight
  11145. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11146. */
  11147. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11148. /**
  11149. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11150. * @param mesh The mesh to highlight
  11151. */
  11152. removeMesh(mesh: Mesh): void;
  11153. /**
  11154. * Force the stencil to the normal expected value for none glowing parts
  11155. */
  11156. private _defaultStencilReference(mesh);
  11157. /**
  11158. * Free any resources and references associated to a mesh.
  11159. * Internal use
  11160. * @param mesh The mesh to free.
  11161. */
  11162. _disposeMesh(mesh: Mesh): void;
  11163. /**
  11164. * Dispose the highlight layer and free resources.
  11165. */
  11166. dispose(): void;
  11167. /**
  11168. * Gets the class name of the effect layer
  11169. * @returns the string with the class name of the effect layer
  11170. */
  11171. getClassName(): string;
  11172. /**
  11173. * Serializes this Highlight layer
  11174. * @returns a serialized Highlight layer object
  11175. */
  11176. serialize(): any;
  11177. /**
  11178. * Creates a Highlight layer from parsed Highlight layer data
  11179. * @param parsedHightlightLayer defines the Highlight layer data
  11180. * @param scene defines the current scene
  11181. * @param rootUrl defines the root URL containing the Highlight layer information
  11182. * @returns a parsed Highlight layer
  11183. */
  11184. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11185. }
  11186. }
  11187. declare module BABYLON {
  11188. class Layer {
  11189. name: string;
  11190. texture: Nullable<Texture>;
  11191. isBackground: boolean;
  11192. color: Color4;
  11193. scale: Vector2;
  11194. offset: Vector2;
  11195. alphaBlendingMode: number;
  11196. alphaTest: boolean;
  11197. layerMask: number;
  11198. private _scene;
  11199. private _vertexBuffers;
  11200. private _indexBuffer;
  11201. private _effect;
  11202. private _alphaTestEffect;
  11203. /**
  11204. * An event triggered when the layer is disposed.
  11205. */
  11206. onDisposeObservable: Observable<Layer>;
  11207. private _onDisposeObserver;
  11208. onDispose: () => void;
  11209. /**
  11210. * An event triggered before rendering the scene
  11211. */
  11212. onBeforeRenderObservable: Observable<Layer>;
  11213. private _onBeforeRenderObserver;
  11214. onBeforeRender: () => void;
  11215. /**
  11216. * An event triggered after rendering the scene
  11217. */
  11218. onAfterRenderObservable: Observable<Layer>;
  11219. private _onAfterRenderObserver;
  11220. onAfterRender: () => void;
  11221. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11222. private _createIndexBuffer();
  11223. _rebuild(): void;
  11224. render(): void;
  11225. dispose(): void;
  11226. }
  11227. }
  11228. declare module BABYLON {
  11229. interface AbstractScene {
  11230. /**
  11231. * The list of layers (background and foreground) of the scene
  11232. */
  11233. layers: Array<Layer>;
  11234. }
  11235. /**
  11236. * Defines the layer scene component responsible to manage any layers
  11237. * in a given scene.
  11238. */
  11239. class LayerSceneComponent implements ISceneComponent {
  11240. /**
  11241. * The component name helpfull to identify the component in the list of scene components.
  11242. */
  11243. readonly name: string;
  11244. /**
  11245. * The scene the component belongs to.
  11246. */
  11247. scene: Scene;
  11248. private _engine;
  11249. private _layers;
  11250. /**
  11251. * Creates a new instance of the component for the given scene
  11252. * @param scene Defines the scene to register the component in
  11253. */
  11254. constructor(scene: Scene);
  11255. /**
  11256. * Registers the component in a given scene
  11257. */
  11258. register(): void;
  11259. /**
  11260. * Rebuilds the elements related to this component in case of
  11261. * context lost for instance.
  11262. */
  11263. rebuild(): void;
  11264. /**
  11265. * Serializes the component data to the specified json object
  11266. * @param serializationObject The object to serialize to
  11267. */
  11268. serialize(serializationObject: any): void;
  11269. /**
  11270. * Adds all the element from the container to the scene
  11271. * @param container the container holding the elements
  11272. */
  11273. addFromContainer(container: AbstractScene): void;
  11274. /**
  11275. * Removes all the elements in the container from the scene
  11276. * @param container contains the elements to remove
  11277. */
  11278. removeFromContainer(container: AbstractScene): void;
  11279. /**
  11280. * Disposes the component and the associated ressources.
  11281. */
  11282. dispose(): void;
  11283. private _draw(camera, isBackground);
  11284. private _drawBackground(camera);
  11285. private _drawForeground(camera);
  11286. }
  11287. }
  11288. declare module BABYLON {
  11289. /**
  11290. * A directional light is defined by a direction (what a surprise!).
  11291. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11292. * 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.
  11293. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11294. */
  11295. class DirectionalLight extends ShadowLight {
  11296. private _shadowFrustumSize;
  11297. /**
  11298. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11299. */
  11300. /**
  11301. * Specifies a fix frustum size for the shadow generation.
  11302. */
  11303. shadowFrustumSize: number;
  11304. private _shadowOrthoScale;
  11305. /**
  11306. * Gets the shadow projection scale against the optimal computed one.
  11307. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11308. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11309. */
  11310. /**
  11311. * Sets the shadow projection scale against the optimal computed one.
  11312. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11313. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11314. */
  11315. shadowOrthoScale: number;
  11316. /**
  11317. * Automatically compute the projection matrix to best fit (including all the casters)
  11318. * on each frame.
  11319. */
  11320. autoUpdateExtends: boolean;
  11321. private _orthoLeft;
  11322. private _orthoRight;
  11323. private _orthoTop;
  11324. private _orthoBottom;
  11325. /**
  11326. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11327. * The directional light is emitted from everywhere in the given direction.
  11328. * It can cast shawdows.
  11329. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11330. * @param name The friendly name of the light
  11331. * @param direction The direction of the light
  11332. * @param scene The scene the light belongs to
  11333. */
  11334. constructor(name: string, direction: Vector3, scene: Scene);
  11335. /**
  11336. * Returns the string "DirectionalLight".
  11337. * @return The class name
  11338. */
  11339. getClassName(): string;
  11340. /**
  11341. * Returns the integer 1.
  11342. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11343. */
  11344. getTypeID(): number;
  11345. /**
  11346. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  11347. * Returns the DirectionalLight Shadow projection matrix.
  11348. */
  11349. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11350. /**
  11351. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  11352. * Returns the DirectionalLight Shadow projection matrix.
  11353. */
  11354. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  11355. /**
  11356. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  11357. * Returns the DirectionalLight Shadow projection matrix.
  11358. */
  11359. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11360. protected _buildUniformLayout(): void;
  11361. /**
  11362. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11363. * @param effect The effect to update
  11364. * @param lightIndex The index of the light in the effect to update
  11365. * @returns The directional light
  11366. */
  11367. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  11368. /**
  11369. * Gets the minZ used for shadow according to both the scene and the light.
  11370. *
  11371. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11372. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11373. * @param activeCamera The camera we are returning the min for
  11374. * @returns the depth min z
  11375. */
  11376. getDepthMinZ(activeCamera: Camera): number;
  11377. /**
  11378. * Gets the maxZ used for shadow according to both the scene and the light.
  11379. *
  11380. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11381. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11382. * @param activeCamera The camera we are returning the max for
  11383. * @returns the depth max z
  11384. */
  11385. getDepthMaxZ(activeCamera: Camera): number;
  11386. }
  11387. }
  11388. declare module BABYLON {
  11389. /**
  11390. * The HemisphericLight simulates the ambient environment light,
  11391. * so the passed direction is the light reflection direction, not the incoming direction.
  11392. */
  11393. class HemisphericLight extends Light {
  11394. /**
  11395. * The groundColor is the light in the opposite direction to the one specified during creation.
  11396. * 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.
  11397. */
  11398. groundColor: Color3;
  11399. /**
  11400. * The light reflection direction, not the incoming direction.
  11401. */
  11402. direction: Vector3;
  11403. private _worldMatrix;
  11404. /**
  11405. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11406. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11407. * The HemisphericLight can't cast shadows.
  11408. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11409. * @param name The friendly name of the light
  11410. * @param direction The direction of the light reflection
  11411. * @param scene The scene the light belongs to
  11412. */
  11413. constructor(name: string, direction: Vector3, scene: Scene);
  11414. protected _buildUniformLayout(): void;
  11415. /**
  11416. * Returns the string "HemisphericLight".
  11417. * @return The class name
  11418. */
  11419. getClassName(): string;
  11420. /**
  11421. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11422. * Returns the updated direction.
  11423. * @param target The target the direction should point to
  11424. * @return The computed direction
  11425. */
  11426. setDirectionToTarget(target: Vector3): Vector3;
  11427. /**
  11428. * Returns the shadow generator associated to the light.
  11429. * @returns Always null for hemispheric lights because it does not support shadows.
  11430. */
  11431. getShadowGenerator(): Nullable<ShadowGenerator>;
  11432. /**
  11433. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11434. * @param effect The effect to update
  11435. * @param lightIndex The index of the light in the effect to update
  11436. * @returns The hemispheric light
  11437. */
  11438. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11439. /**
  11440. * @hidden internal use only.
  11441. */
  11442. _getWorldMatrix(): Matrix;
  11443. /**
  11444. * Returns the integer 3.
  11445. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11446. */
  11447. getTypeID(): number;
  11448. }
  11449. }
  11450. declare module BABYLON {
  11451. /**
  11452. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11453. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11454. * 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.
  11455. */
  11456. abstract class Light extends Node {
  11457. private static _LIGHTMAP_DEFAULT;
  11458. private static _LIGHTMAP_SPECULAR;
  11459. private static _LIGHTMAP_SHADOWSONLY;
  11460. /**
  11461. * If every light affecting the material is in this lightmapMode,
  11462. * material.lightmapTexture adds or multiplies
  11463. * (depends on material.useLightmapAsShadowmap)
  11464. * after every other light calculations.
  11465. */
  11466. static readonly LIGHTMAP_DEFAULT: number;
  11467. /**
  11468. * material.lightmapTexture as only diffuse lighting from this light
  11469. * adds only specular lighting from this light
  11470. * adds dynamic shadows
  11471. */
  11472. static readonly LIGHTMAP_SPECULAR: number;
  11473. /**
  11474. * material.lightmapTexture as only lighting
  11475. * no light calculation from this light
  11476. * only adds dynamic shadows from this light
  11477. */
  11478. static readonly LIGHTMAP_SHADOWSONLY: number;
  11479. private static _INTENSITYMODE_AUTOMATIC;
  11480. private static _INTENSITYMODE_LUMINOUSPOWER;
  11481. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  11482. private static _INTENSITYMODE_ILLUMINANCE;
  11483. private static _INTENSITYMODE_LUMINANCE;
  11484. /**
  11485. * Each light type uses the default quantity according to its type:
  11486. * point/spot lights use luminous intensity
  11487. * directional lights use illuminance
  11488. */
  11489. static readonly INTENSITYMODE_AUTOMATIC: number;
  11490. /**
  11491. * lumen (lm)
  11492. */
  11493. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11494. /**
  11495. * candela (lm/sr)
  11496. */
  11497. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11498. /**
  11499. * lux (lm/m^2)
  11500. */
  11501. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11502. /**
  11503. * nit (cd/m^2)
  11504. */
  11505. static readonly INTENSITYMODE_LUMINANCE: number;
  11506. private static _LIGHTTYPEID_POINTLIGHT;
  11507. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  11508. private static _LIGHTTYPEID_SPOTLIGHT;
  11509. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  11510. /**
  11511. * Light type const id of the point light.
  11512. */
  11513. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11514. /**
  11515. * Light type const id of the directional light.
  11516. */
  11517. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11518. /**
  11519. * Light type const id of the spot light.
  11520. */
  11521. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11522. /**
  11523. * Light type const id of the hemispheric light.
  11524. */
  11525. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11526. /**
  11527. * Diffuse gives the basic color to an object.
  11528. */
  11529. diffuse: Color3;
  11530. /**
  11531. * Specular produces a highlight color on an object.
  11532. * Note: This is note affecting PBR materials.
  11533. */
  11534. specular: Color3;
  11535. /**
  11536. * Strength of the light.
  11537. * Note: By default it is define in the framework own unit.
  11538. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11539. */
  11540. intensity: number;
  11541. /**
  11542. * Defines how far from the source the light is impacting in scene units.
  11543. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11544. */
  11545. range: number;
  11546. /**
  11547. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11548. * of light.
  11549. */
  11550. private _photometricScale;
  11551. private _intensityMode;
  11552. /**
  11553. * Gets the photometric scale used to interpret the intensity.
  11554. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11555. */
  11556. /**
  11557. * Sets the photometric scale used to interpret the intensity.
  11558. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11559. */
  11560. intensityMode: number;
  11561. private _radius;
  11562. /**
  11563. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11564. */
  11565. /**
  11566. * sets the light radius used by PBR Materials to simulate soft area lights.
  11567. */
  11568. radius: number;
  11569. private _renderPriority;
  11570. /**
  11571. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11572. * exceeding the number allowed of the materials.
  11573. */
  11574. renderPriority: number;
  11575. private _shadowEnabled;
  11576. /**
  11577. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11578. * the current shadow generator.
  11579. */
  11580. /**
  11581. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11582. * the current shadow generator.
  11583. */
  11584. shadowEnabled: boolean;
  11585. private _includedOnlyMeshes;
  11586. /**
  11587. * Gets the only meshes impacted by this light.
  11588. */
  11589. /**
  11590. * Sets the only meshes impacted by this light.
  11591. */
  11592. includedOnlyMeshes: AbstractMesh[];
  11593. private _excludedMeshes;
  11594. /**
  11595. * Gets the meshes not impacted by this light.
  11596. */
  11597. /**
  11598. * Sets the meshes not impacted by this light.
  11599. */
  11600. excludedMeshes: AbstractMesh[];
  11601. private _excludeWithLayerMask;
  11602. /**
  11603. * Gets the layer id use to find what meshes are not impacted by the light.
  11604. * Inactive if 0
  11605. */
  11606. /**
  11607. * Sets the layer id use to find what meshes are not impacted by the light.
  11608. * Inactive if 0
  11609. */
  11610. excludeWithLayerMask: number;
  11611. private _includeOnlyWithLayerMask;
  11612. /**
  11613. * Gets the layer id use to find what meshes are impacted by the light.
  11614. * Inactive if 0
  11615. */
  11616. /**
  11617. * Sets the layer id use to find what meshes are impacted by the light.
  11618. * Inactive if 0
  11619. */
  11620. includeOnlyWithLayerMask: number;
  11621. private _lightmapMode;
  11622. /**
  11623. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11624. */
  11625. /**
  11626. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11627. */
  11628. lightmapMode: number;
  11629. private _parentedWorldMatrix;
  11630. /**
  11631. * Shadow generator associted to the light.
  11632. * Internal use only.
  11633. */
  11634. _shadowGenerator: Nullable<IShadowGenerator>;
  11635. /**
  11636. * @hidden Internal use only.
  11637. */
  11638. _excludedMeshesIds: string[];
  11639. /**
  11640. * @hidden Internal use only.
  11641. */
  11642. _includedOnlyMeshesIds: string[];
  11643. /**
  11644. * The current light unifom buffer.
  11645. * @hidden Internal use only.
  11646. */
  11647. _uniformBuffer: UniformBuffer;
  11648. /**
  11649. * Creates a Light object in the scene.
  11650. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11651. * @param name The firendly name of the light
  11652. * @param scene The scene the light belongs too
  11653. */
  11654. constructor(name: string, scene: Scene);
  11655. protected abstract _buildUniformLayout(): void;
  11656. /**
  11657. * Sets the passed Effect "effect" with the Light information.
  11658. * @param effect The effect to update
  11659. * @param lightIndex The index of the light in the effect to update
  11660. * @returns The light
  11661. */
  11662. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11663. /**
  11664. * @hidden internal use only.
  11665. */
  11666. abstract _getWorldMatrix(): Matrix;
  11667. /**
  11668. * Returns the string "Light".
  11669. * @returns the class name
  11670. */
  11671. getClassName(): string;
  11672. /**
  11673. * Converts the light information to a readable string for debug purpose.
  11674. * @param fullDetails Supports for multiple levels of logging within scene loading
  11675. * @returns the human readable light info
  11676. */
  11677. toString(fullDetails?: boolean): string;
  11678. /**
  11679. * Set the enabled state of this node.
  11680. * @param value - the new enabled state
  11681. */
  11682. setEnabled(value: boolean): void;
  11683. /**
  11684. * Returns the Light associated shadow generator if any.
  11685. * @return the associated shadow generator.
  11686. */
  11687. getShadowGenerator(): Nullable<IShadowGenerator>;
  11688. /**
  11689. * Returns a Vector3, the absolute light position in the World.
  11690. * @returns the world space position of the light
  11691. */
  11692. getAbsolutePosition(): Vector3;
  11693. /**
  11694. * Specifies if the light will affect the passed mesh.
  11695. * @param mesh The mesh to test against the light
  11696. * @return true the mesh is affected otherwise, false.
  11697. */
  11698. canAffectMesh(mesh: AbstractMesh): boolean;
  11699. /**
  11700. * Computes and Returns the light World matrix.
  11701. * @returns the world matrix
  11702. */
  11703. getWorldMatrix(): Matrix;
  11704. /**
  11705. * Sort function to order lights for rendering.
  11706. * @param a First Light object to compare to second.
  11707. * @param b Second Light object to compare first.
  11708. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11709. */
  11710. static CompareLightsPriority(a: Light, b: Light): number;
  11711. /**
  11712. * Releases resources associated with this node.
  11713. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11714. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11715. */
  11716. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11717. /**
  11718. * Returns the light type ID (integer).
  11719. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11720. */
  11721. getTypeID(): number;
  11722. /**
  11723. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11724. * @returns the scaled intensity in intensity mode unit
  11725. */
  11726. getScaledIntensity(): number;
  11727. /**
  11728. * Returns a new Light object, named "name", from the current one.
  11729. * @param name The name of the cloned light
  11730. * @returns the new created light
  11731. */
  11732. clone(name: string): Nullable<Light>;
  11733. /**
  11734. * Serializes the current light into a Serialization object.
  11735. * @returns the serialized object.
  11736. */
  11737. serialize(): any;
  11738. /**
  11739. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11740. * This new light is named "name" and added to the passed scene.
  11741. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11742. * @param name The friendly name of the light
  11743. * @param scene The scene the new light will belong to
  11744. * @returns the constructor function
  11745. */
  11746. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11747. /**
  11748. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11749. * @param parsedLight The JSON representation of the light
  11750. * @param scene The scene to create the parsed light in
  11751. * @returns the created light after parsing
  11752. */
  11753. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11754. private _hookArrayForExcluded(array);
  11755. private _hookArrayForIncludedOnly(array);
  11756. private _resyncMeshes();
  11757. /**
  11758. * Forces the meshes to update their light related information in their rendering used effects
  11759. * @hidden Internal Use Only
  11760. */
  11761. _markMeshesAsLightDirty(): void;
  11762. /**
  11763. * Recomputes the cached photometric scale if needed.
  11764. */
  11765. private _computePhotometricScale();
  11766. /**
  11767. * Returns the Photometric Scale according to the light type and intensity mode.
  11768. */
  11769. private _getPhotometricScale();
  11770. /**
  11771. * Reorder the light in the scene according to their defined priority.
  11772. * @hidden Internal Use Only
  11773. */
  11774. _reorderLightsInScene(): void;
  11775. }
  11776. }
  11777. declare module BABYLON {
  11778. /**
  11779. * A point light is a light defined by an unique point in world space.
  11780. * The light is emitted in every direction from this point.
  11781. * A good example of a point light is a standard light bulb.
  11782. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11783. */
  11784. class PointLight extends ShadowLight {
  11785. private _shadowAngle;
  11786. /**
  11787. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11788. * This specifies what angle the shadow will use to be created.
  11789. *
  11790. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11791. */
  11792. /**
  11793. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11794. * This specifies what angle the shadow will use to be created.
  11795. *
  11796. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11797. */
  11798. shadowAngle: number;
  11799. /**
  11800. * Gets the direction if it has been set.
  11801. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11802. */
  11803. /**
  11804. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11805. */
  11806. direction: Vector3;
  11807. /**
  11808. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  11809. * A PointLight emits the light in every direction.
  11810. * It can cast shadows.
  11811. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  11812. * ```javascript
  11813. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  11814. * ```
  11815. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11816. * @param name The light friendly name
  11817. * @param position The position of the point light in the scene
  11818. * @param scene The scene the lights belongs to
  11819. */
  11820. constructor(name: string, position: Vector3, scene: Scene);
  11821. /**
  11822. * Returns the string "PointLight"
  11823. * @returns the class name
  11824. */
  11825. getClassName(): string;
  11826. /**
  11827. * Returns the integer 0.
  11828. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11829. */
  11830. getTypeID(): number;
  11831. /**
  11832. * Specifies wether or not the shadowmap should be a cube texture.
  11833. * @returns true if the shadowmap needs to be a cube texture.
  11834. */
  11835. needCube(): boolean;
  11836. /**
  11837. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  11838. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11839. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11840. */
  11841. getShadowDirection(faceIndex?: number): Vector3;
  11842. /**
  11843. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  11844. * - fov = PI / 2
  11845. * - aspect ratio : 1.0
  11846. * - z-near and far equal to the active camera minZ and maxZ.
  11847. * Returns the PointLight.
  11848. */
  11849. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11850. protected _buildUniformLayout(): void;
  11851. /**
  11852. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  11853. * @param effect The effect to update
  11854. * @param lightIndex The index of the light in the effect to update
  11855. * @returns The point light
  11856. */
  11857. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  11858. }
  11859. }
  11860. declare module BABYLON {
  11861. /**
  11862. * Interface describing all the common properties and methods a shadow light needs to implement.
  11863. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  11864. * as well as binding the different shadow properties to the effects.
  11865. */
  11866. interface IShadowLight extends Light {
  11867. /**
  11868. * The light id in the scene (used in scene.findLighById for instance)
  11869. */
  11870. id: string;
  11871. /**
  11872. * The position the shdow will be casted from.
  11873. */
  11874. position: Vector3;
  11875. /**
  11876. * In 2d mode (needCube being false), the direction used to cast the shadow.
  11877. */
  11878. direction: Vector3;
  11879. /**
  11880. * The transformed position. Position of the light in world space taking parenting in account.
  11881. */
  11882. transformedPosition: Vector3;
  11883. /**
  11884. * The transformed direction. Direction of the light in world space taking parenting in account.
  11885. */
  11886. transformedDirection: Vector3;
  11887. /**
  11888. * The friendly name of the light in the scene.
  11889. */
  11890. name: string;
  11891. /**
  11892. * Defines the shadow projection clipping minimum z value.
  11893. */
  11894. shadowMinZ: number;
  11895. /**
  11896. * Defines the shadow projection clipping maximum z value.
  11897. */
  11898. shadowMaxZ: number;
  11899. /**
  11900. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11901. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11902. */
  11903. computeTransformedInformation(): boolean;
  11904. /**
  11905. * Gets the scene the light belongs to.
  11906. * @returns The scene
  11907. */
  11908. getScene(): Scene;
  11909. /**
  11910. * Callback defining a custom Projection Matrix Builder.
  11911. * This can be used to override the default projection matrix computation.
  11912. */
  11913. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11914. /**
  11915. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11916. * @param matrix The materix to updated with the projection information
  11917. * @param viewMatrix The transform matrix of the light
  11918. * @param renderList The list of mesh to render in the map
  11919. * @returns The current light
  11920. */
  11921. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11922. /**
  11923. * Gets the current depth scale used in ESM.
  11924. * @returns The scale
  11925. */
  11926. getDepthScale(): number;
  11927. /**
  11928. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11929. * @returns true if a cube texture needs to be use
  11930. */
  11931. needCube(): boolean;
  11932. /**
  11933. * Detects if the projection matrix requires to be recomputed this frame.
  11934. * @returns true if it requires to be recomputed otherwise, false.
  11935. */
  11936. needProjectionMatrixCompute(): boolean;
  11937. /**
  11938. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11939. */
  11940. forceProjectionMatrixCompute(): void;
  11941. /**
  11942. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11943. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11944. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11945. */
  11946. getShadowDirection(faceIndex?: number): Vector3;
  11947. /**
  11948. * Gets the minZ used for shadow according to both the scene and the light.
  11949. * @param activeCamera The camera we are returning the min for
  11950. * @returns the depth min z
  11951. */
  11952. getDepthMinZ(activeCamera: Camera): number;
  11953. /**
  11954. * Gets the maxZ used for shadow according to both the scene and the light.
  11955. * @param activeCamera The camera we are returning the max for
  11956. * @returns the depth max z
  11957. */
  11958. getDepthMaxZ(activeCamera: Camera): number;
  11959. }
  11960. /**
  11961. * Base implementation IShadowLight
  11962. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  11963. */
  11964. abstract class ShadowLight extends Light implements IShadowLight {
  11965. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11966. protected _position: Vector3;
  11967. protected _setPosition(value: Vector3): void;
  11968. /**
  11969. * Sets the position the shadow will be casted from. Also use as the light position for both
  11970. * point and spot lights.
  11971. */
  11972. /**
  11973. * Sets the position the shadow will be casted from. Also use as the light position for both
  11974. * point and spot lights.
  11975. */
  11976. position: Vector3;
  11977. protected _direction: Vector3;
  11978. protected _setDirection(value: Vector3): void;
  11979. /**
  11980. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  11981. * Also use as the light direction on spot and directional lights.
  11982. */
  11983. /**
  11984. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  11985. * Also use as the light direction on spot and directional lights.
  11986. */
  11987. direction: Vector3;
  11988. private _shadowMinZ;
  11989. /**
  11990. * Gets the shadow projection clipping minimum z value.
  11991. */
  11992. /**
  11993. * Sets the shadow projection clipping minimum z value.
  11994. */
  11995. shadowMinZ: number;
  11996. private _shadowMaxZ;
  11997. /**
  11998. * Sets the shadow projection clipping maximum z value.
  11999. */
  12000. /**
  12001. * Gets the shadow projection clipping maximum z value.
  12002. */
  12003. shadowMaxZ: number;
  12004. /**
  12005. * Callback defining a custom Projection Matrix Builder.
  12006. * This can be used to override the default projection matrix computation.
  12007. */
  12008. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12009. /**
  12010. * The transformed position. Position of the light in world space taking parenting in account.
  12011. */
  12012. transformedPosition: Vector3;
  12013. /**
  12014. * The transformed direction. Direction of the light in world space taking parenting in account.
  12015. */
  12016. transformedDirection: Vector3;
  12017. private _worldMatrix;
  12018. private _needProjectionMatrixCompute;
  12019. /**
  12020. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12021. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12022. */
  12023. computeTransformedInformation(): boolean;
  12024. /**
  12025. * Return the depth scale used for the shadow map.
  12026. * @returns the depth scale.
  12027. */
  12028. getDepthScale(): number;
  12029. /**
  12030. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12031. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12032. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12033. */
  12034. getShadowDirection(faceIndex?: number): Vector3;
  12035. /**
  12036. * Returns the ShadowLight absolute position in the World.
  12037. * @returns the position vector in world space
  12038. */
  12039. getAbsolutePosition(): Vector3;
  12040. /**
  12041. * Sets the ShadowLight direction toward the passed target.
  12042. * @param target The point tot target in local space
  12043. * @returns the updated ShadowLight direction
  12044. */
  12045. setDirectionToTarget(target: Vector3): Vector3;
  12046. /**
  12047. * Returns the light rotation in euler definition.
  12048. * @returns the x y z rotation in local space.
  12049. */
  12050. getRotation(): Vector3;
  12051. /**
  12052. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12053. * @returns true if a cube texture needs to be use
  12054. */
  12055. needCube(): boolean;
  12056. /**
  12057. * Detects if the projection matrix requires to be recomputed this frame.
  12058. * @returns true if it requires to be recomputed otherwise, false.
  12059. */
  12060. needProjectionMatrixCompute(): boolean;
  12061. /**
  12062. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12063. */
  12064. forceProjectionMatrixCompute(): void;
  12065. /**
  12066. * Get the world matrix of the sahdow lights.
  12067. * @hidden Internal Use Only
  12068. */
  12069. _getWorldMatrix(): Matrix;
  12070. /**
  12071. * Gets the minZ used for shadow according to both the scene and the light.
  12072. * @param activeCamera The camera we are returning the min for
  12073. * @returns the depth min z
  12074. */
  12075. getDepthMinZ(activeCamera: Camera): number;
  12076. /**
  12077. * Gets the maxZ used for shadow according to both the scene and the light.
  12078. * @param activeCamera The camera we are returning the max for
  12079. * @returns the depth max z
  12080. */
  12081. getDepthMaxZ(activeCamera: Camera): number;
  12082. /**
  12083. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12084. * @param matrix The materix to updated with the projection information
  12085. * @param viewMatrix The transform matrix of the light
  12086. * @param renderList The list of mesh to render in the map
  12087. * @returns The current light
  12088. */
  12089. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12090. }
  12091. }
  12092. declare module BABYLON {
  12093. /**
  12094. * A spot light is defined by a position, a direction, an angle, and an exponent.
  12095. * These values define a cone of light starting from the position, emitting toward the direction.
  12096. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  12097. * and the exponent defines the speed of the decay of the light with distance (reach).
  12098. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12099. */
  12100. class SpotLight extends ShadowLight {
  12101. private _angle;
  12102. /**
  12103. * Gets the cone angle of the spot light in Radians.
  12104. */
  12105. /**
  12106. * Sets the cone angle of the spot light in Radians.
  12107. */
  12108. angle: number;
  12109. private _shadowAngleScale;
  12110. /**
  12111. * Allows scaling the angle of the light for shadow generation only.
  12112. */
  12113. /**
  12114. * Allows scaling the angle of the light for shadow generation only.
  12115. */
  12116. shadowAngleScale: number;
  12117. /**
  12118. * The light decay speed with the distance from the emission spot.
  12119. */
  12120. exponent: number;
  12121. private _projectionTextureMatrix;
  12122. /**
  12123. * Allows reading the projecton texture
  12124. */
  12125. readonly projectionTextureMatrix: Matrix;
  12126. protected _projectionTextureLightNear: number;
  12127. /**
  12128. * Gets the near clip of the Spotlight for texture projection.
  12129. */
  12130. /**
  12131. * Sets the near clip of the Spotlight for texture projection.
  12132. */
  12133. projectionTextureLightNear: number;
  12134. protected _projectionTextureLightFar: number;
  12135. /**
  12136. * Gets the far clip of the Spotlight for texture projection.
  12137. */
  12138. /**
  12139. * Sets the far clip of the Spotlight for texture projection.
  12140. */
  12141. projectionTextureLightFar: number;
  12142. protected _projectionTextureUpDirection: Vector3;
  12143. /**
  12144. * Gets the Up vector of the Spotlight for texture projection.
  12145. */
  12146. /**
  12147. * Sets the Up vector of the Spotlight for texture projection.
  12148. */
  12149. projectionTextureUpDirection: Vector3;
  12150. private _projectionTexture;
  12151. /**
  12152. * Gets the projection texture of the light.
  12153. */
  12154. /**
  12155. * Sets the projection texture of the light.
  12156. */
  12157. projectionTexture: Nullable<BaseTexture>;
  12158. private _projectionTextureViewLightDirty;
  12159. private _projectionTextureProjectionLightDirty;
  12160. private _projectionTextureDirty;
  12161. private _projectionTextureViewTargetVector;
  12162. private _projectionTextureViewLightMatrix;
  12163. private _projectionTextureProjectionLightMatrix;
  12164. private _projectionTextureScalingMatrix;
  12165. /**
  12166. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12167. * It can cast shadows.
  12168. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12169. * @param name The light friendly name
  12170. * @param position The position of the spot light in the scene
  12171. * @param direction The direction of the light in the scene
  12172. * @param angle The cone angle of the light in Radians
  12173. * @param exponent The light decay speed with the distance from the emission spot
  12174. * @param scene The scene the lights belongs to
  12175. */
  12176. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12177. /**
  12178. * Returns the string "SpotLight".
  12179. * @returns the class name
  12180. */
  12181. getClassName(): string;
  12182. /**
  12183. * Returns the integer 2.
  12184. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12185. */
  12186. getTypeID(): number;
  12187. /**
  12188. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12189. */
  12190. protected _setDirection(value: Vector3): void;
  12191. /**
  12192. * Overrides the position setter to recompute the projection texture view light Matrix.
  12193. */
  12194. protected _setPosition(value: Vector3): void;
  12195. /**
  12196. * 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.
  12197. * Returns the SpotLight.
  12198. */
  12199. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12200. protected _computeProjectionTextureViewLightMatrix(): void;
  12201. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12202. /**
  12203. * Main function for light texture projection matrix computing.
  12204. */
  12205. protected _computeProjectionTextureMatrix(): void;
  12206. protected _buildUniformLayout(): void;
  12207. /**
  12208. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12209. * @param effect The effect to update
  12210. * @param lightIndex The index of the light in the effect to update
  12211. * @returns The spot light
  12212. */
  12213. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12214. /**
  12215. * Disposes the light and the associated resources.
  12216. */
  12217. dispose(): void;
  12218. }
  12219. }
  12220. declare module BABYLON {
  12221. interface ILoadingScreen {
  12222. displayLoadingUI: () => void;
  12223. hideLoadingUI: () => void;
  12224. loadingUIBackgroundColor: string;
  12225. loadingUIText: string;
  12226. }
  12227. class DefaultLoadingScreen implements ILoadingScreen {
  12228. private _renderingCanvas;
  12229. private _loadingText;
  12230. private _loadingDivBackgroundColor;
  12231. private _loadingDiv;
  12232. private _loadingTextDiv;
  12233. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  12234. displayLoadingUI(): void;
  12235. hideLoadingUI(): void;
  12236. loadingUIText: string;
  12237. loadingUIBackgroundColor: string;
  12238. private _resizeLoadingUI;
  12239. }
  12240. }
  12241. declare module BABYLON {
  12242. class SceneLoaderProgressEvent {
  12243. readonly lengthComputable: boolean;
  12244. readonly loaded: number;
  12245. readonly total: number;
  12246. constructor(lengthComputable: boolean, loaded: number, total: number);
  12247. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  12248. }
  12249. interface ISceneLoaderPluginExtensions {
  12250. [extension: string]: {
  12251. isBinary: boolean;
  12252. };
  12253. }
  12254. interface ISceneLoaderPluginFactory {
  12255. name: string;
  12256. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  12257. canDirectLoad?: (data: string) => boolean;
  12258. }
  12259. interface ISceneLoaderPlugin {
  12260. /**
  12261. * The friendly name of this plugin.
  12262. */
  12263. name: string;
  12264. /**
  12265. * The file extensions supported by this plugin.
  12266. */
  12267. extensions: string | ISceneLoaderPluginExtensions;
  12268. /**
  12269. * Import meshes into a scene.
  12270. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12271. * @param scene The scene to import into
  12272. * @param data The data to import
  12273. * @param rootUrl The root url for scene and resources
  12274. * @param meshes The meshes array to import into
  12275. * @param particleSystems The particle systems array to import into
  12276. * @param skeletons The skeletons array to import into
  12277. * @param onError The callback when import fails
  12278. * @returns True if successful or false otherwise
  12279. */
  12280. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  12281. /**
  12282. * Load into a scene.
  12283. * @param scene The scene to load into
  12284. * @param data The data to import
  12285. * @param rootUrl The root url for scene and resources
  12286. * @param onError The callback when import fails
  12287. * @returns true if successful or false otherwise
  12288. */
  12289. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  12290. /**
  12291. * The callback that returns true if the data can be directly loaded.
  12292. */
  12293. canDirectLoad?: (data: string) => boolean;
  12294. /**
  12295. * The callback that allows custom handling of the root url based on the response url.
  12296. */
  12297. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12298. /**
  12299. * Load into an asset container.
  12300. * @param scene The scene to load into
  12301. * @param data The data to import
  12302. * @param rootUrl The root url for scene and resources
  12303. * @param onError The callback when import fails
  12304. * @returns The loaded asset container
  12305. */
  12306. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  12307. }
  12308. interface ISceneLoaderPluginAsync {
  12309. /**
  12310. * The friendly name of this plugin.
  12311. */
  12312. name: string;
  12313. /**
  12314. * The file extensions supported by this plugin.
  12315. */
  12316. extensions: string | ISceneLoaderPluginExtensions;
  12317. /**
  12318. * Import meshes into a scene.
  12319. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12320. * @param scene The scene to import into
  12321. * @param data The data to import
  12322. * @param rootUrl The root url for scene and resources
  12323. * @param onProgress The callback when the load progresses
  12324. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  12325. */
  12326. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  12327. meshes: AbstractMesh[];
  12328. particleSystems: ParticleSystem[];
  12329. skeletons: Skeleton[];
  12330. animationGroups: AnimationGroup[];
  12331. }>;
  12332. /**
  12333. * Load into a scene.
  12334. * @param scene The scene to load into
  12335. * @param data The data to import
  12336. * @param rootUrl The root url for scene and resources
  12337. * @param onProgress The callback when the load progresses
  12338. * @returns Nothing
  12339. */
  12340. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  12341. /**
  12342. * The callback that returns true if the data can be directly loaded.
  12343. */
  12344. canDirectLoad?: (data: string) => boolean;
  12345. /**
  12346. * The callback that allows custom handling of the root url based on the response url.
  12347. */
  12348. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12349. /**
  12350. * Load into an asset container.
  12351. * @param scene The scene to load into
  12352. * @param data The data to import
  12353. * @param rootUrl The root url for scene and resources
  12354. * @param onProgress The callback when the load progresses
  12355. * @returns The loaded asset container
  12356. */
  12357. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  12358. }
  12359. class SceneLoader {
  12360. private static _ForceFullSceneLoadingForIncremental;
  12361. private static _ShowLoadingScreen;
  12362. private static _CleanBoneMatrixWeights;
  12363. static readonly NO_LOGGING: number;
  12364. static readonly MINIMAL_LOGGING: number;
  12365. static readonly SUMMARY_LOGGING: number;
  12366. static readonly DETAILED_LOGGING: number;
  12367. private static _loggingLevel;
  12368. static ForceFullSceneLoadingForIncremental: boolean;
  12369. static ShowLoadingScreen: boolean;
  12370. static loggingLevel: number;
  12371. static CleanBoneMatrixWeights: boolean;
  12372. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12373. private static _registeredPlugins;
  12374. private static _getDefaultPlugin();
  12375. private static _getPluginForExtension(extension);
  12376. private static _getPluginForDirectLoad(data);
  12377. private static _getPluginForFilename(sceneFilename);
  12378. private static _getDirectLoad(sceneFilename);
  12379. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  12380. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  12381. static IsPluginForExtensionAvailable(extension: string): boolean;
  12382. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  12383. /**
  12384. * Import meshes into a scene
  12385. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12386. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12387. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12388. * @param scene the instance of BABYLON.Scene to append to
  12389. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  12390. * @param onProgress a callback with a progress event for each file being loaded
  12391. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12392. * @param pluginExtension the extension used to determine the plugin
  12393. * @returns The loaded plugin
  12394. */
  12395. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], 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>;
  12396. /**
  12397. * Import meshes into a scene
  12398. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12399. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12400. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12401. * @param scene the instance of BABYLON.Scene to append to
  12402. * @param onProgress a callback with a progress event for each file being loaded
  12403. * @param pluginExtension the extension used to determine the plugin
  12404. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  12405. */
  12406. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  12407. meshes: AbstractMesh[];
  12408. particleSystems: ParticleSystem[];
  12409. skeletons: Skeleton[];
  12410. animationGroups: AnimationGroup[];
  12411. }>;
  12412. /**
  12413. * Load a scene
  12414. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12415. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12416. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12417. * @param onSuccess a callback with the scene when import succeeds
  12418. * @param onProgress a callback with a progress event for each file being loaded
  12419. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12420. * @param pluginExtension the extension used to determine the plugin
  12421. * @returns The loaded plugin
  12422. */
  12423. static Load(rootUrl: string, sceneFilename: any, engine: 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>;
  12424. /**
  12425. * Load a scene
  12426. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12427. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12428. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12429. * @param onProgress a callback with a progress event for each file being loaded
  12430. * @param pluginExtension the extension used to determine the plugin
  12431. * @returns The loaded scene
  12432. */
  12433. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12434. /**
  12435. * Append a scene
  12436. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12437. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12438. * @param scene is the instance of BABYLON.Scene to append to
  12439. * @param onSuccess a callback with the scene when import succeeds
  12440. * @param onProgress a callback with a progress event for each file being loaded
  12441. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12442. * @param pluginExtension the extension used to determine the plugin
  12443. * @returns The loaded plugin
  12444. */
  12445. static Append(rootUrl: string, sceneFilename?: any, 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>;
  12446. /**
  12447. * Append a scene
  12448. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12449. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12450. * @param scene is the instance of BABYLON.Scene to append to
  12451. * @param onProgress a callback with a progress event for each file being loaded
  12452. * @param pluginExtension the extension used to determine the plugin
  12453. * @returns The given scene
  12454. */
  12455. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12456. /**
  12457. * Load a scene into an asset container
  12458. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12459. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12460. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  12461. * @param onSuccess a callback with the scene when import succeeds
  12462. * @param onProgress a callback with a progress event for each file being loaded
  12463. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12464. * @param pluginExtension the extension used to determine the plugin
  12465. * @returns The loaded plugin
  12466. */
  12467. static LoadAssetContainer(rootUrl: string, sceneFilename?: any, 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>;
  12468. /**
  12469. * Load a scene into an asset container
  12470. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12471. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12472. * @param scene is the instance of BABYLON.Scene to append to
  12473. * @param onProgress a callback with a progress event for each file being loaded
  12474. * @param pluginExtension the extension used to determine the plugin
  12475. * @returns The loaded asset container
  12476. */
  12477. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  12478. }
  12479. }
  12480. declare module BABYLON {
  12481. class LensFlare {
  12482. size: number;
  12483. position: number;
  12484. color: Color3;
  12485. texture: Nullable<Texture>;
  12486. alphaMode: number;
  12487. private _system;
  12488. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  12489. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  12490. dispose(): void;
  12491. }
  12492. }
  12493. declare module BABYLON {
  12494. class LensFlareSystem {
  12495. name: string;
  12496. lensFlares: LensFlare[];
  12497. borderLimit: number;
  12498. viewportBorder: number;
  12499. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  12500. layerMask: number;
  12501. id: string;
  12502. private _scene;
  12503. private _emitter;
  12504. private _vertexBuffers;
  12505. private _indexBuffer;
  12506. private _effect;
  12507. private _positionX;
  12508. private _positionY;
  12509. private _isEnabled;
  12510. constructor(name: string, emitter: any, scene: Scene);
  12511. isEnabled: boolean;
  12512. getScene(): Scene;
  12513. getEmitter(): any;
  12514. setEmitter(newEmitter: any): void;
  12515. getEmitterPosition(): Vector3;
  12516. computeEffectivePosition(globalViewport: Viewport): boolean;
  12517. _isVisible(): boolean;
  12518. render(): boolean;
  12519. dispose(): void;
  12520. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  12521. serialize(): any;
  12522. }
  12523. }
  12524. declare module BABYLON {
  12525. interface AbstractScene {
  12526. /**
  12527. * The list of lens flare system added to the scene
  12528. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  12529. */
  12530. lensFlareSystems: Array<LensFlareSystem>;
  12531. /**
  12532. * Removes the given lens flare system from this scene.
  12533. * @param toRemove The lens flare system to remove
  12534. * @returns The index of the removed lens flare system
  12535. */
  12536. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  12537. /**
  12538. * Adds the given lens flare system to this scene
  12539. * @param newLensFlareSystem The lens flare system to add
  12540. */
  12541. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  12542. /**
  12543. * Gets a lens flare system using its name
  12544. * @param name defines the name to look for
  12545. * @returns the lens flare system or null if not found
  12546. */
  12547. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  12548. /**
  12549. * Gets a lens flare system using its id
  12550. * @param id defines the id to look for
  12551. * @returns the lens flare system or null if not found
  12552. */
  12553. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  12554. }
  12555. /**
  12556. * Defines the layer scene component responsible to manage any layers
  12557. * in a given scene.
  12558. */
  12559. class LensFlareSystemSceneComponent implements ISceneComponent {
  12560. /**
  12561. * The component name helpfull to identify the component in the list of scene components.
  12562. */
  12563. readonly name: string;
  12564. /**
  12565. * The scene the component belongs to.
  12566. */
  12567. scene: Scene;
  12568. private _lensFlareSystems;
  12569. /**
  12570. * Creates a new instance of the component for the given scene
  12571. * @param scene Defines the scene to register the component in
  12572. */
  12573. constructor(scene: Scene);
  12574. /**
  12575. * Registers the component in a given scene
  12576. */
  12577. register(): void;
  12578. /**
  12579. * Rebuilds the elements related to this component in case of
  12580. * context lost for instance.
  12581. */
  12582. rebuild(): void;
  12583. /**
  12584. * Adds all the element from the container to the scene
  12585. * @param container the container holding the elements
  12586. */
  12587. addFromContainer(container: AbstractScene): void;
  12588. /**
  12589. * Removes all the elements in the container from the scene
  12590. * @param container contains the elements to remove
  12591. */
  12592. removeFromContainer(container: AbstractScene): void;
  12593. /**
  12594. * Serializes the component data to the specified json object
  12595. * @param serializationObject The object to serialize to
  12596. */
  12597. serialize(serializationObject: any): void;
  12598. /**
  12599. * Disposes the component and the associated ressources.
  12600. */
  12601. dispose(): void;
  12602. private _draw(camera);
  12603. }
  12604. }
  12605. declare module BABYLON {
  12606. /**
  12607. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  12608. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  12609. * 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;
  12610. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  12611. */
  12612. class ColorCurves {
  12613. private _dirty;
  12614. private _tempColor;
  12615. private _globalCurve;
  12616. private _highlightsCurve;
  12617. private _midtonesCurve;
  12618. private _shadowsCurve;
  12619. private _positiveCurve;
  12620. private _negativeCurve;
  12621. private _globalHue;
  12622. private _globalDensity;
  12623. private _globalSaturation;
  12624. private _globalExposure;
  12625. /**
  12626. * Gets the global Hue value.
  12627. * 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).
  12628. */
  12629. /**
  12630. * Sets the global Hue value.
  12631. * 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).
  12632. */
  12633. globalHue: number;
  12634. /**
  12635. * Gets the global Density value.
  12636. * 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.
  12637. * Values less than zero provide a filter of opposite hue.
  12638. */
  12639. /**
  12640. * Sets the global Density value.
  12641. * 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.
  12642. * Values less than zero provide a filter of opposite hue.
  12643. */
  12644. globalDensity: number;
  12645. /**
  12646. * Gets the global Saturation value.
  12647. * 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.
  12648. */
  12649. /**
  12650. * Sets the global Saturation value.
  12651. * 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.
  12652. */
  12653. globalSaturation: number;
  12654. /**
  12655. * Gets the global Exposure value.
  12656. * 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.
  12657. */
  12658. /**
  12659. * Sets the global Exposure value.
  12660. * 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.
  12661. */
  12662. globalExposure: number;
  12663. private _highlightsHue;
  12664. private _highlightsDensity;
  12665. private _highlightsSaturation;
  12666. private _highlightsExposure;
  12667. /**
  12668. * Gets the highlights Hue value.
  12669. * 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).
  12670. */
  12671. /**
  12672. * Sets the highlights Hue value.
  12673. * 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).
  12674. */
  12675. highlightsHue: number;
  12676. /**
  12677. * Gets the highlights Density value.
  12678. * 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.
  12679. * Values less than zero provide a filter of opposite hue.
  12680. */
  12681. /**
  12682. * Sets the highlights Density value.
  12683. * 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.
  12684. * Values less than zero provide a filter of opposite hue.
  12685. */
  12686. highlightsDensity: number;
  12687. /**
  12688. * Gets the highlights Saturation value.
  12689. * 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.
  12690. */
  12691. /**
  12692. * Sets the highlights Saturation value.
  12693. * 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.
  12694. */
  12695. highlightsSaturation: number;
  12696. /**
  12697. * Gets the highlights Exposure value.
  12698. * 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.
  12699. */
  12700. /**
  12701. * Sets the highlights Exposure value.
  12702. * 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.
  12703. */
  12704. highlightsExposure: number;
  12705. private _midtonesHue;
  12706. private _midtonesDensity;
  12707. private _midtonesSaturation;
  12708. private _midtonesExposure;
  12709. /**
  12710. * Gets the midtones Hue value.
  12711. * 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).
  12712. */
  12713. /**
  12714. * Sets the midtones Hue value.
  12715. * 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).
  12716. */
  12717. midtonesHue: number;
  12718. /**
  12719. * Gets the midtones Density value.
  12720. * 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.
  12721. * Values less than zero provide a filter of opposite hue.
  12722. */
  12723. /**
  12724. * Sets the midtones Density value.
  12725. * 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.
  12726. * Values less than zero provide a filter of opposite hue.
  12727. */
  12728. midtonesDensity: number;
  12729. /**
  12730. * Gets the midtones Saturation value.
  12731. * 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.
  12732. */
  12733. /**
  12734. * Sets the midtones Saturation value.
  12735. * 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.
  12736. */
  12737. midtonesSaturation: number;
  12738. /**
  12739. * Gets the midtones Exposure value.
  12740. * 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.
  12741. */
  12742. /**
  12743. * Sets the midtones Exposure value.
  12744. * 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.
  12745. */
  12746. midtonesExposure: number;
  12747. private _shadowsHue;
  12748. private _shadowsDensity;
  12749. private _shadowsSaturation;
  12750. private _shadowsExposure;
  12751. /**
  12752. * Gets the shadows Hue value.
  12753. * 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).
  12754. */
  12755. /**
  12756. * Sets the shadows Hue value.
  12757. * 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).
  12758. */
  12759. shadowsHue: number;
  12760. /**
  12761. * Gets the shadows Density value.
  12762. * 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.
  12763. * Values less than zero provide a filter of opposite hue.
  12764. */
  12765. /**
  12766. * Sets the shadows Density value.
  12767. * 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.
  12768. * Values less than zero provide a filter of opposite hue.
  12769. */
  12770. shadowsDensity: number;
  12771. /**
  12772. * Gets the shadows Saturation value.
  12773. * 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.
  12774. */
  12775. /**
  12776. * Sets the shadows Saturation value.
  12777. * 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.
  12778. */
  12779. shadowsSaturation: number;
  12780. /**
  12781. * Gets the shadows Exposure value.
  12782. * 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.
  12783. */
  12784. /**
  12785. * Sets the shadows Exposure value.
  12786. * 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.
  12787. */
  12788. shadowsExposure: number;
  12789. getClassName(): string;
  12790. /**
  12791. * Binds the color curves to the shader.
  12792. * @param colorCurves The color curve to bind
  12793. * @param effect The effect to bind to
  12794. */
  12795. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  12796. /**
  12797. * Prepare the list of uniforms associated with the ColorCurves effects.
  12798. * @param uniformsList The list of uniforms used in the effect
  12799. */
  12800. static PrepareUniforms(uniformsList: string[]): void;
  12801. /**
  12802. * Returns color grading data based on a hue, density, saturation and exposure value.
  12803. * @param filterHue The hue of the color filter.
  12804. * @param filterDensity The density of the color filter.
  12805. * @param saturation The saturation.
  12806. * @param exposure The exposure.
  12807. * @param result The result data container.
  12808. */
  12809. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  12810. /**
  12811. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  12812. * @param value The input slider value in range [-100,100].
  12813. * @returns Adjusted value.
  12814. */
  12815. private static applyColorGradingSliderNonlinear(value);
  12816. /**
  12817. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  12818. * @param hue The hue (H) input.
  12819. * @param saturation The saturation (S) input.
  12820. * @param brightness The brightness (B) input.
  12821. * @result An RGBA color represented as Vector4.
  12822. */
  12823. private static fromHSBToRef(hue, saturation, brightness, result);
  12824. /**
  12825. * Returns a value clamped between min and max
  12826. * @param value The value to clamp
  12827. * @param min The minimum of value
  12828. * @param max The maximum of value
  12829. * @returns The clamped value.
  12830. */
  12831. private static clamp(value, min, max);
  12832. /**
  12833. * Clones the current color curve instance.
  12834. * @return The cloned curves
  12835. */
  12836. clone(): ColorCurves;
  12837. /**
  12838. * Serializes the current color curve instance to a json representation.
  12839. * @return a JSON representation
  12840. */
  12841. serialize(): any;
  12842. /**
  12843. * Parses the color curve from a json representation.
  12844. * @param source the JSON source to parse
  12845. * @return The parsed curves
  12846. */
  12847. static Parse(source: any): ColorCurves;
  12848. }
  12849. }
  12850. declare module BABYLON {
  12851. /**
  12852. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12853. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12854. */
  12855. class EffectFallbacks {
  12856. private _defines;
  12857. private _currentRank;
  12858. private _maxRank;
  12859. private _mesh;
  12860. /**
  12861. * Removes the fallback from the bound mesh.
  12862. */
  12863. unBindMesh(): void;
  12864. /**
  12865. * Adds a fallback on the specified property.
  12866. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12867. * @param define The name of the define in the shader
  12868. */
  12869. addFallback(rank: number, define: string): void;
  12870. /**
  12871. * Sets the mesh to use CPU skinning when needing to fallback.
  12872. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12873. * @param mesh The mesh to use the fallbacks.
  12874. */
  12875. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12876. /**
  12877. * Checks to see if more fallbacks are still availible.
  12878. */
  12879. readonly isMoreFallbacks: boolean;
  12880. /**
  12881. * Removes the defines that shoould be removed when falling back.
  12882. * @param currentDefines defines the current define statements for the shader.
  12883. * @param effect defines the current effect we try to compile
  12884. * @returns The resulting defines with defines of the current rank removed.
  12885. */
  12886. reduce(currentDefines: string, effect: Effect): string;
  12887. }
  12888. /**
  12889. * Options to be used when creating an effect.
  12890. */
  12891. class EffectCreationOptions {
  12892. /**
  12893. * Atrributes that will be used in the shader.
  12894. */
  12895. attributes: string[];
  12896. /**
  12897. * Uniform varible names that will be set in the shader.
  12898. */
  12899. uniformsNames: string[];
  12900. /**
  12901. * Uniform buffer varible names that will be set in the shader.
  12902. */
  12903. uniformBuffersNames: string[];
  12904. /**
  12905. * Sampler texture variable names that will be set in the shader.
  12906. */
  12907. samplers: string[];
  12908. /**
  12909. * Define statements that will be set in the shader.
  12910. */
  12911. defines: any;
  12912. /**
  12913. * Possible fallbacks for this effect to improve performance when needed.
  12914. */
  12915. fallbacks: Nullable<EffectFallbacks>;
  12916. /**
  12917. * Callback that will be called when the shader is compiled.
  12918. */
  12919. onCompiled: Nullable<(effect: Effect) => void>;
  12920. /**
  12921. * Callback that will be called if an error occurs during shader compilation.
  12922. */
  12923. onError: Nullable<(effect: Effect, errors: string) => void>;
  12924. /**
  12925. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12926. */
  12927. indexParameters: any;
  12928. /**
  12929. * Max number of lights that can be used in the shader.
  12930. */
  12931. maxSimultaneousLights: number;
  12932. /**
  12933. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  12934. */
  12935. transformFeedbackVaryings: Nullable<string[]>;
  12936. }
  12937. /**
  12938. * Effect containing vertex and fragment shader that can be executed on an object.
  12939. */
  12940. class Effect {
  12941. /**
  12942. * Name of the effect.
  12943. */
  12944. name: any;
  12945. /**
  12946. * String container all the define statements that should be set on the shader.
  12947. */
  12948. defines: string;
  12949. /**
  12950. * Callback that will be called when the shader is compiled.
  12951. */
  12952. onCompiled: Nullable<(effect: Effect) => void>;
  12953. /**
  12954. * Callback that will be called if an error occurs during shader compilation.
  12955. */
  12956. onError: Nullable<(effect: Effect, errors: string) => void>;
  12957. /**
  12958. * Callback that will be called when effect is bound.
  12959. */
  12960. onBind: Nullable<(effect: Effect) => void>;
  12961. /**
  12962. * Unique ID of the effect.
  12963. */
  12964. uniqueId: number;
  12965. /**
  12966. * Observable that will be called when the shader is compiled.
  12967. */
  12968. onCompileObservable: Observable<Effect>;
  12969. /**
  12970. * Observable that will be called if an error occurs during shader compilation.
  12971. */
  12972. onErrorObservable: Observable<Effect>;
  12973. /**
  12974. * Observable that will be called when effect is bound.
  12975. */
  12976. onBindObservable: Observable<Effect>;
  12977. /** @hidden */
  12978. _bonesComputationForcedToCPU: boolean;
  12979. private static _uniqueIdSeed;
  12980. private _engine;
  12981. private _uniformBuffersNames;
  12982. private _uniformsNames;
  12983. private _samplers;
  12984. private _isReady;
  12985. private _compilationError;
  12986. private _attributesNames;
  12987. private _attributes;
  12988. private _uniforms;
  12989. /**
  12990. * Key for the effect.
  12991. */
  12992. _key: string;
  12993. private _indexParameters;
  12994. private _fallbacks;
  12995. private _vertexSourceCode;
  12996. private _fragmentSourceCode;
  12997. private _vertexSourceCodeOverride;
  12998. private _fragmentSourceCodeOverride;
  12999. private _transformFeedbackVaryings;
  13000. /**
  13001. * Compiled shader to webGL program.
  13002. */
  13003. _program: WebGLProgram;
  13004. private _valueCache;
  13005. private static _baseCache;
  13006. /**
  13007. * Instantiates an effect.
  13008. * An effect can be used to create/manage/execute vertex and fragment shaders.
  13009. * @param baseName Name of the effect.
  13010. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  13011. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  13012. * @param samplers List of sampler variables that will be passed to the shader.
  13013. * @param engine Engine to be used to render the effect
  13014. * @param defines Define statements to be added to the shader.
  13015. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  13016. * @param onCompiled Callback that will be called when the shader is compiled.
  13017. * @param onError Callback that will be called if an error occurs during shader compilation.
  13018. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13019. */
  13020. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  13021. /**
  13022. * Unique key for this effect
  13023. */
  13024. readonly key: string;
  13025. /**
  13026. * If the effect has been compiled and prepared.
  13027. * @returns if the effect is compiled and prepared.
  13028. */
  13029. isReady(): boolean;
  13030. /**
  13031. * The engine the effect was initialized with.
  13032. * @returns the engine.
  13033. */
  13034. getEngine(): Engine;
  13035. /**
  13036. * The compiled webGL program for the effect
  13037. * @returns the webGL program.
  13038. */
  13039. getProgram(): WebGLProgram;
  13040. /**
  13041. * The set of names of attribute variables for the shader.
  13042. * @returns An array of attribute names.
  13043. */
  13044. getAttributesNames(): string[];
  13045. /**
  13046. * Returns the attribute at the given index.
  13047. * @param index The index of the attribute.
  13048. * @returns The location of the attribute.
  13049. */
  13050. getAttributeLocation(index: number): number;
  13051. /**
  13052. * Returns the attribute based on the name of the variable.
  13053. * @param name of the attribute to look up.
  13054. * @returns the attribute location.
  13055. */
  13056. getAttributeLocationByName(name: string): number;
  13057. /**
  13058. * The number of attributes.
  13059. * @returns the numnber of attributes.
  13060. */
  13061. getAttributesCount(): number;
  13062. /**
  13063. * Gets the index of a uniform variable.
  13064. * @param uniformName of the uniform to look up.
  13065. * @returns the index.
  13066. */
  13067. getUniformIndex(uniformName: string): number;
  13068. /**
  13069. * Returns the attribute based on the name of the variable.
  13070. * @param uniformName of the uniform to look up.
  13071. * @returns the location of the uniform.
  13072. */
  13073. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  13074. /**
  13075. * Returns an array of sampler variable names
  13076. * @returns The array of sampler variable neames.
  13077. */
  13078. getSamplers(): string[];
  13079. /**
  13080. * The error from the last compilation.
  13081. * @returns the error string.
  13082. */
  13083. getCompilationError(): string;
  13084. /**
  13085. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  13086. * @param func The callback to be used.
  13087. */
  13088. executeWhenCompiled(func: (effect: Effect) => void): void;
  13089. /** @hidden */
  13090. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  13091. /** @hidden */
  13092. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  13093. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  13094. private _processShaderConversion(sourceCode, isFragment, callback);
  13095. private _processIncludes(sourceCode, callback);
  13096. private _processPrecision(source);
  13097. /**
  13098. * Recompiles the webGL program
  13099. * @param vertexSourceCode The source code for the vertex shader.
  13100. * @param fragmentSourceCode The source code for the fragment shader.
  13101. * @param onCompiled Callback called when completed.
  13102. * @param onError Callback called on error.
  13103. */
  13104. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  13105. /**
  13106. * Gets the uniform locations of the the specified variable names
  13107. * @param names THe names of the variables to lookup.
  13108. * @returns Array of locations in the same order as variable names.
  13109. */
  13110. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  13111. /**
  13112. * Prepares the effect
  13113. */
  13114. _prepareEffect(): void;
  13115. /**
  13116. * Checks if the effect is supported. (Must be called after compilation)
  13117. */
  13118. readonly isSupported: boolean;
  13119. /**
  13120. * Binds a texture to the engine to be used as output of the shader.
  13121. * @param channel Name of the output variable.
  13122. * @param texture Texture to bind.
  13123. */
  13124. _bindTexture(channel: string, texture: InternalTexture): void;
  13125. /**
  13126. * Sets a texture on the engine to be used in the shader.
  13127. * @param channel Name of the sampler variable.
  13128. * @param texture Texture to set.
  13129. */
  13130. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  13131. /**
  13132. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  13133. * @param channel Name of the sampler variable.
  13134. * @param texture Texture to set.
  13135. */
  13136. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  13137. /**
  13138. * Sets an array of textures on the engine to be used in the shader.
  13139. * @param channel Name of the variable.
  13140. * @param textures Textures to set.
  13141. */
  13142. setTextureArray(channel: string, textures: BaseTexture[]): void;
  13143. /**
  13144. * 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)
  13145. * @param channel Name of the sampler variable.
  13146. * @param postProcess Post process to get the input texture from.
  13147. */
  13148. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  13149. /**
  13150. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  13151. * 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)
  13152. * @param channel Name of the sampler variable.
  13153. * @param postProcess Post process to get the output texture from.
  13154. */
  13155. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  13156. /** @hidden */
  13157. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  13158. /** @hidden */
  13159. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  13160. /** @hidden */
  13161. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  13162. /** @hidden */
  13163. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  13164. /**
  13165. * Binds a buffer to a uniform.
  13166. * @param buffer Buffer to bind.
  13167. * @param name Name of the uniform variable to bind to.
  13168. */
  13169. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  13170. /**
  13171. * Binds block to a uniform.
  13172. * @param blockName Name of the block to bind.
  13173. * @param index Index to bind.
  13174. */
  13175. bindUniformBlock(blockName: string, index: number): void;
  13176. /**
  13177. * Sets an interger value on a uniform variable.
  13178. * @param uniformName Name of the variable.
  13179. * @param value Value to be set.
  13180. * @returns this effect.
  13181. */
  13182. setInt(uniformName: string, value: number): Effect;
  13183. /**
  13184. * Sets an int array on a uniform variable.
  13185. * @param uniformName Name of the variable.
  13186. * @param array array to be set.
  13187. * @returns this effect.
  13188. */
  13189. setIntArray(uniformName: string, array: Int32Array): Effect;
  13190. /**
  13191. * 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)
  13192. * @param uniformName Name of the variable.
  13193. * @param array array to be set.
  13194. * @returns this effect.
  13195. */
  13196. setIntArray2(uniformName: string, array: Int32Array): Effect;
  13197. /**
  13198. * 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)
  13199. * @param uniformName Name of the variable.
  13200. * @param array array to be set.
  13201. * @returns this effect.
  13202. */
  13203. setIntArray3(uniformName: string, array: Int32Array): Effect;
  13204. /**
  13205. * 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)
  13206. * @param uniformName Name of the variable.
  13207. * @param array array to be set.
  13208. * @returns this effect.
  13209. */
  13210. setIntArray4(uniformName: string, array: Int32Array): Effect;
  13211. /**
  13212. * Sets an float array on a uniform variable.
  13213. * @param uniformName Name of the variable.
  13214. * @param array array to be set.
  13215. * @returns this effect.
  13216. */
  13217. setFloatArray(uniformName: string, array: Float32Array): Effect;
  13218. /**
  13219. * 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)
  13220. * @param uniformName Name of the variable.
  13221. * @param array array to be set.
  13222. * @returns this effect.
  13223. */
  13224. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  13225. /**
  13226. * 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)
  13227. * @param uniformName Name of the variable.
  13228. * @param array array to be set.
  13229. * @returns this effect.
  13230. */
  13231. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  13232. /**
  13233. * 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)
  13234. * @param uniformName Name of the variable.
  13235. * @param array array to be set.
  13236. * @returns this effect.
  13237. */
  13238. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  13239. /**
  13240. * Sets an array on a uniform variable.
  13241. * @param uniformName Name of the variable.
  13242. * @param array array to be set.
  13243. * @returns this effect.
  13244. */
  13245. setArray(uniformName: string, array: number[]): Effect;
  13246. /**
  13247. * 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)
  13248. * @param uniformName Name of the variable.
  13249. * @param array array to be set.
  13250. * @returns this effect.
  13251. */
  13252. setArray2(uniformName: string, array: number[]): Effect;
  13253. /**
  13254. * 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)
  13255. * @param uniformName Name of the variable.
  13256. * @param array array to be set.
  13257. * @returns this effect.
  13258. */
  13259. setArray3(uniformName: string, array: number[]): Effect;
  13260. /**
  13261. * 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)
  13262. * @param uniformName Name of the variable.
  13263. * @param array array to be set.
  13264. * @returns this effect.
  13265. */
  13266. setArray4(uniformName: string, array: number[]): Effect;
  13267. /**
  13268. * Sets matrices on a uniform variable.
  13269. * @param uniformName Name of the variable.
  13270. * @param matrices matrices to be set.
  13271. * @returns this effect.
  13272. */
  13273. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  13274. /**
  13275. * Sets matrix on a uniform variable.
  13276. * @param uniformName Name of the variable.
  13277. * @param matrix matrix to be set.
  13278. * @returns this effect.
  13279. */
  13280. setMatrix(uniformName: string, matrix: Matrix): Effect;
  13281. /**
  13282. * 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)
  13283. * @param uniformName Name of the variable.
  13284. * @param matrix matrix to be set.
  13285. * @returns this effect.
  13286. */
  13287. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  13288. /**
  13289. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  13290. * @param uniformName Name of the variable.
  13291. * @param matrix matrix to be set.
  13292. * @returns this effect.
  13293. */
  13294. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  13295. /**
  13296. * Sets a float on a uniform variable.
  13297. * @param uniformName Name of the variable.
  13298. * @param value value to be set.
  13299. * @returns this effect.
  13300. */
  13301. setFloat(uniformName: string, value: number): Effect;
  13302. /**
  13303. * Sets a boolean on a uniform variable.
  13304. * @param uniformName Name of the variable.
  13305. * @param bool value to be set.
  13306. * @returns this effect.
  13307. */
  13308. setBool(uniformName: string, bool: boolean): Effect;
  13309. /**
  13310. * Sets a Vector2 on a uniform variable.
  13311. * @param uniformName Name of the variable.
  13312. * @param vector2 vector2 to be set.
  13313. * @returns this effect.
  13314. */
  13315. setVector2(uniformName: string, vector2: Vector2): Effect;
  13316. /**
  13317. * Sets a float2 on a uniform variable.
  13318. * @param uniformName Name of the variable.
  13319. * @param x First float in float2.
  13320. * @param y Second float in float2.
  13321. * @returns this effect.
  13322. */
  13323. setFloat2(uniformName: string, x: number, y: number): Effect;
  13324. /**
  13325. * Sets a Vector3 on a uniform variable.
  13326. * @param uniformName Name of the variable.
  13327. * @param vector3 Value to be set.
  13328. * @returns this effect.
  13329. */
  13330. setVector3(uniformName: string, vector3: Vector3): Effect;
  13331. /**
  13332. * Sets a float3 on a uniform variable.
  13333. * @param uniformName Name of the variable.
  13334. * @param x First float in float3.
  13335. * @param y Second float in float3.
  13336. * @param z Third float in float3.
  13337. * @returns this effect.
  13338. */
  13339. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  13340. /**
  13341. * Sets a Vector4 on a uniform variable.
  13342. * @param uniformName Name of the variable.
  13343. * @param vector4 Value to be set.
  13344. * @returns this effect.
  13345. */
  13346. setVector4(uniformName: string, vector4: Vector4): Effect;
  13347. /**
  13348. * Sets a float4 on a uniform variable.
  13349. * @param uniformName Name of the variable.
  13350. * @param x First float in float4.
  13351. * @param y Second float in float4.
  13352. * @param z Third float in float4.
  13353. * @param w Fourth float in float4.
  13354. * @returns this effect.
  13355. */
  13356. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  13357. /**
  13358. * Sets a Color3 on a uniform variable.
  13359. * @param uniformName Name of the variable.
  13360. * @param color3 Value to be set.
  13361. * @returns this effect.
  13362. */
  13363. setColor3(uniformName: string, color3: Color3): Effect;
  13364. /**
  13365. * Sets a Color4 on a uniform variable.
  13366. * @param uniformName Name of the variable.
  13367. * @param color3 Value to be set.
  13368. * @param alpha Alpha value to be set.
  13369. * @returns this effect.
  13370. */
  13371. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  13372. /**
  13373. * Sets a Color4 on a uniform variable
  13374. * @param uniformName defines the name of the variable
  13375. * @param color4 defines the value to be set
  13376. * @returns this effect.
  13377. */
  13378. setDirectColor4(uniformName: string, color4: Color4): Effect;
  13379. /**
  13380. * Store of each shader (The can be looked up using effect.key)
  13381. */
  13382. static ShadersStore: {
  13383. [key: string]: string;
  13384. };
  13385. /**
  13386. * Store of each included file for a shader (The can be looked up using effect.key)
  13387. */
  13388. static IncludesShadersStore: {
  13389. [key: string]: string;
  13390. };
  13391. /**
  13392. * Resets the cache of effects.
  13393. */
  13394. static ResetCache(): void;
  13395. }
  13396. }
  13397. declare module BABYLON {
  13398. class FresnelParameters {
  13399. private _isEnabled;
  13400. isEnabled: boolean;
  13401. leftColor: Color3;
  13402. rightColor: Color3;
  13403. bias: number;
  13404. power: number;
  13405. clone(): FresnelParameters;
  13406. serialize(): any;
  13407. static Parse(parsedFresnelParameters: any): FresnelParameters;
  13408. }
  13409. }
  13410. declare module BABYLON {
  13411. /**
  13412. * Interface to follow in your material defines to integrate easily the
  13413. * Image proccessing functions.
  13414. * @hidden
  13415. */
  13416. interface IImageProcessingConfigurationDefines {
  13417. IMAGEPROCESSING: boolean;
  13418. VIGNETTE: boolean;
  13419. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13420. VIGNETTEBLENDMODEOPAQUE: boolean;
  13421. TONEMAPPING: boolean;
  13422. CONTRAST: boolean;
  13423. EXPOSURE: boolean;
  13424. COLORCURVES: boolean;
  13425. COLORGRADING: boolean;
  13426. COLORGRADING3D: boolean;
  13427. SAMPLER3DGREENDEPTH: boolean;
  13428. SAMPLER3DBGRMAP: boolean;
  13429. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13430. }
  13431. /**
  13432. * This groups together the common properties used for image processing either in direct forward pass
  13433. * or through post processing effect depending on the use of the image processing pipeline in your scene
  13434. * or not.
  13435. */
  13436. class ImageProcessingConfiguration {
  13437. /**
  13438. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  13439. */
  13440. colorCurves: Nullable<ColorCurves>;
  13441. private _colorCurvesEnabled;
  13442. /**
  13443. * Gets wether the color curves effect is enabled.
  13444. */
  13445. /**
  13446. * Sets wether the color curves effect is enabled.
  13447. */
  13448. colorCurvesEnabled: boolean;
  13449. /**
  13450. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  13451. */
  13452. colorGradingTexture: Nullable<BaseTexture>;
  13453. private _colorGradingEnabled;
  13454. /**
  13455. * Gets wether the color grading effect is enabled.
  13456. */
  13457. /**
  13458. * Sets wether the color grading effect is enabled.
  13459. */
  13460. colorGradingEnabled: boolean;
  13461. private _colorGradingWithGreenDepth;
  13462. /**
  13463. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  13464. */
  13465. /**
  13466. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  13467. */
  13468. colorGradingWithGreenDepth: boolean;
  13469. private _colorGradingBGR;
  13470. /**
  13471. * Gets wether the color grading texture contains BGR values.
  13472. */
  13473. /**
  13474. * Sets wether the color grading texture contains BGR values.
  13475. */
  13476. colorGradingBGR: boolean;
  13477. _exposure: number;
  13478. /**
  13479. * Gets the Exposure used in the effect.
  13480. */
  13481. /**
  13482. * Sets the Exposure used in the effect.
  13483. */
  13484. exposure: number;
  13485. private _toneMappingEnabled;
  13486. /**
  13487. * Gets wether the tone mapping effect is enabled.
  13488. */
  13489. /**
  13490. * Sets wether the tone mapping effect is enabled.
  13491. */
  13492. toneMappingEnabled: boolean;
  13493. protected _contrast: number;
  13494. /**
  13495. * Gets the contrast used in the effect.
  13496. */
  13497. /**
  13498. * Sets the contrast used in the effect.
  13499. */
  13500. contrast: number;
  13501. /**
  13502. * Vignette stretch size.
  13503. */
  13504. vignetteStretch: number;
  13505. /**
  13506. * Vignette centre X Offset.
  13507. */
  13508. vignetteCentreX: number;
  13509. /**
  13510. * Vignette centre Y Offset.
  13511. */
  13512. vignetteCentreY: number;
  13513. /**
  13514. * Vignette weight or intensity of the vignette effect.
  13515. */
  13516. vignetteWeight: number;
  13517. /**
  13518. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  13519. * if vignetteEnabled is set to true.
  13520. */
  13521. vignetteColor: Color4;
  13522. /**
  13523. * Camera field of view used by the Vignette effect.
  13524. */
  13525. vignetteCameraFov: number;
  13526. private _vignetteBlendMode;
  13527. /**
  13528. * Gets the vignette blend mode allowing different kind of effect.
  13529. */
  13530. /**
  13531. * Sets the vignette blend mode allowing different kind of effect.
  13532. */
  13533. vignetteBlendMode: number;
  13534. private _vignetteEnabled;
  13535. /**
  13536. * Gets wether the vignette effect is enabled.
  13537. */
  13538. /**
  13539. * Sets wether the vignette effect is enabled.
  13540. */
  13541. vignetteEnabled: boolean;
  13542. private _applyByPostProcess;
  13543. /**
  13544. * Gets wether the image processing is applied through a post process or not.
  13545. */
  13546. /**
  13547. * Sets wether the image processing is applied through a post process or not.
  13548. */
  13549. applyByPostProcess: boolean;
  13550. private _isEnabled;
  13551. /**
  13552. * Gets wether the image processing is enabled or not.
  13553. */
  13554. /**
  13555. * Sets wether the image processing is enabled or not.
  13556. */
  13557. isEnabled: boolean;
  13558. /**
  13559. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  13560. */
  13561. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  13562. /**
  13563. * Method called each time the image processing information changes requires to recompile the effect.
  13564. */
  13565. protected _updateParameters(): void;
  13566. getClassName(): string;
  13567. /**
  13568. * Prepare the list of uniforms associated with the Image Processing effects.
  13569. * @param uniformsList The list of uniforms used in the effect
  13570. * @param defines the list of defines currently in use
  13571. */
  13572. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  13573. /**
  13574. * Prepare the list of samplers associated with the Image Processing effects.
  13575. * @param uniformsList The list of uniforms used in the effect
  13576. * @param defines the list of defines currently in use
  13577. */
  13578. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  13579. /**
  13580. * Prepare the list of defines associated to the shader.
  13581. * @param defines the list of defines to complete
  13582. */
  13583. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  13584. /**
  13585. * Returns true if all the image processing information are ready.
  13586. */
  13587. isReady(): boolean;
  13588. /**
  13589. * Binds the image processing to the shader.
  13590. * @param effect The effect to bind to
  13591. */
  13592. bind(effect: Effect, aspectRatio?: number): void;
  13593. /**
  13594. * Clones the current image processing instance.
  13595. * @return The cloned image processing
  13596. */
  13597. clone(): ImageProcessingConfiguration;
  13598. /**
  13599. * Serializes the current image processing instance to a json representation.
  13600. * @return a JSON representation
  13601. */
  13602. serialize(): any;
  13603. /**
  13604. * Parses the image processing from a json representation.
  13605. * @param source the JSON source to parse
  13606. * @return The parsed image processing
  13607. */
  13608. static Parse(source: any): ImageProcessingConfiguration;
  13609. private static _VIGNETTEMODE_MULTIPLY;
  13610. private static _VIGNETTEMODE_OPAQUE;
  13611. /**
  13612. * Used to apply the vignette as a mix with the pixel color.
  13613. */
  13614. static readonly VIGNETTEMODE_MULTIPLY: number;
  13615. /**
  13616. * Used to apply the vignette as a replacement of the pixel color.
  13617. */
  13618. static readonly VIGNETTEMODE_OPAQUE: number;
  13619. }
  13620. }
  13621. declare module BABYLON {
  13622. /**
  13623. * Manages the defines for the Material
  13624. */
  13625. class MaterialDefines {
  13626. private _keys;
  13627. private _isDirty;
  13628. /** @hidden */
  13629. _renderId: number;
  13630. /** @hidden */
  13631. _areLightsDirty: boolean;
  13632. /** @hidden */
  13633. _areAttributesDirty: boolean;
  13634. /** @hidden */
  13635. _areTexturesDirty: boolean;
  13636. /** @hidden */
  13637. _areFresnelDirty: boolean;
  13638. /** @hidden */
  13639. _areMiscDirty: boolean;
  13640. /** @hidden */
  13641. _areImageProcessingDirty: boolean;
  13642. /** @hidden */
  13643. _normals: boolean;
  13644. /** @hidden */
  13645. _uvs: boolean;
  13646. /** @hidden */
  13647. _needNormals: boolean;
  13648. /** @hidden */
  13649. _needUVs: boolean;
  13650. /**
  13651. * Specifies if the material needs to be re-calculated
  13652. */
  13653. readonly isDirty: boolean;
  13654. /**
  13655. * Marks the material to indicate that it has been re-calculated
  13656. */
  13657. markAsProcessed(): void;
  13658. /**
  13659. * Marks the material to indicate that it needs to be re-calculated
  13660. */
  13661. markAsUnprocessed(): void;
  13662. /**
  13663. * Marks the material to indicate all of its defines need to be re-calculated
  13664. */
  13665. markAllAsDirty(): void;
  13666. /**
  13667. * Marks the material to indicate that image processing needs to be re-calculated
  13668. */
  13669. markAsImageProcessingDirty(): void;
  13670. /**
  13671. * Marks the material to indicate the lights need to be re-calculated
  13672. */
  13673. markAsLightDirty(): void;
  13674. /**
  13675. * Marks the attribute state as changed
  13676. */
  13677. markAsAttributesDirty(): void;
  13678. /**
  13679. * Marks the texture state as changed
  13680. */
  13681. markAsTexturesDirty(): void;
  13682. /**
  13683. * Marks the fresnel state as changed
  13684. */
  13685. markAsFresnelDirty(): void;
  13686. /**
  13687. * Marks the misc state as changed
  13688. */
  13689. markAsMiscDirty(): void;
  13690. /**
  13691. * Rebuilds the material defines
  13692. */
  13693. rebuild(): void;
  13694. /**
  13695. * Specifies if two material defines are equal
  13696. * @param other - A material define instance to compare to
  13697. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  13698. */
  13699. isEqual(other: MaterialDefines): boolean;
  13700. /**
  13701. * Clones this instance's defines to another instance
  13702. * @param other - material defines to clone values to
  13703. */
  13704. cloneTo(other: MaterialDefines): void;
  13705. /**
  13706. * Resets the material define values
  13707. */
  13708. reset(): void;
  13709. /**
  13710. * Converts the material define values to a string
  13711. * @returns - String of material define information
  13712. */
  13713. toString(): string;
  13714. }
  13715. /**
  13716. * Base class for the main features of a material in Babylon.js
  13717. */
  13718. class Material implements IAnimatable {
  13719. private static _TriangleFillMode;
  13720. private static _WireFrameFillMode;
  13721. private static _PointFillMode;
  13722. private static _PointListDrawMode;
  13723. private static _LineListDrawMode;
  13724. private static _LineLoopDrawMode;
  13725. private static _LineStripDrawMode;
  13726. private static _TriangleStripDrawMode;
  13727. private static _TriangleFanDrawMode;
  13728. /**
  13729. * Returns the triangle fill mode
  13730. */
  13731. static readonly TriangleFillMode: number;
  13732. /**
  13733. * Returns the wireframe mode
  13734. */
  13735. static readonly WireFrameFillMode: number;
  13736. /**
  13737. * Returns the point fill mode
  13738. */
  13739. static readonly PointFillMode: number;
  13740. /**
  13741. * Returns the point list draw mode
  13742. */
  13743. static readonly PointListDrawMode: number;
  13744. /**
  13745. * Returns the line list draw mode
  13746. */
  13747. static readonly LineListDrawMode: number;
  13748. /**
  13749. * Returns the line loop draw mode
  13750. */
  13751. static readonly LineLoopDrawMode: number;
  13752. /**
  13753. * Returns the line strip draw mode
  13754. */
  13755. static readonly LineStripDrawMode: number;
  13756. /**
  13757. * Returns the triangle strip draw mode
  13758. */
  13759. static readonly TriangleStripDrawMode: number;
  13760. /**
  13761. * Returns the triangle fan draw mode
  13762. */
  13763. static readonly TriangleFanDrawMode: number;
  13764. /**
  13765. * Stores the clock-wise side orientation
  13766. */
  13767. private static _ClockWiseSideOrientation;
  13768. /**
  13769. * Stores the counter clock-wise side orientation
  13770. */
  13771. private static _CounterClockWiseSideOrientation;
  13772. /**
  13773. * Returns the clock-wise side orientation
  13774. */
  13775. static readonly ClockWiseSideOrientation: number;
  13776. /**
  13777. * Returns the counter clock-wise side orientation
  13778. */
  13779. static readonly CounterClockWiseSideOrientation: number;
  13780. /**
  13781. * The dirty texture flag value
  13782. */
  13783. private static _TextureDirtyFlag;
  13784. /**
  13785. * The dirty light flag value
  13786. */
  13787. private static _LightDirtyFlag;
  13788. /**
  13789. * The dirty fresnel flag value
  13790. */
  13791. private static _FresnelDirtyFlag;
  13792. /**
  13793. * The dirty attribute flag value
  13794. */
  13795. private static _AttributesDirtyFlag;
  13796. /**
  13797. * The dirty misc flag value
  13798. */
  13799. private static _MiscDirtyFlag;
  13800. /**
  13801. * Returns the dirty texture flag value
  13802. */
  13803. static readonly TextureDirtyFlag: number;
  13804. /**
  13805. * Returns the dirty light flag value
  13806. */
  13807. static readonly LightDirtyFlag: number;
  13808. /**
  13809. * Returns the dirty fresnel flag value
  13810. */
  13811. static readonly FresnelDirtyFlag: number;
  13812. /**
  13813. * Returns the dirty attributes flag value
  13814. */
  13815. static readonly AttributesDirtyFlag: number;
  13816. /**
  13817. * Returns the dirty misc flag value
  13818. */
  13819. static readonly MiscDirtyFlag: number;
  13820. /**
  13821. * The ID of the material
  13822. */
  13823. id: string;
  13824. /**
  13825. * Gets or sets the unique id of the material
  13826. */
  13827. uniqueId: number;
  13828. /**
  13829. * The name of the material
  13830. */
  13831. name: string;
  13832. /**
  13833. * Specifies if the ready state should be checked on each call
  13834. */
  13835. checkReadyOnEveryCall: boolean;
  13836. /**
  13837. * Specifies if the ready state should be checked once
  13838. */
  13839. checkReadyOnlyOnce: boolean;
  13840. /**
  13841. * The state of the material
  13842. */
  13843. state: string;
  13844. /**
  13845. * The alpha value of the material
  13846. */
  13847. protected _alpha: number;
  13848. /**
  13849. * Gets the alpha value of the material
  13850. */
  13851. /**
  13852. * Sets the alpha value of the material
  13853. */
  13854. alpha: number;
  13855. /**
  13856. * Specifies if back face culling is enabled
  13857. */
  13858. protected _backFaceCulling: boolean;
  13859. /**
  13860. * Gets the back-face culling state
  13861. */
  13862. /**
  13863. * Sets the back-face culling state
  13864. */
  13865. backFaceCulling: boolean;
  13866. /**
  13867. * Stores the value for side orientation
  13868. */
  13869. sideOrientation: number;
  13870. /**
  13871. * Callback triggered when the material is compiled
  13872. */
  13873. onCompiled: (effect: Effect) => void;
  13874. /**
  13875. * Callback triggered when an error occurs
  13876. */
  13877. onError: (effect: Effect, errors: string) => void;
  13878. /**
  13879. * Callback triggered to get the render target textures
  13880. */
  13881. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  13882. /**
  13883. * Specifies if the material should be serialized
  13884. */
  13885. doNotSerialize: boolean;
  13886. /**
  13887. * Specifies if the effect should be stored on sub meshes
  13888. */
  13889. storeEffectOnSubMeshes: boolean;
  13890. /**
  13891. * Stores the animations for the material
  13892. */
  13893. animations: Array<Animation>;
  13894. /**
  13895. * An event triggered when the material is disposed
  13896. */
  13897. onDisposeObservable: Observable<Material>;
  13898. /**
  13899. * An observer which watches for dispose events
  13900. */
  13901. private _onDisposeObserver;
  13902. /**
  13903. * Called during a dispose event
  13904. */
  13905. onDispose: () => void;
  13906. /**
  13907. * An event triggered when the material is bound
  13908. */
  13909. onBindObservable: Observable<AbstractMesh>;
  13910. /**
  13911. * An observer which watches for bind events
  13912. */
  13913. private _onBindObserver;
  13914. /**
  13915. * Called during a bind event
  13916. */
  13917. onBind: (Mesh: AbstractMesh) => void;
  13918. /**
  13919. * An event triggered when the material is unbound
  13920. */
  13921. onUnBindObservable: Observable<Material>;
  13922. /**
  13923. * Stores the value of the alpha mode
  13924. */
  13925. private _alphaMode;
  13926. /**
  13927. * Gets the value of the alpha mode
  13928. */
  13929. /**
  13930. * Sets the value of the alpha mode.
  13931. *
  13932. * | Value | Type | Description |
  13933. * | --- | --- | --- |
  13934. * | 0 | ALPHA_DISABLE | |
  13935. * | 1 | ALPHA_ADD | |
  13936. * | 2 | ALPHA_COMBINE | |
  13937. * | 3 | ALPHA_SUBTRACT | |
  13938. * | 4 | ALPHA_MULTIPLY | |
  13939. * | 5 | ALPHA_MAXIMIZED | |
  13940. * | 6 | ALPHA_ONEONE | |
  13941. * | 7 | ALPHA_PREMULTIPLIED | |
  13942. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  13943. * | 9 | ALPHA_INTERPOLATE | |
  13944. * | 10 | ALPHA_SCREENMODE | |
  13945. *
  13946. */
  13947. alphaMode: number;
  13948. /**
  13949. * Stores the state of the need depth pre-pass value
  13950. */
  13951. private _needDepthPrePass;
  13952. /**
  13953. * Gets the depth pre-pass value
  13954. */
  13955. /**
  13956. * Sets the need depth pre-pass value
  13957. */
  13958. needDepthPrePass: boolean;
  13959. /**
  13960. * Specifies if depth writing should be disabled
  13961. */
  13962. disableDepthWrite: boolean;
  13963. /**
  13964. * Specifies if depth writing should be forced
  13965. */
  13966. forceDepthWrite: boolean;
  13967. /**
  13968. * Specifies if there should be a separate pass for culling
  13969. */
  13970. separateCullingPass: boolean;
  13971. /**
  13972. * Stores the state specifing if fog should be enabled
  13973. */
  13974. private _fogEnabled;
  13975. /**
  13976. * Gets the value of the fog enabled state
  13977. */
  13978. /**
  13979. * Sets the state for enabling fog
  13980. */
  13981. fogEnabled: boolean;
  13982. /**
  13983. * Stores the size of points
  13984. */
  13985. pointSize: number;
  13986. /**
  13987. * Stores the z offset value
  13988. */
  13989. zOffset: number;
  13990. /**
  13991. * Gets a value specifying if wireframe mode is enabled
  13992. */
  13993. /**
  13994. * Sets the state of wireframe mode
  13995. */
  13996. wireframe: boolean;
  13997. /**
  13998. * Gets the value specifying if point clouds are enabled
  13999. */
  14000. /**
  14001. * Sets the state of point cloud mode
  14002. */
  14003. pointsCloud: boolean;
  14004. /**
  14005. * Gets the material fill mode
  14006. */
  14007. /**
  14008. * Sets the material fill mode
  14009. */
  14010. fillMode: number;
  14011. /**
  14012. * Stores the effects for the material
  14013. */
  14014. _effect: Nullable<Effect>;
  14015. /**
  14016. * Specifies if the material was previously ready
  14017. */
  14018. _wasPreviouslyReady: boolean;
  14019. /**
  14020. * Specifies if uniform buffers should be used
  14021. */
  14022. private _useUBO;
  14023. /**
  14024. * Stores a reference to the scene
  14025. */
  14026. private _scene;
  14027. /**
  14028. * Stores the fill mode state
  14029. */
  14030. private _fillMode;
  14031. /**
  14032. * Specifies if the depth write state should be cached
  14033. */
  14034. private _cachedDepthWriteState;
  14035. /**
  14036. * Stores the uniform buffer
  14037. */
  14038. protected _uniformBuffer: UniformBuffer;
  14039. /**
  14040. * Creates a material instance
  14041. * @param name defines the name of the material
  14042. * @param scene defines the scene to reference
  14043. * @param doNotAdd specifies if the material should be added to the scene
  14044. */
  14045. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  14046. /**
  14047. * Returns a string representation of the current material
  14048. * @param fullDetails defines a boolean indicating which levels of logging is desired
  14049. * @returns a string with material information
  14050. */
  14051. toString(fullDetails?: boolean): string;
  14052. /**
  14053. * Gets the class name of the material
  14054. * @returns a string with the class name of the material
  14055. */
  14056. getClassName(): string;
  14057. /**
  14058. * Specifies if updates for the material been locked
  14059. */
  14060. readonly isFrozen: boolean;
  14061. /**
  14062. * Locks updates for the material
  14063. */
  14064. freeze(): void;
  14065. /**
  14066. * Unlocks updates for the material
  14067. */
  14068. unfreeze(): void;
  14069. /**
  14070. * Specifies if the material is ready to be used
  14071. * @param mesh defines the mesh to check
  14072. * @param useInstances specifies if instances should be used
  14073. * @returns a boolean indicating if the material is ready to be used
  14074. */
  14075. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14076. /**
  14077. * Specifies that the submesh is ready to be used
  14078. * @param mesh defines the mesh to check
  14079. * @param subMesh defines which submesh to check
  14080. * @param useInstances specifies that instances should be used
  14081. * @returns a boolean indicating that the submesh is ready or not
  14082. */
  14083. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14084. /**
  14085. * Returns the material effect
  14086. * @returns the effect associated with the material
  14087. */
  14088. getEffect(): Nullable<Effect>;
  14089. /**
  14090. * Returns the current scene
  14091. * @returns a Scene
  14092. */
  14093. getScene(): Scene;
  14094. /**
  14095. * Specifies if the material will require alpha blending
  14096. * @returns a boolean specifying if alpha blending is needed
  14097. */
  14098. needAlphaBlending(): boolean;
  14099. /**
  14100. * Specifies if the mesh will require alpha blending
  14101. * @param mesh defines the mesh to check
  14102. * @returns a boolean specifying if alpha blending is needed for the mesh
  14103. */
  14104. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  14105. /**
  14106. * Specifies if this material should be rendered in alpha test mode
  14107. * @returns a boolean specifying if an alpha test is needed.
  14108. */
  14109. needAlphaTesting(): boolean;
  14110. /**
  14111. * Gets the texture used for the alpha test
  14112. * @returns the texture to use for alpha testing
  14113. */
  14114. getAlphaTestTexture(): Nullable<BaseTexture>;
  14115. /**
  14116. * Marks the material to indicate that it needs to be re-calculated
  14117. */
  14118. markDirty(): void;
  14119. /** @hidden */
  14120. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  14121. /**
  14122. * Binds the material to the mesh
  14123. * @param world defines the world transformation matrix
  14124. * @param mesh defines the mesh to bind the material to
  14125. */
  14126. bind(world: Matrix, mesh?: Mesh): void;
  14127. /**
  14128. * Binds the submesh to the material
  14129. * @param world defines the world transformation matrix
  14130. * @param mesh defines the mesh containing the submesh
  14131. * @param subMesh defines the submesh to bind the material to
  14132. */
  14133. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14134. /**
  14135. * Binds the world matrix to the material
  14136. * @param world defines the world transformation matrix
  14137. */
  14138. bindOnlyWorldMatrix(world: Matrix): void;
  14139. /**
  14140. * Binds the scene's uniform buffer to the effect.
  14141. * @param effect defines the effect to bind to the scene uniform buffer
  14142. * @param sceneUbo defines the uniform buffer storing scene data
  14143. */
  14144. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  14145. /**
  14146. * Binds the view matrix to the effect
  14147. * @param effect defines the effect to bind the view matrix to
  14148. */
  14149. bindView(effect: Effect): void;
  14150. /**
  14151. * Binds the view projection matrix to the effect
  14152. * @param effect defines the effect to bind the view projection matrix to
  14153. */
  14154. bindViewProjection(effect: Effect): void;
  14155. /**
  14156. * Specifies if material alpha testing should be turned on for the mesh
  14157. * @param mesh defines the mesh to check
  14158. */
  14159. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  14160. /**
  14161. * Processes to execute after binding the material to a mesh
  14162. * @param mesh defines the rendered mesh
  14163. */
  14164. protected _afterBind(mesh?: Mesh): void;
  14165. /**
  14166. * Unbinds the material from the mesh
  14167. */
  14168. unbind(): void;
  14169. /**
  14170. * Gets the active textures from the material
  14171. * @returns an array of textures
  14172. */
  14173. getActiveTextures(): BaseTexture[];
  14174. /**
  14175. * Specifies if the material uses a texture
  14176. * @param texture defines the texture to check against the material
  14177. * @returns a boolean specifying if the material uses the texture
  14178. */
  14179. hasTexture(texture: BaseTexture): boolean;
  14180. /**
  14181. * Makes a duplicate of the material, and gives it a new name
  14182. * @param name defines the new name for the duplicated material
  14183. * @returns the cloned material
  14184. */
  14185. clone(name: string): Nullable<Material>;
  14186. /**
  14187. * Gets the meshes bound to the material
  14188. * @returns an array of meshes bound to the material
  14189. */
  14190. getBindedMeshes(): AbstractMesh[];
  14191. /**
  14192. * Force shader compilation
  14193. * @param mesh defines the mesh associated with this material
  14194. * @param onCompiled defines a function to execute once the material is compiled
  14195. * @param options defines the options to configure the compilation
  14196. */
  14197. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  14198. clipPlane: boolean;
  14199. }>): void;
  14200. /**
  14201. * Force shader compilation
  14202. * @param mesh defines the mesh that will use this material
  14203. * @param options defines additional options for compiling the shaders
  14204. * @returns a promise that resolves when the compilation completes
  14205. */
  14206. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  14207. clipPlane: boolean;
  14208. }>): Promise<void>;
  14209. /**
  14210. * Marks a define in the material to indicate that it needs to be re-computed
  14211. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  14212. */
  14213. markAsDirty(flag: number): void;
  14214. /**
  14215. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  14216. * @param func defines a function which checks material defines against the submeshes
  14217. */
  14218. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  14219. /**
  14220. * Indicates that image processing needs to be re-calculated for all submeshes
  14221. */
  14222. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  14223. /**
  14224. * Indicates that textures need to be re-calculated for all submeshes
  14225. */
  14226. protected _markAllSubMeshesAsTexturesDirty(): void;
  14227. /**
  14228. * Indicates that fresnel needs to be re-calculated for all submeshes
  14229. */
  14230. protected _markAllSubMeshesAsFresnelDirty(): void;
  14231. /**
  14232. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  14233. */
  14234. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  14235. /**
  14236. * Indicates that lights need to be re-calculated for all submeshes
  14237. */
  14238. protected _markAllSubMeshesAsLightsDirty(): void;
  14239. /**
  14240. * Indicates that attributes need to be re-calculated for all submeshes
  14241. */
  14242. protected _markAllSubMeshesAsAttributesDirty(): void;
  14243. /**
  14244. * Indicates that misc needs to be re-calculated for all submeshes
  14245. */
  14246. protected _markAllSubMeshesAsMiscDirty(): void;
  14247. /**
  14248. * Indicates that textures and misc need to be re-calculated for all submeshes
  14249. */
  14250. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  14251. /**
  14252. * Disposes the material
  14253. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  14254. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  14255. */
  14256. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14257. /**
  14258. * Serializes this material
  14259. * @returns the serialized material object
  14260. */
  14261. serialize(): any;
  14262. /**
  14263. * Creates a MultiMaterial from parsed MultiMaterial data.
  14264. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  14265. * @param scene defines the hosting scene
  14266. * @returns a new MultiMaterial
  14267. */
  14268. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  14269. /**
  14270. * Creates a material from parsed material data
  14271. * @param parsedMaterial defines parsed material data
  14272. * @param scene defines the hosting scene
  14273. * @param rootUrl defines the root URL to use to load textures
  14274. * @returns a new material
  14275. */
  14276. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  14277. }
  14278. }
  14279. declare module BABYLON {
  14280. /**
  14281. * "Static Class" containing the most commonly used helper while dealing with material for
  14282. * rendering purpose.
  14283. *
  14284. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  14285. *
  14286. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14287. */
  14288. class MaterialHelper {
  14289. /**
  14290. * Bind the current view position to an effect.
  14291. * @param effect The effect to be bound
  14292. * @param scene The scene the eyes position is used from
  14293. */
  14294. static BindEyePosition(effect: Effect, scene: Scene): void;
  14295. /**
  14296. * Helps preparing the defines values about the UVs in used in the effect.
  14297. * UVs are shared as much as we can accross chanels in the shaders.
  14298. * @param texture The texture we are preparing the UVs for
  14299. * @param defines The defines to update
  14300. * @param key The chanel key "diffuse", "specular"... used in the shader
  14301. */
  14302. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  14303. /**
  14304. * Binds a texture matrix value to its corrsponding uniform
  14305. * @param texture The texture to bind the matrix for
  14306. * @param uniformBuffer The uniform buffer receivin the data
  14307. * @param key The chanel key "diffuse", "specular"... used in the shader
  14308. */
  14309. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  14310. /**
  14311. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  14312. * @param mesh defines the current mesh
  14313. * @param scene defines the current scene
  14314. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  14315. * @param pointsCloud defines if point cloud rendering has to be turned on
  14316. * @param fogEnabled defines if fog has to be turned on
  14317. * @param alphaTest defines if alpha testing has to be turned on
  14318. * @param defines defines the current list of defines
  14319. */
  14320. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  14321. /**
  14322. * Helper used to prepare the list of defines associated with frame values for shader compilation
  14323. * @param scene defines the current scene
  14324. * @param engine defines the current engine
  14325. * @param defines specifies the list of active defines
  14326. * @param useInstances defines if instances have to be turned on
  14327. * @param useClipPlane defines if clip plane have to be turned on
  14328. */
  14329. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  14330. /**
  14331. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  14332. * @param mesh The mesh containing the geometry data we will draw
  14333. * @param defines The defines to update
  14334. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  14335. * @param useBones Precise whether bones should be used or not (override mesh info)
  14336. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  14337. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  14338. * @returns false if defines are considered not dirty and have not been checked
  14339. */
  14340. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  14341. /**
  14342. * Prepares the defines related to the light information passed in parameter
  14343. * @param scene The scene we are intending to draw
  14344. * @param mesh The mesh the effect is compiling for
  14345. * @param defines The defines to update
  14346. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  14347. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  14348. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  14349. * @returns true if normals will be required for the rest of the effect
  14350. */
  14351. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  14352. /**
  14353. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  14354. * that won t be acctive due to defines being turned off.
  14355. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  14356. * @param samplersList The samplers list
  14357. * @param defines The defines helping in the list generation
  14358. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  14359. */
  14360. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  14361. /**
  14362. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  14363. * @param defines The defines to update while falling back
  14364. * @param fallbacks The authorized effect fallbacks
  14365. * @param maxSimultaneousLights The maximum number of lights allowed
  14366. * @param rank the current rank of the Effect
  14367. * @returns The newly affected rank
  14368. */
  14369. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  14370. /**
  14371. * Prepares the list of attributes required for morph targets according to the effect defines.
  14372. * @param attribs The current list of supported attribs
  14373. * @param mesh The mesh to prepare the morph targets attributes for
  14374. * @param defines The current Defines of the effect
  14375. */
  14376. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  14377. /**
  14378. * Prepares the list of attributes required for bones according to the effect defines.
  14379. * @param attribs The current list of supported attribs
  14380. * @param mesh The mesh to prepare the bones attributes for
  14381. * @param defines The current Defines of the effect
  14382. * @param fallbacks The current efffect fallback strategy
  14383. */
  14384. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  14385. /**
  14386. * Prepares the list of attributes required for instances according to the effect defines.
  14387. * @param attribs The current list of supported attribs
  14388. * @param defines The current Defines of the effect
  14389. */
  14390. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  14391. /**
  14392. * Binds the light shadow information to the effect for the given mesh.
  14393. * @param light The light containing the generator
  14394. * @param scene The scene the lights belongs to
  14395. * @param mesh The mesh we are binding the information to render
  14396. * @param lightIndex The light index in the effect used to render the mesh
  14397. * @param effect The effect we are binding the data to
  14398. */
  14399. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  14400. /**
  14401. * Binds the light information to the effect.
  14402. * @param light The light containing the generator
  14403. * @param effect The effect we are binding the data to
  14404. * @param lightIndex The light index in the effect used to render
  14405. */
  14406. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  14407. /**
  14408. * Binds the lights information from the scene to the effect for the given mesh.
  14409. * @param scene The scene the lights belongs to
  14410. * @param mesh The mesh we are binding the information to render
  14411. * @param effect The effect we are binding the data to
  14412. * @param defines The generated defines for the effect
  14413. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  14414. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  14415. */
  14416. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  14417. /**
  14418. * Binds the fog information from the scene to the effect for the given mesh.
  14419. * @param scene The scene the lights belongs to
  14420. * @param mesh The mesh we are binding the information to render
  14421. * @param effect The effect we are binding the data to
  14422. */
  14423. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  14424. /**
  14425. * Binds the bones information from the mesh to the effect.
  14426. * @param mesh The mesh we are binding the information to render
  14427. * @param effect The effect we are binding the data to
  14428. */
  14429. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  14430. /**
  14431. * Binds the morph targets information from the mesh to the effect.
  14432. * @param abstractMesh The mesh we are binding the information to render
  14433. * @param effect The effect we are binding the data to
  14434. */
  14435. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  14436. /**
  14437. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  14438. * @param defines The generated defines used in the effect
  14439. * @param effect The effect we are binding the data to
  14440. * @param scene The scene we are willing to render with logarithmic scale for
  14441. */
  14442. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  14443. /**
  14444. * Binds the clip plane information from the scene to the effect.
  14445. * @param scene The scene the clip plane information are extracted from
  14446. * @param effect The effect we are binding the data to
  14447. */
  14448. static BindClipPlane(effect: Effect, scene: Scene): void;
  14449. }
  14450. }
  14451. declare module BABYLON {
  14452. class MultiMaterial extends Material {
  14453. private _subMaterials;
  14454. subMaterials: Nullable<Material>[];
  14455. constructor(name: string, scene: Scene);
  14456. private _hookArray(array);
  14457. getSubMaterial(index: number): Nullable<Material>;
  14458. getActiveTextures(): BaseTexture[];
  14459. getClassName(): string;
  14460. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14461. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  14462. serialize(): any;
  14463. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14464. }
  14465. }
  14466. declare module BABYLON {
  14467. class PushMaterial extends Material {
  14468. protected _activeEffect: Effect;
  14469. protected _normalMatrix: Matrix;
  14470. constructor(name: string, scene: Scene);
  14471. getEffect(): Effect;
  14472. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14473. /**
  14474. * Binds the given world matrix to the active effect
  14475. *
  14476. * @param world the matrix to bind
  14477. */
  14478. bindOnlyWorldMatrix(world: Matrix): void;
  14479. /**
  14480. * Binds the given normal matrix to the active effect
  14481. *
  14482. * @param normalMatrix the matrix to bind
  14483. */
  14484. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14485. bind(world: Matrix, mesh?: Mesh): void;
  14486. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14487. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14488. }
  14489. }
  14490. declare module BABYLON {
  14491. class ShaderMaterial extends Material {
  14492. private _shaderPath;
  14493. private _options;
  14494. private _textures;
  14495. private _textureArrays;
  14496. private _floats;
  14497. private _ints;
  14498. private _floatsArrays;
  14499. private _colors3;
  14500. private _colors3Arrays;
  14501. private _colors4;
  14502. private _vectors2;
  14503. private _vectors3;
  14504. private _vectors4;
  14505. private _matrices;
  14506. private _matrices3x3;
  14507. private _matrices2x2;
  14508. private _vectors2Arrays;
  14509. private _vectors3Arrays;
  14510. private _cachedWorldViewMatrix;
  14511. private _renderId;
  14512. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  14513. getClassName(): string;
  14514. needAlphaBlending(): boolean;
  14515. needAlphaTesting(): boolean;
  14516. private _checkUniform(uniformName);
  14517. setTexture(name: string, texture: Texture): ShaderMaterial;
  14518. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  14519. setFloat(name: string, value: number): ShaderMaterial;
  14520. setInt(name: string, value: number): ShaderMaterial;
  14521. setFloats(name: string, value: number[]): ShaderMaterial;
  14522. setColor3(name: string, value: Color3): ShaderMaterial;
  14523. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  14524. setColor4(name: string, value: Color4): ShaderMaterial;
  14525. setVector2(name: string, value: Vector2): ShaderMaterial;
  14526. setVector3(name: string, value: Vector3): ShaderMaterial;
  14527. setVector4(name: string, value: Vector4): ShaderMaterial;
  14528. setMatrix(name: string, value: Matrix): ShaderMaterial;
  14529. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  14530. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  14531. setArray2(name: string, value: number[]): ShaderMaterial;
  14532. setArray3(name: string, value: number[]): ShaderMaterial;
  14533. private _checkCache(scene, mesh?, useInstances?);
  14534. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14535. bindOnlyWorldMatrix(world: Matrix): void;
  14536. bind(world: Matrix, mesh?: Mesh): void;
  14537. getActiveTextures(): BaseTexture[];
  14538. hasTexture(texture: BaseTexture): boolean;
  14539. clone(name: string): ShaderMaterial;
  14540. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14541. serialize(): any;
  14542. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  14543. }
  14544. }
  14545. declare module BABYLON {
  14546. /** @hidden */
  14547. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  14548. MAINUV1: boolean;
  14549. MAINUV2: boolean;
  14550. DIFFUSE: boolean;
  14551. DIFFUSEDIRECTUV: number;
  14552. AMBIENT: boolean;
  14553. AMBIENTDIRECTUV: number;
  14554. OPACITY: boolean;
  14555. OPACITYDIRECTUV: number;
  14556. OPACITYRGB: boolean;
  14557. REFLECTION: boolean;
  14558. EMISSIVE: boolean;
  14559. EMISSIVEDIRECTUV: number;
  14560. SPECULAR: boolean;
  14561. SPECULARDIRECTUV: number;
  14562. BUMP: boolean;
  14563. BUMPDIRECTUV: number;
  14564. PARALLAX: boolean;
  14565. PARALLAXOCCLUSION: boolean;
  14566. SPECULAROVERALPHA: boolean;
  14567. CLIPPLANE: boolean;
  14568. ALPHATEST: boolean;
  14569. DEPTHPREPASS: boolean;
  14570. ALPHAFROMDIFFUSE: boolean;
  14571. POINTSIZE: boolean;
  14572. FOG: boolean;
  14573. SPECULARTERM: boolean;
  14574. DIFFUSEFRESNEL: boolean;
  14575. OPACITYFRESNEL: boolean;
  14576. REFLECTIONFRESNEL: boolean;
  14577. REFRACTIONFRESNEL: boolean;
  14578. EMISSIVEFRESNEL: boolean;
  14579. FRESNEL: boolean;
  14580. NORMAL: boolean;
  14581. UV1: boolean;
  14582. UV2: boolean;
  14583. VERTEXCOLOR: boolean;
  14584. VERTEXALPHA: boolean;
  14585. NUM_BONE_INFLUENCERS: number;
  14586. BonesPerMesh: number;
  14587. INSTANCES: boolean;
  14588. GLOSSINESS: boolean;
  14589. ROUGHNESS: boolean;
  14590. EMISSIVEASILLUMINATION: boolean;
  14591. LINKEMISSIVEWITHDIFFUSE: boolean;
  14592. REFLECTIONFRESNELFROMSPECULAR: boolean;
  14593. LIGHTMAP: boolean;
  14594. LIGHTMAPDIRECTUV: number;
  14595. OBJECTSPACE_NORMALMAP: boolean;
  14596. USELIGHTMAPASSHADOWMAP: boolean;
  14597. REFLECTIONMAP_3D: boolean;
  14598. REFLECTIONMAP_SPHERICAL: boolean;
  14599. REFLECTIONMAP_PLANAR: boolean;
  14600. REFLECTIONMAP_CUBIC: boolean;
  14601. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  14602. REFLECTIONMAP_PROJECTION: boolean;
  14603. REFLECTIONMAP_SKYBOX: boolean;
  14604. REFLECTIONMAP_EXPLICIT: boolean;
  14605. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  14606. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  14607. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  14608. INVERTCUBICMAP: boolean;
  14609. LOGARITHMICDEPTH: boolean;
  14610. REFRACTION: boolean;
  14611. REFRACTIONMAP_3D: boolean;
  14612. REFLECTIONOVERALPHA: boolean;
  14613. TWOSIDEDLIGHTING: boolean;
  14614. SHADOWFLOAT: boolean;
  14615. MORPHTARGETS: boolean;
  14616. MORPHTARGETS_NORMAL: boolean;
  14617. MORPHTARGETS_TANGENT: boolean;
  14618. NUM_MORPH_INFLUENCERS: number;
  14619. NONUNIFORMSCALING: boolean;
  14620. PREMULTIPLYALPHA: boolean;
  14621. IMAGEPROCESSING: boolean;
  14622. VIGNETTE: boolean;
  14623. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14624. VIGNETTEBLENDMODEOPAQUE: boolean;
  14625. TONEMAPPING: boolean;
  14626. CONTRAST: boolean;
  14627. COLORCURVES: boolean;
  14628. COLORGRADING: boolean;
  14629. COLORGRADING3D: boolean;
  14630. SAMPLER3DGREENDEPTH: boolean;
  14631. SAMPLER3DBGRMAP: boolean;
  14632. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14633. /**
  14634. * If the reflection texture on this material is in linear color space
  14635. * @hidden
  14636. */
  14637. IS_REFLECTION_LINEAR: boolean;
  14638. /**
  14639. * If the refraction texture on this material is in linear color space
  14640. * @hidden
  14641. */
  14642. IS_REFRACTION_LINEAR: boolean;
  14643. EXPOSURE: boolean;
  14644. constructor();
  14645. setReflectionMode(modeToEnable: string): void;
  14646. }
  14647. class StandardMaterial extends PushMaterial {
  14648. private _diffuseTexture;
  14649. diffuseTexture: Nullable<BaseTexture>;
  14650. private _ambientTexture;
  14651. ambientTexture: Nullable<BaseTexture>;
  14652. private _opacityTexture;
  14653. opacityTexture: Nullable<BaseTexture>;
  14654. private _reflectionTexture;
  14655. reflectionTexture: Nullable<BaseTexture>;
  14656. private _emissiveTexture;
  14657. emissiveTexture: Nullable<BaseTexture>;
  14658. private _specularTexture;
  14659. specularTexture: Nullable<BaseTexture>;
  14660. private _bumpTexture;
  14661. bumpTexture: Nullable<BaseTexture>;
  14662. private _lightmapTexture;
  14663. lightmapTexture: Nullable<BaseTexture>;
  14664. private _refractionTexture;
  14665. refractionTexture: Nullable<BaseTexture>;
  14666. ambientColor: Color3;
  14667. diffuseColor: Color3;
  14668. specularColor: Color3;
  14669. emissiveColor: Color3;
  14670. specularPower: number;
  14671. private _useAlphaFromDiffuseTexture;
  14672. useAlphaFromDiffuseTexture: boolean;
  14673. private _useEmissiveAsIllumination;
  14674. useEmissiveAsIllumination: boolean;
  14675. private _linkEmissiveWithDiffuse;
  14676. linkEmissiveWithDiffuse: boolean;
  14677. private _useSpecularOverAlpha;
  14678. useSpecularOverAlpha: boolean;
  14679. private _useReflectionOverAlpha;
  14680. useReflectionOverAlpha: boolean;
  14681. private _disableLighting;
  14682. disableLighting: boolean;
  14683. private _useObjectSpaceNormalMap;
  14684. /**
  14685. * Allows using an object space normal map (instead of tangent space).
  14686. */
  14687. useObjectSpaceNormalMap: boolean;
  14688. private _useParallax;
  14689. useParallax: boolean;
  14690. private _useParallaxOcclusion;
  14691. useParallaxOcclusion: boolean;
  14692. parallaxScaleBias: number;
  14693. private _roughness;
  14694. roughness: number;
  14695. indexOfRefraction: number;
  14696. invertRefractionY: boolean;
  14697. /**
  14698. * Defines the alpha limits in alpha test mode
  14699. */
  14700. alphaCutOff: number;
  14701. private _useLightmapAsShadowmap;
  14702. useLightmapAsShadowmap: boolean;
  14703. private _diffuseFresnelParameters;
  14704. diffuseFresnelParameters: FresnelParameters;
  14705. private _opacityFresnelParameters;
  14706. opacityFresnelParameters: FresnelParameters;
  14707. private _reflectionFresnelParameters;
  14708. reflectionFresnelParameters: FresnelParameters;
  14709. private _refractionFresnelParameters;
  14710. refractionFresnelParameters: FresnelParameters;
  14711. private _emissiveFresnelParameters;
  14712. emissiveFresnelParameters: FresnelParameters;
  14713. private _useReflectionFresnelFromSpecular;
  14714. useReflectionFresnelFromSpecular: boolean;
  14715. private _useGlossinessFromSpecularMapAlpha;
  14716. useGlossinessFromSpecularMapAlpha: boolean;
  14717. private _maxSimultaneousLights;
  14718. maxSimultaneousLights: number;
  14719. /**
  14720. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  14721. */
  14722. private _invertNormalMapX;
  14723. invertNormalMapX: boolean;
  14724. /**
  14725. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  14726. */
  14727. private _invertNormalMapY;
  14728. invertNormalMapY: boolean;
  14729. /**
  14730. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  14731. */
  14732. private _twoSidedLighting;
  14733. twoSidedLighting: boolean;
  14734. /**
  14735. * Default configuration related to image processing available in the standard Material.
  14736. */
  14737. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14738. /**
  14739. * Gets the image processing configuration used either in this material.
  14740. */
  14741. /**
  14742. * Sets the Default image processing configuration used either in the this material.
  14743. *
  14744. * If sets to null, the scene one is in use.
  14745. */
  14746. imageProcessingConfiguration: ImageProcessingConfiguration;
  14747. /**
  14748. * Keep track of the image processing observer to allow dispose and replace.
  14749. */
  14750. private _imageProcessingObserver;
  14751. /**
  14752. * Attaches a new image processing configuration to the Standard Material.
  14753. * @param configuration
  14754. */
  14755. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14756. /**
  14757. * Gets wether the color curves effect is enabled.
  14758. */
  14759. /**
  14760. * Sets wether the color curves effect is enabled.
  14761. */
  14762. cameraColorCurvesEnabled: boolean;
  14763. /**
  14764. * Gets wether the color grading effect is enabled.
  14765. */
  14766. /**
  14767. * Gets wether the color grading effect is enabled.
  14768. */
  14769. cameraColorGradingEnabled: boolean;
  14770. /**
  14771. * Gets wether tonemapping is enabled or not.
  14772. */
  14773. /**
  14774. * Sets wether tonemapping is enabled or not
  14775. */
  14776. cameraToneMappingEnabled: boolean;
  14777. /**
  14778. * The camera exposure used on this material.
  14779. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14780. * This corresponds to a photographic exposure.
  14781. */
  14782. /**
  14783. * The camera exposure used on this material.
  14784. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14785. * This corresponds to a photographic exposure.
  14786. */
  14787. cameraExposure: number;
  14788. /**
  14789. * Gets The camera contrast used on this material.
  14790. */
  14791. /**
  14792. * Sets The camera contrast used on this material.
  14793. */
  14794. cameraContrast: number;
  14795. /**
  14796. * Gets the Color Grading 2D Lookup Texture.
  14797. */
  14798. /**
  14799. * Sets the Color Grading 2D Lookup Texture.
  14800. */
  14801. cameraColorGradingTexture: Nullable<BaseTexture>;
  14802. /**
  14803. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14804. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14805. * 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;
  14806. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14807. */
  14808. /**
  14809. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14810. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14811. * 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;
  14812. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14813. */
  14814. cameraColorCurves: Nullable<ColorCurves>;
  14815. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  14816. protected _renderTargets: SmartArray<RenderTargetTexture>;
  14817. protected _worldViewProjectionMatrix: Matrix;
  14818. protected _globalAmbientColor: Color3;
  14819. protected _useLogarithmicDepth: boolean;
  14820. constructor(name: string, scene: Scene);
  14821. getClassName(): string;
  14822. useLogarithmicDepth: boolean;
  14823. needAlphaBlending(): boolean;
  14824. needAlphaTesting(): boolean;
  14825. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  14826. getAlphaTestTexture(): Nullable<BaseTexture>;
  14827. /**
  14828. * Child classes can use it to update shaders
  14829. */
  14830. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  14831. buildUniformLayout(): void;
  14832. unbind(): void;
  14833. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14834. getAnimatables(): IAnimatable[];
  14835. getActiveTextures(): BaseTexture[];
  14836. hasTexture(texture: BaseTexture): boolean;
  14837. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14838. clone(name: string): StandardMaterial;
  14839. serialize(): any;
  14840. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  14841. static _DiffuseTextureEnabled: boolean;
  14842. static DiffuseTextureEnabled: boolean;
  14843. static _AmbientTextureEnabled: boolean;
  14844. static AmbientTextureEnabled: boolean;
  14845. static _OpacityTextureEnabled: boolean;
  14846. static OpacityTextureEnabled: boolean;
  14847. static _ReflectionTextureEnabled: boolean;
  14848. static ReflectionTextureEnabled: boolean;
  14849. static _EmissiveTextureEnabled: boolean;
  14850. static EmissiveTextureEnabled: boolean;
  14851. static _SpecularTextureEnabled: boolean;
  14852. static SpecularTextureEnabled: boolean;
  14853. static _BumpTextureEnabled: boolean;
  14854. static BumpTextureEnabled: boolean;
  14855. static _LightmapTextureEnabled: boolean;
  14856. static LightmapTextureEnabled: boolean;
  14857. static _RefractionTextureEnabled: boolean;
  14858. static RefractionTextureEnabled: boolean;
  14859. static _ColorGradingTextureEnabled: boolean;
  14860. static ColorGradingTextureEnabled: boolean;
  14861. static _FresnelEnabled: boolean;
  14862. static FresnelEnabled: boolean;
  14863. }
  14864. }
  14865. declare module BABYLON {
  14866. class UniformBuffer {
  14867. private _engine;
  14868. private _buffer;
  14869. private _data;
  14870. private _bufferData;
  14871. private _dynamic?;
  14872. private _uniformLocations;
  14873. private _uniformSizes;
  14874. private _uniformLocationPointer;
  14875. private _needSync;
  14876. private _noUBO;
  14877. private _currentEffect;
  14878. private static _MAX_UNIFORM_SIZE;
  14879. private static _tempBuffer;
  14880. /**
  14881. * Wrapper for updateUniform.
  14882. * @method updateMatrix3x3
  14883. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14884. * @param {Float32Array} matrix
  14885. */
  14886. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  14887. /**
  14888. * Wrapper for updateUniform.
  14889. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14890. * @param {Float32Array} matrix
  14891. */
  14892. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  14893. /**
  14894. * Wrapper for updateUniform.
  14895. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14896. * @param {number} x
  14897. */
  14898. updateFloat: (name: string, x: number) => void;
  14899. /**
  14900. * Wrapper for updateUniform.
  14901. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14902. * @param {number} x
  14903. * @param {number} y
  14904. * @param {string} [suffix] Suffix to add to the uniform name.
  14905. */
  14906. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  14907. /**
  14908. * Wrapper for updateUniform.
  14909. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14910. * @param {number} x
  14911. * @param {number} y
  14912. * @param {number} z
  14913. * @param {string} [suffix] Suffix to add to the uniform name.
  14914. */
  14915. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  14916. /**
  14917. * Wrapper for updateUniform.
  14918. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14919. * @param {number} x
  14920. * @param {number} y
  14921. * @param {number} z
  14922. * @param {number} w
  14923. * @param {string} [suffix] Suffix to add to the uniform name.
  14924. */
  14925. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  14926. /**
  14927. * Wrapper for updateUniform.
  14928. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14929. * @param {Matrix} A 4x4 matrix.
  14930. */
  14931. updateMatrix: (name: string, mat: Matrix) => void;
  14932. /**
  14933. * Wrapper for updateUniform.
  14934. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14935. * @param {Vector3} vector
  14936. */
  14937. updateVector3: (name: string, vector: Vector3) => void;
  14938. /**
  14939. * Wrapper for updateUniform.
  14940. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14941. * @param {Vector4} vector
  14942. */
  14943. updateVector4: (name: string, vector: Vector4) => void;
  14944. /**
  14945. * Wrapper for updateUniform.
  14946. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14947. * @param {Color3} color
  14948. * @param {string} [suffix] Suffix to add to the uniform name.
  14949. */
  14950. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  14951. /**
  14952. * Wrapper for updateUniform.
  14953. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14954. * @param {Color3} color
  14955. * @param {number} alpha
  14956. * @param {string} [suffix] Suffix to add to the uniform name.
  14957. */
  14958. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  14959. /**
  14960. * Uniform buffer objects.
  14961. *
  14962. * Handles blocks of uniform on the GPU.
  14963. *
  14964. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  14965. *
  14966. * For more information, please refer to :
  14967. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  14968. */
  14969. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  14970. /**
  14971. * Indicates if the buffer is using the WebGL2 UBO implementation,
  14972. * or just falling back on setUniformXXX calls.
  14973. */
  14974. readonly useUbo: boolean;
  14975. /**
  14976. * Indicates if the WebGL underlying uniform buffer is in sync
  14977. * with the javascript cache data.
  14978. */
  14979. readonly isSync: boolean;
  14980. /**
  14981. * Indicates if the WebGL underlying uniform buffer is dynamic.
  14982. * Also, a dynamic UniformBuffer will disable cache verification and always
  14983. * update the underlying WebGL uniform buffer to the GPU.
  14984. */
  14985. isDynamic(): boolean;
  14986. /**
  14987. * The data cache on JS side.
  14988. */
  14989. getData(): Float32Array;
  14990. /**
  14991. * The underlying WebGL Uniform buffer.
  14992. */
  14993. getBuffer(): Nullable<WebGLBuffer>;
  14994. /**
  14995. * std140 layout specifies how to align data within an UBO structure.
  14996. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  14997. * for specs.
  14998. */
  14999. private _fillAlignment(size);
  15000. /**
  15001. * Adds an uniform in the buffer.
  15002. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  15003. * for the layout to be correct !
  15004. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15005. * @param {number|number[]} size Data size, or data directly.
  15006. */
  15007. addUniform(name: string, size: number | number[]): void;
  15008. /**
  15009. * Wrapper for addUniform.
  15010. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15011. * @param {Matrix} mat A 4x4 matrix.
  15012. */
  15013. addMatrix(name: string, mat: Matrix): void;
  15014. /**
  15015. * Wrapper for addUniform.
  15016. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15017. * @param {number} x
  15018. * @param {number} y
  15019. */
  15020. addFloat2(name: string, x: number, y: number): void;
  15021. /**
  15022. * Wrapper for addUniform.
  15023. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15024. * @param {number} x
  15025. * @param {number} y
  15026. * @param {number} z
  15027. */
  15028. addFloat3(name: string, x: number, y: number, z: number): void;
  15029. /**
  15030. * Wrapper for addUniform.
  15031. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15032. * @param {Color3} color
  15033. */
  15034. addColor3(name: string, color: Color3): void;
  15035. /**
  15036. * Wrapper for addUniform.
  15037. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15038. * @param {Color3} color
  15039. * @param {number} alpha
  15040. */
  15041. addColor4(name: string, color: Color3, alpha: number): void;
  15042. /**
  15043. * Wrapper for addUniform.
  15044. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15045. * @param {Vector3} vector
  15046. */
  15047. addVector3(name: string, vector: Vector3): void;
  15048. /**
  15049. * Wrapper for addUniform.
  15050. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15051. */
  15052. addMatrix3x3(name: string): void;
  15053. /**
  15054. * Wrapper for addUniform.
  15055. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15056. */
  15057. addMatrix2x2(name: string): void;
  15058. /**
  15059. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  15060. */
  15061. create(): void;
  15062. _rebuild(): void;
  15063. /**
  15064. * Updates the WebGL Uniform Buffer on the GPU.
  15065. * If the `dynamic` flag is set to true, no cache comparison is done.
  15066. * Otherwise, the buffer will be updated only if the cache differs.
  15067. */
  15068. update(): void;
  15069. /**
  15070. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  15071. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15072. * @param {number[]|Float32Array} data Flattened data
  15073. * @param {number} size Size of the data.
  15074. */
  15075. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  15076. private _updateMatrix3x3ForUniform(name, matrix);
  15077. private _updateMatrix3x3ForEffect(name, matrix);
  15078. private _updateMatrix2x2ForEffect(name, matrix);
  15079. private _updateMatrix2x2ForUniform(name, matrix);
  15080. private _updateFloatForEffect(name, x);
  15081. private _updateFloatForUniform(name, x);
  15082. private _updateFloat2ForEffect(name, x, y, suffix?);
  15083. private _updateFloat2ForUniform(name, x, y, suffix?);
  15084. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  15085. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  15086. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  15087. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  15088. private _updateMatrixForEffect(name, mat);
  15089. private _updateMatrixForUniform(name, mat);
  15090. private _updateVector3ForEffect(name, vector);
  15091. private _updateVector3ForUniform(name, vector);
  15092. private _updateVector4ForEffect(name, vector);
  15093. private _updateVector4ForUniform(name, vector);
  15094. private _updateColor3ForEffect(name, color, suffix?);
  15095. private _updateColor3ForUniform(name, color, suffix?);
  15096. private _updateColor4ForEffect(name, color, alpha, suffix?);
  15097. private _updateColor4ForUniform(name, color, alpha, suffix?);
  15098. /**
  15099. * Sets a sampler uniform on the effect.
  15100. * @param {string} name Name of the sampler.
  15101. * @param {Texture} texture
  15102. */
  15103. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  15104. /**
  15105. * Directly updates the value of the uniform in the cache AND on the GPU.
  15106. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15107. * @param {number[]|Float32Array} data Flattened data
  15108. */
  15109. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  15110. /**
  15111. * Binds this uniform buffer to an effect.
  15112. * @param {Effect} effect
  15113. * @param {string} name Name of the uniform block in the shader.
  15114. */
  15115. bindToEffect(effect: Effect, name: string): void;
  15116. /**
  15117. * Disposes the uniform buffer.
  15118. */
  15119. dispose(): void;
  15120. }
  15121. }
  15122. declare module BABYLON {
  15123. class Scalar {
  15124. /**
  15125. * Two pi constants convenient for computation.
  15126. */
  15127. static TwoPi: number;
  15128. /**
  15129. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  15130. */
  15131. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  15132. /**
  15133. * Returns a string : the upper case translation of the number i to hexadecimal.
  15134. */
  15135. static ToHex(i: number): string;
  15136. /**
  15137. * Returns -1 if value is negative and +1 is value is positive.
  15138. * Returns the value itself if it's equal to zero.
  15139. */
  15140. static Sign(value: number): number;
  15141. /**
  15142. * Returns the value itself if it's between min and max.
  15143. * Returns min if the value is lower than min.
  15144. * Returns max if the value is greater than max.
  15145. */
  15146. static Clamp(value: number, min?: number, max?: number): number;
  15147. /**
  15148. * Returns the log2 of value.
  15149. */
  15150. static Log2(value: number): number;
  15151. /**
  15152. * Loops the value, so that it is never larger than length and never smaller than 0.
  15153. *
  15154. * This is similar to the modulo operator but it works with floating point numbers.
  15155. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  15156. * With t = 5 and length = 2.5, the result would be 0.0.
  15157. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  15158. */
  15159. static Repeat(value: number, length: number): number;
  15160. /**
  15161. * Normalize the value between 0.0 and 1.0 using min and max values
  15162. */
  15163. static Normalize(value: number, min: number, max: number): number;
  15164. /**
  15165. * Denormalize the value from 0.0 and 1.0 using min and max values
  15166. */
  15167. static Denormalize(normalized: number, min: number, max: number): number;
  15168. /**
  15169. * Calculates the shortest difference between two given angles given in degrees.
  15170. */
  15171. static DeltaAngle(current: number, target: number): number;
  15172. /**
  15173. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  15174. *
  15175. * The returned value will move back and forth between 0 and length
  15176. */
  15177. static PingPong(tx: number, length: number): number;
  15178. /**
  15179. * Interpolates between min and max with smoothing at the limits.
  15180. *
  15181. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  15182. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  15183. */
  15184. static SmoothStep(from: number, to: number, tx: number): number;
  15185. /**
  15186. * Moves a value current towards target.
  15187. *
  15188. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  15189. * Negative values of maxDelta pushes the value away from target.
  15190. */
  15191. static MoveTowards(current: number, target: number, maxDelta: number): number;
  15192. /**
  15193. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15194. *
  15195. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  15196. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  15197. */
  15198. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  15199. /**
  15200. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  15201. */
  15202. static Lerp(start: number, end: number, amount: number): number;
  15203. /**
  15204. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15205. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  15206. */
  15207. static LerpAngle(start: number, end: number, amount: number): number;
  15208. /**
  15209. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  15210. */
  15211. static InverseLerp(a: number, b: number, value: number): number;
  15212. /**
  15213. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  15214. */
  15215. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  15216. /**
  15217. * Returns a random float number between and min and max values
  15218. */
  15219. static RandomRange(min: number, max: number): number;
  15220. /**
  15221. * This function returns percentage of a number in a given range.
  15222. *
  15223. * RangeToPercent(40,20,60) will return 0.5 (50%)
  15224. * RangeToPercent(34,0,100) will return 0.34 (34%)
  15225. */
  15226. static RangeToPercent(number: number, min: number, max: number): number;
  15227. /**
  15228. * This function returns number that corresponds to the percentage in a given range.
  15229. *
  15230. * PercentToRange(0.34,0,100) will return 34.
  15231. */
  15232. static PercentToRange(percent: number, min: number, max: number): number;
  15233. /**
  15234. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  15235. * @param angle The angle to normalize in radian.
  15236. * @return The converted angle.
  15237. */
  15238. static NormalizeRadians(angle: number): number;
  15239. }
  15240. }
  15241. declare module BABYLON {
  15242. const ToGammaSpace: number;
  15243. const ToLinearSpace = 2.2;
  15244. const Epsilon = 0.001;
  15245. /**
  15246. * Class used to hold a RBG color
  15247. */
  15248. class Color3 {
  15249. /**
  15250. * Defines the red component (between 0 and 1, default is 0)
  15251. */
  15252. r: number;
  15253. /**
  15254. * Defines the green component (between 0 and 1, default is 0)
  15255. */
  15256. g: number;
  15257. /**
  15258. * Defines the blue component (between 0 and 1, default is 0)
  15259. */
  15260. b: number;
  15261. /**
  15262. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  15263. * @param r defines the red component (between 0 and 1, default is 0)
  15264. * @param g defines the green component (between 0 and 1, default is 0)
  15265. * @param b defines the blue component (between 0 and 1, default is 0)
  15266. */
  15267. constructor(
  15268. /**
  15269. * Defines the red component (between 0 and 1, default is 0)
  15270. */
  15271. r?: number,
  15272. /**
  15273. * Defines the green component (between 0 and 1, default is 0)
  15274. */
  15275. g?: number,
  15276. /**
  15277. * Defines the blue component (between 0 and 1, default is 0)
  15278. */
  15279. b?: number);
  15280. /**
  15281. * Creates a string with the Color3 current values
  15282. * @returns the string representation of the Color3 object
  15283. */
  15284. toString(): string;
  15285. /**
  15286. * Returns the string "Color3"
  15287. * @returns "Color3"
  15288. */
  15289. getClassName(): string;
  15290. /**
  15291. * Compute the Color3 hash code
  15292. * @returns an unique number that can be used to hash Color3 objects
  15293. */
  15294. getHashCode(): number;
  15295. /**
  15296. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  15297. * @param array defines the array where to store the r,g,b components
  15298. * @param index defines an optional index in the target array to define where to start storing values
  15299. * @returns the current Color3 object
  15300. */
  15301. toArray(array: FloatArray, index?: number): Color3;
  15302. /**
  15303. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  15304. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  15305. * @returns a new {BABYLON.Color4} object
  15306. */
  15307. toColor4(alpha?: number): Color4;
  15308. /**
  15309. * Returns a new array populated with 3 numeric elements : red, green and blue values
  15310. * @returns the new array
  15311. */
  15312. asArray(): number[];
  15313. /**
  15314. * Returns the luminance value
  15315. * @returns a float value
  15316. */
  15317. toLuminance(): number;
  15318. /**
  15319. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  15320. * @param otherColor defines the second operand
  15321. * @returns the new Color3 object
  15322. */
  15323. multiply(otherColor: Color3): Color3;
  15324. /**
  15325. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  15326. * @param otherColor defines the second operand
  15327. * @param result defines the Color3 object where to store the result
  15328. * @returns the current Color3
  15329. */
  15330. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  15331. /**
  15332. * Determines equality between Color3 objects
  15333. * @param otherColor defines the second operand
  15334. * @returns true if the rgb values are equal to the given ones
  15335. */
  15336. equals(otherColor: Color3): boolean;
  15337. /**
  15338. * Determines equality between the current Color3 object and a set of r,b,g values
  15339. * @param r defines the red component to check
  15340. * @param g defines the green component to check
  15341. * @param b defines the blue component to check
  15342. * @returns true if the rgb values are equal to the given ones
  15343. */
  15344. equalsFloats(r: number, g: number, b: number): boolean;
  15345. /**
  15346. * Multiplies in place each rgb value by scale
  15347. * @param scale defines the scaling factor
  15348. * @returns the updated Color3
  15349. */
  15350. scale(scale: number): Color3;
  15351. /**
  15352. * Multiplies the rgb values by scale and stores the result into "result"
  15353. * @param scale defines the scaling factor
  15354. * @param result defines the Color3 object where to store the result
  15355. * @returns the unmodified current Color3
  15356. */
  15357. scaleToRef(scale: number, result: Color3): Color3;
  15358. /**
  15359. * Scale the current Color3 values by a factor and add the result to a given Color3
  15360. * @param scale defines the scale factor
  15361. * @param result defines color to store the result into
  15362. * @returns the unmodified current Color3
  15363. */
  15364. scaleAndAddToRef(scale: number, result: Color3): Color3;
  15365. /**
  15366. * Clamps the rgb values by the min and max values and stores the result into "result"
  15367. * @param min defines minimum clamping value (default is 0)
  15368. * @param max defines maximum clamping value (default is 1)
  15369. * @param result defines color to store the result into
  15370. * @returns the original Color3
  15371. */
  15372. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  15373. /**
  15374. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  15375. * @param otherColor defines the second operand
  15376. * @returns the new Color3
  15377. */
  15378. add(otherColor: Color3): Color3;
  15379. /**
  15380. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  15381. * @param otherColor defines the second operand
  15382. * @param result defines Color3 object to store the result into
  15383. * @returns the unmodified current Color3
  15384. */
  15385. addToRef(otherColor: Color3, result: Color3): Color3;
  15386. /**
  15387. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  15388. * @param otherColor defines the second operand
  15389. * @returns the new Color3
  15390. */
  15391. subtract(otherColor: Color3): Color3;
  15392. /**
  15393. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  15394. * @param otherColor defines the second operand
  15395. * @param result defines Color3 object to store the result into
  15396. * @returns the unmodified current Color3
  15397. */
  15398. subtractToRef(otherColor: Color3, result: Color3): Color3;
  15399. /**
  15400. * Copy the current object
  15401. * @returns a new Color3 copied the current one
  15402. */
  15403. clone(): Color3;
  15404. /**
  15405. * Copies the rgb values from the source in the current Color3
  15406. * @param source defines the source Color3 object
  15407. * @returns the updated Color3 object
  15408. */
  15409. copyFrom(source: Color3): Color3;
  15410. /**
  15411. * Updates the Color3 rgb values from the given floats
  15412. * @param r defines the red component to read from
  15413. * @param g defines the green component to read from
  15414. * @param b defines the blue component to read from
  15415. * @returns the current Color3 object
  15416. */
  15417. copyFromFloats(r: number, g: number, b: number): Color3;
  15418. /**
  15419. * Updates the Color3 rgb values from the given floats
  15420. * @param r defines the red component to read from
  15421. * @param g defines the green component to read from
  15422. * @param b defines the blue component to read from
  15423. * @returns the current Color3 object
  15424. */
  15425. set(r: number, g: number, b: number): Color3;
  15426. /**
  15427. * Compute the Color3 hexadecimal code as a string
  15428. * @returns a string containing the hexadecimal representation of the Color3 object
  15429. */
  15430. toHexString(): string;
  15431. /**
  15432. * Computes a new Color3 converted from the current one to linear space
  15433. * @returns a new Color3 object
  15434. */
  15435. toLinearSpace(): Color3;
  15436. /**
  15437. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  15438. * @param convertedColor defines the Color3 object where to store the linear space version
  15439. * @returns the unmodified Color3
  15440. */
  15441. toLinearSpaceToRef(convertedColor: Color3): Color3;
  15442. /**
  15443. * Computes a new Color3 converted from the current one to gamma space
  15444. * @returns a new Color3 object
  15445. */
  15446. toGammaSpace(): Color3;
  15447. /**
  15448. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  15449. * @param convertedColor defines the Color3 object where to store the gamma space version
  15450. * @returns the unmodified Color3
  15451. */
  15452. toGammaSpaceToRef(convertedColor: Color3): Color3;
  15453. /**
  15454. * Creates a new Color3 from the string containing valid hexadecimal values
  15455. * @param hex defines a string containing valid hexadecimal values
  15456. * @returns a new Color3 object
  15457. */
  15458. static FromHexString(hex: string): Color3;
  15459. /**
  15460. * Creates a new Vector3 from the starting index of the given array
  15461. * @param array defines the source array
  15462. * @param offset defines an offset in the source array
  15463. * @returns a new Color3 object
  15464. */
  15465. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  15466. /**
  15467. * Creates a new Color3 from integer values (< 256)
  15468. * @param r defines the red component to read from (value between 0 and 255)
  15469. * @param g defines the green component to read from (value between 0 and 255)
  15470. * @param b defines the blue component to read from (value between 0 and 255)
  15471. * @returns a new Color3 object
  15472. */
  15473. static FromInts(r: number, g: number, b: number): Color3;
  15474. /**
  15475. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  15476. * @param start defines the start Color3 value
  15477. * @param end defines the end Color3 value
  15478. * @param amount defines the gradient value between start and end
  15479. * @returns a new Color3 object
  15480. */
  15481. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  15482. /**
  15483. * Returns a Color3 value containing a red color
  15484. * @returns a new Color3 object
  15485. */
  15486. static Red(): Color3;
  15487. /**
  15488. * Returns a Color3 value containing a green color
  15489. * @returns a new Color3 object
  15490. */
  15491. static Green(): Color3;
  15492. /**
  15493. * Returns a Color3 value containing a blue color
  15494. * @returns a new Color3 object
  15495. */
  15496. static Blue(): Color3;
  15497. /**
  15498. * Returns a Color3 value containing a black color
  15499. * @returns a new Color3 object
  15500. */
  15501. static Black(): Color3;
  15502. /**
  15503. * Returns a Color3 value containing a white color
  15504. * @returns a new Color3 object
  15505. */
  15506. static White(): Color3;
  15507. /**
  15508. * Returns a Color3 value containing a purple color
  15509. * @returns a new Color3 object
  15510. */
  15511. static Purple(): Color3;
  15512. /**
  15513. * Returns a Color3 value containing a magenta color
  15514. * @returns a new Color3 object
  15515. */
  15516. static Magenta(): Color3;
  15517. /**
  15518. * Returns a Color3 value containing a yellow color
  15519. * @returns a new Color3 object
  15520. */
  15521. static Yellow(): Color3;
  15522. /**
  15523. * Returns a Color3 value containing a gray color
  15524. * @returns a new Color3 object
  15525. */
  15526. static Gray(): Color3;
  15527. /**
  15528. * Returns a Color3 value containing a teal color
  15529. * @returns a new Color3 object
  15530. */
  15531. static Teal(): Color3;
  15532. /**
  15533. * Returns a Color3 value containing a random color
  15534. * @returns a new Color3 object
  15535. */
  15536. static Random(): Color3;
  15537. }
  15538. /**
  15539. * Class used to hold a RBGA color
  15540. */
  15541. class Color4 {
  15542. /**
  15543. * Defines the red component (between 0 and 1, default is 0)
  15544. */
  15545. r: number;
  15546. /**
  15547. * Defines the green component (between 0 and 1, default is 0)
  15548. */
  15549. g: number;
  15550. /**
  15551. * Defines the blue component (between 0 and 1, default is 0)
  15552. */
  15553. b: number;
  15554. /**
  15555. * Defines the alpha component (between 0 and 1, default is 1)
  15556. */
  15557. a: number;
  15558. /**
  15559. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  15560. * @param r defines the red component (between 0 and 1, default is 0)
  15561. * @param g defines the green component (between 0 and 1, default is 0)
  15562. * @param b defines the blue component (between 0 and 1, default is 0)
  15563. * @param a defines the alpha component (between 0 and 1, default is 1)
  15564. */
  15565. constructor(
  15566. /**
  15567. * Defines the red component (between 0 and 1, default is 0)
  15568. */
  15569. r?: number,
  15570. /**
  15571. * Defines the green component (between 0 and 1, default is 0)
  15572. */
  15573. g?: number,
  15574. /**
  15575. * Defines the blue component (between 0 and 1, default is 0)
  15576. */
  15577. b?: number,
  15578. /**
  15579. * Defines the alpha component (between 0 and 1, default is 1)
  15580. */
  15581. a?: number);
  15582. /**
  15583. * Adds in place the given Color4 values to the current Color4 object
  15584. * @param right defines the second operand
  15585. * @returns the current updated Color4 object
  15586. */
  15587. addInPlace(right: Color4): Color4;
  15588. /**
  15589. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  15590. * @returns the new array
  15591. */
  15592. asArray(): number[];
  15593. /**
  15594. * Stores from the starting index in the given array the Color4 successive values
  15595. * @param array defines the array where to store the r,g,b components
  15596. * @param index defines an optional index in the target array to define where to start storing values
  15597. * @returns the current Color4 object
  15598. */
  15599. toArray(array: number[], index?: number): Color4;
  15600. /**
  15601. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  15602. * @param right defines the second operand
  15603. * @returns a new Color4 object
  15604. */
  15605. add(right: Color4): Color4;
  15606. /**
  15607. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  15608. * @param right defines the second operand
  15609. * @returns a new Color4 object
  15610. */
  15611. subtract(right: Color4): Color4;
  15612. /**
  15613. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  15614. * @param right defines the second operand
  15615. * @param result defines the Color4 object where to store the result
  15616. * @returns the current Color4 object
  15617. */
  15618. subtractToRef(right: Color4, result: Color4): Color4;
  15619. /**
  15620. * Creates a new Color4 with the current Color4 values multiplied by scale
  15621. * @param scale defines the scaling factor to apply
  15622. * @returns a new Color4 object
  15623. */
  15624. scale(scale: number): Color4;
  15625. /**
  15626. * Multiplies the current Color4 values by scale and stores the result in "result"
  15627. * @param scale defines the scaling factor to apply
  15628. * @param result defines the Color4 object where to store the result
  15629. * @returns the current unmodified Color4
  15630. */
  15631. scaleToRef(scale: number, result: Color4): Color4;
  15632. /**
  15633. * Scale the current Color4 values by a factor and add the result to a given Color4
  15634. * @param scale defines the scale factor
  15635. * @param result defines the Color4 object where to store the result
  15636. * @returns the unmodified current Color4
  15637. */
  15638. scaleAndAddToRef(scale: number, result: Color4): Color4;
  15639. /**
  15640. * Clamps the rgb values by the min and max values and stores the result into "result"
  15641. * @param min defines minimum clamping value (default is 0)
  15642. * @param max defines maximum clamping value (default is 1)
  15643. * @param result defines color to store the result into.
  15644. * @returns the cuurent Color4
  15645. */
  15646. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  15647. /**
  15648. * Multipy an Color4 value by another and return a new Color4 object
  15649. * @param color defines the Color4 value to multiply by
  15650. * @returns a new Color4 object
  15651. */
  15652. multiply(color: Color4): Color4;
  15653. /**
  15654. * Multipy a Color4 value by another and push the result in a reference value
  15655. * @param color defines the Color4 value to multiply by
  15656. * @param result defines the Color4 to fill the result in
  15657. * @returns the result Color4
  15658. */
  15659. multiplyToRef(color: Color4, result: Color4): Color4;
  15660. /**
  15661. * Creates a string with the Color4 current values
  15662. * @returns the string representation of the Color4 object
  15663. */
  15664. toString(): string;
  15665. /**
  15666. * Returns the string "Color4"
  15667. * @returns "Color4"
  15668. */
  15669. getClassName(): string;
  15670. /**
  15671. * Compute the Color4 hash code
  15672. * @returns an unique number that can be used to hash Color4 objects
  15673. */
  15674. getHashCode(): number;
  15675. /**
  15676. * Creates a new Color4 copied from the current one
  15677. * @returns a new Color4 object
  15678. */
  15679. clone(): Color4;
  15680. /**
  15681. * Copies the given Color4 values into the current one
  15682. * @param source defines the source Color4 object
  15683. * @returns the current updated Color4 object
  15684. */
  15685. copyFrom(source: Color4): Color4;
  15686. /**
  15687. * Copies the given float values into the current one
  15688. * @param r defines the red component to read from
  15689. * @param g defines the green component to read from
  15690. * @param b defines the blue component to read from
  15691. * @param a defines the alpha component to read from
  15692. * @returns the current updated Color4 object
  15693. */
  15694. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  15695. /**
  15696. * Copies the given float values into the current one
  15697. * @param r defines the red component to read from
  15698. * @param g defines the green component to read from
  15699. * @param b defines the blue component to read from
  15700. * @param a defines the alpha component to read from
  15701. * @returns the current updated Color4 object
  15702. */
  15703. set(r: number, g: number, b: number, a: number): Color4;
  15704. /**
  15705. * Compute the Color4 hexadecimal code as a string
  15706. * @returns a string containing the hexadecimal representation of the Color4 object
  15707. */
  15708. toHexString(): string;
  15709. /**
  15710. * Computes a new Color4 converted from the current one to linear space
  15711. * @returns a new Color4 object
  15712. */
  15713. toLinearSpace(): Color4;
  15714. /**
  15715. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  15716. * @param convertedColor defines the Color4 object where to store the linear space version
  15717. * @returns the unmodified Color4
  15718. */
  15719. toLinearSpaceToRef(convertedColor: Color4): Color4;
  15720. /**
  15721. * Computes a new Color4 converted from the current one to gamma space
  15722. * @returns a new Color4 object
  15723. */
  15724. toGammaSpace(): Color4;
  15725. /**
  15726. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  15727. * @param convertedColor defines the Color4 object where to store the gamma space version
  15728. * @returns the unmodified Color4
  15729. */
  15730. toGammaSpaceToRef(convertedColor: Color4): Color4;
  15731. /**
  15732. * Creates a new Color4 from the string containing valid hexadecimal values
  15733. * @param hex defines a string containing valid hexadecimal values
  15734. * @returns a new Color4 object
  15735. */
  15736. static FromHexString(hex: string): Color4;
  15737. /**
  15738. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15739. * @param left defines the start value
  15740. * @param right defines the end value
  15741. * @param amount defines the gradient factor
  15742. * @returns a new Color4 object
  15743. */
  15744. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  15745. /**
  15746. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15747. * @param left defines the start value
  15748. * @param right defines the end value
  15749. * @param amount defines the gradient factor
  15750. * @param result defines the Color4 object where to store data
  15751. */
  15752. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  15753. /**
  15754. * Creates a new Color4 from the starting index element of the given array
  15755. * @param array defines the source array to read from
  15756. * @param offset defines the offset in the source array
  15757. * @returns a new Color4 object
  15758. */
  15759. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  15760. /**
  15761. * Creates a new Color3 from integer values (< 256)
  15762. * @param r defines the red component to read from (value between 0 and 255)
  15763. * @param g defines the green component to read from (value between 0 and 255)
  15764. * @param b defines the blue component to read from (value between 0 and 255)
  15765. * @param a defines the alpha component to read from (value between 0 and 255)
  15766. * @returns a new Color3 object
  15767. */
  15768. static FromInts(r: number, g: number, b: number, a: number): Color4;
  15769. /**
  15770. * Check the content of a given array and convert it to an array containing RGBA data
  15771. * If the original array was already containing count * 4 values then it is returned directly
  15772. * @param colors defines the array to check
  15773. * @param count defines the number of RGBA data to expect
  15774. * @returns an array containing count * 4 values (RGBA)
  15775. */
  15776. static CheckColors4(colors: number[], count: number): number[];
  15777. }
  15778. /**
  15779. * Class representing a vector containing 2 coordinates
  15780. */
  15781. class Vector2 {
  15782. /** defines the first coordinate */
  15783. x: number;
  15784. /** defines the second coordinate */
  15785. y: number;
  15786. /**
  15787. * Creates a new Vector2 from the given x and y coordinates
  15788. * @param x defines the first coordinate
  15789. * @param y defines the second coordinate
  15790. */
  15791. constructor(
  15792. /** defines the first coordinate */
  15793. x?: number,
  15794. /** defines the second coordinate */
  15795. y?: number);
  15796. /**
  15797. * Gets a string with the Vector2 coordinates
  15798. * @returns a string with the Vector2 coordinates
  15799. */
  15800. toString(): string;
  15801. /**
  15802. * Gets class name
  15803. * @returns the string "Vector2"
  15804. */
  15805. getClassName(): string;
  15806. /**
  15807. * Gets current vector hash code
  15808. * @returns the Vector2 hash code as a number
  15809. */
  15810. getHashCode(): number;
  15811. /**
  15812. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  15813. * @param array defines the source array
  15814. * @param index defines the offset in source array
  15815. * @returns the current Vector2
  15816. */
  15817. toArray(array: FloatArray, index?: number): Vector2;
  15818. /**
  15819. * Copy the current vector to an array
  15820. * @returns a new array with 2 elements: the Vector2 coordinates.
  15821. */
  15822. asArray(): number[];
  15823. /**
  15824. * Sets the Vector2 coordinates with the given Vector2 coordinates
  15825. * @param source defines the source Vector2
  15826. * @returns the current updated Vector2
  15827. */
  15828. copyFrom(source: Vector2): Vector2;
  15829. /**
  15830. * Sets the Vector2 coordinates with the given floats
  15831. * @param x defines the first coordinate
  15832. * @param y defines the second coordinate
  15833. * @returns the current updated Vector2
  15834. */
  15835. copyFromFloats(x: number, y: number): Vector2;
  15836. /**
  15837. * Sets the Vector2 coordinates with the given floats
  15838. * @param x defines the first coordinate
  15839. * @param y defines the second coordinate
  15840. * @returns the current updated Vector2
  15841. */
  15842. set(x: number, y: number): Vector2;
  15843. /**
  15844. * Add another vector with the current one
  15845. * @param otherVector defines the other vector
  15846. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  15847. */
  15848. add(otherVector: Vector2): Vector2;
  15849. /**
  15850. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  15851. * @param otherVector defines the other vector
  15852. * @param result defines the target vector
  15853. * @returns the unmodified current Vector2
  15854. */
  15855. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  15856. /**
  15857. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  15858. * @param otherVector defines the other vector
  15859. * @returns the current updated Vector2
  15860. */
  15861. addInPlace(otherVector: Vector2): Vector2;
  15862. /**
  15863. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  15864. * @param otherVector defines the other vector
  15865. * @returns a new Vector2
  15866. */
  15867. addVector3(otherVector: Vector3): Vector2;
  15868. /**
  15869. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  15870. * @param otherVector defines the other vector
  15871. * @returns a new Vector2
  15872. */
  15873. subtract(otherVector: Vector2): Vector2;
  15874. /**
  15875. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  15876. * @param otherVector defines the other vector
  15877. * @param result defines the target vector
  15878. * @returns the unmodified current Vector2
  15879. */
  15880. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  15881. /**
  15882. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  15883. * @param otherVector defines the other vector
  15884. * @returns the current updated Vector2
  15885. */
  15886. subtractInPlace(otherVector: Vector2): Vector2;
  15887. /**
  15888. * Multiplies in place the current Vector2 coordinates by the given ones
  15889. * @param otherVector defines the other vector
  15890. * @returns the current updated Vector2
  15891. */
  15892. multiplyInPlace(otherVector: Vector2): Vector2;
  15893. /**
  15894. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  15895. * @param otherVector defines the other vector
  15896. * @returns a new Vector2
  15897. */
  15898. multiply(otherVector: Vector2): Vector2;
  15899. /**
  15900. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  15901. * @param otherVector defines the other vector
  15902. * @param result defines the target vector
  15903. * @returns the unmodified current Vector2
  15904. */
  15905. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  15906. /**
  15907. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  15908. * @param x defines the first coordinate
  15909. * @param y defines the second coordinate
  15910. * @returns a new Vector2
  15911. */
  15912. multiplyByFloats(x: number, y: number): Vector2;
  15913. /**
  15914. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  15915. * @param otherVector defines the other vector
  15916. * @returns a new Vector2
  15917. */
  15918. divide(otherVector: Vector2): Vector2;
  15919. /**
  15920. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  15921. * @param otherVector defines the other vector
  15922. * @param result defines the target vector
  15923. * @returns the unmodified current Vector2
  15924. */
  15925. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  15926. /**
  15927. * Divides the current Vector3 coordinates by the given ones
  15928. * @param otherVector defines the other vector
  15929. * @returns the current updated Vector2
  15930. */
  15931. divideInPlace(otherVector: Vector2): Vector2;
  15932. /**
  15933. * Gets a new Vector2 with current Vector2 negated coordinates
  15934. * @returns a new Vector2
  15935. */
  15936. negate(): Vector2;
  15937. /**
  15938. * Multiply the Vector2 coordinates by scale
  15939. * @param scale defines the scaling factor
  15940. * @returns the current updated Vector2
  15941. */
  15942. scaleInPlace(scale: number): Vector2;
  15943. /**
  15944. * Returns a new Vector2 scaled by "scale" from the current Vector2
  15945. * @param scale defines the scaling factor
  15946. * @returns a new Vector2
  15947. */
  15948. scale(scale: number): Vector2;
  15949. /**
  15950. * Scale the current Vector2 values by a factor to a given Vector2
  15951. * @param scale defines the scale factor
  15952. * @param result defines the Vector2 object where to store the result
  15953. * @returns the unmodified current Vector2
  15954. */
  15955. scaleToRef(scale: number, result: Vector2): Vector2;
  15956. /**
  15957. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  15958. * @param scale defines the scale factor
  15959. * @param result defines the Vector2 object where to store the result
  15960. * @returns the unmodified current Vector2
  15961. */
  15962. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  15963. /**
  15964. * Gets a boolean if two vectors are equals
  15965. * @param otherVector defines the other vector
  15966. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  15967. */
  15968. equals(otherVector: Vector2): boolean;
  15969. /**
  15970. * Gets a boolean if two vectors are equals (using an epsilon value)
  15971. * @param otherVector defines the other vector
  15972. * @param epsilon defines the minimal distance to consider equality
  15973. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  15974. */
  15975. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  15976. /**
  15977. * Gets the length of the vector
  15978. * @returns the vector length (float)
  15979. */
  15980. length(): number;
  15981. /**
  15982. * Gets the vector squared length
  15983. * @returns the vector squared length (float)
  15984. */
  15985. lengthSquared(): number;
  15986. /**
  15987. * Normalize the vector
  15988. * @returns the current updated Vector2
  15989. */
  15990. normalize(): Vector2;
  15991. /**
  15992. * Gets a new Vector2 copied from the Vector2
  15993. * @returns a new Vector2
  15994. */
  15995. clone(): Vector2;
  15996. /**
  15997. * Gets a new Vector2(0, 0)
  15998. * @returns a new Vector2
  15999. */
  16000. static Zero(): Vector2;
  16001. /**
  16002. * Gets a new Vector2(1, 1)
  16003. * @returns a new Vector2
  16004. */
  16005. static One(): Vector2;
  16006. /**
  16007. * Gets a new Vector2 set from the given index element of the given array
  16008. * @param array defines the data source
  16009. * @param offset defines the offset in the data source
  16010. * @returns a new Vector2
  16011. */
  16012. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  16013. /**
  16014. * Sets "result" from the given index element of the given array
  16015. * @param array defines the data source
  16016. * @param offset defines the offset in the data source
  16017. * @param result defines the target vector
  16018. */
  16019. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  16020. /**
  16021. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  16022. * @param value1 defines 1st point of control
  16023. * @param value2 defines 2nd point of control
  16024. * @param value3 defines 3rd point of control
  16025. * @param value4 defines 4th point of control
  16026. * @param amount defines the interpolation factor
  16027. * @returns a new Vector2
  16028. */
  16029. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  16030. /**
  16031. * 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".
  16032. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  16033. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  16034. * @param value defines the value to clamp
  16035. * @param min defines the lower limit
  16036. * @param max defines the upper limit
  16037. * @returns a new Vector2
  16038. */
  16039. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  16040. /**
  16041. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  16042. * @param value1 defines the 1st control point
  16043. * @param tangent1 defines the outgoing tangent
  16044. * @param value2 defines the 2nd control point
  16045. * @param tangent2 defines the incoming tangent
  16046. * @param amount defines the interpolation factor
  16047. * @returns a new Vector2
  16048. */
  16049. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  16050. /**
  16051. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  16052. * @param start defines the start vector
  16053. * @param end defines the end vector
  16054. * @param amount defines the interpolation factor
  16055. * @returns a new Vector2
  16056. */
  16057. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  16058. /**
  16059. * Gets the dot product of the vector "left" and the vector "right"
  16060. * @param left defines first vector
  16061. * @param right defines second vector
  16062. * @returns the dot product (float)
  16063. */
  16064. static Dot(left: Vector2, right: Vector2): number;
  16065. /**
  16066. * Returns a new Vector2 equal to the normalized given vector
  16067. * @param vector defines the vector to normalize
  16068. * @returns a new Vector2
  16069. */
  16070. static Normalize(vector: Vector2): Vector2;
  16071. /**
  16072. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  16073. * @param left defines 1st vector
  16074. * @param right defines 2nd vector
  16075. * @returns a new Vector2
  16076. */
  16077. static Minimize(left: Vector2, right: Vector2): Vector2;
  16078. /**
  16079. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  16080. * @param left defines 1st vector
  16081. * @param right defines 2nd vector
  16082. * @returns a new Vector2
  16083. */
  16084. static Maximize(left: Vector2, right: Vector2): Vector2;
  16085. /**
  16086. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  16087. * @param vector defines the vector to transform
  16088. * @param transformation defines the matrix to apply
  16089. * @returns a new Vector2
  16090. */
  16091. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  16092. /**
  16093. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  16094. * @param vector defines the vector to transform
  16095. * @param transformation defines the matrix to apply
  16096. * @param result defines the target vector
  16097. */
  16098. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  16099. /**
  16100. * Determines if a given vector is included in a triangle
  16101. * @param p defines the vector to test
  16102. * @param p0 defines 1st triangle point
  16103. * @param p1 defines 2nd triangle point
  16104. * @param p2 defines 3rd triangle point
  16105. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  16106. */
  16107. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  16108. /**
  16109. * Gets the distance between the vectors "value1" and "value2"
  16110. * @param value1 defines first vector
  16111. * @param value2 defines second vector
  16112. * @returns the distance between vectors
  16113. */
  16114. static Distance(value1: Vector2, value2: Vector2): number;
  16115. /**
  16116. * Returns the squared distance between the vectors "value1" and "value2"
  16117. * @param value1 defines first vector
  16118. * @param value2 defines second vector
  16119. * @returns the squared distance between vectors
  16120. */
  16121. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  16122. /**
  16123. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  16124. * @param value1 defines first vector
  16125. * @param value2 defines second vector
  16126. * @returns a new Vector2
  16127. */
  16128. static Center(value1: Vector2, value2: Vector2): Vector2;
  16129. /**
  16130. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  16131. * @param p defines the middle point
  16132. * @param segA defines one point of the segment
  16133. * @param segB defines the other point of the segment
  16134. * @returns the shortest distance
  16135. */
  16136. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  16137. }
  16138. /**
  16139. * Classed used to store (x,y,z) vector representation
  16140. * A Vector3 is the main object used in 3D geometry
  16141. * It can represent etiher the coordinates of a point the space, either a direction
  16142. * Reminder: Babylon.js uses a left handed forward facing system
  16143. */
  16144. class Vector3 {
  16145. /**
  16146. * Defines the first coordinates (on X axis)
  16147. */
  16148. x: number;
  16149. /**
  16150. * Defines the second coordinates (on Y axis)
  16151. */
  16152. y: number;
  16153. /**
  16154. * Defines the third coordinates (on Z axis)
  16155. */
  16156. z: number;
  16157. /**
  16158. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  16159. * @param x defines the first coordinates (on X axis)
  16160. * @param y defines the second coordinates (on Y axis)
  16161. * @param z defines the third coordinates (on Z axis)
  16162. */
  16163. constructor(
  16164. /**
  16165. * Defines the first coordinates (on X axis)
  16166. */
  16167. x?: number,
  16168. /**
  16169. * Defines the second coordinates (on Y axis)
  16170. */
  16171. y?: number,
  16172. /**
  16173. * Defines the third coordinates (on Z axis)
  16174. */
  16175. z?: number);
  16176. /**
  16177. * Creates a string representation of the Vector3
  16178. * @returns a string with the Vector3 coordinates.
  16179. */
  16180. toString(): string;
  16181. /**
  16182. * Gets the class name
  16183. * @returns the string "Vector3"
  16184. */
  16185. getClassName(): string;
  16186. /**
  16187. * Creates the Vector3 hash code
  16188. * @returns a number which tends to be unique between Vector3 instances
  16189. */
  16190. getHashCode(): number;
  16191. /**
  16192. * Creates an array containing three elements : the coordinates of the Vector3
  16193. * @returns a new array of numbers
  16194. */
  16195. asArray(): number[];
  16196. /**
  16197. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  16198. * @param array defines the destination array
  16199. * @param index defines the offset in the destination array
  16200. * @returns the current Vector3
  16201. */
  16202. toArray(array: FloatArray, index?: number): Vector3;
  16203. /**
  16204. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  16205. * @returns a new Quaternion object, computed from the Vector3 coordinates
  16206. */
  16207. toQuaternion(): Quaternion;
  16208. /**
  16209. * Adds the given vector to the current Vector3
  16210. * @param otherVector defines the second operand
  16211. * @returns the current updated Vector3
  16212. */
  16213. addInPlace(otherVector: Vector3): Vector3;
  16214. /**
  16215. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  16216. * @param otherVector defines the second operand
  16217. * @returns the resulting Vector3
  16218. */
  16219. add(otherVector: Vector3): Vector3;
  16220. /**
  16221. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  16222. * @param otherVector defines the second operand
  16223. * @param result defines the Vector3 object where to store the result
  16224. * @returns the current Vector3
  16225. */
  16226. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  16227. /**
  16228. * Subtract the given vector from the current Vector3
  16229. * @param otherVector defines the second operand
  16230. * @returns the current updated Vector3
  16231. */
  16232. subtractInPlace(otherVector: Vector3): Vector3;
  16233. /**
  16234. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  16235. * @param otherVector defines the second operand
  16236. * @returns the resulting Vector3
  16237. */
  16238. subtract(otherVector: Vector3): Vector3;
  16239. /**
  16240. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  16241. * @param otherVector defines the second operand
  16242. * @param result defines the Vector3 object where to store the result
  16243. * @returns the current Vector3
  16244. */
  16245. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  16246. /**
  16247. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  16248. * @param x defines the x coordinate of the operand
  16249. * @param y defines the y coordinate of the operand
  16250. * @param z defines the z coordinate of the operand
  16251. * @returns the resulting Vector3
  16252. */
  16253. subtractFromFloats(x: number, y: number, z: number): Vector3;
  16254. /**
  16255. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  16256. * @param x defines the x coordinate of the operand
  16257. * @param y defines the y coordinate of the operand
  16258. * @param z defines the z coordinate of the operand
  16259. * @param result defines the Vector3 object where to store the result
  16260. * @returns the current Vector3
  16261. */
  16262. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  16263. /**
  16264. * Gets a new Vector3 set with the current Vector3 negated coordinates
  16265. * @returns a new Vector3
  16266. */
  16267. negate(): Vector3;
  16268. /**
  16269. * Multiplies the Vector3 coordinates by the float "scale"
  16270. * @param scale defines the multiplier factor
  16271. * @returns the current updated Vector3
  16272. */
  16273. scaleInPlace(scale: number): Vector3;
  16274. /**
  16275. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  16276. * @param scale defines the multiplier factor
  16277. * @returns a new Vector3
  16278. */
  16279. scale(scale: number): Vector3;
  16280. /**
  16281. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  16282. * @param scale defines the multiplier factor
  16283. * @param result defines the Vector3 object where to store the result
  16284. * @returns the current Vector3
  16285. */
  16286. scaleToRef(scale: number, result: Vector3): Vector3;
  16287. /**
  16288. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  16289. * @param scale defines the scale factor
  16290. * @param result defines the Vector3 object where to store the result
  16291. * @returns the unmodified current Vector3
  16292. */
  16293. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  16294. /**
  16295. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  16296. * @param otherVector defines the second operand
  16297. * @returns true if both vectors are equals
  16298. */
  16299. equals(otherVector: Vector3): boolean;
  16300. /**
  16301. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  16302. * @param otherVector defines the second operand
  16303. * @param epsilon defines the minimal distance to define values as equals
  16304. * @returns true if both vectors are distant less than epsilon
  16305. */
  16306. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  16307. /**
  16308. * Returns true if the current Vector3 coordinates equals the given floats
  16309. * @param x defines the x coordinate of the operand
  16310. * @param y defines the y coordinate of the operand
  16311. * @param z defines the z coordinate of the operand
  16312. * @returns true if both vectors are equals
  16313. */
  16314. equalsToFloats(x: number, y: number, z: number): boolean;
  16315. /**
  16316. * Multiplies the current Vector3 coordinates by the given ones
  16317. * @param otherVector defines the second operand
  16318. * @returns the current updated Vector3
  16319. */
  16320. multiplyInPlace(otherVector: Vector3): Vector3;
  16321. /**
  16322. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  16323. * @param otherVector defines the second operand
  16324. * @returns the new Vector3
  16325. */
  16326. multiply(otherVector: Vector3): Vector3;
  16327. /**
  16328. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  16329. * @param otherVector defines the second operand
  16330. * @param result defines the Vector3 object where to store the result
  16331. * @returns the current Vector3
  16332. */
  16333. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  16334. /**
  16335. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  16336. * @param x defines the x coordinate of the operand
  16337. * @param y defines the y coordinate of the operand
  16338. * @param z defines the z coordinate of the operand
  16339. * @returns the new Vector3
  16340. */
  16341. multiplyByFloats(x: number, y: number, z: number): Vector3;
  16342. /**
  16343. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  16344. * @param otherVector defines the second operand
  16345. * @returns the new Vector3
  16346. */
  16347. divide(otherVector: Vector3): Vector3;
  16348. /**
  16349. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  16350. * @param otherVector defines the second operand
  16351. * @param result defines the Vector3 object where to store the result
  16352. * @returns the current Vector3
  16353. */
  16354. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  16355. /**
  16356. * Divides the current Vector3 coordinates by the given ones.
  16357. * @param otherVector defines the second operand
  16358. * @returns the current updated Vector3
  16359. */
  16360. divideInPlace(otherVector: Vector3): Vector3;
  16361. /**
  16362. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  16363. * @param other defines the second operand
  16364. * @returns the current updated Vector3
  16365. */
  16366. minimizeInPlace(other: Vector3): Vector3;
  16367. /**
  16368. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  16369. * @param other defines the second operand
  16370. * @returns the current updated Vector3
  16371. */
  16372. maximizeInPlace(other: Vector3): Vector3;
  16373. /**
  16374. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  16375. */
  16376. readonly isNonUniform: boolean;
  16377. /**
  16378. * Gets the length of the Vector3
  16379. * @returns the length of the Vecto3
  16380. */
  16381. length(): number;
  16382. /**
  16383. * Gets the squared length of the Vector3
  16384. * @returns squared length of the Vector3
  16385. */
  16386. lengthSquared(): number;
  16387. /**
  16388. * Normalize the current Vector3.
  16389. * Please note that this is an in place operation.
  16390. * @returns the current updated Vector3
  16391. */
  16392. normalize(): Vector3;
  16393. /**
  16394. * Normalize the current Vector3 to a new vector
  16395. * @returns the new Vector3
  16396. */
  16397. normalizeToNew(): Vector3;
  16398. /**
  16399. * Normalize the current Vector3 to the reference
  16400. * @param reference define the Vector3 to update
  16401. * @returns the updated Vector3
  16402. */
  16403. normalizeToRef(reference: Vector3): Vector3;
  16404. /**
  16405. * Creates a new Vector3 copied from the current Vector3
  16406. * @returns the new Vector3
  16407. */
  16408. clone(): Vector3;
  16409. /**
  16410. * Copies the given vector coordinates to the current Vector3 ones
  16411. * @param source defines the source Vector3
  16412. * @returns the current updated Vector3
  16413. */
  16414. copyFrom(source: Vector3): Vector3;
  16415. /**
  16416. * Copies the given floats to the current Vector3 coordinates
  16417. * @param x defines the x coordinate of the operand
  16418. * @param y defines the y coordinate of the operand
  16419. * @param z defines the z coordinate of the operand
  16420. * @returns the current updated Vector3
  16421. */
  16422. copyFromFloats(x: number, y: number, z: number): Vector3;
  16423. /**
  16424. * Copies the given floats to the current Vector3 coordinates
  16425. * @param x defines the x coordinate of the operand
  16426. * @param y defines the y coordinate of the operand
  16427. * @param z defines the z coordinate of the operand
  16428. * @returns the current updated Vector3
  16429. */
  16430. set(x: number, y: number, z: number): Vector3;
  16431. /**
  16432. * Get the clip factor between two vectors
  16433. * @param vector0 defines the first operand
  16434. * @param vector1 defines the second operand
  16435. * @param axis defines the axis to use
  16436. * @param size defines the size along the axis
  16437. * @returns the clip factor
  16438. */
  16439. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  16440. /**
  16441. * Get angle between two vectors
  16442. * @param vector0 angle between vector0 and vector1
  16443. * @param vector1 angle between vector0 and vector1
  16444. * @param normal direction of the normal
  16445. * @return the angle between vector0 and vector1
  16446. */
  16447. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  16448. /**
  16449. * Returns a new Vector3 set from the index "offset" of the given array
  16450. * @param array defines the source array
  16451. * @param offset defines the offset in the source array
  16452. * @returns the new Vector3
  16453. */
  16454. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  16455. /**
  16456. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  16457. * This function is deprecated. Use FromArray instead
  16458. * @param array defines the source array
  16459. * @param offset defines the offset in the source array
  16460. * @returns the new Vector3
  16461. */
  16462. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  16463. /**
  16464. * Sets the given vector "result" with the element values from the index "offset" of the given array
  16465. * @param array defines the source array
  16466. * @param offset defines the offset in the source array
  16467. * @param result defines the Vector3 where to store the result
  16468. */
  16469. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  16470. /**
  16471. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  16472. * This function is deprecated. Use FromArrayToRef instead.
  16473. * @param array defines the source array
  16474. * @param offset defines the offset in the source array
  16475. * @param result defines the Vector3 where to store the result
  16476. */
  16477. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  16478. /**
  16479. * Sets the given vector "result" with the given floats.
  16480. * @param x defines the x coordinate of the source
  16481. * @param y defines the y coordinate of the source
  16482. * @param z defines the z coordinate of the source
  16483. * @param result defines the Vector3 where to store the result
  16484. */
  16485. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  16486. /**
  16487. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  16488. * @returns a new empty Vector3
  16489. */
  16490. static Zero(): Vector3;
  16491. /**
  16492. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  16493. * @returns a new unit Vector3
  16494. */
  16495. static One(): Vector3;
  16496. /**
  16497. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  16498. * @returns a new up Vector3
  16499. */
  16500. static Up(): Vector3;
  16501. /**
  16502. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  16503. * @returns a new down Vector3
  16504. */
  16505. static Down(): Vector3;
  16506. /**
  16507. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  16508. * @returns a new forward Vector3
  16509. */
  16510. static Forward(): Vector3;
  16511. /**
  16512. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  16513. * @returns a new right Vector3
  16514. */
  16515. static Right(): Vector3;
  16516. /**
  16517. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  16518. * @returns a new left Vector3
  16519. */
  16520. static Left(): Vector3;
  16521. /**
  16522. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  16523. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16524. * @param vector defines the Vector3 to transform
  16525. * @param transformation defines the transformation matrix
  16526. * @returns the transformed Vector3
  16527. */
  16528. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  16529. /**
  16530. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  16531. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16532. * @param vector defines the Vector3 to transform
  16533. * @param transformation defines the transformation matrix
  16534. * @param result defines the Vector3 where to store the result
  16535. */
  16536. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16537. /**
  16538. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  16539. * This method computes tranformed coordinates only, not transformed direction vectors
  16540. * @param x define the x coordinate of the source vector
  16541. * @param y define the y coordinate of the source vector
  16542. * @param z define the z coordinate of the source vector
  16543. * @param transformation defines the transformation matrix
  16544. * @param result defines the Vector3 where to store the result
  16545. */
  16546. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16547. /**
  16548. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  16549. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16550. * @param vector defines the Vector3 to transform
  16551. * @param transformation defines the transformation matrix
  16552. * @returns the new Vector3
  16553. */
  16554. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  16555. /**
  16556. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  16557. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16558. * @param vector defines the Vector3 to transform
  16559. * @param transformation defines the transformation matrix
  16560. * @param result defines the Vector3 where to store the result
  16561. */
  16562. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16563. /**
  16564. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  16565. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16566. * @param x define the x coordinate of the source vector
  16567. * @param y define the y coordinate of the source vector
  16568. * @param z define the z coordinate of the source vector
  16569. * @param transformation defines the transformation matrix
  16570. * @param result defines the Vector3 where to store the result
  16571. */
  16572. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16573. /**
  16574. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  16575. * @param value1 defines the first control point
  16576. * @param value2 defines the second control point
  16577. * @param value3 defines the third control point
  16578. * @param value4 defines the fourth control point
  16579. * @param amount defines the amount on the spline to use
  16580. * @returns the new Vector3
  16581. */
  16582. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  16583. /**
  16584. * 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"
  16585. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  16586. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  16587. * @param value defines the current value
  16588. * @param min defines the lower range value
  16589. * @param max defines the upper range value
  16590. * @returns the new Vector3
  16591. */
  16592. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  16593. /**
  16594. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  16595. * @param value1 defines the first control point
  16596. * @param tangent1 defines the first tangent vector
  16597. * @param value2 defines the second control point
  16598. * @param tangent2 defines the second tangent vector
  16599. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  16600. * @returns the new Vector3
  16601. */
  16602. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  16603. /**
  16604. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  16605. * @param start defines the start value
  16606. * @param end defines the end value
  16607. * @param amount max defines amount between both (between 0 and 1)
  16608. * @returns the new Vector3
  16609. */
  16610. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  16611. /**
  16612. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  16613. * @param start defines the start value
  16614. * @param end defines the end value
  16615. * @param amount max defines amount between both (between 0 and 1)
  16616. * @param result defines the Vector3 where to store the result
  16617. */
  16618. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  16619. /**
  16620. * Returns the dot product (float) between the vectors "left" and "right"
  16621. * @param left defines the left operand
  16622. * @param right defines the right operand
  16623. * @returns the dot product
  16624. */
  16625. static Dot(left: Vector3, right: Vector3): number;
  16626. /**
  16627. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  16628. * The cross product is then orthogonal to both "left" and "right"
  16629. * @param left defines the left operand
  16630. * @param right defines the right operand
  16631. * @returns the cross product
  16632. */
  16633. static Cross(left: Vector3, right: Vector3): Vector3;
  16634. /**
  16635. * Sets the given vector "result" with the cross product of "left" and "right"
  16636. * The cross product is then orthogonal to both "left" and "right"
  16637. * @param left defines the left operand
  16638. * @param right defines the right operand
  16639. * @param result defines the Vector3 where to store the result
  16640. */
  16641. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  16642. /**
  16643. * Returns a new Vector3 as the normalization of the given vector
  16644. * @param vector defines the Vector3 to normalize
  16645. * @returns the new Vector3
  16646. */
  16647. static Normalize(vector: Vector3): Vector3;
  16648. /**
  16649. * Sets the given vector "result" with the normalization of the given first vector
  16650. * @param vector defines the Vector3 to normalize
  16651. * @param result defines the Vector3 where to store the result
  16652. */
  16653. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  16654. private static _viewportMatrixCache;
  16655. /**
  16656. * Project a Vector3 onto screen space
  16657. * @param vector defines the Vector3 to project
  16658. * @param world defines the world matrix to use
  16659. * @param transform defines the transform (view x projection) matrix to use
  16660. * @param viewport defines the screen viewport to use
  16661. * @returns the new Vector3
  16662. */
  16663. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  16664. /**
  16665. * Unproject from screen space to object space
  16666. * @param source defines the screen space Vector3 to use
  16667. * @param viewportWidth defines the current width of the viewport
  16668. * @param viewportHeight defines the current height of the viewport
  16669. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16670. * @param transform defines the transform (view x projection) matrix to use
  16671. * @returns the new Vector3
  16672. */
  16673. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  16674. /**
  16675. * Unproject from screen space to object space
  16676. * @param source defines the screen space Vector3 to use
  16677. * @param viewportWidth defines the current width of the viewport
  16678. * @param viewportHeight defines the current height of the viewport
  16679. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16680. * @param view defines the view matrix to use
  16681. * @param projection defines the projection matrix to use
  16682. * @returns the new Vector3
  16683. */
  16684. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  16685. /**
  16686. * Unproject from screen space to object space
  16687. * @param source defines the screen space Vector3 to use
  16688. * @param viewportWidth defines the current width of the viewport
  16689. * @param viewportHeight defines the current height of the viewport
  16690. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16691. * @param view defines the view matrix to use
  16692. * @param projection defines the projection matrix to use
  16693. * @param result defines the Vector3 where to store the result
  16694. */
  16695. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16696. /**
  16697. * Unproject from screen space to object space
  16698. * @param sourceX defines the screen space x coordinate to use
  16699. * @param sourceY defines the screen space y coordinate to use
  16700. * @param sourceZ defines the screen space z coordinate to use
  16701. * @param viewportWidth defines the current width of the viewport
  16702. * @param viewportHeight defines the current height of the viewport
  16703. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16704. * @param view defines the view matrix to use
  16705. * @param projection defines the projection matrix to use
  16706. * @param result defines the Vector3 where to store the result
  16707. */
  16708. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16709. /**
  16710. * Gets the minimal coordinate values between two Vector3
  16711. * @param left defines the first operand
  16712. * @param right defines the second operand
  16713. * @returns the new Vector3
  16714. */
  16715. static Minimize(left: Vector3, right: Vector3): Vector3;
  16716. /**
  16717. * Gets the maximal coordinate values between two Vector3
  16718. * @param left defines the first operand
  16719. * @param right defines the second operand
  16720. * @returns the new Vector3
  16721. */
  16722. static Maximize(left: Vector3, right: Vector3): Vector3;
  16723. /**
  16724. * Returns the distance between the vectors "value1" and "value2"
  16725. * @param value1 defines the first operand
  16726. * @param value2 defines the second operand
  16727. * @returns the distance
  16728. */
  16729. static Distance(value1: Vector3, value2: Vector3): number;
  16730. /**
  16731. * Returns the squared distance between the vectors "value1" and "value2"
  16732. * @param value1 defines the first operand
  16733. * @param value2 defines the second operand
  16734. * @returns the squared distance
  16735. */
  16736. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  16737. /**
  16738. * Returns a new Vector3 located at the center between "value1" and "value2"
  16739. * @param value1 defines the first operand
  16740. * @param value2 defines the second operand
  16741. * @returns the new Vector3
  16742. */
  16743. static Center(value1: Vector3, value2: Vector3): Vector3;
  16744. /**
  16745. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  16746. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  16747. * to something in order to rotate it from its local system to the given target system
  16748. * Note: axis1, axis2 and axis3 are normalized during this operation
  16749. * @param axis1 defines the first axis
  16750. * @param axis2 defines the second axis
  16751. * @param axis3 defines the third axis
  16752. * @returns a new Vector3
  16753. */
  16754. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  16755. /**
  16756. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  16757. * @param axis1 defines the first axis
  16758. * @param axis2 defines the second axis
  16759. * @param axis3 defines the third axis
  16760. * @param ref defines the Vector3 where to store the result
  16761. */
  16762. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  16763. }
  16764. class Vector4 {
  16765. x: number;
  16766. y: number;
  16767. z: number;
  16768. w: number;
  16769. /**
  16770. * Creates a Vector4 object from the given floats.
  16771. */
  16772. constructor(x: number, y: number, z: number, w: number);
  16773. /**
  16774. * Returns the string with the Vector4 coordinates.
  16775. */
  16776. toString(): string;
  16777. /**
  16778. * Returns the string "Vector4".
  16779. */
  16780. getClassName(): string;
  16781. /**
  16782. * Returns the Vector4 hash code.
  16783. */
  16784. getHashCode(): number;
  16785. /**
  16786. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  16787. */
  16788. asArray(): number[];
  16789. /**
  16790. * Populates the given array from the given index with the Vector4 coordinates.
  16791. * Returns the Vector4.
  16792. */
  16793. toArray(array: FloatArray, index?: number): Vector4;
  16794. /**
  16795. * Adds the given vector to the current Vector4.
  16796. * Returns the updated Vector4.
  16797. */
  16798. addInPlace(otherVector: Vector4): Vector4;
  16799. /**
  16800. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  16801. */
  16802. add(otherVector: Vector4): Vector4;
  16803. /**
  16804. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  16805. * Returns the current Vector4.
  16806. */
  16807. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  16808. /**
  16809. * Subtract in place the given vector from the current Vector4.
  16810. * Returns the updated Vector4.
  16811. */
  16812. subtractInPlace(otherVector: Vector4): Vector4;
  16813. /**
  16814. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  16815. */
  16816. subtract(otherVector: Vector4): Vector4;
  16817. /**
  16818. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  16819. * Returns the current Vector4.
  16820. */
  16821. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  16822. /**
  16823. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16824. */
  16825. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16826. /**
  16827. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16828. * Returns the current Vector4.
  16829. */
  16830. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  16831. /**
  16832. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  16833. */
  16834. negate(): Vector4;
  16835. /**
  16836. * Multiplies the current Vector4 coordinates by scale (float).
  16837. * Returns the updated Vector4.
  16838. */
  16839. scaleInPlace(scale: number): Vector4;
  16840. /**
  16841. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  16842. */
  16843. scale(scale: number): Vector4;
  16844. /**
  16845. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  16846. * Returns the current Vector4.
  16847. */
  16848. scaleToRef(scale: number, result: Vector4): Vector4;
  16849. /**
  16850. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  16851. * @param scale defines the scale factor
  16852. * @param result defines the Vector4 object where to store the result
  16853. * @returns the unmodified current Vector4
  16854. */
  16855. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  16856. /**
  16857. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  16858. */
  16859. equals(otherVector: Vector4): boolean;
  16860. /**
  16861. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  16862. */
  16863. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  16864. /**
  16865. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  16866. */
  16867. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  16868. /**
  16869. * Multiplies in place the current Vector4 by the given one.
  16870. * Returns the updated Vector4.
  16871. */
  16872. multiplyInPlace(otherVector: Vector4): Vector4;
  16873. /**
  16874. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  16875. */
  16876. multiply(otherVector: Vector4): Vector4;
  16877. /**
  16878. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  16879. * Returns the current Vector4.
  16880. */
  16881. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  16882. /**
  16883. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  16884. */
  16885. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  16886. /**
  16887. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  16888. */
  16889. divide(otherVector: Vector4): Vector4;
  16890. /**
  16891. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  16892. * Returns the current Vector4.
  16893. */
  16894. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  16895. /**
  16896. * Divides the current Vector3 coordinates by the given ones.
  16897. * @returns the updated Vector3.
  16898. */
  16899. divideInPlace(otherVector: Vector4): Vector4;
  16900. /**
  16901. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  16902. * @param other defines the second operand
  16903. * @returns the current updated Vector4
  16904. */
  16905. minimizeInPlace(other: Vector4): Vector4;
  16906. /**
  16907. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  16908. * @param other defines the second operand
  16909. * @returns the current updated Vector4
  16910. */
  16911. maximizeInPlace(other: Vector4): Vector4;
  16912. /**
  16913. * Returns the Vector4 length (float).
  16914. */
  16915. length(): number;
  16916. /**
  16917. * Returns the Vector4 squared length (float).
  16918. */
  16919. lengthSquared(): number;
  16920. /**
  16921. * Normalizes in place the Vector4.
  16922. * Returns the updated Vector4.
  16923. */
  16924. normalize(): Vector4;
  16925. /**
  16926. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  16927. */
  16928. toVector3(): Vector3;
  16929. /**
  16930. * Returns a new Vector4 copied from the current one.
  16931. */
  16932. clone(): Vector4;
  16933. /**
  16934. * Updates the current Vector4 with the given one coordinates.
  16935. * Returns the updated Vector4.
  16936. */
  16937. copyFrom(source: Vector4): Vector4;
  16938. /**
  16939. * Updates the current Vector4 coordinates with the given floats.
  16940. * Returns the updated Vector4.
  16941. */
  16942. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16943. /**
  16944. * Updates the current Vector4 coordinates with the given floats.
  16945. * Returns the updated Vector4.
  16946. */
  16947. set(x: number, y: number, z: number, w: number): Vector4;
  16948. /**
  16949. * Returns a new Vector4 set from the starting index of the given array.
  16950. */
  16951. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  16952. /**
  16953. * Updates the given vector "result" from the starting index of the given array.
  16954. */
  16955. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  16956. /**
  16957. * Updates the given vector "result" from the starting index of the given Float32Array.
  16958. */
  16959. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  16960. /**
  16961. * Updates the given vector "result" coordinates from the given floats.
  16962. */
  16963. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  16964. /**
  16965. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  16966. */
  16967. static Zero(): Vector4;
  16968. /**
  16969. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  16970. */
  16971. static One(): Vector4;
  16972. /**
  16973. * Returns a new normalized Vector4 from the given one.
  16974. */
  16975. static Normalize(vector: Vector4): Vector4;
  16976. /**
  16977. * Updates the given vector "result" from the normalization of the given one.
  16978. */
  16979. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  16980. static Minimize(left: Vector4, right: Vector4): Vector4;
  16981. static Maximize(left: Vector4, right: Vector4): Vector4;
  16982. /**
  16983. * Returns the distance (float) between the vectors "value1" and "value2".
  16984. */
  16985. static Distance(value1: Vector4, value2: Vector4): number;
  16986. /**
  16987. * Returns the squared distance (float) between the vectors "value1" and "value2".
  16988. */
  16989. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  16990. /**
  16991. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  16992. */
  16993. static Center(value1: Vector4, value2: Vector4): Vector4;
  16994. /**
  16995. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  16996. * This methods computes transformed normalized direction vectors only.
  16997. */
  16998. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  16999. /**
  17000. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  17001. * This methods computes transformed normalized direction vectors only.
  17002. */
  17003. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  17004. /**
  17005. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  17006. * This methods computes transformed normalized direction vectors only.
  17007. */
  17008. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  17009. }
  17010. interface ISize {
  17011. width: number;
  17012. height: number;
  17013. }
  17014. class Size implements ISize {
  17015. width: number;
  17016. height: number;
  17017. /**
  17018. * Creates a Size object from the given width and height (floats).
  17019. */
  17020. constructor(width: number, height: number);
  17021. toString(): string;
  17022. /**
  17023. * Returns the string "Size"
  17024. */
  17025. getClassName(): string;
  17026. /**
  17027. * Returns the Size hash code.
  17028. */
  17029. getHashCode(): number;
  17030. /**
  17031. * Updates the current size from the given one.
  17032. * Returns the updated Size.
  17033. */
  17034. copyFrom(src: Size): void;
  17035. /**
  17036. * Updates in place the current Size from the given floats.
  17037. * Returns the updated Size.
  17038. */
  17039. copyFromFloats(width: number, height: number): Size;
  17040. /**
  17041. * Updates in place the current Size from the given floats.
  17042. * Returns the updated Size.
  17043. */
  17044. set(width: number, height: number): Size;
  17045. /**
  17046. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  17047. */
  17048. multiplyByFloats(w: number, h: number): Size;
  17049. /**
  17050. * Returns a new Size copied from the given one.
  17051. */
  17052. clone(): Size;
  17053. /**
  17054. * Boolean : True if the current Size and the given one width and height are strictly equal.
  17055. */
  17056. equals(other: Size): boolean;
  17057. /**
  17058. * Returns the surface of the Size : width * height (float).
  17059. */
  17060. readonly surface: number;
  17061. /**
  17062. * Returns a new Size set to (0.0, 0.0)
  17063. */
  17064. static Zero(): Size;
  17065. /**
  17066. * Returns a new Size set as the addition result of the current Size and the given one.
  17067. */
  17068. add(otherSize: Size): Size;
  17069. /**
  17070. * Returns a new Size set as the subtraction result of the given one from the current Size.
  17071. */
  17072. subtract(otherSize: Size): Size;
  17073. /**
  17074. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  17075. */
  17076. static Lerp(start: Size, end: Size, amount: number): Size;
  17077. }
  17078. /**
  17079. * Class used to store quaternion data
  17080. * @see https://en.wikipedia.org/wiki/Quaternion
  17081. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  17082. */
  17083. class Quaternion {
  17084. /** defines the first component (0 by default) */
  17085. x: number;
  17086. /** defines the second component (0 by default) */
  17087. y: number;
  17088. /** defines the third component (0 by default) */
  17089. z: number;
  17090. /** defines the fourth component (1.0 by default) */
  17091. w: number;
  17092. /**
  17093. * Creates a new Quaternion from the given floats
  17094. * @param x defines the first component (0 by default)
  17095. * @param y defines the second component (0 by default)
  17096. * @param z defines the third component (0 by default)
  17097. * @param w defines the fourth component (1.0 by default)
  17098. */
  17099. constructor(
  17100. /** defines the first component (0 by default) */
  17101. x?: number,
  17102. /** defines the second component (0 by default) */
  17103. y?: number,
  17104. /** defines the third component (0 by default) */
  17105. z?: number,
  17106. /** defines the fourth component (1.0 by default) */
  17107. w?: number);
  17108. /**
  17109. * Gets a string representation for the current quaternion
  17110. * @returns a string with the Quaternion coordinates
  17111. */
  17112. toString(): string;
  17113. /**
  17114. * Gets the class name of the quaternion
  17115. * @returns the string "Quaternion"
  17116. */
  17117. getClassName(): string;
  17118. /**
  17119. * Gets a hash code for this quaternion
  17120. * @returns the quaternion hash code
  17121. */
  17122. getHashCode(): number;
  17123. /**
  17124. * Copy the quaternion to an array
  17125. * @returns a new array populated with 4 elements from the quaternion coordinates
  17126. */
  17127. asArray(): number[];
  17128. /**
  17129. * Check if two quaternions are equals
  17130. * @param otherQuaternion defines the second operand
  17131. * @return true if the current quaternion and the given one coordinates are strictly equals
  17132. */
  17133. equals(otherQuaternion: Quaternion): boolean;
  17134. /**
  17135. * Clone the current quaternion
  17136. * @returns a new quaternion copied from the current one
  17137. */
  17138. clone(): Quaternion;
  17139. /**
  17140. * Copy a quaternion to the current one
  17141. * @param other defines the other quaternion
  17142. * @returns the updated current quaternion
  17143. */
  17144. copyFrom(other: Quaternion): Quaternion;
  17145. /**
  17146. * Updates the current quaternion with the given float coordinates
  17147. * @param x defines the x coordinate
  17148. * @param y defines the y coordinate
  17149. * @param z defines the z coordinate
  17150. * @param w defines the w coordinate
  17151. * @returns the updated current quaternion
  17152. */
  17153. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  17154. /**
  17155. * Updates the current quaternion from the given float coordinates
  17156. * @param x defines the x coordinate
  17157. * @param y defines the y coordinate
  17158. * @param z defines the z coordinate
  17159. * @param w defines the w coordinate
  17160. * @returns the updated current quaternion
  17161. */
  17162. set(x: number, y: number, z: number, w: number): Quaternion;
  17163. /**
  17164. * Adds two quaternions
  17165. * @param other defines the second operand
  17166. * @returns a new quaternion as the addition result of the given one and the current quaternion
  17167. */
  17168. add(other: Quaternion): Quaternion;
  17169. /**
  17170. * Add a quaternion to the current one
  17171. * @param other defines the quaternion to add
  17172. * @returns the current quaternion
  17173. */
  17174. addInPlace(other: Quaternion): Quaternion;
  17175. /**
  17176. * Subtract two quaternions
  17177. * @param other defines the second operand
  17178. * @returns a new quaternion as the subtraction result of the given one from the current one
  17179. */
  17180. subtract(other: Quaternion): Quaternion;
  17181. /**
  17182. * Multiplies the current quaternion by a scale factor
  17183. * @param value defines the scale factor
  17184. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  17185. */
  17186. scale(value: number): Quaternion;
  17187. /**
  17188. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  17189. * @param scale defines the scale factor
  17190. * @param result defines the Quaternion object where to store the result
  17191. * @returns the unmodified current quaternion
  17192. */
  17193. scaleToRef(scale: number, result: Quaternion): Quaternion;
  17194. /**
  17195. * Multiplies in place the current quaternion by a scale factor
  17196. * @param value defines the scale factor
  17197. * @returns the current modified quaternion
  17198. */
  17199. scaleInPlace(value: number): Quaternion;
  17200. /**
  17201. * Scale the current quaternion values by a factor and add the result to a given quaternion
  17202. * @param scale defines the scale factor
  17203. * @param result defines the Quaternion object where to store the result
  17204. * @returns the unmodified current quaternion
  17205. */
  17206. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  17207. /**
  17208. * Multiplies two quaternions
  17209. * @param q1 defines the second operand
  17210. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  17211. */
  17212. multiply(q1: Quaternion): Quaternion;
  17213. /**
  17214. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  17215. * @param q1 defines the second operand
  17216. * @param result defines the target quaternion
  17217. * @returns the current quaternion
  17218. */
  17219. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  17220. /**
  17221. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  17222. * @param q1 defines the second operand
  17223. * @returns the currentupdated quaternion
  17224. */
  17225. multiplyInPlace(q1: Quaternion): Quaternion;
  17226. /**
  17227. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  17228. * @param ref defines the target quaternion
  17229. * @returns the current quaternion
  17230. */
  17231. conjugateToRef(ref: Quaternion): Quaternion;
  17232. /**
  17233. * Conjugates in place (1-q) the current quaternion
  17234. * @returns the current updated quaternion
  17235. */
  17236. conjugateInPlace(): Quaternion;
  17237. /**
  17238. * Conjugates in place (1-q) the current quaternion
  17239. * @returns a new quaternion
  17240. */
  17241. conjugate(): Quaternion;
  17242. /**
  17243. * Gets length of current quaternion
  17244. * @returns the quaternion length (float)
  17245. */
  17246. length(): number;
  17247. /**
  17248. * Normalize in place the current quaternion
  17249. * @returns the current updated quaternion
  17250. */
  17251. normalize(): Quaternion;
  17252. /**
  17253. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  17254. * @param order is a reserved parameter and is ignore for now
  17255. * @returns a new Vector3 containing the Euler angles
  17256. */
  17257. toEulerAngles(order?: string): Vector3;
  17258. /**
  17259. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  17260. * @param result defines the vector which will be filled with the Euler angles
  17261. * @param order is a reserved parameter and is ignore for now
  17262. * @returns the current unchanged quaternion
  17263. */
  17264. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  17265. /**
  17266. * Updates the given rotation matrix with the current quaternion values
  17267. * @param result defines the target matrix
  17268. * @returns the current unchanged quaternion
  17269. */
  17270. toRotationMatrix(result: Matrix): Quaternion;
  17271. /**
  17272. * Updates the current quaternion from the given rotation matrix values
  17273. * @param matrix defines the source matrix
  17274. * @returns the current updated quaternion
  17275. */
  17276. fromRotationMatrix(matrix: Matrix): Quaternion;
  17277. /**
  17278. * Creates a new quaternion from a rotation matrix
  17279. * @param matrix defines the source matrix
  17280. * @returns a new quaternion created from the given rotation matrix values
  17281. */
  17282. static FromRotationMatrix(matrix: Matrix): Quaternion;
  17283. /**
  17284. * Updates the given quaternion with the given rotation matrix values
  17285. * @param matrix defines the source matrix
  17286. * @param result defines the target quaternion
  17287. */
  17288. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  17289. /**
  17290. * Returns the dot product (float) between the quaternions "left" and "right"
  17291. * @param left defines the left operand
  17292. * @param right defines the right operand
  17293. * @returns the dot product
  17294. */
  17295. static Dot(left: Quaternion, right: Quaternion): number;
  17296. /**
  17297. * Checks if the two quaternions are close to each other
  17298. * @param quat0 defines the first quaternion to check
  17299. * @param quat1 defines the second quaternion to check
  17300. * @returns true if the two quaternions are close to each other
  17301. */
  17302. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  17303. /**
  17304. * Creates an empty quaternion
  17305. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  17306. */
  17307. static Zero(): Quaternion;
  17308. /**
  17309. * Inverse a given quaternion
  17310. * @param q defines the source quaternion
  17311. * @returns a new quaternion as the inverted current quaternion
  17312. */
  17313. static Inverse(q: Quaternion): Quaternion;
  17314. /**
  17315. * Creates an identity quaternion
  17316. * @returns the identity quaternion
  17317. */
  17318. static Identity(): Quaternion;
  17319. /**
  17320. * Gets a boolean indicating if the given quaternion is identity
  17321. * @param quaternion defines the quaternion to check
  17322. * @returns true if the quaternion is identity
  17323. */
  17324. static IsIdentity(quaternion: Quaternion): boolean;
  17325. /**
  17326. * Creates a quaternion from a rotation around an axis
  17327. * @param axis defines the axis to use
  17328. * @param angle defines the angle to use
  17329. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  17330. */
  17331. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  17332. /**
  17333. * Creates a rotation around an axis and stores it into the given quaternion
  17334. * @param axis defines the axis to use
  17335. * @param angle defines the angle to use
  17336. * @param result defines the target quaternion
  17337. * @returns the target quaternion
  17338. */
  17339. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  17340. /**
  17341. * Creates a new quaternion from data stored into an array
  17342. * @param array defines the data source
  17343. * @param offset defines the offset in the source array where the data starts
  17344. * @returns a new quaternion
  17345. */
  17346. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  17347. /**
  17348. * Creates a new quaternion from the given Euler float angles (y, x, z)
  17349. * @param yaw defines the rotation around Y axis
  17350. * @param pitch defines the rotation around X axis
  17351. * @param roll defines the rotation around Z axis
  17352. * @returns the new quaternion
  17353. */
  17354. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  17355. /**
  17356. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  17357. * @param yaw defines the rotation around Y axis
  17358. * @param pitch defines the rotation around X axis
  17359. * @param roll defines the rotation around Z axis
  17360. * @param result defines the target quaternion
  17361. */
  17362. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  17363. /**
  17364. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  17365. * @param alpha defines the rotation around first axis
  17366. * @param beta defines the rotation around second axis
  17367. * @param gamma defines the rotation around third axis
  17368. * @returns the new quaternion
  17369. */
  17370. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  17371. /**
  17372. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  17373. * @param alpha defines the rotation around first axis
  17374. * @param beta defines the rotation around second axis
  17375. * @param gamma defines the rotation around third axis
  17376. * @param result defines the target quaternion
  17377. */
  17378. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  17379. /**
  17380. * 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)
  17381. * @param axis1 defines the first axis
  17382. * @param axis2 defines the second axis
  17383. * @param axis3 defines the third axis
  17384. * @returns the new quaternion
  17385. */
  17386. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  17387. /**
  17388. * 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
  17389. * @param axis1 defines the first axis
  17390. * @param axis2 defines the second axis
  17391. * @param axis3 defines the third axis
  17392. * @param ref defines the target quaternion
  17393. */
  17394. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  17395. /**
  17396. * Interpolates between two quaternions
  17397. * @param left defines first quaternion
  17398. * @param right defines second quaternion
  17399. * @param amount defines the gradient to use
  17400. * @returns the new interpolated quaternion
  17401. */
  17402. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  17403. /**
  17404. * Interpolates between two quaternions and stores it into a target quaternion
  17405. * @param left defines first quaternion
  17406. * @param right defines second quaternion
  17407. * @param amount defines the gradient to use
  17408. * @param result defines the target quaternion
  17409. */
  17410. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  17411. /**
  17412. * Interpolate between two quaternions using Hermite interpolation
  17413. * @param value1 defines first quaternion
  17414. * @param tangent1 defines the incoming tangent
  17415. * @param value2 defines second quaternion
  17416. * @param tangent2 defines the outgoing tangent
  17417. * @param amount defines the target quaternion
  17418. * @returns the new interpolated quaternion
  17419. */
  17420. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  17421. }
  17422. /**
  17423. * Class used to store matrix data (4x4)
  17424. */
  17425. class Matrix {
  17426. private static _tempQuaternion;
  17427. private static _xAxis;
  17428. private static _yAxis;
  17429. private static _zAxis;
  17430. private static _updateFlagSeed;
  17431. private static _identityReadOnly;
  17432. private _isIdentity;
  17433. private _isIdentityDirty;
  17434. /**
  17435. * Gets the update flag of the matrix which is an unique number for the matrix.
  17436. * It will be incremented every time the matrix data change.
  17437. * You can use it to speed the comparison between two versions of the same matrix.
  17438. */
  17439. updateFlag: number;
  17440. /**
  17441. * Gets or sets the internal data of the matrix
  17442. */
  17443. m: Float32Array;
  17444. /** @hidden */
  17445. _markAsUpdated(): void;
  17446. /**
  17447. * Creates an empty matrix (filled with zeros)
  17448. */
  17449. constructor();
  17450. /**
  17451. * Check if the current matrix is indentity
  17452. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  17453. * @returns true is the matrix is the identity matrix
  17454. */
  17455. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  17456. /**
  17457. * Gets the determinant of the matrix
  17458. * @returns the matrix determinant
  17459. */
  17460. determinant(): number;
  17461. /**
  17462. * Returns the matrix as a Float32Array
  17463. * @returns the matrix underlying array
  17464. */
  17465. toArray(): Float32Array;
  17466. /**
  17467. * Returns the matrix as a Float32Array
  17468. * @returns the matrix underlying array.
  17469. */
  17470. asArray(): Float32Array;
  17471. /**
  17472. * Inverts the current matrix in place
  17473. * @returns the current inverted matrix
  17474. */
  17475. invert(): Matrix;
  17476. /**
  17477. * Sets all the matrix elements to zero
  17478. * @returns the current matrix
  17479. */
  17480. reset(): Matrix;
  17481. /**
  17482. * Adds the current matrix with a second one
  17483. * @param other defines the matrix to add
  17484. * @returns a new matrix as the addition of the current matrix and the given one
  17485. */
  17486. add(other: Matrix): Matrix;
  17487. /**
  17488. * Sets the given matrix "result" to the addition of the current matrix and the given one
  17489. * @param other defines the matrix to add
  17490. * @param result defines the target matrix
  17491. * @returns the current matrix
  17492. */
  17493. addToRef(other: Matrix, result: Matrix): Matrix;
  17494. /**
  17495. * Adds in place the given matrix to the current matrix
  17496. * @param other defines the second operand
  17497. * @returns the current updated matrix
  17498. */
  17499. addToSelf(other: Matrix): Matrix;
  17500. /**
  17501. * Sets the given matrix to the current inverted Matrix
  17502. * @param other defines the target matrix
  17503. * @returns the unmodified current matrix
  17504. */
  17505. invertToRef(other: Matrix): Matrix;
  17506. /**
  17507. * Inserts the translation vector (using 3 floats) in the current matrix
  17508. * @param x defines the 1st component of the translation
  17509. * @param y defines the 2nd component of the translation
  17510. * @param z defines the 3rd component of the translation
  17511. * @returns the current updated matrix
  17512. */
  17513. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  17514. /**
  17515. * Inserts the translation vector in the current matrix
  17516. * @param vector3 defines the translation to insert
  17517. * @returns the current updated matrix
  17518. */
  17519. setTranslation(vector3: Vector3): Matrix;
  17520. /**
  17521. * Gets the translation value of the current matrix
  17522. * @returns a new Vector3 as the extracted translation from the matrix
  17523. */
  17524. getTranslation(): Vector3;
  17525. /**
  17526. * Fill a Vector3 with the extracted translation from the matrix
  17527. * @param result defines the Vector3 where to store the translation
  17528. * @returns the current matrix
  17529. */
  17530. getTranslationToRef(result: Vector3): Matrix;
  17531. /**
  17532. * Remove rotation and scaling part from the matrix
  17533. * @returns the updated matrix
  17534. */
  17535. removeRotationAndScaling(): Matrix;
  17536. /**
  17537. * Multiply two matrices
  17538. * @param other defines the second operand
  17539. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  17540. */
  17541. multiply(other: Matrix): Matrix;
  17542. /**
  17543. * Copy the current matrix from the given one
  17544. * @param other defines the source matrix
  17545. * @returns the current updated matrix
  17546. */
  17547. copyFrom(other: Matrix): Matrix;
  17548. /**
  17549. * Populates the given array from the starting index with the current matrix values
  17550. * @param array defines the target array
  17551. * @param offset defines the offset in the target array where to start storing values
  17552. * @returns the current matrix
  17553. */
  17554. copyToArray(array: Float32Array, offset?: number): Matrix;
  17555. /**
  17556. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  17557. * @param other defines the second operand
  17558. * @param result defines the matrix where to store the multiplication
  17559. * @returns the current matrix
  17560. */
  17561. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  17562. /**
  17563. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  17564. * @param other defines the second operand
  17565. * @param result defines the array where to store the multiplication
  17566. * @param offset defines the offset in the target array where to start storing values
  17567. * @returns the current matrix
  17568. */
  17569. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  17570. /**
  17571. * Check equality between this matrix and a second one
  17572. * @param value defines the second matrix to compare
  17573. * @returns true is the current matrix and the given one values are strictly equal
  17574. */
  17575. equals(value: Matrix): boolean;
  17576. /**
  17577. * Clone the current matrix
  17578. * @returns a new matrix from the current matrix
  17579. */
  17580. clone(): Matrix;
  17581. /**
  17582. * Returns the name of the current matrix class
  17583. * @returns the string "Matrix"
  17584. */
  17585. getClassName(): string;
  17586. /**
  17587. * Gets the hash code of the current matrix
  17588. * @returns the hash code
  17589. */
  17590. getHashCode(): number;
  17591. /**
  17592. * Decomposes the current Matrix into a translation, rotation and scaling components
  17593. * @param scale defines the scale vector3 given as a reference to update
  17594. * @param rotation defines the rotation quaternion given as a reference to update
  17595. * @param translation defines the translation vector3 given as a reference to update
  17596. * @returns true if operation was successful
  17597. */
  17598. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  17599. /**
  17600. * Gets specific row of the matrix
  17601. * @param index defines the number of the row to get
  17602. * @returns the index-th row of the current matrix as a new Vector4
  17603. */
  17604. getRow(index: number): Nullable<Vector4>;
  17605. /**
  17606. * Sets the index-th row of the current matrix to the vector4 values
  17607. * @param index defines the number of the row to set
  17608. * @param row defines the target vector4
  17609. * @returns the updated current matrix
  17610. */
  17611. setRow(index: number, row: Vector4): Matrix;
  17612. /**
  17613. * Compute the transpose of the matrix
  17614. * @returns the new transposed matrix
  17615. */
  17616. transpose(): Matrix;
  17617. /**
  17618. * Compute the transpose of the matrix and store it in a given matrix
  17619. * @param result defines the target matrix
  17620. * @returns the current matrix
  17621. */
  17622. transposeToRef(result: Matrix): Matrix;
  17623. /**
  17624. * Sets the index-th row of the current matrix with the given 4 x float values
  17625. * @param index defines the row index
  17626. * @param x defines the x component to set
  17627. * @param y defines the y component to set
  17628. * @param z defines the z component to set
  17629. * @param w defines the w component to set
  17630. * @returns the updated current matrix
  17631. */
  17632. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  17633. /**
  17634. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  17635. * @param scale defines the scale factor
  17636. * @returns a new matrix
  17637. */
  17638. scale(scale: number): Matrix;
  17639. /**
  17640. * Scale the current matrix values by a factor to a given result matrix
  17641. * @param scale defines the scale factor
  17642. * @param result defines the matrix to store the result
  17643. * @returns the current matrix
  17644. */
  17645. scaleToRef(scale: number, result: Matrix): Matrix;
  17646. /**
  17647. * Scale the current matrix values by a factor and add the result to a given matrix
  17648. * @param scale defines the scale factor
  17649. * @param result defines the Matrix to store the result
  17650. * @returns the current matrix
  17651. */
  17652. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  17653. /**
  17654. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  17655. * @param ref matrix to store the result
  17656. */
  17657. toNormalMatrix(ref: Matrix): void;
  17658. /**
  17659. * Gets only rotation part of the current matrix
  17660. * @returns a new matrix sets to the extracted rotation matrix from the current one
  17661. */
  17662. getRotationMatrix(): Matrix;
  17663. /**
  17664. * Extracts the rotation matrix from the current one and sets it as the given "result"
  17665. * @param result defines the target matrix to store data to
  17666. * @returns the current matrix
  17667. */
  17668. getRotationMatrixToRef(result: Matrix): Matrix;
  17669. /**
  17670. * Creates a matrix from an array
  17671. * @param array defines the source array
  17672. * @param offset defines an offset in the source array
  17673. * @returns a new Matrix set from the starting index of the given array
  17674. */
  17675. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  17676. /**
  17677. * Copy the content of an array into a given matrix
  17678. * @param array defines the source array
  17679. * @param offset defines an offset in the source array
  17680. * @param result defines the target matrix
  17681. */
  17682. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  17683. /**
  17684. * Stores an array into a matrix after having multiplied each component by a given factor
  17685. * @param array defines the source array
  17686. * @param offset defines the offset in the source array
  17687. * @param scale defines the scaling factor
  17688. * @param result defines the target matrix
  17689. */
  17690. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  17691. /**
  17692. * Stores a list of values (16) inside a given matrix
  17693. * @param initialM11 defines 1st value of 1st row
  17694. * @param initialM12 defines 2nd value of 1st row
  17695. * @param initialM13 defines 3rd value of 1st row
  17696. * @param initialM14 defines 4th value of 1st row
  17697. * @param initialM21 defines 1st value of 2nd row
  17698. * @param initialM22 defines 2nd value of 2nd row
  17699. * @param initialM23 defines 3rd value of 2nd row
  17700. * @param initialM24 defines 4th value of 2nd row
  17701. * @param initialM31 defines 1st value of 3rd row
  17702. * @param initialM32 defines 2nd value of 3rd row
  17703. * @param initialM33 defines 3rd value of 3rd row
  17704. * @param initialM34 defines 4th value of 3rd row
  17705. * @param initialM41 defines 1st value of 4th row
  17706. * @param initialM42 defines 2nd value of 4th row
  17707. * @param initialM43 defines 3rd value of 4th row
  17708. * @param initialM44 defines 4th value of 4th row
  17709. * @param result defines the target matrix
  17710. */
  17711. 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;
  17712. /**
  17713. * Gets an identity matrix that must not be updated
  17714. */
  17715. static readonly IdentityReadOnly: Matrix;
  17716. /**
  17717. * Creates new matrix from a list of values (16)
  17718. * @param initialM11 defines 1st value of 1st row
  17719. * @param initialM12 defines 2nd value of 1st row
  17720. * @param initialM13 defines 3rd value of 1st row
  17721. * @param initialM14 defines 4th value of 1st row
  17722. * @param initialM21 defines 1st value of 2nd row
  17723. * @param initialM22 defines 2nd value of 2nd row
  17724. * @param initialM23 defines 3rd value of 2nd row
  17725. * @param initialM24 defines 4th value of 2nd row
  17726. * @param initialM31 defines 1st value of 3rd row
  17727. * @param initialM32 defines 2nd value of 3rd row
  17728. * @param initialM33 defines 3rd value of 3rd row
  17729. * @param initialM34 defines 4th value of 3rd row
  17730. * @param initialM41 defines 1st value of 4th row
  17731. * @param initialM42 defines 2nd value of 4th row
  17732. * @param initialM43 defines 3rd value of 4th row
  17733. * @param initialM44 defines 4th value of 4th row
  17734. * @returns the new matrix
  17735. */
  17736. 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;
  17737. /**
  17738. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17739. * @param scale defines the scale vector3
  17740. * @param rotation defines the rotation quaternion
  17741. * @param translation defines the translation vector3
  17742. * @returns a new matrix
  17743. */
  17744. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  17745. /**
  17746. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17747. * @param scale defines the scale vector3
  17748. * @param rotation defines the rotation quaternion
  17749. * @param translation defines the translation vector3
  17750. * @param result defines the target matrix
  17751. */
  17752. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  17753. /**
  17754. * Creates a new identity matrix
  17755. * @returns a new identity matrix
  17756. */
  17757. static Identity(): Matrix;
  17758. /**
  17759. * Creates a new identity matrix and stores the result in a given matrix
  17760. * @param result defines the target matrix
  17761. */
  17762. static IdentityToRef(result: Matrix): void;
  17763. /**
  17764. * Creates a new zero matrix
  17765. * @returns a new zero matrix
  17766. */
  17767. static Zero(): Matrix;
  17768. /**
  17769. * Creates a new rotation matrix for "angle" radians around the X axis
  17770. * @param angle defines the angle (in radians) to use
  17771. * @return the new matrix
  17772. */
  17773. static RotationX(angle: number): Matrix;
  17774. /**
  17775. * Creates a new matrix as the invert of a given matrix
  17776. * @param source defines the source matrix
  17777. * @returns the new matrix
  17778. */
  17779. static Invert(source: Matrix): Matrix;
  17780. /**
  17781. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  17782. * @param angle defines the angle (in radians) to use
  17783. * @param result defines the target matrix
  17784. */
  17785. static RotationXToRef(angle: number, result: Matrix): void;
  17786. /**
  17787. * Creates a new rotation matrix for "angle" radians around the Y axis
  17788. * @param angle defines the angle (in radians) to use
  17789. * @return the new matrix
  17790. */
  17791. static RotationY(angle: number): Matrix;
  17792. /**
  17793. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  17794. * @param angle defines the angle (in radians) to use
  17795. * @param result defines the target matrix
  17796. */
  17797. static RotationYToRef(angle: number, result: Matrix): void;
  17798. /**
  17799. * Creates a new rotation matrix for "angle" radians around the Z axis
  17800. * @param angle defines the angle (in radians) to use
  17801. * @return the new matrix
  17802. */
  17803. static RotationZ(angle: number): Matrix;
  17804. /**
  17805. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  17806. * @param angle defines the angle (in radians) to use
  17807. * @param result defines the target matrix
  17808. */
  17809. static RotationZToRef(angle: number, result: Matrix): void;
  17810. /**
  17811. * Creates a new rotation matrix for "angle" radians around the given axis
  17812. * @param axis defines the axis to use
  17813. * @param angle defines the angle (in radians) to use
  17814. * @return the new matrix
  17815. */
  17816. static RotationAxis(axis: Vector3, angle: number): Matrix;
  17817. /**
  17818. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  17819. * @param axis defines the axis to use
  17820. * @param angle defines the angle (in radians) to use
  17821. * @param result defines the target matrix
  17822. */
  17823. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  17824. /**
  17825. * Creates a rotation matrix
  17826. * @param yaw defines the yaw angle in radians (Y axis)
  17827. * @param pitch defines the pitch angle in radians (X axis)
  17828. * @param roll defines the roll angle in radians (X axis)
  17829. * @returns the new rotation matrix
  17830. */
  17831. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  17832. /**
  17833. * Creates a rotation matrix and stores it in a given matrix
  17834. * @param yaw defines the yaw angle in radians (Y axis)
  17835. * @param pitch defines the pitch angle in radians (X axis)
  17836. * @param roll defines the roll angle in radians (X axis)
  17837. * @param result defines the target matrix
  17838. */
  17839. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  17840. /**
  17841. * Creates a scaling matrix
  17842. * @param x defines the scale factor on X axis
  17843. * @param y defines the scale factor on Y axis
  17844. * @param z defines the scale factor on Z axis
  17845. * @returns the new matrix
  17846. */
  17847. static Scaling(x: number, y: number, z: number): Matrix;
  17848. /**
  17849. * Creates a scaling matrix and stores it in a given matrix
  17850. * @param x defines the scale factor on X axis
  17851. * @param y defines the scale factor on Y axis
  17852. * @param z defines the scale factor on Z axis
  17853. * @param result defines the target matrix
  17854. */
  17855. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  17856. /**
  17857. * Creates a translation matrix
  17858. * @param x defines the translation on X axis
  17859. * @param y defines the translation on Y axis
  17860. * @param z defines the translationon Z axis
  17861. * @returns the new matrix
  17862. */
  17863. static Translation(x: number, y: number, z: number): Matrix;
  17864. /**
  17865. * Creates a translation matrix and stores it in a given matrix
  17866. * @param x defines the translation on X axis
  17867. * @param y defines the translation on Y axis
  17868. * @param z defines the translationon Z axis
  17869. * @param result defines the target matrix
  17870. */
  17871. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  17872. /**
  17873. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17874. * @param startValue defines the start value
  17875. * @param endValue defines the end value
  17876. * @param gradient defines the gradient factor
  17877. * @returns the new matrix
  17878. */
  17879. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17880. /**
  17881. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17882. * @param startValue defines the start value
  17883. * @param endValue defines the end value
  17884. * @param gradient defines the gradient factor
  17885. * @param result defines the Matrix object where to store data
  17886. */
  17887. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17888. /**
  17889. * Builds a new matrix whose values are computed by:
  17890. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17891. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17892. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17893. * @param startValue defines the first matrix
  17894. * @param endValue defines the second matrix
  17895. * @param gradient defines the gradient between the two matrices
  17896. * @returns the new matrix
  17897. */
  17898. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17899. /**
  17900. * Update a matrix to values which are computed by:
  17901. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17902. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17903. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17904. * @param startValue defines the first matrix
  17905. * @param endValue defines the second matrix
  17906. * @param gradient defines the gradient between the two matrices
  17907. * @param result defines the target matrix
  17908. */
  17909. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17910. /**
  17911. * 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"
  17912. * This function works in left handed mode
  17913. * @param eye defines the final position of the entity
  17914. * @param target defines where the entity should look at
  17915. * @param up defines the up vector for the entity
  17916. * @returns the new matrix
  17917. */
  17918. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17919. /**
  17920. * 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".
  17921. * This function works in left handed mode
  17922. * @param eye defines the final position of the entity
  17923. * @param target defines where the entity should look at
  17924. * @param up defines the up vector for the entity
  17925. * @param result defines the target matrix
  17926. */
  17927. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17928. /**
  17929. * 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"
  17930. * This function works in right handed mode
  17931. * @param eye defines the final position of the entity
  17932. * @param target defines where the entity should look at
  17933. * @param up defines the up vector for the entity
  17934. * @returns the new matrix
  17935. */
  17936. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17937. /**
  17938. * 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".
  17939. * This function works in right handed mode
  17940. * @param eye defines the final position of the entity
  17941. * @param target defines where the entity should look at
  17942. * @param up defines the up vector for the entity
  17943. * @param result defines the target matrix
  17944. */
  17945. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17946. /**
  17947. * Create a left-handed orthographic projection matrix
  17948. * @param width defines the viewport width
  17949. * @param height defines the viewport height
  17950. * @param znear defines the near clip plane
  17951. * @param zfar defines the far clip plane
  17952. * @returns a new matrix as a left-handed orthographic projection matrix
  17953. */
  17954. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17955. /**
  17956. * Store a left-handed orthographic projection to a given matrix
  17957. * @param width defines the viewport width
  17958. * @param height defines the viewport height
  17959. * @param znear defines the near clip plane
  17960. * @param zfar defines the far clip plane
  17961. * @param result defines the target matrix
  17962. */
  17963. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  17964. /**
  17965. * Create a left-handed orthographic projection matrix
  17966. * @param left defines the viewport left coordinate
  17967. * @param right defines the viewport right coordinate
  17968. * @param bottom defines the viewport bottom coordinate
  17969. * @param top defines the viewport top coordinate
  17970. * @param znear defines the near clip plane
  17971. * @param zfar defines the far clip plane
  17972. * @returns a new matrix as a left-handed orthographic projection matrix
  17973. */
  17974. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17975. /**
  17976. * Stores a left-handed orthographic projection into a given matrix
  17977. * @param left defines the viewport left coordinate
  17978. * @param right defines the viewport right coordinate
  17979. * @param bottom defines the viewport bottom coordinate
  17980. * @param top defines the viewport top coordinate
  17981. * @param znear defines the near clip plane
  17982. * @param zfar defines the far clip plane
  17983. * @param result defines the target matrix
  17984. */
  17985. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17986. /**
  17987. * Creates a right-handed orthographic projection matrix
  17988. * @param left defines the viewport left coordinate
  17989. * @param right defines the viewport right coordinate
  17990. * @param bottom defines the viewport bottom coordinate
  17991. * @param top defines the viewport top coordinate
  17992. * @param znear defines the near clip plane
  17993. * @param zfar defines the far clip plane
  17994. * @returns a new matrix as a right-handed orthographic projection matrix
  17995. */
  17996. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17997. /**
  17998. * Stores a right-handed orthographic projection into a given matrix
  17999. * @param left defines the viewport left coordinate
  18000. * @param right defines the viewport right coordinate
  18001. * @param bottom defines the viewport bottom coordinate
  18002. * @param top defines the viewport top coordinate
  18003. * @param znear defines the near clip plane
  18004. * @param zfar defines the far clip plane
  18005. * @param result defines the target matrix
  18006. */
  18007. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18008. /**
  18009. * Creates a left-handed perspective projection matrix
  18010. * @param width defines the viewport width
  18011. * @param height defines the viewport height
  18012. * @param znear defines the near clip plane
  18013. * @param zfar defines the far clip plane
  18014. * @returns a new matrix as a left-handed perspective projection matrix
  18015. */
  18016. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18017. /**
  18018. * Creates a left-handed perspective projection matrix
  18019. * @param fov defines the horizontal field of view
  18020. * @param aspect defines the aspect ratio
  18021. * @param znear defines the near clip plane
  18022. * @param zfar defines the far clip plane
  18023. * @returns a new matrix as a left-handed perspective projection matrix
  18024. */
  18025. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18026. /**
  18027. * Stores a left-handed perspective projection into a given matrix
  18028. * @param fov defines the horizontal field of view
  18029. * @param aspect defines the aspect ratio
  18030. * @param znear defines the near clip plane
  18031. * @param zfar defines the far clip plane
  18032. * @param result defines the target matrix
  18033. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18034. */
  18035. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18036. /**
  18037. * Creates a right-handed perspective projection matrix
  18038. * @param fov defines the horizontal field of view
  18039. * @param aspect defines the aspect ratio
  18040. * @param znear defines the near clip plane
  18041. * @param zfar defines the far clip plane
  18042. * @returns a new matrix as a right-handed perspective projection matrix
  18043. */
  18044. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18045. /**
  18046. * Stores a right-handed perspective projection into a given matrix
  18047. * @param fov defines the horizontal field of view
  18048. * @param aspect defines the aspect ratio
  18049. * @param znear defines the near clip plane
  18050. * @param zfar defines the far clip plane
  18051. * @param result defines the target matrix
  18052. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18053. */
  18054. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18055. /**
  18056. * Stores a perspective projection for WebVR info a given matrix
  18057. * @param fov defines the field of view
  18058. * @param znear defines the near clip plane
  18059. * @param zfar defines the far clip plane
  18060. * @param result defines the target matrix
  18061. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  18062. */
  18063. static PerspectiveFovWebVRToRef(fov: {
  18064. upDegrees: number;
  18065. downDegrees: number;
  18066. leftDegrees: number;
  18067. rightDegrees: number;
  18068. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  18069. /**
  18070. * Computes a complete transformation matrix
  18071. * @param viewport defines the viewport to use
  18072. * @param world defines the world matrix
  18073. * @param view defines the view matrix
  18074. * @param projection defines the projection matrix
  18075. * @param zmin defines the near clip plane
  18076. * @param zmax defines the far clip plane
  18077. * @returns the transformation matrix
  18078. */
  18079. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  18080. /**
  18081. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  18082. * @param matrix defines the matrix to use
  18083. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  18084. */
  18085. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  18086. /**
  18087. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  18088. * @param matrix defines the matrix to use
  18089. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  18090. */
  18091. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  18092. /**
  18093. * Compute the transpose of a given matrix
  18094. * @param matrix defines the matrix to transpose
  18095. * @returns the new matrix
  18096. */
  18097. static Transpose(matrix: Matrix): Matrix;
  18098. /**
  18099. * Compute the transpose of a matrix and store it in a target matrix
  18100. * @param matrix defines the matrix to transpose
  18101. * @param result defines the target matrix
  18102. */
  18103. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  18104. /**
  18105. * Computes a reflection matrix from a plane
  18106. * @param plane defines the reflection plane
  18107. * @returns a new matrix
  18108. */
  18109. static Reflection(plane: Plane): Matrix;
  18110. /**
  18111. * Computes a reflection matrix from a plane
  18112. * @param plane defines the reflection plane
  18113. * @param result defines the target matrix
  18114. */
  18115. static ReflectionToRef(plane: Plane, result: Matrix): void;
  18116. /**
  18117. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  18118. * @param xaxis defines the value of the 1st axis
  18119. * @param yaxis defines the value of the 2nd axis
  18120. * @param zaxis defines the value of the 3rd axis
  18121. * @param result defines the target matrix
  18122. */
  18123. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  18124. /**
  18125. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  18126. * @param quat defines the quaternion to use
  18127. * @param result defines the target matrix
  18128. */
  18129. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  18130. }
  18131. class Plane {
  18132. normal: Vector3;
  18133. d: number;
  18134. /**
  18135. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  18136. */
  18137. constructor(a: number, b: number, c: number, d: number);
  18138. /**
  18139. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  18140. */
  18141. asArray(): number[];
  18142. /**
  18143. * Returns a new plane copied from the current Plane.
  18144. */
  18145. clone(): Plane;
  18146. /**
  18147. * Returns the string "Plane".
  18148. */
  18149. getClassName(): string;
  18150. /**
  18151. * Returns the Plane hash code.
  18152. */
  18153. getHashCode(): number;
  18154. /**
  18155. * Normalize the current Plane in place.
  18156. * Returns the updated Plane.
  18157. */
  18158. normalize(): Plane;
  18159. /**
  18160. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  18161. */
  18162. transform(transformation: Matrix): Plane;
  18163. /**
  18164. * Returns the dot product (float) of the point coordinates and the plane normal.
  18165. */
  18166. dotCoordinate(point: Vector3): number;
  18167. /**
  18168. * Updates the current Plane from the plane defined by the three given points.
  18169. * Returns the updated Plane.
  18170. */
  18171. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18172. /**
  18173. * Boolean : True is the vector "direction" is the same side than the plane normal.
  18174. */
  18175. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  18176. /**
  18177. * Returns the signed distance (float) from the given point to the Plane.
  18178. */
  18179. signedDistanceTo(point: Vector3): number;
  18180. /**
  18181. * Returns a new Plane from the given array.
  18182. */
  18183. static FromArray(array: ArrayLike<number>): Plane;
  18184. /**
  18185. * Returns a new Plane defined by the three given points.
  18186. */
  18187. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18188. /**
  18189. * Returns a new Plane the normal vector to this plane at the given origin point.
  18190. * Note : the vector "normal" is updated because normalized.
  18191. */
  18192. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  18193. /**
  18194. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  18195. */
  18196. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  18197. }
  18198. class Viewport {
  18199. x: number;
  18200. y: number;
  18201. width: number;
  18202. height: number;
  18203. /**
  18204. * Creates a Viewport object located at (x, y) and sized (width, height).
  18205. */
  18206. constructor(x: number, y: number, width: number, height: number);
  18207. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  18208. /**
  18209. * Returns a new Viewport copied from the current one.
  18210. */
  18211. clone(): Viewport;
  18212. }
  18213. class Frustum {
  18214. /**
  18215. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  18216. */
  18217. static GetPlanes(transform: Matrix): Plane[];
  18218. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18219. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18220. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18221. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18222. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18223. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18224. /**
  18225. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  18226. */
  18227. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  18228. }
  18229. /** Defines supported spaces */
  18230. enum Space {
  18231. /** Local (object) space */
  18232. LOCAL = 0,
  18233. /** World space */
  18234. WORLD = 1,
  18235. /** Bone space */
  18236. BONE = 2,
  18237. }
  18238. /** Defines the 3 main axes */
  18239. class Axis {
  18240. /** X axis */
  18241. static X: Vector3;
  18242. /** Y axis */
  18243. static Y: Vector3;
  18244. /** Z axis */
  18245. static Z: Vector3;
  18246. }
  18247. class BezierCurve {
  18248. /**
  18249. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  18250. */
  18251. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  18252. }
  18253. /**
  18254. * Defines potential orientation for back face culling
  18255. */
  18256. enum Orientation {
  18257. /**
  18258. * Clockwise
  18259. */
  18260. CW = 0,
  18261. /** Counter clockwise */
  18262. CCW = 1,
  18263. }
  18264. /**
  18265. * Defines angle representation
  18266. */
  18267. class Angle {
  18268. private _radians;
  18269. /**
  18270. * Creates an Angle object of "radians" radians (float).
  18271. */
  18272. constructor(radians: number);
  18273. /**
  18274. * Get value in degrees
  18275. * @returns the Angle value in degrees (float)
  18276. */
  18277. degrees(): number;
  18278. /**
  18279. * Get value in radians
  18280. * @returns the Angle value in radians (float)
  18281. */
  18282. radians(): number;
  18283. /**
  18284. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  18285. * @param a defines first vector
  18286. * @param b defines second vector
  18287. * @returns a new Angle
  18288. */
  18289. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  18290. /**
  18291. * Gets a new Angle object from the given float in radians
  18292. * @param radians defines the angle value in radians
  18293. * @returns a new Angle
  18294. */
  18295. static FromRadians(radians: number): Angle;
  18296. /**
  18297. * Gets a new Angle object from the given float in degrees
  18298. * @param degrees defines the angle value in degrees
  18299. * @returns a new Angle
  18300. */
  18301. static FromDegrees(degrees: number): Angle;
  18302. }
  18303. class Arc2 {
  18304. startPoint: Vector2;
  18305. midPoint: Vector2;
  18306. endPoint: Vector2;
  18307. centerPoint: Vector2;
  18308. radius: number;
  18309. angle: Angle;
  18310. startAngle: Angle;
  18311. orientation: Orientation;
  18312. /**
  18313. * Creates an Arc object from the three given points : start, middle and end.
  18314. */
  18315. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  18316. }
  18317. class Path2 {
  18318. private _points;
  18319. private _length;
  18320. closed: boolean;
  18321. /**
  18322. * Creates a Path2 object from the starting 2D coordinates x and y.
  18323. */
  18324. constructor(x: number, y: number);
  18325. /**
  18326. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  18327. * Returns the updated Path2.
  18328. */
  18329. addLineTo(x: number, y: number): Path2;
  18330. /**
  18331. * 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.
  18332. * Returns the updated Path2.
  18333. */
  18334. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  18335. /**
  18336. * Closes the Path2.
  18337. * Returns the Path2.
  18338. */
  18339. close(): Path2;
  18340. /**
  18341. * Returns the Path2 total length (float).
  18342. */
  18343. length(): number;
  18344. /**
  18345. * Returns the Path2 internal array of points.
  18346. */
  18347. getPoints(): Vector2[];
  18348. /**
  18349. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  18350. */
  18351. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  18352. /**
  18353. * Returns a new Path2 starting at the coordinates (x, y).
  18354. */
  18355. static StartingAt(x: number, y: number): Path2;
  18356. }
  18357. class Path3D {
  18358. path: Vector3[];
  18359. private _curve;
  18360. private _distances;
  18361. private _tangents;
  18362. private _normals;
  18363. private _binormals;
  18364. private _raw;
  18365. /**
  18366. * new Path3D(path, normal, raw)
  18367. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  18368. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  18369. * path : an array of Vector3, the curve axis of the Path3D
  18370. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  18371. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  18372. */
  18373. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  18374. /**
  18375. * Returns the Path3D array of successive Vector3 designing its curve.
  18376. */
  18377. getCurve(): Vector3[];
  18378. /**
  18379. * Returns an array populated with tangent vectors on each Path3D curve point.
  18380. */
  18381. getTangents(): Vector3[];
  18382. /**
  18383. * Returns an array populated with normal vectors on each Path3D curve point.
  18384. */
  18385. getNormals(): Vector3[];
  18386. /**
  18387. * Returns an array populated with binormal vectors on each Path3D curve point.
  18388. */
  18389. getBinormals(): Vector3[];
  18390. /**
  18391. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  18392. */
  18393. getDistances(): number[];
  18394. /**
  18395. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  18396. * Returns the same object updated.
  18397. */
  18398. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  18399. private _compute(firstNormal);
  18400. private _getFirstNonNullVector(index);
  18401. private _getLastNonNullVector(index);
  18402. private _normalVector(v0, vt, va);
  18403. }
  18404. class Curve3 {
  18405. private _points;
  18406. private _length;
  18407. /**
  18408. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  18409. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  18410. * @param v1 (Vector3) the control point
  18411. * @param v2 (Vector3) the end point of the Quadratic Bezier
  18412. * @param nbPoints (integer) the wanted number of points in the curve
  18413. */
  18414. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  18415. /**
  18416. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  18417. * @param v0 (Vector3) the origin point of the Cubic Bezier
  18418. * @param v1 (Vector3) the first control point
  18419. * @param v2 (Vector3) the second control point
  18420. * @param v3 (Vector3) the end point of the Cubic Bezier
  18421. * @param nbPoints (integer) the wanted number of points in the curve
  18422. */
  18423. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  18424. /**
  18425. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  18426. * @param p1 (Vector3) the origin point of the Hermite Spline
  18427. * @param t1 (Vector3) the tangent vector at the origin point
  18428. * @param p2 (Vector3) the end point of the Hermite Spline
  18429. * @param t2 (Vector3) the tangent vector at the end point
  18430. * @param nbPoints (integer) the wanted number of points in the curve
  18431. */
  18432. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  18433. /**
  18434. * Returns a Curve3 object along a CatmullRom Spline curve :
  18435. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  18436. * @param nbPoints (integer) the wanted number of points between each curve control points
  18437. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  18438. */
  18439. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  18440. /**
  18441. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  18442. * A Curve3 is designed from a series of successive Vector3.
  18443. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  18444. */
  18445. constructor(points: Vector3[]);
  18446. /**
  18447. * Returns the Curve3 stored array of successive Vector3
  18448. */
  18449. getPoints(): Vector3[];
  18450. /**
  18451. * Returns the computed length (float) of the curve.
  18452. */
  18453. length(): number;
  18454. /**
  18455. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  18456. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  18457. * curveA and curveB keep unchanged.
  18458. */
  18459. continue(curve: Curve3): Curve3;
  18460. private _computeLength(path);
  18461. }
  18462. class PositionNormalVertex {
  18463. position: Vector3;
  18464. normal: Vector3;
  18465. constructor(position?: Vector3, normal?: Vector3);
  18466. clone(): PositionNormalVertex;
  18467. }
  18468. class PositionNormalTextureVertex {
  18469. position: Vector3;
  18470. normal: Vector3;
  18471. uv: Vector2;
  18472. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  18473. clone(): PositionNormalTextureVertex;
  18474. }
  18475. class Tmp {
  18476. static Color3: Color3[];
  18477. static Color4: Color4[];
  18478. static Vector2: Vector2[];
  18479. static Vector3: Vector3[];
  18480. static Vector4: Vector4[];
  18481. static Quaternion: Quaternion[];
  18482. static Matrix: Matrix[];
  18483. }
  18484. }
  18485. declare module BABYLON {
  18486. class SphericalPolynomial {
  18487. x: Vector3;
  18488. y: Vector3;
  18489. z: Vector3;
  18490. xx: Vector3;
  18491. yy: Vector3;
  18492. zz: Vector3;
  18493. xy: Vector3;
  18494. yz: Vector3;
  18495. zx: Vector3;
  18496. addAmbient(color: Color3): void;
  18497. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  18498. scale(scale: number): void;
  18499. }
  18500. class SphericalHarmonics {
  18501. L00: Vector3;
  18502. L1_1: Vector3;
  18503. L10: Vector3;
  18504. L11: Vector3;
  18505. L2_2: Vector3;
  18506. L2_1: Vector3;
  18507. L20: Vector3;
  18508. L21: Vector3;
  18509. L22: Vector3;
  18510. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  18511. scale(scale: number): void;
  18512. convertIncidentRadianceToIrradiance(): void;
  18513. convertIrradianceToLambertianRadiance(): void;
  18514. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  18515. }
  18516. }
  18517. declare module BABYLON {
  18518. /**
  18519. * Defines a target to use with MorphTargetManager
  18520. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18521. */
  18522. class MorphTarget implements IAnimatable {
  18523. /** defines the name of the target */
  18524. name: string;
  18525. /**
  18526. * Gets or sets the list of animations
  18527. */
  18528. animations: Animation[];
  18529. private _scene;
  18530. private _positions;
  18531. private _normals;
  18532. private _tangents;
  18533. private _influence;
  18534. /**
  18535. * Observable raised when the influence changes
  18536. */
  18537. onInfluenceChanged: Observable<boolean>;
  18538. /**
  18539. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18540. */
  18541. influence: number;
  18542. private _animationPropertiesOverride;
  18543. /**
  18544. * Gets or sets the animation properties override
  18545. */
  18546. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18547. /**
  18548. * Creates a new MorphTarget
  18549. * @param name defines the name of the target
  18550. * @param influence defines the influence to use
  18551. */
  18552. constructor(
  18553. /** defines the name of the target */
  18554. name: string, influence?: number, scene?: Nullable<Scene>);
  18555. /**
  18556. * Gets a boolean defining if the target contains position data
  18557. */
  18558. readonly hasPositions: boolean;
  18559. /**
  18560. * Gets a boolean defining if the target contains normal data
  18561. */
  18562. readonly hasNormals: boolean;
  18563. /**
  18564. * Gets a boolean defining if the target contains tangent data
  18565. */
  18566. readonly hasTangents: boolean;
  18567. /**
  18568. * Affects position data to this target
  18569. * @param data defines the position data to use
  18570. */
  18571. setPositions(data: Nullable<FloatArray>): void;
  18572. /**
  18573. * Gets the position data stored in this target
  18574. * @returns a FloatArray containing the position data (or null if not present)
  18575. */
  18576. getPositions(): Nullable<FloatArray>;
  18577. /**
  18578. * Affects normal data to this target
  18579. * @param data defines the normal data to use
  18580. */
  18581. setNormals(data: Nullable<FloatArray>): void;
  18582. /**
  18583. * Gets the normal data stored in this target
  18584. * @returns a FloatArray containing the normal data (or null if not present)
  18585. */
  18586. getNormals(): Nullable<FloatArray>;
  18587. /**
  18588. * Affects tangent data to this target
  18589. * @param data defines the tangent data to use
  18590. */
  18591. setTangents(data: Nullable<FloatArray>): void;
  18592. /**
  18593. * Gets the tangent data stored in this target
  18594. * @returns a FloatArray containing the tangent data (or null if not present)
  18595. */
  18596. getTangents(): Nullable<FloatArray>;
  18597. /**
  18598. * Serializes the current target into a Serialization object
  18599. * @returns the serialized object
  18600. */
  18601. serialize(): any;
  18602. /**
  18603. * Creates a new target from serialized data
  18604. * @param serializationObject defines the serialized data to use
  18605. * @returns a new MorphTarget
  18606. */
  18607. static Parse(serializationObject: any): MorphTarget;
  18608. /**
  18609. * Creates a MorphTarget from mesh data
  18610. * @param mesh defines the source mesh
  18611. * @param name defines the name to use for the new target
  18612. * @param influence defines the influence to attach to the target
  18613. * @returns a new MorphTarget
  18614. */
  18615. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18616. }
  18617. }
  18618. declare module BABYLON {
  18619. /**
  18620. * This class is used to deform meshes using morphing between different targets
  18621. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18622. */
  18623. class MorphTargetManager {
  18624. private _targets;
  18625. private _targetObservable;
  18626. private _activeTargets;
  18627. private _scene;
  18628. private _influences;
  18629. private _supportsNormals;
  18630. private _supportsTangents;
  18631. private _vertexCount;
  18632. private _uniqueId;
  18633. private _tempInfluences;
  18634. /**
  18635. * Creates a new MorphTargetManager
  18636. * @param scene defines the current scene
  18637. */
  18638. constructor(scene?: Nullable<Scene>);
  18639. /**
  18640. * Gets the unique ID of this manager
  18641. */
  18642. readonly uniqueId: number;
  18643. /**
  18644. * Gets the number of vertices handled by this manager
  18645. */
  18646. readonly vertexCount: number;
  18647. /**
  18648. * Gets a boolean indicating if this manager supports morphing of normals
  18649. */
  18650. readonly supportsNormals: boolean;
  18651. /**
  18652. * Gets a boolean indicating if this manager supports morphing of tangents
  18653. */
  18654. readonly supportsTangents: boolean;
  18655. /**
  18656. * Gets the number of targets stored in this manager
  18657. */
  18658. readonly numTargets: number;
  18659. /**
  18660. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18661. */
  18662. readonly numInfluencers: number;
  18663. /**
  18664. * Gets the list of influences (one per target)
  18665. */
  18666. readonly influences: Float32Array;
  18667. /**
  18668. * Gets the active target at specified index. An active target is a target with an influence > 0
  18669. * @param index defines the index to check
  18670. * @returns the requested target
  18671. */
  18672. getActiveTarget(index: number): MorphTarget;
  18673. /**
  18674. * Gets the target at specified index
  18675. * @param index defines the index to check
  18676. * @returns the requested target
  18677. */
  18678. getTarget(index: number): MorphTarget;
  18679. /**
  18680. * Add a new target to this manager
  18681. * @param target defines the target to add
  18682. */
  18683. addTarget(target: MorphTarget): void;
  18684. /**
  18685. * Removes a target from the manager
  18686. * @param target defines the target to remove
  18687. */
  18688. removeTarget(target: MorphTarget): void;
  18689. /**
  18690. * Serializes the current manager into a Serialization object
  18691. * @returns the serialized object
  18692. */
  18693. serialize(): any;
  18694. private _syncActiveTargets(needUpdate);
  18695. /**
  18696. * Syncrhonize the targets with all the meshes using this morph target manager
  18697. */
  18698. synchronize(): void;
  18699. /**
  18700. * Creates a new MorphTargetManager from serialized data
  18701. * @param serializationObject defines the serialized data
  18702. * @param scene defines the hosting scene
  18703. * @returns the new MorphTargetManager
  18704. */
  18705. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18706. }
  18707. }
  18708. declare module BABYLON {
  18709. /**
  18710. * Class used to store all common mesh properties
  18711. */
  18712. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  18713. /** No occlusion */
  18714. static OCCLUSION_TYPE_NONE: number;
  18715. /** Occlusion set to optimisitic */
  18716. static OCCLUSION_TYPE_OPTIMISTIC: number;
  18717. /** Occlusion set to strict */
  18718. static OCCLUSION_TYPE_STRICT: number;
  18719. /** Use an accurante occlusion algorithm */
  18720. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  18721. /** Use a conservative occlusion algorithm */
  18722. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  18723. /**
  18724. * No billboard
  18725. */
  18726. static readonly BILLBOARDMODE_NONE: number;
  18727. /** Billboard on X axis */
  18728. static readonly BILLBOARDMODE_X: number;
  18729. /** Billboard on Y axis */
  18730. static readonly BILLBOARDMODE_Y: number;
  18731. /** Billboard on Z axis */
  18732. static readonly BILLBOARDMODE_Z: number;
  18733. /** Billboard on all axes */
  18734. static readonly BILLBOARDMODE_ALL: number;
  18735. private _facetPositions;
  18736. private _facetNormals;
  18737. private _facetPartitioning;
  18738. private _facetNb;
  18739. private _partitioningSubdivisions;
  18740. private _partitioningBBoxRatio;
  18741. private _facetDataEnabled;
  18742. private _facetParameters;
  18743. private _bbSize;
  18744. private _subDiv;
  18745. private _facetDepthSort;
  18746. private _facetDepthSortEnabled;
  18747. private _depthSortedIndices;
  18748. private _depthSortedFacets;
  18749. private _facetDepthSortFunction;
  18750. private _facetDepthSortFrom;
  18751. private _facetDepthSortOrigin;
  18752. private _invertedMatrix;
  18753. /**
  18754. * Gets the number of facets in the mesh
  18755. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  18756. */
  18757. readonly facetNb: number;
  18758. /**
  18759. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  18760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  18761. */
  18762. partitioningSubdivisions: number;
  18763. /**
  18764. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  18765. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  18766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  18767. */
  18768. partitioningBBoxRatio: number;
  18769. /**
  18770. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  18771. * Works only for updatable meshes.
  18772. * Doesn't work with multi-materials
  18773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  18774. */
  18775. mustDepthSortFacets: boolean;
  18776. /**
  18777. * The location (Vector3) where the facet depth sort must be computed from.
  18778. * By default, the active camera position.
  18779. * Used only when facet depth sort is enabled
  18780. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  18781. */
  18782. facetDepthSortFrom: Vector3;
  18783. /**
  18784. * gets a boolean indicating if facetData is enabled
  18785. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  18786. */
  18787. readonly isFacetDataEnabled: boolean;
  18788. /** @hidden */
  18789. _updateNonUniformScalingState(value: boolean): boolean;
  18790. /**
  18791. * An event triggered when this mesh collides with another one
  18792. */
  18793. onCollideObservable: Observable<AbstractMesh>;
  18794. private _onCollideObserver;
  18795. /** Set a function to call when this mesh collides with another one */
  18796. onCollide: () => void;
  18797. /**
  18798. * An event triggered when the collision's position changes
  18799. */
  18800. onCollisionPositionChangeObservable: Observable<Vector3>;
  18801. private _onCollisionPositionChangeObserver;
  18802. /** Set a function to call when the collision's position changes */
  18803. onCollisionPositionChange: () => void;
  18804. /**
  18805. * An event triggered when material is changed
  18806. */
  18807. onMaterialChangedObservable: Observable<AbstractMesh>;
  18808. /**
  18809. * Gets or sets the orientation for POV movement & rotation
  18810. */
  18811. definedFacingForward: boolean;
  18812. /**
  18813. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  18814. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  18815. * * 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.
  18816. * @see http://doc.babylonjs.com/features/occlusionquery
  18817. */
  18818. occlusionQueryAlgorithmType: number;
  18819. /**
  18820. * 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:
  18821. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  18822. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  18823. * * 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.
  18824. * @see http://doc.babylonjs.com/features/occlusionquery
  18825. */
  18826. occlusionType: number;
  18827. /**
  18828. * 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.
  18829. * The default value is -1 which means don't break the query and wait till the result
  18830. * @see http://doc.babylonjs.com/features/occlusionquery
  18831. */
  18832. occlusionRetryCount: number;
  18833. private _occlusionInternalRetryCounter;
  18834. protected _isOccluded: boolean;
  18835. /**
  18836. * 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
  18837. * @see http://doc.babylonjs.com/features/occlusionquery
  18838. */
  18839. isOccluded: boolean;
  18840. private _isOcclusionQueryInProgress;
  18841. /**
  18842. * Flag to check the progress status of the query
  18843. * @see http://doc.babylonjs.com/features/occlusionquery
  18844. */
  18845. readonly isOcclusionQueryInProgress: boolean;
  18846. private _occlusionQuery;
  18847. private _visibility;
  18848. /**
  18849. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  18850. */
  18851. /**
  18852. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  18853. */
  18854. visibility: number;
  18855. /** Gets or sets the alpha index used to sort transparent meshes
  18856. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  18857. */
  18858. alphaIndex: number;
  18859. /**
  18860. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  18861. */
  18862. isVisible: boolean;
  18863. /**
  18864. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  18865. */
  18866. isPickable: boolean;
  18867. /**
  18868. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  18869. */
  18870. showBoundingBox: boolean;
  18871. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  18872. showSubMeshesBoundingBox: boolean;
  18873. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  18874. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  18875. */
  18876. isBlocker: boolean;
  18877. /**
  18878. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  18879. */
  18880. enablePointerMoveEvents: boolean;
  18881. /**
  18882. * Specifies the rendering group id for this mesh (0 by default)
  18883. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  18884. */
  18885. renderingGroupId: number;
  18886. private _material;
  18887. /** Gets or sets current material */
  18888. material: Nullable<Material>;
  18889. private _receiveShadows;
  18890. /**
  18891. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  18892. * @see http://doc.babylonjs.com/babylon101/shadows
  18893. */
  18894. receiveShadows: boolean;
  18895. /**
  18896. * Gets or sets a boolean indicating if the outline must be rendered as well
  18897. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  18898. */
  18899. renderOutline: boolean;
  18900. /** Defines color to use when rendering outline */
  18901. outlineColor: Color3;
  18902. /** Define width to use when rendering outline */
  18903. outlineWidth: number;
  18904. /**
  18905. * Gets or sets a boolean indicating if the overlay must be rendered as well
  18906. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  18907. */
  18908. renderOverlay: boolean;
  18909. /** Defines color to use when rendering overlay */
  18910. overlayColor: Color3;
  18911. /** Defines alpha to use when rendering overlay */
  18912. overlayAlpha: number;
  18913. private _hasVertexAlpha;
  18914. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  18915. hasVertexAlpha: boolean;
  18916. private _useVertexColors;
  18917. /** 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) */
  18918. useVertexColors: boolean;
  18919. private _computeBonesUsingShaders;
  18920. /**
  18921. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  18922. */
  18923. computeBonesUsingShaders: boolean;
  18924. private _numBoneInfluencers;
  18925. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  18926. numBoneInfluencers: number;
  18927. private _applyFog;
  18928. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  18929. applyFog: boolean;
  18930. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  18931. useOctreeForRenderingSelection: boolean;
  18932. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  18933. useOctreeForPicking: boolean;
  18934. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  18935. useOctreeForCollisions: boolean;
  18936. private _layerMask;
  18937. /**
  18938. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  18939. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  18940. */
  18941. layerMask: number;
  18942. /**
  18943. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  18944. */
  18945. alwaysSelectAsActiveMesh: boolean;
  18946. /**
  18947. * Gets or sets the current action manager
  18948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18949. */
  18950. actionManager: Nullable<ActionManager>;
  18951. /**
  18952. * Gets or sets impostor used for physic simulation
  18953. * @see http://doc.babylonjs.com/features/physics_engine
  18954. */
  18955. physicsImpostor: Nullable<PhysicsImpostor>;
  18956. private _checkCollisions;
  18957. private _collisionMask;
  18958. private _collisionGroup;
  18959. /**
  18960. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  18961. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18962. */
  18963. ellipsoid: Vector3;
  18964. /**
  18965. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  18966. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18967. */
  18968. ellipsoidOffset: Vector3;
  18969. private _collider;
  18970. private _oldPositionForCollisions;
  18971. private _diffPositionForCollisions;
  18972. /**
  18973. * Gets or sets a collision mask used to mask collisions (default is -1).
  18974. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  18975. */
  18976. collisionMask: number;
  18977. /**
  18978. * Gets or sets the current collision group mask (-1 by default).
  18979. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  18980. */
  18981. collisionGroup: number;
  18982. /**
  18983. * Defines edge width used when edgesRenderer is enabled
  18984. * @see https://www.babylonjs-playground.com/#10OJSG#13
  18985. */
  18986. edgesWidth: number;
  18987. /**
  18988. * Defines edge color used when edgesRenderer is enabled
  18989. * @see https://www.babylonjs-playground.com/#10OJSG#13
  18990. */
  18991. edgesColor: Color4;
  18992. /** @hidden */
  18993. _edgesRenderer: Nullable<EdgesRenderer>;
  18994. private _collisionsTransformMatrix;
  18995. private _collisionsScalingMatrix;
  18996. /** @hidden */
  18997. _masterMesh: Nullable<AbstractMesh>;
  18998. /** @hidden */
  18999. _boundingInfo: Nullable<BoundingInfo>;
  19000. /** @hidden */
  19001. _renderId: number;
  19002. /**
  19003. * Gets or sets the list of subMeshes
  19004. * @see http://doc.babylonjs.com/how_to/multi_materials
  19005. */
  19006. subMeshes: SubMesh[];
  19007. /** @hidden */
  19008. _submeshesOctree: Octree<SubMesh>;
  19009. /** @hidden */
  19010. _intersectionsInProgress: AbstractMesh[];
  19011. /** @hidden */
  19012. _unIndexed: boolean;
  19013. /** @hidden */
  19014. _lightSources: Light[];
  19015. /** @hidden */
  19016. readonly _positions: Nullable<Vector3[]>;
  19017. /** @hidden */
  19018. _waitingActions: any;
  19019. /** @hidden */
  19020. _waitingFreezeWorldMatrix: Nullable<boolean>;
  19021. private _skeleton;
  19022. /** @hidden */
  19023. _bonesTransformMatrices: Nullable<Float32Array>;
  19024. /**
  19025. * Gets or sets a skeleton to apply skining transformations
  19026. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19027. */
  19028. skeleton: Nullable<Skeleton>;
  19029. /**
  19030. * Creates a new AbstractMesh
  19031. * @param name defines the name of the mesh
  19032. * @param scene defines the hosting scene
  19033. */
  19034. constructor(name: string, scene?: Nullable<Scene>);
  19035. /**
  19036. * Returns the string "AbstractMesh"
  19037. * @returns "AbstractMesh"
  19038. */
  19039. getClassName(): string;
  19040. /**
  19041. * Gets a string representation of the current mesh
  19042. * @param fullDetails defines a boolean indicating if full details must be included
  19043. * @returns a string representation of the current mesh
  19044. */
  19045. toString(fullDetails?: boolean): string;
  19046. /** @hidden */
  19047. _rebuild(): void;
  19048. /** @hidden */
  19049. _resyncLightSources(): void;
  19050. /** @hidden */
  19051. _resyncLighSource(light: Light): void;
  19052. /** @hidden */
  19053. _unBindEffect(): void;
  19054. /** @hidden */
  19055. _removeLightSource(light: Light): void;
  19056. private _markSubMeshesAsDirty(func);
  19057. /** @hidden */
  19058. _markSubMeshesAsLightDirty(): void;
  19059. /** @hidden */
  19060. _markSubMeshesAsAttributesDirty(): void;
  19061. /** @hidden */
  19062. _markSubMeshesAsMiscDirty(): void;
  19063. /**
  19064. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  19065. */
  19066. scaling: Vector3;
  19067. /**
  19068. * Disables the mesh edge rendering mode
  19069. * @returns the currentAbstractMesh
  19070. */
  19071. disableEdgesRendering(): AbstractMesh;
  19072. /**
  19073. * Enables the edge rendering mode on the mesh.
  19074. * This mode makes the mesh edges visible
  19075. * @param epsilon defines the maximal distance between two angles to detect a face
  19076. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19077. * @returns the currentAbstractMesh
  19078. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19079. */
  19080. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19081. /**
  19082. * Gets the edgesRenderer associated with the mesh
  19083. */
  19084. readonly edgesRenderer: Nullable<EdgesRenderer>;
  19085. /**
  19086. * Returns true if the mesh is blocked. Implemented by child classes
  19087. */
  19088. readonly isBlocked: boolean;
  19089. /**
  19090. * Returns the mesh itself by default. Implemented by child classes
  19091. * @param camera defines the camera to use to pick the right LOD level
  19092. * @returns the currentAbstractMesh
  19093. */
  19094. getLOD(camera: Camera): Nullable<AbstractMesh>;
  19095. /**
  19096. * Returns 0 by default. Implemented by child classes
  19097. * @returns an integer
  19098. */
  19099. getTotalVertices(): number;
  19100. /**
  19101. * Returns null by default. Implemented by child classes
  19102. * @returns null
  19103. */
  19104. getIndices(): Nullable<IndicesArray>;
  19105. /**
  19106. * Returns the array of the requested vertex data kind. Implemented by child classes
  19107. * @param kind defines the vertex data kind to use
  19108. * @returns null
  19109. */
  19110. getVerticesData(kind: string): Nullable<FloatArray>;
  19111. /**
  19112. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19113. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19114. * Note that a new underlying VertexBuffer object is created each call.
  19115. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19116. * @param kind defines vertex data kind:
  19117. * * BABYLON.VertexBuffer.PositionKind
  19118. * * BABYLON.VertexBuffer.UVKind
  19119. * * BABYLON.VertexBuffer.UV2Kind
  19120. * * BABYLON.VertexBuffer.UV3Kind
  19121. * * BABYLON.VertexBuffer.UV4Kind
  19122. * * BABYLON.VertexBuffer.UV5Kind
  19123. * * BABYLON.VertexBuffer.UV6Kind
  19124. * * BABYLON.VertexBuffer.ColorKind
  19125. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19126. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19127. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19128. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19129. * @param data defines the data source
  19130. * @param updatable defines if the data must be flagged as updatable (or static)
  19131. * @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
  19132. * @returns the current mesh
  19133. */
  19134. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19135. /**
  19136. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19137. * If the mesh has no geometry, it is simply returned as it is.
  19138. * @param kind defines vertex data kind:
  19139. * * BABYLON.VertexBuffer.PositionKind
  19140. * * BABYLON.VertexBuffer.UVKind
  19141. * * BABYLON.VertexBuffer.UV2Kind
  19142. * * BABYLON.VertexBuffer.UV3Kind
  19143. * * BABYLON.VertexBuffer.UV4Kind
  19144. * * BABYLON.VertexBuffer.UV5Kind
  19145. * * BABYLON.VertexBuffer.UV6Kind
  19146. * * BABYLON.VertexBuffer.ColorKind
  19147. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19148. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19149. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19150. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19151. * @param data defines the data source
  19152. * @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
  19153. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  19154. * @returns the current mesh
  19155. */
  19156. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19157. /**
  19158. * Sets the mesh indices,
  19159. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19160. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19161. * @param totalVertices Defines the total number of vertices
  19162. * @returns the current mesh
  19163. */
  19164. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19165. /**
  19166. * Gets a boolean indicating if specific vertex data is present
  19167. * @param kind defines the vertex data kind to use
  19168. * @returns true is data kind is present
  19169. */
  19170. isVerticesDataPresent(kind: string): boolean;
  19171. /**
  19172. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  19173. * @returns a BoundingInfo
  19174. */
  19175. getBoundingInfo(): BoundingInfo;
  19176. /**
  19177. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  19178. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  19179. * @returns the current mesh
  19180. */
  19181. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19182. /**
  19183. * Overwrite the current bounding info
  19184. * @param boundingInfo defines the new bounding info
  19185. * @returns the current mesh
  19186. */
  19187. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19188. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  19189. readonly useBones: boolean;
  19190. /** @hidden */
  19191. _preActivate(): void;
  19192. /** @hidden */
  19193. _preActivateForIntermediateRendering(renderId: number): void;
  19194. /** @hidden */
  19195. _activate(renderId: number): void;
  19196. /**
  19197. * Gets the current world matrix
  19198. * @returns a Matrix
  19199. */
  19200. getWorldMatrix(): Matrix;
  19201. /** @hidden */
  19202. _getWorldMatrixDeterminant(): number;
  19203. /**
  19204. * Perform relative position change from the point of view of behind the front of the mesh.
  19205. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19206. * Supports definition of mesh facing forward or backward
  19207. * @param amountRight defines the distance on the right axis
  19208. * @param amountUp defines the distance on the up axis
  19209. * @param amountForward defines the distance on the forward axis
  19210. * @returns the current mesh
  19211. */
  19212. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  19213. /**
  19214. * Calculate relative position change from the point of view of behind the front of the mesh.
  19215. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19216. * Supports definition of mesh facing forward or backward
  19217. * @param amountRight defines the distance on the right axis
  19218. * @param amountUp defines the distance on the up axis
  19219. * @param amountForward defines the distance on the forward axis
  19220. * @returns the new displacement vector
  19221. */
  19222. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  19223. /**
  19224. * Perform relative rotation change from the point of view of behind the front of the mesh.
  19225. * Supports definition of mesh facing forward or backward
  19226. * @param flipBack defines the flip
  19227. * @param twirlClockwise defines the twirl
  19228. * @param tiltRight defines the tilt
  19229. * @returns the current mesh
  19230. */
  19231. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  19232. /**
  19233. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  19234. * Supports definition of mesh facing forward or backward.
  19235. * @param flipBack defines the flip
  19236. * @param twirlClockwise defines the twirl
  19237. * @param tiltRight defines the tilt
  19238. * @returns the new rotation vector
  19239. */
  19240. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  19241. /**
  19242. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  19243. * @param includeDescendants Include bounding info from descendants as well (true by default)
  19244. * @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
  19245. * @returns the new bounding vectors
  19246. */
  19247. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  19248. min: Vector3;
  19249. max: Vector3;
  19250. };
  19251. /** @hidden */
  19252. _updateBoundingInfo(): AbstractMesh;
  19253. /** @hidden */
  19254. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  19255. /** @hidden */
  19256. protected _afterComputeWorldMatrix(): void;
  19257. /**
  19258. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19259. * A mesh is in the frustum if its bounding box intersects the frustum
  19260. * @param frustumPlanes defines the frustum to test
  19261. * @returns true if the mesh is in the frustum planes
  19262. */
  19263. isInFrustum(frustumPlanes: Plane[]): boolean;
  19264. /**
  19265. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  19266. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  19267. * @param frustumPlanes defines the frustum to test
  19268. * @returns true if the mesh is completely in the frustum planes
  19269. */
  19270. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19271. /**
  19272. * True if the mesh intersects another mesh or a SolidParticle object
  19273. * @param mesh defines a target mesh or SolidParticle to test
  19274. * @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)
  19275. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  19276. * @returns true if there is an intersection
  19277. */
  19278. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  19279. /**
  19280. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  19281. * @param point defines the point to test
  19282. * @returns true if there is an intersection
  19283. */
  19284. intersectsPoint(point: Vector3): boolean;
  19285. /**
  19286. * Gets the current physics impostor
  19287. * @see http://doc.babylonjs.com/features/physics_engine
  19288. * @returns a physics impostor or null
  19289. */
  19290. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  19291. /**
  19292. * Gets the position of the current mesh in camera space
  19293. * @param camera defines the camera to use
  19294. * @returns a position
  19295. */
  19296. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  19297. /**
  19298. * Returns the distance from the mesh to the active camera
  19299. * @param camera defines the camera to use
  19300. * @returns the distance
  19301. */
  19302. getDistanceToCamera(camera?: Nullable<Camera>): number;
  19303. /**
  19304. * Apply a physic impulse to the mesh
  19305. * @param force defines the force to apply
  19306. * @param contactPoint defines where to apply the force
  19307. * @returns the current mesh
  19308. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19309. */
  19310. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  19311. /**
  19312. * Creates a physic joint between two meshes
  19313. * @param otherMesh defines the other mesh to use
  19314. * @param pivot1 defines the pivot to use on this mesh
  19315. * @param pivot2 defines the pivot to use on the other mesh
  19316. * @param options defines additional options (can be plugin dependent)
  19317. * @returns the current mesh
  19318. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  19319. */
  19320. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  19321. /**
  19322. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  19323. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19324. */
  19325. checkCollisions: boolean;
  19326. /**
  19327. * Gets Collider object used to compute collisions (not physics)
  19328. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19329. */
  19330. readonly collider: Collider;
  19331. /**
  19332. * Move the mesh using collision engine
  19333. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19334. * @param displacement defines the requested displacement vector
  19335. * @returns the current mesh
  19336. */
  19337. moveWithCollisions(displacement: Vector3): AbstractMesh;
  19338. private _onCollisionPositionChange;
  19339. /**
  19340. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  19341. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19342. * @param maxCapacity defines the maximum size of each block (64 by default)
  19343. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  19344. * @returns the new octree
  19345. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  19346. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  19347. */
  19348. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  19349. /** @hidden */
  19350. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  19351. /** @hidden */
  19352. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  19353. /** @hidden */
  19354. _checkCollision(collider: Collider): AbstractMesh;
  19355. /** @hidden */
  19356. _generatePointsArray(): boolean;
  19357. /**
  19358. * Checks if the passed Ray intersects with the mesh
  19359. * @param ray defines the ray to use
  19360. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  19361. * @returns the picking info
  19362. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  19363. */
  19364. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  19365. /**
  19366. * Clones the current mesh
  19367. * @param name defines the mesh name
  19368. * @param newParent defines the new mesh parent
  19369. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  19370. * @returns the new mesh
  19371. */
  19372. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19373. /**
  19374. * Disposes all the submeshes of the current meshnp
  19375. * @returns the current mesh
  19376. */
  19377. releaseSubMeshes(): AbstractMesh;
  19378. /**
  19379. * Releases resources associated with this abstract mesh.
  19380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19382. */
  19383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19384. /**
  19385. * Adds the passed mesh as a child to the current mesh
  19386. * @param mesh defines the child mesh
  19387. * @returns the current mesh
  19388. */
  19389. addChild(mesh: AbstractMesh): AbstractMesh;
  19390. /**
  19391. * Removes the passed mesh from the current mesh children list
  19392. * @param mesh defines the child mesh
  19393. * @returns the current mesh
  19394. */
  19395. removeChild(mesh: AbstractMesh): AbstractMesh;
  19396. /** @hidden */
  19397. private _initFacetData();
  19398. /**
  19399. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  19400. * This method can be called within the render loop.
  19401. * 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
  19402. * @returns the current mesh
  19403. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19404. */
  19405. updateFacetData(): AbstractMesh;
  19406. /**
  19407. * Returns the facetLocalNormals array.
  19408. * The normals are expressed in the mesh local spac
  19409. * @returns an array of Vector3
  19410. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19411. */
  19412. getFacetLocalNormals(): Vector3[];
  19413. /**
  19414. * Returns the facetLocalPositions array.
  19415. * The facet positions are expressed in the mesh local space
  19416. * @returns an array of Vector3
  19417. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19418. */
  19419. getFacetLocalPositions(): Vector3[];
  19420. /**
  19421. * Returns the facetLocalPartioning array
  19422. * @returns an array of array of numbers
  19423. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19424. */
  19425. getFacetLocalPartitioning(): number[][];
  19426. /**
  19427. * Returns the i-th facet position in the world system.
  19428. * This method allocates a new Vector3 per call
  19429. * @param i defines the facet index
  19430. * @returns a new Vector3
  19431. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19432. */
  19433. getFacetPosition(i: number): Vector3;
  19434. /**
  19435. * Sets the reference Vector3 with the i-th facet position in the world system
  19436. * @param i defines the facet index
  19437. * @param ref defines the target vector
  19438. * @returns the current mesh
  19439. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19440. */
  19441. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  19442. /**
  19443. * Returns the i-th facet normal in the world system.
  19444. * This method allocates a new Vector3 per call
  19445. * @param i defines the facet index
  19446. * @returns a new Vector3
  19447. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19448. */
  19449. getFacetNormal(i: number): Vector3;
  19450. /**
  19451. * Sets the reference Vector3 with the i-th facet normal in the world system
  19452. * @param i defines the facet index
  19453. * @param ref defines the target vector
  19454. * @returns the current mesh
  19455. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19456. */
  19457. getFacetNormalToRef(i: number, ref: Vector3): this;
  19458. /**
  19459. * 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)
  19460. * @param x defines x coordinate
  19461. * @param y defines y coordinate
  19462. * @param z defines z coordinate
  19463. * @returns the array of facet indexes
  19464. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19465. */
  19466. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  19467. /**
  19468. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  19469. * @param projected sets as the (x,y,z) world projection on the facet
  19470. * @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
  19471. * @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
  19472. * @param x defines x coordinate
  19473. * @param y defines y coordinate
  19474. * @param z defines z coordinate
  19475. * @returns the face index if found (or null instead)
  19476. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19477. */
  19478. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19479. /**
  19480. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  19481. * @param projected sets as the (x,y,z) local projection on the facet
  19482. * @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
  19483. * @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
  19484. * @param x defines x coordinate
  19485. * @param y defines y coordinate
  19486. * @param z defines z coordinate
  19487. * @returns the face index if found (or null instead)
  19488. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19489. */
  19490. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19491. /**
  19492. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  19493. * @returns the parameters
  19494. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19495. */
  19496. getFacetDataParameters(): any;
  19497. /**
  19498. * Disables the feature FacetData and frees the related memory
  19499. * @returns the current mesh
  19500. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19501. */
  19502. disableFacetData(): AbstractMesh;
  19503. /**
  19504. * Updates the AbstractMesh indices array
  19505. * @param indices defines the data source
  19506. * @returns the current mesh
  19507. */
  19508. updateIndices(indices: IndicesArray): AbstractMesh;
  19509. /**
  19510. * Creates new normals data for the mesh
  19511. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  19512. * @returns the current mesh
  19513. */
  19514. createNormals(updatable: boolean): AbstractMesh;
  19515. /**
  19516. * Align the mesh with a normal
  19517. * @param normal defines the normal to use
  19518. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  19519. * @returns the current mesh
  19520. */
  19521. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  19522. /** @hidden */
  19523. protected _checkOcclusionQuery(): void;
  19524. }
  19525. }
  19526. declare module BABYLON {
  19527. class Buffer {
  19528. private _engine;
  19529. private _buffer;
  19530. /** @hidden */
  19531. _data: Nullable<DataArray>;
  19532. private _updatable;
  19533. private _instanced;
  19534. /**
  19535. * Gets the byte stride.
  19536. */
  19537. readonly byteStride: number;
  19538. /**
  19539. * Constructor
  19540. * @param engine the engine
  19541. * @param data the data to use for this buffer
  19542. * @param updatable whether the data is updatable
  19543. * @param stride the stride (optional)
  19544. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  19545. * @param instanced whether the buffer is instanced (optional)
  19546. * @param useBytes set to true if the stride in in bytes (optional)
  19547. */
  19548. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  19549. /**
  19550. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  19551. * @param kind defines the vertex buffer kind (position, normal, etc.)
  19552. * @param offset defines offset in the buffer (0 by default)
  19553. * @param size defines the size in floats of attributes (position is 3 for instance)
  19554. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  19555. * @param instanced defines if the vertex buffer contains indexed data
  19556. * @param useBytes defines if the offset and stride are in bytes
  19557. * @returns the new vertex buffer
  19558. */
  19559. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  19560. isUpdatable(): boolean;
  19561. getData(): Nullable<DataArray>;
  19562. getBuffer(): Nullable<WebGLBuffer>;
  19563. /**
  19564. * Gets the stride in float32 units (i.e. byte stride / 4).
  19565. * May not be an integer if the byte stride is not divisible by 4.
  19566. * DEPRECATED. Use byteStride instead.
  19567. * @returns the stride in float32 units
  19568. */
  19569. getStrideSize(): number;
  19570. create(data?: Nullable<DataArray>): void;
  19571. _rebuild(): void;
  19572. update(data: DataArray): void;
  19573. /**
  19574. * Updates the data directly.
  19575. * @param data the new data
  19576. * @param offset the new offset
  19577. * @param vertexCount the vertex count (optional)
  19578. * @param useBytes set to true if the offset is in bytes
  19579. */
  19580. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  19581. dispose(): void;
  19582. }
  19583. }
  19584. declare module BABYLON {
  19585. class CSG {
  19586. private polygons;
  19587. matrix: Matrix;
  19588. position: Vector3;
  19589. rotation: Vector3;
  19590. rotationQuaternion: Nullable<Quaternion>;
  19591. scaling: Vector3;
  19592. static FromMesh(mesh: Mesh): CSG;
  19593. private static FromPolygons(polygons);
  19594. clone(): CSG;
  19595. union(csg: CSG): CSG;
  19596. unionInPlace(csg: CSG): void;
  19597. subtract(csg: CSG): CSG;
  19598. subtractInPlace(csg: CSG): void;
  19599. intersect(csg: CSG): CSG;
  19600. intersectInPlace(csg: CSG): void;
  19601. inverse(): CSG;
  19602. inverseInPlace(): void;
  19603. copyTransformAttributes(csg: CSG): CSG;
  19604. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  19605. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  19606. }
  19607. }
  19608. declare module BABYLON {
  19609. /**
  19610. * Class used to store geometry data (vertex buffers + index buffer)
  19611. */
  19612. class Geometry implements IGetSetVerticesData {
  19613. /**
  19614. * Gets or sets the unique ID of the geometry
  19615. */
  19616. id: string;
  19617. /**
  19618. * Gets the delay loading state of the geometry (none by default which means not delayed)
  19619. */
  19620. delayLoadState: number;
  19621. /**
  19622. * Gets the file containing the data to load when running in delay load state
  19623. */
  19624. delayLoadingFile: Nullable<string>;
  19625. /**
  19626. * Callback called when the geometry is updated
  19627. */
  19628. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  19629. private _scene;
  19630. private _engine;
  19631. private _meshes;
  19632. private _totalVertices;
  19633. /** @hidden */
  19634. _indices: IndicesArray;
  19635. /** @hidden */
  19636. _vertexBuffers: {
  19637. [key: string]: VertexBuffer;
  19638. };
  19639. private _isDisposed;
  19640. private _extend;
  19641. private _boundingBias;
  19642. /** @hidden */
  19643. _delayInfo: Array<string>;
  19644. private _indexBuffer;
  19645. private _indexBufferIsUpdatable;
  19646. /** @hidden */
  19647. _boundingInfo: Nullable<BoundingInfo>;
  19648. /** @hidden */
  19649. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  19650. /** @hidden */
  19651. _softwareSkinningRenderId: number;
  19652. private _vertexArrayObjects;
  19653. private _updatable;
  19654. /** @hidden */
  19655. _positions: Nullable<Vector3[]>;
  19656. /**
  19657. * 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
  19658. */
  19659. /**
  19660. * 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
  19661. */
  19662. boundingBias: Vector2;
  19663. /**
  19664. * Static function used to attach a new empty geometry to a mesh
  19665. * @param mesh defines the mesh to attach the geometry to
  19666. * @returns the new {BABYLON.Geometry}
  19667. */
  19668. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  19669. /**
  19670. * Creates a new geometry
  19671. * @param id defines the unique ID
  19672. * @param scene defines the hosting scene
  19673. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  19674. * @param updatable defines if geometry must be updatable (false by default)
  19675. * @param mesh defines the mesh that will be associated with the geometry
  19676. */
  19677. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  19678. /**
  19679. * Gets the current extend of the geometry
  19680. */
  19681. readonly extend: {
  19682. minimum: Vector3;
  19683. maximum: Vector3;
  19684. };
  19685. /**
  19686. * Gets the hosting scene
  19687. * @returns the hosting {BABYLON.Scene}
  19688. */
  19689. getScene(): Scene;
  19690. /**
  19691. * Gets the hosting engine
  19692. * @returns the hosting {BABYLON.Engine}
  19693. */
  19694. getEngine(): Engine;
  19695. /**
  19696. * Defines if the geometry is ready to use
  19697. * @returns true if the geometry is ready to be used
  19698. */
  19699. isReady(): boolean;
  19700. /**
  19701. * Gets a value indicating that the geometry should not be serialized
  19702. */
  19703. readonly doNotSerialize: boolean;
  19704. /** @hidden */
  19705. _rebuild(): void;
  19706. /**
  19707. * Affects all geometry data in one call
  19708. * @param vertexData defines the geometry data
  19709. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  19710. */
  19711. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19712. /**
  19713. * Set specific vertex data
  19714. * @param kind defines the data kind (Position, normal, etc...)
  19715. * @param data defines the vertex data to use
  19716. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  19717. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  19718. */
  19719. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  19720. /**
  19721. * Removes a specific vertex data
  19722. * @param kind defines the data kind (Position, normal, etc...)
  19723. */
  19724. removeVerticesData(kind: string): void;
  19725. /**
  19726. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  19727. * @param buffer defines the vertex buffer to use
  19728. * @param totalVertices defines the total number of vertices for position kind (could be null)
  19729. */
  19730. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  19731. /**
  19732. * Update a specific vertex buffer
  19733. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  19734. * It will do nothing if the buffer is not updatable
  19735. * @param kind defines the data kind (Position, normal, etc...)
  19736. * @param data defines the data to use
  19737. * @param offset defines the offset in the target buffer where to store the data
  19738. * @param useBytes set to true if the offset is in bytes
  19739. */
  19740. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  19741. /**
  19742. * Update a specific vertex buffer
  19743. * This function will create a new buffer if the current one is not updatable
  19744. * @param kind defines the data kind (Position, normal, etc...)
  19745. * @param data defines the data to use
  19746. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  19747. */
  19748. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  19749. private _updateBoundingInfo(updateExtends, data);
  19750. /** @hidden */
  19751. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  19752. /**
  19753. * Gets total number of vertices
  19754. * @returns the total number of vertices
  19755. */
  19756. getTotalVertices(): number;
  19757. /**
  19758. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  19759. * @param kind defines the data kind (Position, normal, etc...)
  19760. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19761. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19762. * @returns a float array containing vertex data
  19763. */
  19764. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19765. /**
  19766. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  19767. * @param kind defines the data kind (Position, normal, etc...)
  19768. * @returns true if the vertex buffer with the specified kind is updatable
  19769. */
  19770. isVertexBufferUpdatable(kind: string): boolean;
  19771. /**
  19772. * Gets a specific vertex buffer
  19773. * @param kind defines the data kind (Position, normal, etc...)
  19774. * @returns a {BABYLON.VertexBuffer}
  19775. */
  19776. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19777. /**
  19778. * Returns all vertex buffers
  19779. * @return an object holding all vertex buffers indexed by kind
  19780. */
  19781. getVertexBuffers(): Nullable<{
  19782. [key: string]: VertexBuffer;
  19783. }>;
  19784. /**
  19785. * Gets a boolean indicating if specific vertex buffer is present
  19786. * @param kind defines the data kind (Position, normal, etc...)
  19787. * @returns true if data is present
  19788. */
  19789. isVerticesDataPresent(kind: string): boolean;
  19790. /**
  19791. * Gets a list of all attached data kinds (Position, normal, etc...)
  19792. * @returns a list of string containing all kinds
  19793. */
  19794. getVerticesDataKinds(): string[];
  19795. /**
  19796. * Update index buffer
  19797. * @param indices defines the indices to store in the index buffer
  19798. * @param offset defines the offset in the target buffer where to store the data
  19799. */
  19800. updateIndices(indices: IndicesArray, offset?: number): void;
  19801. /**
  19802. * Creates a new index buffer
  19803. * @param indices defines the indices to store in the index buffer
  19804. * @param totalVertices defines the total number of vertices (could be null)
  19805. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  19806. */
  19807. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  19808. /**
  19809. * Return the total number of indices
  19810. * @returns the total number of indices
  19811. */
  19812. getTotalIndices(): number;
  19813. /**
  19814. * Gets the index buffer array
  19815. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19816. * @returns the index buffer array
  19817. */
  19818. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  19819. /**
  19820. * Gets the index buffer
  19821. * @return the index buffer
  19822. */
  19823. getIndexBuffer(): Nullable<WebGLBuffer>;
  19824. /** @hidden */
  19825. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  19826. /**
  19827. * Release the associated resources for a specific mesh
  19828. * @param mesh defines the source mesh
  19829. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  19830. */
  19831. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  19832. /**
  19833. * Apply current geometry to a given mesh
  19834. * @param mesh defines the mesh to apply geometry to
  19835. */
  19836. applyToMesh(mesh: Mesh): void;
  19837. private _updateExtend(data?);
  19838. private _applyToMesh(mesh);
  19839. private notifyUpdate(kind?);
  19840. /**
  19841. * Load the geometry if it was flagged as delay loaded
  19842. * @param scene defines the hosting scene
  19843. * @param onLoaded defines a callback called when the geometry is loaded
  19844. */
  19845. load(scene: Scene, onLoaded?: () => void): void;
  19846. private _queueLoad(scene, onLoaded?);
  19847. /**
  19848. * Invert the geometry to move from a right handed system to a left handed one.
  19849. */
  19850. toLeftHanded(): void;
  19851. /** @hidden */
  19852. _resetPointsArrayCache(): void;
  19853. /** @hidden */
  19854. _generatePointsArray(): boolean;
  19855. /**
  19856. * Gets a value indicating if the geometry is disposed
  19857. * @returns true if the geometry was disposed
  19858. */
  19859. isDisposed(): boolean;
  19860. private _disposeVertexArrayObjects();
  19861. /**
  19862. * Free all associated resources
  19863. */
  19864. dispose(): void;
  19865. /**
  19866. * Clone the current geometry into a new geometry
  19867. * @param id defines the unique ID of the new geometry
  19868. * @returns a new geometry object
  19869. */
  19870. copy(id: string): Geometry;
  19871. /**
  19872. * Serialize the current geometry info (and not the vertices data) into a JSON object
  19873. * @return a JSON representation of the current geometry data (without the vertices data)
  19874. */
  19875. serialize(): any;
  19876. private toNumberArray(origin);
  19877. /**
  19878. * Serialize all vertices data into a JSON oject
  19879. * @returns a JSON representation of the current geometry data
  19880. */
  19881. serializeVerticeData(): any;
  19882. /**
  19883. * Extracts a clone of a mesh geometry
  19884. * @param mesh defines the source mesh
  19885. * @param id defines the unique ID of the new geometry object
  19886. * @returns the new geometry object
  19887. */
  19888. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  19889. /**
  19890. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  19891. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  19892. * Be aware Math.random() could cause collisions, but:
  19893. * "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"
  19894. * @returns a string containing a new GUID
  19895. */
  19896. static RandomId(): string;
  19897. /** @hidden */
  19898. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  19899. private static _CleanMatricesWeights(parsedGeometry, mesh);
  19900. /**
  19901. * Create a new geometry from persisted data (Using .babylon file format)
  19902. * @param parsedVertexData defines the persisted data
  19903. * @param scene defines the hosting scene
  19904. * @param rootUrl defines the root url to use to load assets (like delayed data)
  19905. * @returns the new geometry object
  19906. */
  19907. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  19908. }
  19909. /**
  19910. * Abstract class used to provide common services for all typed geometries
  19911. * @hidden
  19912. */
  19913. class _PrimitiveGeometry extends Geometry {
  19914. private _canBeRegenerated;
  19915. private _beingRegenerated;
  19916. /**
  19917. * Creates a new typed geometry
  19918. * @param id defines the unique ID of the geometry
  19919. * @param scene defines the hosting scene
  19920. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19921. * @param mesh defines the hosting mesh (can be null)
  19922. */
  19923. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19924. /**
  19925. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  19926. * @returns true if the geometry can be regenerated
  19927. */
  19928. canBeRegenerated(): boolean;
  19929. /**
  19930. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  19931. */
  19932. regenerate(): void;
  19933. /**
  19934. * Clone the geometry
  19935. * @param id defines the unique ID of the new geometry
  19936. * @returns the new geometry
  19937. */
  19938. asNewGeometry(id: string): Geometry;
  19939. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19940. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  19941. /** @hidden */
  19942. _regenerateVertexData(): VertexData;
  19943. copy(id: string): Geometry;
  19944. serialize(): any;
  19945. }
  19946. /**
  19947. * Creates a ribbon geometry
  19948. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  19949. */
  19950. class RibbonGeometry extends _PrimitiveGeometry {
  19951. /**
  19952. * Defines the array of paths to use
  19953. */
  19954. pathArray: Vector3[][];
  19955. /**
  19956. * Defines if the last and first points of each path in your pathArray must be joined
  19957. */
  19958. closeArray: boolean;
  19959. /**
  19960. * Defines if the last and first points of each path in your pathArray must be joined
  19961. */
  19962. closePath: boolean;
  19963. /**
  19964. * Defines the offset between points
  19965. */
  19966. offset: number;
  19967. /**
  19968. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19969. */
  19970. side: number;
  19971. /**
  19972. * Creates a ribbon geometry
  19973. * @param id defines the unique ID of the geometry
  19974. * @param scene defines the hosting scene
  19975. * @param pathArray defines the array of paths to use
  19976. * @param closeArray defines if the last path and the first path must be joined
  19977. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  19978. * @param offset defines the offset between points
  19979. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19980. * @param mesh defines the hosting mesh (can be null)
  19981. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19982. */
  19983. constructor(id: string, scene: Scene,
  19984. /**
  19985. * Defines the array of paths to use
  19986. */
  19987. pathArray: Vector3[][],
  19988. /**
  19989. * Defines if the last and first points of each path in your pathArray must be joined
  19990. */
  19991. closeArray: boolean,
  19992. /**
  19993. * Defines if the last and first points of each path in your pathArray must be joined
  19994. */
  19995. closePath: boolean,
  19996. /**
  19997. * Defines the offset between points
  19998. */
  19999. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  20000. /**
  20001. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20002. */
  20003. side?: number);
  20004. /** @hidden */
  20005. _regenerateVertexData(): VertexData;
  20006. copy(id: string): Geometry;
  20007. }
  20008. /**
  20009. * Creates a box geometry
  20010. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  20011. */
  20012. class BoxGeometry extends _PrimitiveGeometry {
  20013. /**
  20014. * Defines the zise of the box (width, height and depth are the same)
  20015. */
  20016. size: number;
  20017. /**
  20018. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20019. */
  20020. side: number;
  20021. /**
  20022. * Creates a box geometry
  20023. * @param id defines the unique ID of the geometry
  20024. * @param scene defines the hosting scene
  20025. * @param size defines the zise of the box (width, height and depth are the same)
  20026. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20027. * @param mesh defines the hosting mesh (can be null)
  20028. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20029. */
  20030. constructor(id: string, scene: Scene,
  20031. /**
  20032. * Defines the zise of the box (width, height and depth are the same)
  20033. */
  20034. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20035. /**
  20036. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20037. */
  20038. side?: number);
  20039. _regenerateVertexData(): VertexData;
  20040. copy(id: string): Geometry;
  20041. serialize(): any;
  20042. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  20043. }
  20044. /**
  20045. * Creates a sphere geometry
  20046. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  20047. */
  20048. class SphereGeometry extends _PrimitiveGeometry {
  20049. /**
  20050. * Defines the number of segments to use to create the sphere
  20051. */
  20052. segments: number;
  20053. /**
  20054. * Defines the diameter of the sphere
  20055. */
  20056. diameter: number;
  20057. /**
  20058. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20059. */
  20060. side: number;
  20061. /**
  20062. * Create a new sphere geometry
  20063. * @param id defines the unique ID of the geometry
  20064. * @param scene defines the hosting scene
  20065. * @param segments defines the number of segments to use to create the sphere
  20066. * @param diameter defines the diameter of the sphere
  20067. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20068. * @param mesh defines the hosting mesh (can be null)
  20069. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20070. */
  20071. constructor(id: string, scene: Scene,
  20072. /**
  20073. * Defines the number of segments to use to create the sphere
  20074. */
  20075. segments: number,
  20076. /**
  20077. * Defines the diameter of the sphere
  20078. */
  20079. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20080. /**
  20081. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20082. */
  20083. side?: number);
  20084. _regenerateVertexData(): VertexData;
  20085. copy(id: string): Geometry;
  20086. serialize(): any;
  20087. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  20088. }
  20089. /**
  20090. * Creates a disc geometry
  20091. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20092. */
  20093. class DiscGeometry extends _PrimitiveGeometry {
  20094. /**
  20095. * Defines the radius of the disc
  20096. */
  20097. radius: number;
  20098. /**
  20099. * Defines the tesselation factor to apply to the disc
  20100. */
  20101. tessellation: number;
  20102. /**
  20103. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20104. */
  20105. side: number;
  20106. /**
  20107. * Creates a new disc geometry
  20108. * @param id defines the unique ID of the geometry
  20109. * @param scene defines the hosting scene
  20110. * @param radius defines the radius of the disc
  20111. * @param tessellation defines the tesselation factor to apply to the disc
  20112. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20113. * @param mesh defines the hosting mesh (can be null)
  20114. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20115. */
  20116. constructor(id: string, scene: Scene,
  20117. /**
  20118. * Defines the radius of the disc
  20119. */
  20120. radius: number,
  20121. /**
  20122. * Defines the tesselation factor to apply to the disc
  20123. */
  20124. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20125. /**
  20126. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20127. */
  20128. side?: number);
  20129. _regenerateVertexData(): VertexData;
  20130. copy(id: string): Geometry;
  20131. }
  20132. /**
  20133. * Creates a new cylinder geometry
  20134. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20135. */
  20136. class CylinderGeometry extends _PrimitiveGeometry {
  20137. /**
  20138. * Defines the height of the cylinder
  20139. */
  20140. height: number;
  20141. /**
  20142. * Defines the diameter of the cylinder's top cap
  20143. */
  20144. diameterTop: number;
  20145. /**
  20146. * Defines the diameter of the cylinder's bottom cap
  20147. */
  20148. diameterBottom: number;
  20149. /**
  20150. * Defines the tessellation factor to apply to the cylinder
  20151. */
  20152. tessellation: number;
  20153. /**
  20154. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20155. */
  20156. subdivisions: number;
  20157. /**
  20158. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20159. */
  20160. side: number;
  20161. /**
  20162. * Creates a new cylinder geometry
  20163. * @param id defines the unique ID of the geometry
  20164. * @param scene defines the hosting scene
  20165. * @param height defines the height of the cylinder
  20166. * @param diameterTop defines the diameter of the cylinder's top cap
  20167. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20168. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20169. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20170. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20171. * @param mesh defines the hosting mesh (can be null)
  20172. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20173. */
  20174. constructor(id: string, scene: Scene,
  20175. /**
  20176. * Defines the height of the cylinder
  20177. */
  20178. height: number,
  20179. /**
  20180. * Defines the diameter of the cylinder's top cap
  20181. */
  20182. diameterTop: number,
  20183. /**
  20184. * Defines the diameter of the cylinder's bottom cap
  20185. */
  20186. diameterBottom: number,
  20187. /**
  20188. * Defines the tessellation factor to apply to the cylinder
  20189. */
  20190. tessellation: number,
  20191. /**
  20192. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20193. */
  20194. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20195. /**
  20196. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20197. */
  20198. side?: number);
  20199. _regenerateVertexData(): VertexData;
  20200. copy(id: string): Geometry;
  20201. serialize(): any;
  20202. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  20203. }
  20204. /**
  20205. * Creates a new torus geometry
  20206. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  20207. */
  20208. class TorusGeometry extends _PrimitiveGeometry {
  20209. /**
  20210. * Defines the diameter of the torus
  20211. */
  20212. diameter: number;
  20213. /**
  20214. * Defines the thickness of the torus (ie. internal diameter)
  20215. */
  20216. thickness: number;
  20217. /**
  20218. * Defines the tesselation factor to apply to the torus
  20219. */
  20220. tessellation: number;
  20221. /**
  20222. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20223. */
  20224. side: number;
  20225. /**
  20226. * Creates a new torus geometry
  20227. * @param id defines the unique ID of the geometry
  20228. * @param scene defines the hosting scene
  20229. * @param diameter defines the diameter of the torus
  20230. * @param thickness defines the thickness of the torus (ie. internal diameter)
  20231. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  20232. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20233. * @param mesh defines the hosting mesh (can be null)
  20234. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20235. */
  20236. constructor(id: string, scene: Scene,
  20237. /**
  20238. * Defines the diameter of the torus
  20239. */
  20240. diameter: number,
  20241. /**
  20242. * Defines the thickness of the torus (ie. internal diameter)
  20243. */
  20244. thickness: number,
  20245. /**
  20246. * Defines the tesselation factor to apply to the torus
  20247. */
  20248. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20249. /**
  20250. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20251. */
  20252. side?: number);
  20253. _regenerateVertexData(): VertexData;
  20254. copy(id: string): Geometry;
  20255. serialize(): any;
  20256. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  20257. }
  20258. /**
  20259. * Creates a new ground geometry
  20260. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  20261. */
  20262. class GroundGeometry extends _PrimitiveGeometry {
  20263. /**
  20264. * Defines the width of the ground
  20265. */
  20266. width: number;
  20267. /**
  20268. * Defines the height of the ground
  20269. */
  20270. height: number;
  20271. /**
  20272. * Defines the subdivisions to apply to the ground
  20273. */
  20274. subdivisions: number;
  20275. /**
  20276. * Creates a new ground geometry
  20277. * @param id defines the unique ID of the geometry
  20278. * @param scene defines the hosting scene
  20279. * @param width defines the width of the ground
  20280. * @param height defines the height of the ground
  20281. * @param subdivisions defines the subdivisions to apply to the ground
  20282. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20283. * @param mesh defines the hosting mesh (can be null)
  20284. */
  20285. constructor(id: string, scene: Scene,
  20286. /**
  20287. * Defines the width of the ground
  20288. */
  20289. width: number,
  20290. /**
  20291. * Defines the height of the ground
  20292. */
  20293. height: number,
  20294. /**
  20295. * Defines the subdivisions to apply to the ground
  20296. */
  20297. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20298. _regenerateVertexData(): VertexData;
  20299. copy(id: string): Geometry;
  20300. serialize(): any;
  20301. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  20302. }
  20303. /**
  20304. * Creates a tiled ground geometry
  20305. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  20306. */
  20307. class TiledGroundGeometry extends _PrimitiveGeometry {
  20308. /**
  20309. * Defines the minimum value on X axis
  20310. */
  20311. xmin: number;
  20312. /**
  20313. * Defines the minimum value on Z axis
  20314. */
  20315. zmin: number;
  20316. /**
  20317. * Defines the maximum value on X axis
  20318. */
  20319. xmax: number;
  20320. /**
  20321. * Defines the maximum value on Z axis
  20322. */
  20323. zmax: number;
  20324. /**
  20325. * Defines the subdivisions to apply to the ground
  20326. */
  20327. subdivisions: {
  20328. w: number;
  20329. h: number;
  20330. };
  20331. /**
  20332. * Defines the precision to use when computing the tiles
  20333. */
  20334. precision: {
  20335. w: number;
  20336. h: number;
  20337. };
  20338. /**
  20339. * Creates a tiled ground geometry
  20340. * @param id defines the unique ID of the geometry
  20341. * @param scene defines the hosting scene
  20342. * @param xmin defines the minimum value on X axis
  20343. * @param zmin defines the minimum value on Z axis
  20344. * @param xmax defines the maximum value on X axis
  20345. * @param zmax defines the maximum value on Z axis
  20346. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  20347. * @param precision defines the precision to use when computing the tiles
  20348. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20349. * @param mesh defines the hosting mesh (can be null)
  20350. */
  20351. constructor(id: string, scene: Scene,
  20352. /**
  20353. * Defines the minimum value on X axis
  20354. */
  20355. xmin: number,
  20356. /**
  20357. * Defines the minimum value on Z axis
  20358. */
  20359. zmin: number,
  20360. /**
  20361. * Defines the maximum value on X axis
  20362. */
  20363. xmax: number,
  20364. /**
  20365. * Defines the maximum value on Z axis
  20366. */
  20367. zmax: number,
  20368. /**
  20369. * Defines the subdivisions to apply to the ground
  20370. */
  20371. subdivisions: {
  20372. w: number;
  20373. h: number;
  20374. },
  20375. /**
  20376. * Defines the precision to use when computing the tiles
  20377. */
  20378. precision: {
  20379. w: number;
  20380. h: number;
  20381. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20382. _regenerateVertexData(): VertexData;
  20383. copy(id: string): Geometry;
  20384. }
  20385. /**
  20386. * Creates a plane geometry
  20387. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  20388. */
  20389. class PlaneGeometry extends _PrimitiveGeometry {
  20390. /**
  20391. * Defines the size of the plane (width === height)
  20392. */
  20393. size: number;
  20394. /**
  20395. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20396. */
  20397. side: number;
  20398. /**
  20399. * Creates a plane geometry
  20400. * @param id defines the unique ID of the geometry
  20401. * @param scene defines the hosting scene
  20402. * @param size defines the size of the plane (width === height)
  20403. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20404. * @param mesh defines the hosting mesh (can be null)
  20405. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20406. */
  20407. constructor(id: string, scene: Scene,
  20408. /**
  20409. * Defines the size of the plane (width === height)
  20410. */
  20411. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20412. /**
  20413. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20414. */
  20415. side?: number);
  20416. _regenerateVertexData(): VertexData;
  20417. copy(id: string): Geometry;
  20418. serialize(): any;
  20419. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  20420. }
  20421. /**
  20422. * Creates a torus knot geometry
  20423. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  20424. */
  20425. class TorusKnotGeometry extends _PrimitiveGeometry {
  20426. /**
  20427. * Defines the radius of the torus knot
  20428. */
  20429. radius: number;
  20430. /**
  20431. * Defines the thickness of the torus knot tube
  20432. */
  20433. tube: number;
  20434. /**
  20435. * Defines the number of radial segments
  20436. */
  20437. radialSegments: number;
  20438. /**
  20439. * Defines the number of tubular segments
  20440. */
  20441. tubularSegments: number;
  20442. /**
  20443. * Defines the first number of windings
  20444. */
  20445. p: number;
  20446. /**
  20447. * Defines the second number of windings
  20448. */
  20449. q: number;
  20450. /**
  20451. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20452. */
  20453. side: number;
  20454. /**
  20455. * Creates a torus knot geometry
  20456. * @param id defines the unique ID of the geometry
  20457. * @param scene defines the hosting scene
  20458. * @param radius defines the radius of the torus knot
  20459. * @param tube defines the thickness of the torus knot tube
  20460. * @param radialSegments defines the number of radial segments
  20461. * @param tubularSegments defines the number of tubular segments
  20462. * @param p defines the first number of windings
  20463. * @param q defines the second number of windings
  20464. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20465. * @param mesh defines the hosting mesh (can be null)
  20466. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20467. */
  20468. constructor(id: string, scene: Scene,
  20469. /**
  20470. * Defines the radius of the torus knot
  20471. */
  20472. radius: number,
  20473. /**
  20474. * Defines the thickness of the torus knot tube
  20475. */
  20476. tube: number,
  20477. /**
  20478. * Defines the number of radial segments
  20479. */
  20480. radialSegments: number,
  20481. /**
  20482. * Defines the number of tubular segments
  20483. */
  20484. tubularSegments: number,
  20485. /**
  20486. * Defines the first number of windings
  20487. */
  20488. p: number,
  20489. /**
  20490. * Defines the second number of windings
  20491. */
  20492. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20493. /**
  20494. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20495. */
  20496. side?: number);
  20497. _regenerateVertexData(): VertexData;
  20498. copy(id: string): Geometry;
  20499. serialize(): any;
  20500. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  20501. }
  20502. }
  20503. declare module BABYLON {
  20504. class GroundMesh extends Mesh {
  20505. generateOctree: boolean;
  20506. private _heightQuads;
  20507. _subdivisionsX: number;
  20508. _subdivisionsY: number;
  20509. _width: number;
  20510. _height: number;
  20511. _minX: number;
  20512. _maxX: number;
  20513. _minZ: number;
  20514. _maxZ: number;
  20515. constructor(name: string, scene: Scene);
  20516. getClassName(): string;
  20517. readonly subdivisions: number;
  20518. readonly subdivisionsX: number;
  20519. readonly subdivisionsY: number;
  20520. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20521. /**
  20522. * Returns a height (y) value in the Worl system :
  20523. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20524. * Returns the ground y position if (x, z) are outside the ground surface.
  20525. */
  20526. getHeightAtCoordinates(x: number, z: number): number;
  20527. /**
  20528. * Returns a normalized vector (Vector3) orthogonal to the ground
  20529. * at the ground coordinates (x, z) expressed in the World system.
  20530. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20531. */
  20532. getNormalAtCoordinates(x: number, z: number): Vector3;
  20533. /**
  20534. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20535. * at the ground coordinates (x, z) expressed in the World system.
  20536. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20537. * Returns the GroundMesh.
  20538. */
  20539. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20540. /**
  20541. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20542. * if the ground has been updated.
  20543. * This can be used in the render loop.
  20544. * Returns the GroundMesh.
  20545. */
  20546. updateCoordinateHeights(): GroundMesh;
  20547. private _getFacetAt(x, z);
  20548. private _initHeightQuads();
  20549. private _computeHeightQuads();
  20550. serialize(serializationObject: any): void;
  20551. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20552. }
  20553. }
  20554. declare module BABYLON {
  20555. /**
  20556. * Creates an instance based on a source mesh.
  20557. */
  20558. class InstancedMesh extends AbstractMesh {
  20559. private _sourceMesh;
  20560. private _currentLOD;
  20561. constructor(name: string, source: Mesh);
  20562. /**
  20563. * Returns the string "InstancedMesh".
  20564. */
  20565. getClassName(): string;
  20566. readonly receiveShadows: boolean;
  20567. readonly material: Nullable<Material>;
  20568. readonly visibility: number;
  20569. readonly skeleton: Nullable<Skeleton>;
  20570. renderingGroupId: number;
  20571. /**
  20572. * Returns the total number of vertices (integer).
  20573. */
  20574. getTotalVertices(): number;
  20575. readonly sourceMesh: Mesh;
  20576. /**
  20577. * Is this node ready to be used/rendered
  20578. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20579. * @return {boolean} is it ready
  20580. */
  20581. isReady(completeCheck?: boolean): boolean;
  20582. /**
  20583. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  20584. */
  20585. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  20586. /**
  20587. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20588. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20589. * The `data` are either a numeric array either a Float32Array.
  20590. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  20591. * 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).
  20592. * Note that a new underlying VertexBuffer object is created each call.
  20593. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20594. *
  20595. * Possible `kind` values :
  20596. * - BABYLON.VertexBuffer.PositionKind
  20597. * - BABYLON.VertexBuffer.UVKind
  20598. * - BABYLON.VertexBuffer.UV2Kind
  20599. * - BABYLON.VertexBuffer.UV3Kind
  20600. * - BABYLON.VertexBuffer.UV4Kind
  20601. * - BABYLON.VertexBuffer.UV5Kind
  20602. * - BABYLON.VertexBuffer.UV6Kind
  20603. * - BABYLON.VertexBuffer.ColorKind
  20604. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20605. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20606. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20607. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20608. *
  20609. * Returns the Mesh.
  20610. */
  20611. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20612. /**
  20613. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20614. * If the mesh has no geometry, it is simply returned as it is.
  20615. * The `data` are either a numeric array either a Float32Array.
  20616. * No new underlying VertexBuffer object is created.
  20617. * 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.
  20618. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  20619. *
  20620. * Possible `kind` values :
  20621. * - BABYLON.VertexBuffer.PositionKind
  20622. * - BABYLON.VertexBuffer.UVKind
  20623. * - BABYLON.VertexBuffer.UV2Kind
  20624. * - BABYLON.VertexBuffer.UV3Kind
  20625. * - BABYLON.VertexBuffer.UV4Kind
  20626. * - BABYLON.VertexBuffer.UV5Kind
  20627. * - BABYLON.VertexBuffer.UV6Kind
  20628. * - BABYLON.VertexBuffer.ColorKind
  20629. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20630. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20631. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20632. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20633. *
  20634. * Returns the Mesh.
  20635. */
  20636. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20637. /**
  20638. * Sets the mesh indices.
  20639. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  20640. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20641. * This method creates a new index buffer each call.
  20642. * Returns the Mesh.
  20643. */
  20644. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  20645. /**
  20646. * Boolean : True if the mesh owns the requested kind of data.
  20647. */
  20648. isVerticesDataPresent(kind: string): boolean;
  20649. /**
  20650. * Returns an array of indices (IndicesArray).
  20651. */
  20652. getIndices(): Nullable<IndicesArray>;
  20653. readonly _positions: Nullable<Vector3[]>;
  20654. /**
  20655. * Sets a new updated BoundingInfo to the mesh.
  20656. * Returns the mesh.
  20657. */
  20658. refreshBoundingInfo(): InstancedMesh;
  20659. _preActivate(): InstancedMesh;
  20660. _activate(renderId: number): InstancedMesh;
  20661. /**
  20662. * Returns the current associated LOD AbstractMesh.
  20663. */
  20664. getLOD(camera: Camera): AbstractMesh;
  20665. _syncSubMeshes(): InstancedMesh;
  20666. _generatePointsArray(): boolean;
  20667. /**
  20668. * Creates a new InstancedMesh from the current mesh.
  20669. * - name (string) : the cloned mesh name
  20670. * - newParent (optional Node) : the optional Node to parent the clone to.
  20671. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  20672. *
  20673. * Returns the clone.
  20674. */
  20675. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  20676. /**
  20677. * Disposes the InstancedMesh.
  20678. * Returns nothing.
  20679. */
  20680. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20681. }
  20682. }
  20683. declare module BABYLON {
  20684. class LinesMesh extends Mesh {
  20685. useVertexColor: boolean | undefined;
  20686. useVertexAlpha: boolean | undefined;
  20687. color: Color3;
  20688. alpha: number;
  20689. /**
  20690. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20691. * This margin is expressed in world space coordinates, so its value may vary.
  20692. * Default value is 0.1
  20693. * @returns the intersection Threshold value.
  20694. */
  20695. /**
  20696. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20697. * This margin is expressed in world space coordinates, so its value may vary.
  20698. * @param value the new threshold to apply
  20699. */
  20700. intersectionThreshold: number;
  20701. private _intersectionThreshold;
  20702. private _colorShader;
  20703. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  20704. /**
  20705. * Returns the string "LineMesh"
  20706. */
  20707. getClassName(): string;
  20708. material: Material;
  20709. readonly checkCollisions: boolean;
  20710. createInstance(name: string): InstancedMesh;
  20711. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  20712. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  20713. dispose(doNotRecurse?: boolean): void;
  20714. /**
  20715. * Returns a new LineMesh object cloned from the current one.
  20716. */
  20717. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  20718. }
  20719. }
  20720. declare module BABYLON {
  20721. /**
  20722. * @hidden
  20723. **/
  20724. class _InstancesBatch {
  20725. mustReturn: boolean;
  20726. visibleInstances: Nullable<InstancedMesh[]>[];
  20727. renderSelf: boolean[];
  20728. }
  20729. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20730. static _FRONTSIDE: number;
  20731. static _BACKSIDE: number;
  20732. static _DOUBLESIDE: number;
  20733. static _DEFAULTSIDE: number;
  20734. static _NO_CAP: number;
  20735. static _CAP_START: number;
  20736. static _CAP_END: number;
  20737. static _CAP_ALL: number;
  20738. /**
  20739. * Mesh side orientation : usually the external or front surface
  20740. */
  20741. static readonly FRONTSIDE: number;
  20742. /**
  20743. * Mesh side orientation : usually the internal or back surface
  20744. */
  20745. static readonly BACKSIDE: number;
  20746. /**
  20747. * Mesh side orientation : both internal and external or front and back surfaces
  20748. */
  20749. static readonly DOUBLESIDE: number;
  20750. /**
  20751. * Mesh side orientation : by default, `FRONTSIDE`
  20752. */
  20753. static readonly DEFAULTSIDE: number;
  20754. /**
  20755. * Mesh cap setting : no cap
  20756. */
  20757. static readonly NO_CAP: number;
  20758. /**
  20759. * Mesh cap setting : one cap at the beginning of the mesh
  20760. */
  20761. static readonly CAP_START: number;
  20762. /**
  20763. * Mesh cap setting : one cap at the end of the mesh
  20764. */
  20765. static readonly CAP_END: number;
  20766. /**
  20767. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20768. */
  20769. static readonly CAP_ALL: number;
  20770. /**
  20771. * An event triggered before rendering the mesh
  20772. */
  20773. onBeforeRenderObservable: Observable<Mesh>;
  20774. /**
  20775. * An event triggered after rendering the mesh
  20776. */
  20777. onAfterRenderObservable: Observable<Mesh>;
  20778. /**
  20779. * An event triggered before drawing the mesh
  20780. */
  20781. onBeforeDrawObservable: Observable<Mesh>;
  20782. private _onBeforeDrawObserver;
  20783. onBeforeDraw: () => void;
  20784. delayLoadState: number;
  20785. instances: InstancedMesh[];
  20786. delayLoadingFile: string;
  20787. _binaryInfo: any;
  20788. private _LODLevels;
  20789. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20790. private _morphTargetManager;
  20791. morphTargetManager: Nullable<MorphTargetManager>;
  20792. _geometry: Nullable<Geometry>;
  20793. _delayInfo: Array<string>;
  20794. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20795. _visibleInstances: any;
  20796. private _renderIdForInstances;
  20797. private _batchCache;
  20798. private _instancesBufferSize;
  20799. private _instancesBuffer;
  20800. private _instancesData;
  20801. private _overridenInstanceCount;
  20802. private _effectiveMaterial;
  20803. _shouldGenerateFlatShading: boolean;
  20804. private _preActivateId;
  20805. _originalBuilderSideOrientation: number;
  20806. overrideMaterialSideOrientation: Nullable<number>;
  20807. private _areNormalsFrozen;
  20808. private _sourcePositions;
  20809. private _sourceNormals;
  20810. private _source;
  20811. readonly source: Nullable<Mesh>;
  20812. isUnIndexed: boolean;
  20813. /**
  20814. * @constructor
  20815. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  20816. * @param {Scene} scene The scene to add this mesh to.
  20817. * @param {Node} parent The parent of this mesh, if it has one
  20818. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  20819. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20820. * When false, achieved by calling a clone(), also passing False.
  20821. * This will make creation of children, recursive.
  20822. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20823. */
  20824. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20825. /**
  20826. * Returns the string "Mesh".
  20827. */
  20828. getClassName(): string;
  20829. /**
  20830. * Returns a string.
  20831. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  20832. */
  20833. toString(fullDetails?: boolean): string;
  20834. _unBindEffect(): void;
  20835. /**
  20836. * True if the mesh has some Levels Of Details (LOD).
  20837. * Returns a boolean.
  20838. */
  20839. readonly hasLODLevels: boolean;
  20840. /**
  20841. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  20842. * @returns an array of {BABYLON.MeshLODLevel}
  20843. */
  20844. getLODLevels(): MeshLODLevel[];
  20845. private _sortLODLevels();
  20846. /**
  20847. * Add a mesh as LOD level triggered at the given distance.
  20848. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20849. * @param distance The distance from the center of the object to show this level
  20850. * @param mesh The mesh to be added as LOD level (can be null)
  20851. * @return This mesh (for chaining)
  20852. */
  20853. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20854. /**
  20855. * Returns the LOD level mesh at the passed distance or null if not found.
  20856. * It is related to the method `addLODLevel(distance, mesh)`.
  20857. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20858. * Returns an object Mesh or `null`.
  20859. */
  20860. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20861. /**
  20862. * Remove a mesh from the LOD array
  20863. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20864. * @param {Mesh} mesh The mesh to be removed.
  20865. * @return {Mesh} This mesh (for chaining)
  20866. */
  20867. removeLODLevel(mesh: Mesh): Mesh;
  20868. /**
  20869. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20870. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  20871. */
  20872. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20873. /**
  20874. * Returns the mesh internal Geometry object.
  20875. */
  20876. readonly geometry: Nullable<Geometry>;
  20877. /**
  20878. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20879. */
  20880. getTotalVertices(): number;
  20881. /**
  20882. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  20883. * If `copywhenShared` is true (default false) and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  20884. * You can force the copy with forceCopy === true
  20885. * Returns null if the mesh has no geometry or no vertex buffer.
  20886. * Possible `kind` values :
  20887. * - BABYLON.VertexBuffer.PositionKind
  20888. * - BABYLON.VertexBuffer.UVKind
  20889. * - BABYLON.VertexBuffer.UV2Kind
  20890. * - BABYLON.VertexBuffer.UV3Kind
  20891. * - BABYLON.VertexBuffer.UV4Kind
  20892. * - BABYLON.VertexBuffer.UV5Kind
  20893. * - BABYLON.VertexBuffer.UV6Kind
  20894. * - BABYLON.VertexBuffer.ColorKind
  20895. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20896. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20897. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20898. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20899. */
  20900. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20901. /**
  20902. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  20903. * Returns `null` if the mesh has no geometry.
  20904. * Possible `kind` values :
  20905. * - BABYLON.VertexBuffer.PositionKind
  20906. * - BABYLON.VertexBuffer.UVKind
  20907. * - BABYLON.VertexBuffer.UV2Kind
  20908. * - BABYLON.VertexBuffer.UV3Kind
  20909. * - BABYLON.VertexBuffer.UV4Kind
  20910. * - BABYLON.VertexBuffer.UV5Kind
  20911. * - BABYLON.VertexBuffer.UV6Kind
  20912. * - BABYLON.VertexBuffer.ColorKind
  20913. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20914. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20915. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20916. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20917. */
  20918. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20919. isVerticesDataPresent(kind: string): boolean;
  20920. /**
  20921. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20922. * Possible `kind` values :
  20923. * - BABYLON.VertexBuffer.PositionKind
  20924. * - BABYLON.VertexBuffer.UVKind
  20925. * - BABYLON.VertexBuffer.UV2Kind
  20926. * - BABYLON.VertexBuffer.UV3Kind
  20927. * - BABYLON.VertexBuffer.UV4Kind
  20928. * - BABYLON.VertexBuffer.UV5Kind
  20929. * - BABYLON.VertexBuffer.UV6Kind
  20930. * - BABYLON.VertexBuffer.ColorKind
  20931. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20932. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20933. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20934. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20935. */
  20936. isVertexBufferUpdatable(kind: string): boolean;
  20937. /**
  20938. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  20939. * Possible `kind` values :
  20940. * - BABYLON.VertexBuffer.PositionKind
  20941. * - BABYLON.VertexBuffer.UVKind
  20942. * - BABYLON.VertexBuffer.UV2Kind
  20943. * - BABYLON.VertexBuffer.UV3Kind
  20944. * - BABYLON.VertexBuffer.UV4Kind
  20945. * - BABYLON.VertexBuffer.UV5Kind
  20946. * - BABYLON.VertexBuffer.UV6Kind
  20947. * - BABYLON.VertexBuffer.ColorKind
  20948. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20949. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20950. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20951. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20952. */
  20953. getVerticesDataKinds(): string[];
  20954. /**
  20955. * Returns a positive integer : the total number of indices in this mesh geometry.
  20956. * Returns zero if the mesh has no geometry.
  20957. */
  20958. getTotalIndices(): number;
  20959. /**
  20960. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20961. * If the parameter `copyWhenShared` is 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.
  20962. * Returns an empty array if the mesh has no geometry.
  20963. */
  20964. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20965. readonly isBlocked: boolean;
  20966. /**
  20967. * Determine if the current mesh is ready to be rendered
  20968. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20969. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20970. * @returns true if all associated assets are ready (material, textures, shaders)
  20971. */
  20972. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20973. /**
  20974. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  20975. * This property is pertinent only for updatable parametric shapes.
  20976. */
  20977. readonly areNormalsFrozen: boolean;
  20978. /**
  20979. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20980. * It has no effect at all on other shapes.
  20981. * It prevents the mesh normals from being recomputed on next `positions` array update.
  20982. * Returns the Mesh.
  20983. */
  20984. freezeNormals(): Mesh;
  20985. /**
  20986. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20987. * It has no effect at all on other shapes.
  20988. * It reactivates the mesh normals computation if it was previously frozen.
  20989. * Returns the Mesh.
  20990. */
  20991. unfreezeNormals(): Mesh;
  20992. /**
  20993. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20994. */
  20995. overridenInstanceCount: number;
  20996. _preActivate(): Mesh;
  20997. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20998. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20999. /**
  21000. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21001. * This means the mesh underlying bounding box and sphere are recomputed.
  21002. * Returns the Mesh.
  21003. */
  21004. refreshBoundingInfo(): Mesh;
  21005. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  21006. private _getPositionData(applySkeleton);
  21007. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21008. subdivide(count: number): void;
  21009. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21010. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21011. /**
  21012. * Sets the mesh VertexBuffer.
  21013. * Returns the Mesh.
  21014. */
  21015. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21016. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21017. /**
  21018. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21019. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21020. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  21021. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  21022. * Returns the Mesh.
  21023. */
  21024. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21025. /**
  21026. * Creates a un-shared specific occurence of the geometry for the mesh.
  21027. * Returns the Mesh.
  21028. */
  21029. makeGeometryUnique(): Mesh;
  21030. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21031. /**
  21032. * Update the current index buffer
  21033. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21034. * Returns the Mesh.
  21035. */
  21036. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  21037. /**
  21038. * Invert the geometry to move from a right handed system to a left handed one.
  21039. * Returns the Mesh.
  21040. */
  21041. toLeftHanded(): Mesh;
  21042. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21043. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  21044. /**
  21045. * Registers for this mesh a javascript function called just before the rendering process.
  21046. * This function is passed the current mesh.
  21047. * Return the Mesh.
  21048. */
  21049. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21050. /**
  21051. * Disposes a previously registered javascript function called before the rendering.
  21052. * This function is passed the current mesh.
  21053. * Returns the Mesh.
  21054. */
  21055. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21056. /**
  21057. * Registers for this mesh a javascript function called just after the rendering is complete.
  21058. * This function is passed the current mesh.
  21059. * Returns the Mesh.
  21060. */
  21061. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21062. /**
  21063. * Disposes a previously registered javascript function called after the rendering.
  21064. * This function is passed the current mesh.
  21065. * Return the Mesh.
  21066. */
  21067. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21068. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21069. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21070. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21071. /**
  21072. * Triggers the draw call for the mesh.
  21073. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  21074. * Returns the Mesh.
  21075. */
  21076. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21077. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  21078. /**
  21079. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  21080. */
  21081. getEmittedParticleSystems(): IParticleSystem[];
  21082. /**
  21083. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  21084. */
  21085. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21086. /**
  21087. * Normalize matrix weights so that all vertices have a total weight set to 1
  21088. */
  21089. cleanMatrixWeights(): void;
  21090. _checkDelayState(): Mesh;
  21091. private _queueLoad(scene);
  21092. /**
  21093. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  21094. */
  21095. isInFrustum(frustumPlanes: Plane[]): boolean;
  21096. /**
  21097. * Sets the mesh material by the material or multiMaterial `id` property.
  21098. * The material `id` is a string identifying the material or the multiMaterial.
  21099. * This method returns the Mesh.
  21100. */
  21101. setMaterialByID(id: string): Mesh;
  21102. /**
  21103. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21104. */
  21105. getAnimatables(): IAnimatable[];
  21106. /**
  21107. * Modifies the mesh geometry according to the passed transformation matrix.
  21108. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21109. * The mesh normals are modified accordingly the same transformation.
  21110. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21111. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21112. * Returns the Mesh.
  21113. */
  21114. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21115. /**
  21116. * Modifies the mesh geometry according to its own current World Matrix.
  21117. * The mesh World Matrix is then reset.
  21118. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21119. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21120. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21121. * Returns the Mesh.
  21122. */
  21123. bakeCurrentTransformIntoVertices(): Mesh;
  21124. readonly _positions: Nullable<Vector3[]>;
  21125. _resetPointsArrayCache(): Mesh;
  21126. _generatePointsArray(): boolean;
  21127. /**
  21128. * Returns a new Mesh object generated from the current mesh properties.
  21129. * This method must not get confused with createInstance().
  21130. * The parameter `name` is a string, the name given to the new mesh.
  21131. * The optional parameter `newParent` can be any Node object (default `null`).
  21132. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21133. * The parameter `clonePhysicsImpostor` (default `true`) allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any.
  21134. */
  21135. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21136. /**
  21137. * Releases resources associated with this mesh.
  21138. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21139. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21140. */
  21141. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21142. /**
  21143. * Modifies the mesh geometry according to a displacement map.
  21144. * 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.
  21145. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21146. * This method returns nothing.
  21147. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  21148. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21149. * The parameter `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.
  21150. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21151. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21152. *
  21153. * Returns the Mesh.
  21154. */
  21155. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21156. /**
  21157. * Modifies the mesh geometry according to a displacementMap buffer.
  21158. * 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.
  21159. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21160. * This method returns nothing.
  21161. * The parameter `buffer` is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21162. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  21163. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21164. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21165. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21166. *
  21167. * Returns the Mesh.
  21168. */
  21169. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21170. /**
  21171. * Modify the mesh to get a flat shading rendering.
  21172. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21173. * This method returns the Mesh.
  21174. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21175. */
  21176. convertToFlatShadedMesh(): Mesh;
  21177. /**
  21178. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21179. * In other words, more vertices, no more indices and a single bigger VBO.
  21180. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21181. * Returns the Mesh.
  21182. */
  21183. convertToUnIndexedMesh(): Mesh;
  21184. /**
  21185. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  21186. * This method returns the Mesh.
  21187. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21188. */
  21189. flipFaces(flipNormals?: boolean): Mesh;
  21190. /**
  21191. * Creates a new InstancedMesh object from the mesh model.
  21192. * An instance shares the same properties and the same material than its model.
  21193. * Only these properties of each instance can then be set individually :
  21194. * - position
  21195. * - rotation
  21196. * - rotationQuaternion
  21197. * - setPivotMatrix
  21198. * - scaling
  21199. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  21200. * Warning : this method is not supported for Line mesh and LineSystem
  21201. */
  21202. createInstance(name: string): InstancedMesh;
  21203. /**
  21204. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21205. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21206. * This method returns the Mesh.
  21207. */
  21208. synchronizeInstances(): Mesh;
  21209. /**
  21210. * Simplify the mesh according to the given array of settings.
  21211. * Function will return immediately and will simplify async. It returns the Mesh.
  21212. * @param settings a collection of simplification settings.
  21213. * @param parallelProcessing should all levels calculate parallel or one after the other.
  21214. * @param type the type of simplification to run.
  21215. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  21216. */
  21217. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  21218. /**
  21219. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21220. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21221. * This should be used together with the simplification to avoid disappearing triangles.
  21222. * Returns the Mesh.
  21223. * @param successCallback an optional success callback to be called after the optimization finished.
  21224. */
  21225. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21226. serialize(serializationObject: any): void;
  21227. _syncGeometryWithMorphTargetManager(): void;
  21228. /**
  21229. * Returns a new Mesh object parsed from the source provided.
  21230. * The parameter `parsedMesh` is the source.
  21231. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  21232. */
  21233. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21234. /**
  21235. * Creates a ribbon mesh.
  21236. * Please consider using the same method from the MeshBuilder class instead.
  21237. * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21238. *
  21239. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21240. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21241. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  21242. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  21243. * 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.
  21244. * It's the offset to join together the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11.
  21245. * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
  21246. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21247. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21248. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21249. */
  21250. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21251. /**
  21252. * Creates a plane polygonal mesh. By default, this is a disc.
  21253. * Please consider using the same method from the MeshBuilder class instead.
  21254. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  21255. * 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.
  21256. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21257. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21258. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21259. */
  21260. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21261. /**
  21262. * Creates a box mesh.
  21263. * Please consider using the same method from the MeshBuilder class instead.
  21264. * The parameter `size` sets the size (float) of each box side (default 1).
  21265. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21266. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21267. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21268. */
  21269. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21270. /**
  21271. * Creates a sphere mesh.
  21272. * Please consider using the same method from the MeshBuilder class instead.
  21273. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  21274. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  21275. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21276. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21277. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21278. */
  21279. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21280. /**
  21281. * Creates a cylinder or a cone mesh.
  21282. * Please consider using the same method from the MeshBuilder class instead.
  21283. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21284. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21285. * 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.
  21286. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21287. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21288. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21289. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21290. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21291. */
  21292. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21293. /**
  21294. * Creates a torus mesh.
  21295. * Please consider using the same method from the MeshBuilder class instead.
  21296. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  21297. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  21298. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  21299. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21300. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21301. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21302. */
  21303. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21304. /**
  21305. * Creates a torus knot mesh.
  21306. * Please consider using the same method from the MeshBuilder class instead.
  21307. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  21308. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  21309. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  21310. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  21311. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21312. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21313. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21314. */
  21315. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21316. /**
  21317. * Creates a line mesh.
  21318. * Please consider using the same method from the MeshBuilder class instead.
  21319. * 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.
  21320. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21321. * The parameter `points` is an array successive Vector3.
  21322. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  21323. * When updating an instance, remember that only point positions can change, not the number of points.
  21324. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21325. */
  21326. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21327. /**
  21328. * Creates a dashed line mesh.
  21329. * Please consider using the same method from the MeshBuilder class instead.
  21330. * 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.
  21331. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21332. * The parameter `points` is an array successive Vector3.
  21333. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  21334. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  21335. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  21336. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  21337. * When updating an instance, remember that only point positions can change, not the number of points.
  21338. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21339. */
  21340. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21341. /**
  21342. * Creates a polygon mesh.
  21343. * Please consider using the same method from the MeshBuilder class instead.
  21344. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21345. * 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.
  21346. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21347. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21348. * Remember you can only change the shape positions, not their number when updating a polygon.
  21349. */
  21350. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21351. /**
  21352. * Creates an extruded polygon mesh, with depth in the Y direction.
  21353. * Please consider using the same method from the MeshBuilder class instead.
  21354. */
  21355. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21356. /**
  21357. * Creates an extruded shape mesh.
  21358. * The extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21359. * Please consider using the same method from the MeshBuilder class instead.
  21360. *
  21361. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21362. * 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
  21363. * extruded along the Z axis.
  21364. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21365. * 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.
  21366. * The parameter `scale` (float, default 1) is the value to scale the shape.
  21367. * 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
  21368. * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  21369. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21370. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21371. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21372. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21373. */
  21374. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21375. /**
  21376. * Creates an custom extruded shape mesh.
  21377. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21378. * Please consider using the same method from the MeshBuilder class instead.
  21379. *
  21380. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21381. * 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
  21382. * extruded along the Z axis.
  21383. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21384. * 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
  21385. * and the distance of this point from the begining of the path :
  21386. * ```javascript
  21387. * var rotationFunction = function(i, distance) {
  21388. * // do things
  21389. * return rotationValue; }
  21390. * ```
  21391. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  21392. * 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
  21393. * and the distance of this point from the begining of the path :
  21394. * ```javascript
  21395. * var scaleFunction = function(i, distance) {
  21396. * // do things
  21397. * return scaleValue;}
  21398. * ```
  21399. * It must returns a float value that will be the scale value applied to the shape on each path point.
  21400. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  21401. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  21402. * 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
  21403. * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  21404. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21405. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21406. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21407. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21408. */
  21409. 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;
  21410. /**
  21411. * Creates lathe mesh.
  21412. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21413. * Please consider using the same method from the MeshBuilder class instead.
  21414. * 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
  21415. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  21416. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  21417. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  21418. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21419. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21420. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21421. */
  21422. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21423. /**
  21424. * Creates a plane mesh.
  21425. * Please consider using the same method from the MeshBuilder class instead.
  21426. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  21427. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21428. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21429. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21430. */
  21431. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21432. /**
  21433. * Creates a ground mesh.
  21434. * Please consider using the same method from the MeshBuilder class instead.
  21435. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  21436. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  21437. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21438. */
  21439. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21440. /**
  21441. * Creates a tiled ground mesh.
  21442. * Please consider using the same method from the MeshBuilder class instead.
  21443. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  21444. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  21445. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  21446. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  21447. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  21448. * numbers of subdivisions on the ground width and height of each tile.
  21449. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21450. */
  21451. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21452. w: number;
  21453. h: number;
  21454. }, precision: {
  21455. w: number;
  21456. h: number;
  21457. }, scene: Scene, updatable?: boolean): Mesh;
  21458. /**
  21459. * Creates a ground mesh from a height map.
  21460. * tuto : http://doc.babylonjs.com/babylon101/height_map
  21461. * Please consider using the same method from the MeshBuilder class instead.
  21462. * The parameter `url` sets the URL of the height map image resource.
  21463. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  21464. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  21465. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  21466. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  21467. * 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).
  21468. * This function is passed the newly built mesh :
  21469. * ```javascript
  21470. * function(mesh) { // do things
  21471. * return; }
  21472. * ```
  21473. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21474. */
  21475. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void): GroundMesh;
  21476. /**
  21477. * Creates a tube mesh.
  21478. * The tube is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21479. * Please consider using the same method from the MeshBuilder class instead.
  21480. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  21481. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  21482. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  21483. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  21484. * 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.
  21485. * It must return a radius value (positive float) :
  21486. * ```javascript
  21487. * var radiusFunction = function(i, distance) {
  21488. * // do things
  21489. * return radius; }
  21490. * ```
  21491. * 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
  21492. * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#tube
  21493. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21494. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21495. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21496. */
  21497. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21498. (i: number, distance: number): number;
  21499. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21500. /**
  21501. * Creates a polyhedron mesh.
  21502. * Please consider using the same method from the MeshBuilder class instead.
  21503. * 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
  21504. * to choose the wanted type.
  21505. * The parameter `size` (positive float, default 1) sets the polygon size.
  21506. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  21507. * 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`.
  21508. * 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
  21509. * 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)`).
  21510. * 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 : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  21511. * 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.
  21512. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21513. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21514. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21515. */
  21516. static CreatePolyhedron(name: string, options: {
  21517. type?: number;
  21518. size?: number;
  21519. sizeX?: number;
  21520. sizeY?: number;
  21521. sizeZ?: number;
  21522. custom?: any;
  21523. faceUV?: Vector4[];
  21524. faceColors?: Color4[];
  21525. updatable?: boolean;
  21526. sideOrientation?: number;
  21527. }, scene: Scene): Mesh;
  21528. /**
  21529. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  21530. * Please consider using the same method from the MeshBuilder class instead.
  21531. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  21532. * 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`).
  21533. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  21534. * 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.
  21535. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21536. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21537. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21538. */
  21539. static CreateIcoSphere(name: string, options: {
  21540. radius?: number;
  21541. flat?: boolean;
  21542. subdivisions?: number;
  21543. sideOrientation?: number;
  21544. updatable?: boolean;
  21545. }, scene: Scene): Mesh;
  21546. /**
  21547. * Creates a decal mesh.
  21548. * Please consider using the same method from the MeshBuilder class instead.
  21549. * 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.
  21550. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  21551. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  21552. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  21553. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  21554. */
  21555. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21556. /**
  21557. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21558. */
  21559. setPositionsForCPUSkinning(): Float32Array;
  21560. /**
  21561. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21562. */
  21563. setNormalsForCPUSkinning(): Float32Array;
  21564. /**
  21565. * Updates the vertex buffer by applying transformation from the bones.
  21566. * Returns the Mesh.
  21567. *
  21568. * @param {skeleton} skeleton to apply
  21569. */
  21570. applySkeleton(skeleton: Skeleton): Mesh;
  21571. /**
  21572. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  21573. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  21574. */
  21575. static MinMax(meshes: AbstractMesh[]): {
  21576. min: Vector3;
  21577. max: Vector3;
  21578. };
  21579. /**
  21580. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  21581. */
  21582. static Center(meshesOrMinMaxVector: {
  21583. min: Vector3;
  21584. max: Vector3;
  21585. } | AbstractMesh[]): Vector3;
  21586. /**
  21587. * Merge the array of meshes into a single mesh for performance reasons.
  21588. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  21589. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  21590. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  21591. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21592. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  21593. */
  21594. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  21595. }
  21596. }
  21597. declare module BABYLON {
  21598. /**
  21599. * Define an interface for all classes that will get and set the data on vertices
  21600. */
  21601. interface IGetSetVerticesData {
  21602. isVerticesDataPresent(kind: string): boolean;
  21603. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21604. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21605. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21606. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21607. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21608. }
  21609. /**
  21610. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21611. */
  21612. class VertexData {
  21613. /**
  21614. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21615. */
  21616. positions: Nullable<FloatArray>;
  21617. /**
  21618. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21619. */
  21620. normals: Nullable<FloatArray>;
  21621. /**
  21622. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21623. */
  21624. tangents: Nullable<FloatArray>;
  21625. /**
  21626. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21627. */
  21628. uvs: Nullable<FloatArray>;
  21629. /**
  21630. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21631. */
  21632. uvs2: Nullable<FloatArray>;
  21633. /**
  21634. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21635. */
  21636. uvs3: Nullable<FloatArray>;
  21637. /**
  21638. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21639. */
  21640. uvs4: Nullable<FloatArray>;
  21641. /**
  21642. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21643. */
  21644. uvs5: Nullable<FloatArray>;
  21645. /**
  21646. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21647. */
  21648. uvs6: Nullable<FloatArray>;
  21649. /**
  21650. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21651. */
  21652. colors: Nullable<FloatArray>;
  21653. /**
  21654. * 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).
  21655. */
  21656. matricesIndices: Nullable<FloatArray>;
  21657. /**
  21658. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21659. */
  21660. matricesWeights: Nullable<FloatArray>;
  21661. /**
  21662. * An array extending the number of possible indices
  21663. */
  21664. matricesIndicesExtra: Nullable<FloatArray>;
  21665. /**
  21666. * An array extending the number of possible weights when the number of indices is extended
  21667. */
  21668. matricesWeightsExtra: Nullable<FloatArray>;
  21669. /**
  21670. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21671. */
  21672. indices: Nullable<IndicesArray>;
  21673. /**
  21674. * Uses the passed data array to set the set the values for the specified kind of data
  21675. * @param data a linear array of floating numbers
  21676. * @param kind the type of data that is being set, eg positions, colors etc
  21677. */
  21678. set(data: FloatArray, kind: string): void;
  21679. /**
  21680. * Associates the vertexData to the passed Mesh.
  21681. * Sets it as updatable or not (default `false`)
  21682. * @param mesh the mesh the vertexData is applied to
  21683. * @param updatable when used and having the value true allows new data to update the vertexData
  21684. * @returns the VertexData
  21685. */
  21686. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21687. /**
  21688. * Associates the vertexData to the passed Geometry.
  21689. * Sets it as updatable or not (default `false`)
  21690. * @param geometry the geometry the vertexData is applied to
  21691. * @param updatable when used and having the value true allows new data to update the vertexData
  21692. * @returns VertexData
  21693. */
  21694. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21695. /**
  21696. * Updates the associated mesh
  21697. * @param mesh the mesh to be updated
  21698. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21699. * @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
  21700. * @returns VertexData
  21701. */
  21702. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21703. /**
  21704. * Updates the associated geometry
  21705. * @param geometry the geometry to be updated
  21706. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21707. * @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
  21708. * @returns VertexData.
  21709. */
  21710. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21711. private _applyTo(meshOrGeometry, updatable?);
  21712. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  21713. /**
  21714. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21715. * @param matrix the transforming matrix
  21716. * @returns the VertexData
  21717. */
  21718. transform(matrix: Matrix): VertexData;
  21719. /**
  21720. * Merges the passed VertexData into the current one
  21721. * @param other the VertexData to be merged into the current one
  21722. * @returns the modified VertexData
  21723. */
  21724. merge(other: VertexData): VertexData;
  21725. private _mergeElement(source, other);
  21726. private _validate();
  21727. /**
  21728. * Serializes the VertexData
  21729. * @returns a serialized object
  21730. */
  21731. serialize(): any;
  21732. /**
  21733. * Extracts the vertexData from a mesh
  21734. * @param mesh the mesh from which to extract the VertexData
  21735. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21736. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21737. * @returns the object VertexData associated to the passed mesh
  21738. */
  21739. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21740. /**
  21741. * Extracts the vertexData from the geometry
  21742. * @param geometry the geometry from which to extract the VertexData
  21743. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21744. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21745. * @returns the object VertexData associated to the passed mesh
  21746. */
  21747. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21748. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  21749. /**
  21750. * Creates the VertexData for a Ribbon
  21751. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21752. * * pathArray array of paths, each of which an array of successive Vector3
  21753. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21754. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21755. * * 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
  21756. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21757. * * 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)
  21758. * * 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)
  21759. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21760. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21761. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21762. * @returns the VertexData of the ribbon
  21763. */
  21764. static CreateRibbon(options: {
  21765. pathArray: Vector3[][];
  21766. closeArray?: boolean;
  21767. closePath?: boolean;
  21768. offset?: number;
  21769. sideOrientation?: number;
  21770. frontUVs?: Vector4;
  21771. backUVs?: Vector4;
  21772. invertUV?: boolean;
  21773. uvs?: Vector2[];
  21774. colors?: Color4[];
  21775. }): VertexData;
  21776. /**
  21777. * Creates the VertexData for a box
  21778. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21779. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21780. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21781. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21782. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21783. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21784. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21785. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21786. * * 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)
  21787. * * 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)
  21788. * @returns the VertexData of the box
  21789. */
  21790. static CreateBox(options: {
  21791. size?: number;
  21792. width?: number;
  21793. height?: number;
  21794. depth?: number;
  21795. faceUV?: Vector4[];
  21796. faceColors?: Color4[];
  21797. sideOrientation?: number;
  21798. frontUVs?: Vector4;
  21799. backUVs?: Vector4;
  21800. }): VertexData;
  21801. /**
  21802. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21803. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21804. * * segments sets the number of horizontal strips optional, default 32
  21805. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21806. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21807. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21808. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21809. * * 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
  21810. * * 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
  21811. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21812. * * 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)
  21813. * * 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)
  21814. * @returns the VertexData of the ellipsoid
  21815. */
  21816. static CreateSphere(options: {
  21817. segments?: number;
  21818. diameter?: number;
  21819. diameterX?: number;
  21820. diameterY?: number;
  21821. diameterZ?: number;
  21822. arc?: number;
  21823. slice?: number;
  21824. sideOrientation?: number;
  21825. frontUVs?: Vector4;
  21826. backUVs?: Vector4;
  21827. }): VertexData;
  21828. /**
  21829. * Creates the VertexData for a cylinder, cone or prism
  21830. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21831. * * height sets the height (y direction) of the cylinder, optional, default 2
  21832. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21833. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21834. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21835. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21836. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21837. * * 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
  21838. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21839. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21840. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21841. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21842. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21843. * * 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)
  21844. * * 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)
  21845. * @returns the VertexData of the cylinder, cone or prism
  21846. */
  21847. static CreateCylinder(options: {
  21848. height?: number;
  21849. diameterTop?: number;
  21850. diameterBottom?: number;
  21851. diameter?: number;
  21852. tessellation?: number;
  21853. subdivisions?: number;
  21854. arc?: number;
  21855. faceColors?: Color4[];
  21856. faceUV?: Vector4[];
  21857. hasRings?: boolean;
  21858. enclose?: boolean;
  21859. sideOrientation?: number;
  21860. frontUVs?: Vector4;
  21861. backUVs?: Vector4;
  21862. }): VertexData;
  21863. /**
  21864. * Creates the VertexData for a torus
  21865. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21866. * * diameter the diameter of the torus, optional default 1
  21867. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21868. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21869. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21870. * * 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)
  21871. * * 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)
  21872. * @returns the VertexData of the torus
  21873. */
  21874. static CreateTorus(options: {
  21875. diameter?: number;
  21876. thickness?: number;
  21877. tessellation?: number;
  21878. sideOrientation?: number;
  21879. frontUVs?: Vector4;
  21880. backUVs?: Vector4;
  21881. }): VertexData;
  21882. /**
  21883. * Creates the VertexData of the LineSystem
  21884. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21885. * - lines an array of lines, each line being an array of successive Vector3
  21886. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21887. * @returns the VertexData of the LineSystem
  21888. */
  21889. static CreateLineSystem(options: {
  21890. lines: Vector3[][];
  21891. colors?: Nullable<Color4[][]>;
  21892. }): VertexData;
  21893. /**
  21894. * Create the VertexData for a DashedLines
  21895. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21896. * - points an array successive Vector3
  21897. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21898. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21899. * - dashNb the intended total number of dashes, optional, default 200
  21900. * @returns the VertexData for the DashedLines
  21901. */
  21902. static CreateDashedLines(options: {
  21903. points: Vector3[];
  21904. dashSize?: number;
  21905. gapSize?: number;
  21906. dashNb?: number;
  21907. }): VertexData;
  21908. /**
  21909. * Creates the VertexData for a Ground
  21910. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21911. * - width the width (x direction) of the ground, optional, default 1
  21912. * - height the height (z direction) of the ground, optional, default 1
  21913. * - subdivisions the number of subdivisions per side, optional, default 1
  21914. * @returns the VertexData of the Ground
  21915. */
  21916. static CreateGround(options: {
  21917. width?: number;
  21918. height?: number;
  21919. subdivisions?: number;
  21920. subdivisionsX?: number;
  21921. subdivisionsY?: number;
  21922. }): VertexData;
  21923. /**
  21924. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21925. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21926. * * xmin the ground minimum X coordinate, optional, default -1
  21927. * * zmin the ground minimum Z coordinate, optional, default -1
  21928. * * xmax the ground maximum X coordinate, optional, default 1
  21929. * * zmax the ground maximum Z coordinate, optional, default 1
  21930. * * 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}
  21931. * * 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}
  21932. * @returns the VertexData of the TiledGround
  21933. */
  21934. static CreateTiledGround(options: {
  21935. xmin: number;
  21936. zmin: number;
  21937. xmax: number;
  21938. zmax: number;
  21939. subdivisions?: {
  21940. w: number;
  21941. h: number;
  21942. };
  21943. precision?: {
  21944. w: number;
  21945. h: number;
  21946. };
  21947. }): VertexData;
  21948. /**
  21949. * Creates the VertexData of the Ground designed from a heightmap
  21950. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21951. * * width the width (x direction) of the ground
  21952. * * height the height (z direction) of the ground
  21953. * * subdivisions the number of subdivisions per side
  21954. * * minHeight the minimum altitude on the ground, optional, default 0
  21955. * * maxHeight the maximum altitude on the ground, optional default 1
  21956. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21957. * * buffer the array holding the image color data
  21958. * * bufferWidth the width of image
  21959. * * bufferHeight the height of image
  21960. * @returns the VertexData of the Ground designed from a heightmap
  21961. */
  21962. static CreateGroundFromHeightMap(options: {
  21963. width: number;
  21964. height: number;
  21965. subdivisions: number;
  21966. minHeight: number;
  21967. maxHeight: number;
  21968. colorFilter: Color3;
  21969. buffer: Uint8Array;
  21970. bufferWidth: number;
  21971. bufferHeight: number;
  21972. }): VertexData;
  21973. /**
  21974. * Creates the VertexData for a Plane
  21975. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21976. * * size sets the width and height of the plane to the value of size, optional default 1
  21977. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21978. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21979. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21980. * * 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)
  21981. * * 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)
  21982. * @returns the VertexData of the box
  21983. */
  21984. static CreatePlane(options: {
  21985. size?: number;
  21986. width?: number;
  21987. height?: number;
  21988. sideOrientation?: number;
  21989. frontUVs?: Vector4;
  21990. backUVs?: Vector4;
  21991. }): VertexData;
  21992. /**
  21993. * Creates the VertexData of the Disc or regular Polygon
  21994. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21995. * * radius the radius of the disc, optional default 0.5
  21996. * * tessellation the number of polygon sides, optional, default 64
  21997. * * 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
  21998. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21999. * * 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)
  22000. * * 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)
  22001. * @returns the VertexData of the box
  22002. */
  22003. static CreateDisc(options: {
  22004. radius?: number;
  22005. tessellation?: number;
  22006. arc?: number;
  22007. sideOrientation?: number;
  22008. frontUVs?: Vector4;
  22009. backUVs?: Vector4;
  22010. }): VertexData;
  22011. /**
  22012. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22013. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22014. * @param polygon a mesh built from polygonTriangulation.build()
  22015. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22016. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22017. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22018. * @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)
  22019. * @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)
  22020. * @returns the VertexData of the Polygon
  22021. */
  22022. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22023. /**
  22024. * Creates the VertexData of the IcoSphere
  22025. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22026. * * radius the radius of the IcoSphere, optional default 1
  22027. * * radiusX allows stretching in the x direction, optional, default radius
  22028. * * radiusY allows stretching in the y direction, optional, default radius
  22029. * * radiusZ allows stretching in the z direction, optional, default radius
  22030. * * flat when true creates a flat shaded mesh, optional, default true
  22031. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22032. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22033. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22034. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22035. * @returns the VertexData of the IcoSphere
  22036. */
  22037. static CreateIcoSphere(options: {
  22038. radius?: number;
  22039. radiusX?: number;
  22040. radiusY?: number;
  22041. radiusZ?: number;
  22042. flat?: boolean;
  22043. subdivisions?: number;
  22044. sideOrientation?: number;
  22045. frontUVs?: Vector4;
  22046. backUVs?: Vector4;
  22047. }): VertexData;
  22048. /**
  22049. * Creates the VertexData for a Polyhedron
  22050. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22051. * * type provided types are:
  22052. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22053. * * 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)
  22054. * * size the size of the IcoSphere, optional default 1
  22055. * * sizeX allows stretching in the x direction, optional, default size
  22056. * * sizeY allows stretching in the y direction, optional, default size
  22057. * * sizeZ allows stretching in the z direction, optional, default size
  22058. * * 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
  22059. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22060. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22061. * * flat when true creates a flat shaded mesh, optional, default true
  22062. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22063. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22064. * * 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)
  22065. * * 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)
  22066. * @returns the VertexData of the Polyhedron
  22067. */
  22068. static CreatePolyhedron(options: {
  22069. type?: number;
  22070. size?: number;
  22071. sizeX?: number;
  22072. sizeY?: number;
  22073. sizeZ?: number;
  22074. custom?: any;
  22075. faceUV?: Vector4[];
  22076. faceColors?: Color4[];
  22077. flat?: boolean;
  22078. sideOrientation?: number;
  22079. frontUVs?: Vector4;
  22080. backUVs?: Vector4;
  22081. }): VertexData;
  22082. /**
  22083. * Creates the VertexData for a TorusKnot
  22084. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22085. * * radius the radius of the torus knot, optional, default 2
  22086. * * tube the thickness of the tube, optional, default 0.5
  22087. * * radialSegments the number of sides on each tube segments, optional, default 32
  22088. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22089. * * p the number of windings around the z axis, optional, default 2
  22090. * * q the number of windings around the x axis, optional, default 3
  22091. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22092. * * 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)
  22093. * * 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)
  22094. * @returns the VertexData of the Torus Knot
  22095. */
  22096. static CreateTorusKnot(options: {
  22097. radius?: number;
  22098. tube?: number;
  22099. radialSegments?: number;
  22100. tubularSegments?: number;
  22101. p?: number;
  22102. q?: number;
  22103. sideOrientation?: number;
  22104. frontUVs?: Vector4;
  22105. backUVs?: Vector4;
  22106. }): VertexData;
  22107. /**
  22108. * Compute normals for given positions and indices
  22109. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22110. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22111. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22112. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22113. * * facetNormals : optional array of facet normals (vector3)
  22114. * * facetPositions : optional array of facet positions (vector3)
  22115. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22116. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22117. * * bInfo : optional bounding info, required for facetPartitioning computation
  22118. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22119. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22120. * * useRightHandedSystem: optional boolean to for right handed system computation
  22121. * * depthSort : optional boolean to enable the facet depth sort computation
  22122. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22123. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22124. */
  22125. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22126. facetNormals?: any;
  22127. facetPositions?: any;
  22128. facetPartitioning?: any;
  22129. ratio?: number;
  22130. bInfo?: any;
  22131. bbSize?: Vector3;
  22132. subDiv?: any;
  22133. useRightHandedSystem?: boolean;
  22134. depthSort?: boolean;
  22135. distanceTo?: Vector3;
  22136. depthSortedFacets?: any;
  22137. }): void;
  22138. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  22139. /**
  22140. * Applies VertexData created from the imported parameters to the geometry
  22141. * @param parsedVertexData the parsed data from an imported file
  22142. * @param geometry the geometry to apply the VertexData to
  22143. */
  22144. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22145. }
  22146. }
  22147. declare module BABYLON {
  22148. /**
  22149. * Class containing static functions to help procedurally build meshes
  22150. */
  22151. class MeshBuilder {
  22152. private static updateSideOrientation(orientation?);
  22153. /**
  22154. * Creates a box mesh
  22155. * * The parameter `size` sets the size (float) of each box side (default 1)
  22156. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  22157. * * 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)
  22158. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22160. * * 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
  22161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22162. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  22163. * @param name defines the name of the mesh
  22164. * @param options defines the options used to create the mesh
  22165. * @param scene defines the hosting scene
  22166. * @returns the box mesh
  22167. */
  22168. static CreateBox(name: string, options: {
  22169. size?: number;
  22170. width?: number;
  22171. height?: number;
  22172. depth?: number;
  22173. faceUV?: Vector4[];
  22174. faceColors?: Color4[];
  22175. sideOrientation?: number;
  22176. frontUVs?: Vector4;
  22177. backUVs?: Vector4;
  22178. updatable?: boolean;
  22179. }, scene?: Nullable<Scene>): Mesh;
  22180. /**
  22181. * Creates a sphere mesh
  22182. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  22183. * * 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 than `diameter`)
  22184. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  22185. * * 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
  22186. * * 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)
  22187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22188. * * 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
  22189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22190. * @param name defines the name of the mesh
  22191. * @param options defines the options used to create the mesh
  22192. * @param scene defines the hosting scene
  22193. * @returns the sphere mesh
  22194. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  22195. */
  22196. static CreateSphere(name: string, options: {
  22197. segments?: number;
  22198. diameter?: number;
  22199. diameterX?: number;
  22200. diameterY?: number;
  22201. diameterZ?: number;
  22202. arc?: number;
  22203. slice?: number;
  22204. sideOrientation?: number;
  22205. frontUVs?: Vector4;
  22206. backUVs?: Vector4;
  22207. updatable?: boolean;
  22208. }, scene: any): Mesh;
  22209. /**
  22210. * Creates a plane polygonal mesh. By default, this is a disc
  22211. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22212. * * 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
  22213. * * 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
  22214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22215. * * 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
  22216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22217. * @param name defines the name of the mesh
  22218. * @param options defines the options used to create the mesh
  22219. * @param scene defines the hosting scene
  22220. * @returns the plane polygonal mesh
  22221. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22222. */
  22223. static CreateDisc(name: string, options: {
  22224. radius?: number;
  22225. tessellation?: number;
  22226. arc?: number;
  22227. updatable?: boolean;
  22228. sideOrientation?: number;
  22229. frontUVs?: Vector4;
  22230. backUVs?: Vector4;
  22231. }, scene?: Nullable<Scene>): Mesh;
  22232. /**
  22233. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22234. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22235. * * 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`)
  22236. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22237. * * 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
  22238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22239. * * 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
  22240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22241. * @param name defines the name of the mesh
  22242. * @param options defines the options used to create the mesh
  22243. * @param scene defines the hosting scene
  22244. * @returns the icosahedron mesh
  22245. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22246. */
  22247. static CreateIcoSphere(name: string, options: {
  22248. radius?: number;
  22249. radiusX?: number;
  22250. radiusY?: number;
  22251. radiusZ?: number;
  22252. flat?: boolean;
  22253. subdivisions?: number;
  22254. sideOrientation?: number;
  22255. frontUVs?: Vector4;
  22256. backUVs?: Vector4;
  22257. updatable?: boolean;
  22258. }, scene: Scene): Mesh;
  22259. /**
  22260. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22261. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  22262. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  22263. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  22264. * * 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
  22265. * * 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
  22266. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
  22267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22268. * * 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
  22269. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22270. * * 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
  22271. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  22272. * * 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
  22273. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  22274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22275. * @param name defines the name of the mesh
  22276. * @param options defines the options used to create the mesh
  22277. * @param scene defines the hosting scene
  22278. * @returns the ribbon mesh
  22279. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22280. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22281. */
  22282. static CreateRibbon(name: string, options: {
  22283. pathArray: Vector3[][];
  22284. closeArray?: boolean;
  22285. closePath?: boolean;
  22286. offset?: number;
  22287. updatable?: boolean;
  22288. sideOrientation?: number;
  22289. frontUVs?: Vector4;
  22290. backUVs?: Vector4;
  22291. instance?: Mesh;
  22292. invertUV?: boolean;
  22293. uvs?: Vector2[];
  22294. colors?: Color4[];
  22295. }, scene?: Nullable<Scene>): Mesh;
  22296. /**
  22297. * Creates a cylinder or a cone mesh
  22298. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22299. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22300. * * 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.
  22301. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22302. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22303. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  22304. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  22305. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  22306. * * 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).
  22307. * * 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
  22308. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  22309. * * 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
  22310. * * 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.
  22311. * * If `enclose` is false, a ring surface is one element.
  22312. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  22313. * * Example how to set colors and textures on a sliced cylinder : http://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  22314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22315. * * 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
  22316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22317. * @param name defines the name of the mesh
  22318. * @param options defines the options used to create the mesh
  22319. * @param scene defines the hosting scene
  22320. * @returns the cylinder mesh
  22321. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  22322. */
  22323. static CreateCylinder(name: string, options: {
  22324. height?: number;
  22325. diameterTop?: number;
  22326. diameterBottom?: number;
  22327. diameter?: number;
  22328. tessellation?: number;
  22329. subdivisions?: number;
  22330. arc?: number;
  22331. faceColors?: Color4[];
  22332. faceUV?: Vector4[];
  22333. updatable?: boolean;
  22334. hasRings?: boolean;
  22335. enclose?: boolean;
  22336. sideOrientation?: number;
  22337. frontUVs?: Vector4;
  22338. backUVs?: Vector4;
  22339. }, scene: any): Mesh;
  22340. /**
  22341. * Creates a torus mesh
  22342. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  22343. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  22344. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  22345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22346. * * 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
  22347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22348. * @param name defines the name of the mesh
  22349. * @param options defines the options used to create the mesh
  22350. * @param scene defines the hosting scene
  22351. * @returns the torus mesh
  22352. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  22353. */
  22354. static CreateTorus(name: string, options: {
  22355. diameter?: number;
  22356. thickness?: number;
  22357. tessellation?: number;
  22358. updatable?: boolean;
  22359. sideOrientation?: number;
  22360. frontUVs?: Vector4;
  22361. backUVs?: Vector4;
  22362. }, scene: any): Mesh;
  22363. /**
  22364. * Creates a torus knot mesh
  22365. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  22366. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  22367. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  22368. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  22369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22370. * * 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
  22371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22372. * @param name defines the name of the mesh
  22373. * @param options defines the options used to create the mesh
  22374. * @param scene defines the hosting scene
  22375. * @returns the torus knot mesh
  22376. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  22377. */
  22378. static CreateTorusKnot(name: string, options: {
  22379. radius?: number;
  22380. tube?: number;
  22381. radialSegments?: number;
  22382. tubularSegments?: number;
  22383. p?: number;
  22384. q?: number;
  22385. updatable?: boolean;
  22386. sideOrientation?: number;
  22387. frontUVs?: Vector4;
  22388. backUVs?: Vector4;
  22389. }, scene: any): Mesh;
  22390. /**
  22391. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  22392. * * 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
  22393. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  22394. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  22395. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  22396. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  22397. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  22398. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  22399. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  22400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22401. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  22402. * @param name defines the name of the new line system
  22403. * @param options defines the options used to create the line system
  22404. * @param scene defines the hosting scene
  22405. * @returns a new line system mesh
  22406. */
  22407. static CreateLineSystem(name: string, options: {
  22408. lines: Vector3[][];
  22409. updatable?: boolean;
  22410. instance?: Nullable<LinesMesh>;
  22411. colors?: Nullable<Color4[][]>;
  22412. useVertexAlpha?: boolean;
  22413. }, scene: Nullable<Scene>): LinesMesh;
  22414. /**
  22415. * Creates a line mesh
  22416. * 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
  22417. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22418. * * The parameter `points` is an array successive Vector3
  22419. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  22420. * * The optional parameter `colors` is an array of successive Color4, one per line point
  22421. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  22422. * * When updating an instance, remember that only point positions can change, not the number of points
  22423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22424. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  22425. * @param name defines the name of the new line system
  22426. * @param options defines the options used to create the line system
  22427. * @param scene defines the hosting scene
  22428. * @returns a new line mesh
  22429. */
  22430. static CreateLines(name: string, options: {
  22431. points: Vector3[];
  22432. updatable?: boolean;
  22433. instance?: Nullable<LinesMesh>;
  22434. colors?: Color4[];
  22435. useVertexAlpha?: boolean;
  22436. }, scene?: Nullable<Scene>): LinesMesh;
  22437. /**
  22438. * Creates a dashed line mesh
  22439. * * 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
  22440. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22441. * * The parameter `points` is an array successive Vector3
  22442. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  22443. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  22444. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22445. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  22446. * * When updating an instance, remember that only point positions can change, not the number of points
  22447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22448. * @param name defines the name of the mesh
  22449. * @param options defines the options used to create the mesh
  22450. * @param scene defines the hosting scene
  22451. * @returns the dashed line mesh
  22452. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  22453. */
  22454. static CreateDashedLines(name: string, options: {
  22455. points: Vector3[];
  22456. dashSize?: number;
  22457. gapSize?: number;
  22458. dashNb?: number;
  22459. updatable?: boolean;
  22460. instance?: LinesMesh;
  22461. }, scene?: Nullable<Scene>): LinesMesh;
  22462. /**
  22463. * 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.
  22464. * * 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.
  22465. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22466. * * 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.
  22467. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  22468. * * 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
  22469. * * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  22470. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22472. * * 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
  22473. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  22474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22475. * @param name defines the name of the mesh
  22476. * @param options defines the options used to create the mesh
  22477. * @param scene defines the hosting scene
  22478. * @returns the extruded shape mesh
  22479. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22480. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22481. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22482. */
  22483. static ExtrudeShape(name: string, options: {
  22484. shape: Vector3[];
  22485. path: Vector3[];
  22486. scale?: number;
  22487. rotation?: number;
  22488. cap?: number;
  22489. updatable?: boolean;
  22490. sideOrientation?: number;
  22491. frontUVs?: Vector4;
  22492. backUVs?: Vector4;
  22493. instance?: Mesh;
  22494. invertUV?: boolean;
  22495. }, scene?: Nullable<Scene>): Mesh;
  22496. /**
  22497. * Creates an custom extruded shape mesh.
  22498. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  22499. * * 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.
  22500. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22501. * * 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
  22502. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22503. * * 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
  22504. * * It must returns a float value that will be the scale value applied to the shape on each path point
  22505. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22506. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  22507. * * 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
  22508. * * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  22509. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  22510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22511. * * 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
  22512. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22514. * @param name defines the name of the mesh
  22515. * @param options defines the options used to create the mesh
  22516. * @param scene defines the hosting scene
  22517. * @returns the custom extruded shape mesh
  22518. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  22519. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22520. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22521. */
  22522. static ExtrudeShapeCustom(name: string, options: {
  22523. shape: Vector3[];
  22524. path: Vector3[];
  22525. scaleFunction?: any;
  22526. rotationFunction?: any;
  22527. ribbonCloseArray?: boolean;
  22528. ribbonClosePath?: boolean;
  22529. cap?: number;
  22530. updatable?: boolean;
  22531. sideOrientation?: number;
  22532. frontUVs?: Vector4;
  22533. backUVs?: Vector4;
  22534. instance?: Mesh;
  22535. invertUV?: boolean;
  22536. }, scene: Scene): Mesh;
  22537. /**
  22538. * Creates lathe mesh.
  22539. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  22540. * * 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
  22541. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  22542. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  22543. * * 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
  22544. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  22545. * * 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
  22546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22547. * * 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
  22548. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22550. * @param name defines the name of the mesh
  22551. * @param options defines the options used to create the mesh
  22552. * @param scene defines the hosting scene
  22553. * @returns the lathe mesh
  22554. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  22555. */
  22556. static CreateLathe(name: string, options: {
  22557. shape: Vector3[];
  22558. radius?: number;
  22559. tessellation?: number;
  22560. arc?: number;
  22561. closed?: boolean;
  22562. updatable?: boolean;
  22563. sideOrientation?: number;
  22564. frontUVs?: Vector4;
  22565. backUVs?: Vector4;
  22566. cap?: number;
  22567. invertUV?: boolean;
  22568. }, scene: Scene): Mesh;
  22569. /**
  22570. * Creates a plane mesh
  22571. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  22572. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  22573. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  22574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22575. * * 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
  22576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22577. * @param name defines the name of the mesh
  22578. * @param options defines the options used to create the mesh
  22579. * @param scene defines the hosting scene
  22580. * @returns the plane mesh
  22581. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22582. */
  22583. static CreatePlane(name: string, options: {
  22584. size?: number;
  22585. width?: number;
  22586. height?: number;
  22587. sideOrientation?: number;
  22588. frontUVs?: Vector4;
  22589. backUVs?: Vector4;
  22590. updatable?: boolean;
  22591. sourcePlane?: Plane;
  22592. }, scene: Scene): Mesh;
  22593. /**
  22594. * Creates a ground mesh
  22595. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  22596. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  22597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22598. * @param name defines the name of the mesh
  22599. * @param options defines the options used to create the mesh
  22600. * @param scene defines the hosting scene
  22601. * @returns the ground mesh
  22602. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22603. */
  22604. static CreateGround(name: string, options: {
  22605. width?: number;
  22606. height?: number;
  22607. subdivisions?: number;
  22608. subdivisionsX?: number;
  22609. subdivisionsY?: number;
  22610. updatable?: boolean;
  22611. }, scene: any): Mesh;
  22612. /**
  22613. * Creates a tiled ground mesh
  22614. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  22615. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  22616. * * 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
  22617. * * 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
  22618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22619. * @param name defines the name of the mesh
  22620. * @param options defines the options used to create the mesh
  22621. * @param scene defines the hosting scene
  22622. * @returns the tiled ground mesh
  22623. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  22624. */
  22625. static CreateTiledGround(name: string, options: {
  22626. xmin: number;
  22627. zmin: number;
  22628. xmax: number;
  22629. zmax: number;
  22630. subdivisions?: {
  22631. w: number;
  22632. h: number;
  22633. };
  22634. precision?: {
  22635. w: number;
  22636. h: number;
  22637. };
  22638. updatable?: boolean;
  22639. }, scene: Scene): Mesh;
  22640. /**
  22641. * Creates a ground mesh from a height map
  22642. * * The parameter `url` sets the URL of the height map image resource.
  22643. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22644. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22645. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22646. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22647. * * 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.
  22648. * * 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).
  22649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22650. * @param name defines the name of the mesh
  22651. * @param url defines the url to the height map
  22652. * @param options defines the options used to create the mesh
  22653. * @param scene defines the hosting scene
  22654. * @returns the ground mesh
  22655. * @see http://doc.babylonjs.com/babylon101/height_map
  22656. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  22657. */
  22658. static CreateGroundFromHeightMap(name: string, url: string, options: {
  22659. width?: number;
  22660. height?: number;
  22661. subdivisions?: number;
  22662. minHeight?: number;
  22663. maxHeight?: number;
  22664. colorFilter?: Color3;
  22665. updatable?: boolean;
  22666. onReady?: (mesh: GroundMesh) => void;
  22667. }, scene: Scene): GroundMesh;
  22668. /**
  22669. * Creates a polygon mesh
  22670. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  22671. * * 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
  22672. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22674. * * 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)
  22675. * * Remember you can only change the shape positions, not their number when updating a polygon
  22676. * @param name defines the name of the mesh
  22677. * @param options defines the options used to create the mesh
  22678. * @param scene defines the hosting scene
  22679. * @returns the polygon mesh
  22680. */
  22681. static CreatePolygon(name: string, options: {
  22682. shape: Vector3[];
  22683. holes?: Vector3[][];
  22684. depth?: number;
  22685. faceUV?: Vector4[];
  22686. faceColors?: Color4[];
  22687. updatable?: boolean;
  22688. sideOrientation?: number;
  22689. frontUVs?: Vector4;
  22690. backUVs?: Vector4;
  22691. }, scene: Scene): Mesh;
  22692. /**
  22693. * Creates an extruded polygon mesh, with depth in the Y direction.
  22694. * * 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)
  22695. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22696. * @param name defines the name of the mesh
  22697. * @param options defines the options used to create the mesh
  22698. * @param scene defines the hosting scene
  22699. * @returns the polygon mesh
  22700. */
  22701. static ExtrudePolygon(name: string, options: {
  22702. shape: Vector3[];
  22703. holes?: Vector3[][];
  22704. depth?: number;
  22705. faceUV?: Vector4[];
  22706. faceColors?: Color4[];
  22707. updatable?: boolean;
  22708. sideOrientation?: number;
  22709. frontUVs?: Vector4;
  22710. backUVs?: Vector4;
  22711. }, scene: Scene): Mesh;
  22712. /**
  22713. * Creates a tube mesh.
  22714. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22715. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  22716. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  22717. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  22718. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  22719. * * 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)
  22720. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  22721. * * 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
  22722. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#tube
  22723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22724. * * 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
  22725. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22727. * @param name defines the name of the mesh
  22728. * @param options defines the options used to create the mesh
  22729. * @param scene defines the hosting scene
  22730. * @returns the tube mesh
  22731. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22732. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  22733. */
  22734. static CreateTube(name: string, options: {
  22735. path: Vector3[];
  22736. radius?: number;
  22737. tessellation?: number;
  22738. radiusFunction?: {
  22739. (i: number, distance: number): number;
  22740. };
  22741. cap?: number;
  22742. arc?: number;
  22743. updatable?: boolean;
  22744. sideOrientation?: number;
  22745. frontUVs?: Vector4;
  22746. backUVs?: Vector4;
  22747. instance?: Mesh;
  22748. invertUV?: boolean;
  22749. }, scene: Scene): Mesh;
  22750. /**
  22751. * Creates a polyhedron mesh
  22752. * * 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
  22753. * * The parameter `size` (positive float, default 1) sets the polygon size
  22754. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22755. * * 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`
  22756. * * 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
  22757. * * 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)`)
  22758. * * 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 : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22759. * * 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
  22760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22761. * * 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
  22762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22763. * @param name defines the name of the mesh
  22764. * @param options defines the options used to create the mesh
  22765. * @param scene defines the hosting scene
  22766. * @returns the polyhedron mesh
  22767. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  22768. */
  22769. static CreatePolyhedron(name: string, options: {
  22770. type?: number;
  22771. size?: number;
  22772. sizeX?: number;
  22773. sizeY?: number;
  22774. sizeZ?: number;
  22775. custom?: any;
  22776. faceUV?: Vector4[];
  22777. faceColors?: Color4[];
  22778. flat?: boolean;
  22779. updatable?: boolean;
  22780. sideOrientation?: number;
  22781. frontUVs?: Vector4;
  22782. backUVs?: Vector4;
  22783. }, scene: Scene): Mesh;
  22784. /**
  22785. * Creates a decal mesh.
  22786. * 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
  22787. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  22788. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  22789. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  22790. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  22791. * @param name defines the name of the mesh
  22792. * @param sourceMesh defines the mesh where the decal must be applied
  22793. * @param options defines the options used to create the mesh
  22794. * @param scene defines the hosting scene
  22795. * @returns the decal mesh
  22796. * @see http://doc.babylonjs.com/how_to/decals
  22797. */
  22798. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  22799. position?: Vector3;
  22800. normal?: Vector3;
  22801. size?: Vector3;
  22802. angle?: number;
  22803. }): Mesh;
  22804. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  22805. }
  22806. }
  22807. declare module BABYLON {
  22808. class MeshLODLevel {
  22809. distance: number;
  22810. mesh: Nullable<Mesh>;
  22811. constructor(distance: number, mesh: Nullable<Mesh>);
  22812. }
  22813. }
  22814. declare module BABYLON {
  22815. /**
  22816. * A simplifier interface for future simplification implementations.
  22817. */
  22818. interface ISimplifier {
  22819. /**
  22820. * Simplification of a given mesh according to the given settings.
  22821. * Since this requires computation, it is assumed that the function runs async.
  22822. * @param settings The settings of the simplification, including quality and distance
  22823. * @param successCallback A callback that will be called after the mesh was simplified.
  22824. * @param errorCallback in case of an error, this callback will be called. optional.
  22825. */
  22826. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  22827. }
  22828. /**
  22829. * Expected simplification settings.
  22830. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  22831. */
  22832. interface ISimplificationSettings {
  22833. quality: number;
  22834. distance: number;
  22835. optimizeMesh?: boolean;
  22836. }
  22837. class SimplificationSettings implements ISimplificationSettings {
  22838. quality: number;
  22839. distance: number;
  22840. optimizeMesh: boolean | undefined;
  22841. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  22842. }
  22843. interface ISimplificationTask {
  22844. settings: Array<ISimplificationSettings>;
  22845. simplificationType: SimplificationType;
  22846. mesh: Mesh;
  22847. successCallback?: () => void;
  22848. parallelProcessing: boolean;
  22849. }
  22850. class SimplificationQueue {
  22851. private _simplificationArray;
  22852. running: boolean;
  22853. constructor();
  22854. addTask(task: ISimplificationTask): void;
  22855. executeNext(): void;
  22856. runSimplification(task: ISimplificationTask): void;
  22857. private getSimplifier(task);
  22858. }
  22859. /**
  22860. * The implemented types of simplification
  22861. * At the moment only Quadratic Error Decimation is implemented
  22862. */
  22863. enum SimplificationType {
  22864. /** Quadratic error decimation */
  22865. QUADRATIC = 0,
  22866. }
  22867. class DecimationTriangle {
  22868. vertices: Array<DecimationVertex>;
  22869. normal: Vector3;
  22870. error: Array<number>;
  22871. deleted: boolean;
  22872. isDirty: boolean;
  22873. borderFactor: number;
  22874. deletePending: boolean;
  22875. originalOffset: number;
  22876. constructor(vertices: Array<DecimationVertex>);
  22877. }
  22878. class DecimationVertex {
  22879. position: Vector3;
  22880. id: number;
  22881. q: QuadraticMatrix;
  22882. isBorder: boolean;
  22883. triangleStart: number;
  22884. triangleCount: number;
  22885. originalOffsets: Array<number>;
  22886. constructor(position: Vector3, id: number);
  22887. updatePosition(newPosition: Vector3): void;
  22888. }
  22889. class QuadraticMatrix {
  22890. data: Array<number>;
  22891. constructor(data?: Array<number>);
  22892. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  22893. addInPlace(matrix: QuadraticMatrix): void;
  22894. addArrayInPlace(data: Array<number>): void;
  22895. add(matrix: QuadraticMatrix): QuadraticMatrix;
  22896. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  22897. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  22898. }
  22899. class Reference {
  22900. vertexId: number;
  22901. triangleId: number;
  22902. constructor(vertexId: number, triangleId: number);
  22903. }
  22904. /**
  22905. * An implementation of the Quadratic Error simplification algorithm.
  22906. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  22907. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  22908. * @author RaananW
  22909. */
  22910. class QuadraticErrorSimplification implements ISimplifier {
  22911. private _mesh;
  22912. private triangles;
  22913. private vertices;
  22914. private references;
  22915. private _reconstructedMesh;
  22916. syncIterations: number;
  22917. aggressiveness: number;
  22918. decimationIterations: number;
  22919. boundingBoxEpsilon: number;
  22920. constructor(_mesh: Mesh);
  22921. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  22922. private runDecimation(settings, submeshIndex, successCallback);
  22923. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  22924. private init(callback);
  22925. private reconstructMesh(submeshIndex);
  22926. private initDecimatedMesh();
  22927. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  22928. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  22929. private identifyBorder();
  22930. private updateMesh(identifyBorders?);
  22931. private vertexError(q, point);
  22932. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  22933. }
  22934. }
  22935. declare module BABYLON {
  22936. class Polygon {
  22937. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  22938. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  22939. static Parse(input: string): Vector2[];
  22940. static StartingAt(x: number, y: number): Path2;
  22941. }
  22942. class PolygonMeshBuilder {
  22943. private _points;
  22944. private _outlinepoints;
  22945. private _holes;
  22946. private _name;
  22947. private _scene;
  22948. private _epoints;
  22949. private _eholes;
  22950. private _addToepoint(points);
  22951. constructor(name: string, contours: Path2, scene: Scene);
  22952. constructor(name: string, contours: Vector2[], scene: Scene);
  22953. addHole(hole: Vector2[]): PolygonMeshBuilder;
  22954. build(updatable?: boolean, depth?: number): Mesh;
  22955. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  22956. }
  22957. }
  22958. declare module BABYLON {
  22959. class BaseSubMesh {
  22960. _materialDefines: Nullable<MaterialDefines>;
  22961. _materialEffect: Nullable<Effect>;
  22962. readonly effect: Nullable<Effect>;
  22963. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22964. }
  22965. class SubMesh extends BaseSubMesh implements ICullable {
  22966. materialIndex: number;
  22967. verticesStart: number;
  22968. verticesCount: number;
  22969. indexStart: number;
  22970. indexCount: number;
  22971. linesIndexCount: number;
  22972. private _mesh;
  22973. private _renderingMesh;
  22974. private _boundingInfo;
  22975. private _linesIndexBuffer;
  22976. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22977. _trianglePlanes: Plane[];
  22978. _lastColliderTransformMatrix: Matrix;
  22979. _renderId: number;
  22980. _alphaIndex: number;
  22981. _distanceToCamera: number;
  22982. _id: number;
  22983. private _currentMaterial;
  22984. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22985. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22986. readonly IsGlobal: boolean;
  22987. /**
  22988. * Returns the submesh BoudingInfo object.
  22989. */
  22990. getBoundingInfo(): BoundingInfo;
  22991. /**
  22992. * Sets the submesh BoundingInfo.
  22993. * Return the SubMesh.
  22994. */
  22995. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22996. /**
  22997. * Returns the mesh of the current submesh.
  22998. */
  22999. getMesh(): AbstractMesh;
  23000. /**
  23001. * Returns the rendering mesh of the submesh.
  23002. */
  23003. getRenderingMesh(): Mesh;
  23004. /**
  23005. * Returns the submesh material.
  23006. */
  23007. getMaterial(): Nullable<Material>;
  23008. /**
  23009. * Sets a new updated BoundingInfo object to the submesh.
  23010. * Returns the SubMesh.
  23011. */
  23012. refreshBoundingInfo(): SubMesh;
  23013. _checkCollision(collider: Collider): boolean;
  23014. /**
  23015. * Updates the submesh BoundingInfo.
  23016. * Returns the Submesh.
  23017. */
  23018. updateBoundingInfo(world: Matrix): SubMesh;
  23019. /**
  23020. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23021. * Boolean returned.
  23022. */
  23023. isInFrustum(frustumPlanes: Plane[]): boolean;
  23024. /**
  23025. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  23026. * Boolean returned.
  23027. */
  23028. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23029. /**
  23030. * Renders the submesh.
  23031. * Returns it.
  23032. */
  23033. render(enableAlphaMode: boolean): SubMesh;
  23034. /**
  23035. * Returns a new Index Buffer.
  23036. * Type returned : WebGLBuffer.
  23037. */
  23038. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  23039. /**
  23040. * True is the passed Ray intersects the submesh bounding box.
  23041. * Boolean returned.
  23042. */
  23043. canIntersects(ray: Ray): boolean;
  23044. /**
  23045. * Returns an object IntersectionInfo.
  23046. */
  23047. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  23048. _rebuild(): void;
  23049. /**
  23050. * Creates a new Submesh from the passed Mesh.
  23051. */
  23052. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23053. /**
  23054. * Disposes the Submesh.
  23055. * Returns nothing.
  23056. */
  23057. dispose(): void;
  23058. /**
  23059. * Creates a new Submesh from the passed parameters :
  23060. * - materialIndex (integer) : the index of the main mesh material.
  23061. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  23062. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  23063. * - mesh (Mesh) : the main mesh to create the submesh from.
  23064. * - renderingMesh (optional Mesh) : rendering mesh.
  23065. */
  23066. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23067. }
  23068. }
  23069. declare module BABYLON {
  23070. class TransformNode extends Node {
  23071. static BILLBOARDMODE_NONE: number;
  23072. static BILLBOARDMODE_X: number;
  23073. static BILLBOARDMODE_Y: number;
  23074. static BILLBOARDMODE_Z: number;
  23075. static BILLBOARDMODE_ALL: number;
  23076. private _forward;
  23077. private _forwardInverted;
  23078. private _up;
  23079. private _right;
  23080. private _rightInverted;
  23081. private _rotation;
  23082. private _rotationQuaternion;
  23083. protected _scaling: Vector3;
  23084. protected _isDirty: boolean;
  23085. private _transformToBoneReferal;
  23086. /**
  23087. * Set the billboard mode. Default is 0.
  23088. *
  23089. * | Value | Type | Description |
  23090. * | --- | --- | --- |
  23091. * | 0 | BILLBOARDMODE_NONE | |
  23092. * | 1 | BILLBOARDMODE_X | |
  23093. * | 2 | BILLBOARDMODE_Y | |
  23094. * | 4 | BILLBOARDMODE_Z | |
  23095. * | 7 | BILLBOARDMODE_ALL | |
  23096. *
  23097. */
  23098. billboardMode: number;
  23099. scalingDeterminant: number;
  23100. infiniteDistance: boolean;
  23101. /**
  23102. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  23103. * By default the system will update normals to compensate
  23104. */
  23105. ignoreNonUniformScaling: boolean;
  23106. position: Vector3;
  23107. _poseMatrix: Matrix;
  23108. private _localWorld;
  23109. _worldMatrix: Matrix;
  23110. _worldMatrixDeterminant: number;
  23111. private _absolutePosition;
  23112. private _pivotMatrix;
  23113. private _pivotMatrixInverse;
  23114. private _postMultiplyPivotMatrix;
  23115. protected _isWorldMatrixFrozen: boolean;
  23116. /**
  23117. * An event triggered after the world matrix is updated
  23118. */
  23119. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  23120. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  23121. /**
  23122. * Gets a string idenfifying the name of the class
  23123. * @returns "TransformNode" string
  23124. */
  23125. getClassName(): string;
  23126. /**
  23127. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  23128. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  23129. * Default : (0.0, 0.0, 0.0)
  23130. */
  23131. rotation: Vector3;
  23132. /**
  23133. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23134. * Default : (1.0, 1.0, 1.0)
  23135. */
  23136. /**
  23137. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23138. * Default : (1.0, 1.0, 1.0)
  23139. */
  23140. scaling: Vector3;
  23141. /**
  23142. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  23143. * It's null by default.
  23144. * If set, only the rotationQuaternion is then used to compute the mesh rotation and its property `.rotation\ is then ignored and set to (0.0, 0.0, 0.0)
  23145. */
  23146. rotationQuaternion: Nullable<Quaternion>;
  23147. /**
  23148. * The forward direction of that transform in world space.
  23149. */
  23150. readonly forward: Vector3;
  23151. /**
  23152. * The up direction of that transform in world space.
  23153. */
  23154. readonly up: Vector3;
  23155. /**
  23156. * The right direction of that transform in world space.
  23157. */
  23158. readonly right: Vector3;
  23159. /**
  23160. * Returns the latest update of the World matrix
  23161. * Returns a Matrix.
  23162. */
  23163. getWorldMatrix(): Matrix;
  23164. /** @hidden */
  23165. _getWorldMatrixDeterminant(): number;
  23166. /**
  23167. * Returns directly the latest state of the mesh World matrix.
  23168. * A Matrix is returned.
  23169. */
  23170. readonly worldMatrixFromCache: Matrix;
  23171. /**
  23172. * Copies the paramater passed Matrix into the mesh Pose matrix.
  23173. * Returns the TransformNode.
  23174. */
  23175. updatePoseMatrix(matrix: Matrix): TransformNode;
  23176. /**
  23177. * Returns the mesh Pose matrix.
  23178. * Returned object : Matrix
  23179. */
  23180. getPoseMatrix(): Matrix;
  23181. _isSynchronized(): boolean;
  23182. _initCache(): void;
  23183. markAsDirty(property: string): TransformNode;
  23184. /**
  23185. * Returns the current mesh absolute position.
  23186. * Retuns a Vector3.
  23187. */
  23188. readonly absolutePosition: Vector3;
  23189. /**
  23190. * Sets a new matrix to apply before all other transformation
  23191. * @param matrix defines the transform matrix
  23192. * @returns the current TransformNode
  23193. */
  23194. setPreTransformMatrix(matrix: Matrix): TransformNode;
  23195. /**
  23196. * Sets a new pivot matrix to the current node
  23197. * @param matrix defines the new pivot matrix to use
  23198. * @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
  23199. * @returns the current TransformNode
  23200. */
  23201. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  23202. /**
  23203. * Returns the mesh pivot matrix.
  23204. * Default : Identity.
  23205. * A Matrix is returned.
  23206. */
  23207. getPivotMatrix(): Matrix;
  23208. /**
  23209. * Prevents the World matrix to be computed any longer.
  23210. * Returns the TransformNode.
  23211. */
  23212. freezeWorldMatrix(): TransformNode;
  23213. /**
  23214. * Allows back the World matrix computation.
  23215. * Returns the TransformNode.
  23216. */
  23217. unfreezeWorldMatrix(): this;
  23218. /**
  23219. * True if the World matrix has been frozen.
  23220. * Returns a boolean.
  23221. */
  23222. readonly isWorldMatrixFrozen: boolean;
  23223. /**
  23224. * Retuns the mesh absolute position in the World.
  23225. * Returns a Vector3.
  23226. */
  23227. getAbsolutePosition(): Vector3;
  23228. /**
  23229. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  23230. * Returns the TransformNode.
  23231. */
  23232. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23233. /**
  23234. * Sets the mesh position in its local space.
  23235. * Returns the TransformNode.
  23236. */
  23237. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  23238. /**
  23239. * Returns the mesh position in the local space from the current World matrix values.
  23240. * Returns a new Vector3.
  23241. */
  23242. getPositionExpressedInLocalSpace(): Vector3;
  23243. /**
  23244. * Translates the mesh along the passed Vector3 in its local space.
  23245. * Returns the TransformNode.
  23246. */
  23247. locallyTranslate(vector3: Vector3): TransformNode;
  23248. private static _lookAtVectorCache;
  23249. /**
  23250. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  23251. * @param targetPoint the position (must be in same space as current mesh) to look at
  23252. * @param yawCor optional yaw (y-axis) correction in radians
  23253. * @param pitchCor optional pitch (x-axis) correction in radians
  23254. * @param rollCor optional roll (z-axis) correction in radians
  23255. * @param space the choosen space of the target
  23256. * @returns the TransformNode.
  23257. */
  23258. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  23259. /**
  23260. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  23261. * This Vector3 is expressed in the World space.
  23262. */
  23263. getDirection(localAxis: Vector3): Vector3;
  23264. /**
  23265. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  23266. * localAxis is expressed in the mesh local space.
  23267. * result is computed in the Wordl space from the mesh World matrix.
  23268. * Returns the TransformNode.
  23269. */
  23270. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  23271. /**
  23272. * Sets a new pivot point to the current node
  23273. * @param point defines the new pivot point to use
  23274. * @param space defines if the point is in world or local space (local by default)
  23275. * @returns the current TransformNode
  23276. */
  23277. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  23278. /**
  23279. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  23280. */
  23281. getPivotPoint(): Vector3;
  23282. /**
  23283. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  23284. * Returns the TransformNode.
  23285. */
  23286. getPivotPointToRef(result: Vector3): TransformNode;
  23287. /**
  23288. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  23289. */
  23290. getAbsolutePivotPoint(): Vector3;
  23291. /**
  23292. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  23293. * Returns the TransformNode.
  23294. */
  23295. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  23296. /**
  23297. * Defines the passed node as the parent of the current node.
  23298. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  23299. * Returns the TransformNode.
  23300. */
  23301. setParent(node: Nullable<Node>): TransformNode;
  23302. private _nonUniformScaling;
  23303. readonly nonUniformScaling: boolean;
  23304. _updateNonUniformScalingState(value: boolean): boolean;
  23305. /**
  23306. * Attach the current TransformNode to another TransformNode associated with a bone
  23307. * @param bone Bone affecting the TransformNode
  23308. * @param affectedTransformNode TransformNode associated with the bone
  23309. */
  23310. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  23311. detachFromBone(): TransformNode;
  23312. private static _rotationAxisCache;
  23313. /**
  23314. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  23315. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23316. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23317. * The passed axis is also normalized.
  23318. * Returns the TransformNode.
  23319. */
  23320. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23321. /**
  23322. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  23323. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23324. * The passed axis is also normalized.
  23325. * Returns the TransformNode.
  23326. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  23327. */
  23328. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  23329. /**
  23330. * Translates the mesh along the axis vector for the passed distance in the given space.
  23331. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23332. * Returns the TransformNode.
  23333. */
  23334. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23335. /**
  23336. * Adds a rotation step to the mesh current rotation.
  23337. * x, y, z are Euler angles expressed in radians.
  23338. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  23339. * This means this rotation is made in the mesh local space only.
  23340. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  23341. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  23342. * ```javascript
  23343. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  23344. * ```
  23345. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  23346. * 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.
  23347. * Returns the TransformNode.
  23348. */
  23349. addRotation(x: number, y: number, z: number): TransformNode;
  23350. /**
  23351. * Computes the mesh World matrix and returns it.
  23352. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  23353. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  23354. * If the parameter `force`is set to `true`, the actual computation is done.
  23355. * Returns the mesh World Matrix.
  23356. */
  23357. computeWorldMatrix(force?: boolean): Matrix;
  23358. protected _afterComputeWorldMatrix(): void;
  23359. /**
  23360. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  23361. * @param func: callback function to add
  23362. *
  23363. * Returns the TransformNode.
  23364. */
  23365. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23366. /**
  23367. * Removes a registered callback function.
  23368. * Returns the TransformNode.
  23369. */
  23370. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23371. /**
  23372. * Clone the current transform node
  23373. * Returns the new transform node
  23374. * @param name Name of the new clone
  23375. * @param newParent New parent for the clone
  23376. * @param doNotCloneChildren Do not clone children hierarchy
  23377. */
  23378. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  23379. serialize(currentSerializationObject?: any): any;
  23380. /**
  23381. * Returns a new TransformNode object parsed from the source provided.
  23382. * The parameter `parsedMesh` is the source.
  23383. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  23384. */
  23385. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  23386. /**
  23387. * Releases resources associated with this transform node.
  23388. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23389. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23390. */
  23391. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23392. }
  23393. }
  23394. declare module BABYLON {
  23395. class VertexBuffer {
  23396. /** @hidden */
  23397. _buffer: Buffer;
  23398. private _kind;
  23399. private _size;
  23400. private _ownsBuffer;
  23401. private _instanced;
  23402. private _instanceDivisor;
  23403. /**
  23404. * The byte type.
  23405. */
  23406. static readonly BYTE: number;
  23407. /**
  23408. * The unsigned byte type.
  23409. */
  23410. static readonly UNSIGNED_BYTE: number;
  23411. /**
  23412. * The short type.
  23413. */
  23414. static readonly SHORT: number;
  23415. /**
  23416. * The unsigned short type.
  23417. */
  23418. static readonly UNSIGNED_SHORT: number;
  23419. /**
  23420. * The integer type.
  23421. */
  23422. static readonly INT: number;
  23423. /**
  23424. * The unsigned integer type.
  23425. */
  23426. static readonly UNSIGNED_INT: number;
  23427. /**
  23428. * The float type.
  23429. */
  23430. static readonly FLOAT: number;
  23431. /**
  23432. * Gets or sets the instance divisor when in instanced mode
  23433. */
  23434. instanceDivisor: number;
  23435. /**
  23436. * Gets the byte stride.
  23437. */
  23438. readonly byteStride: number;
  23439. /**
  23440. * Gets the byte offset.
  23441. */
  23442. readonly byteOffset: number;
  23443. /**
  23444. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  23445. */
  23446. readonly normalized: boolean;
  23447. /**
  23448. * Gets the data type of each component in the array.
  23449. */
  23450. readonly type: number;
  23451. /**
  23452. * Constructor
  23453. * @param engine the engine
  23454. * @param data the data to use for this vertex buffer
  23455. * @param kind the vertex buffer kind
  23456. * @param updatable whether the data is updatable
  23457. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  23458. * @param stride the stride (optional)
  23459. * @param instanced whether the buffer is instanced (optional)
  23460. * @param offset the offset of the data (optional)
  23461. * @param size the number of components (optional)
  23462. * @param type the type of the component (optional)
  23463. * @param normalized whether the data contains normalized data (optional)
  23464. * @param useBytes set to true if stride and offset are in bytes (optional)
  23465. */
  23466. 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);
  23467. _rebuild(): void;
  23468. /**
  23469. * Returns the kind of the VertexBuffer (string).
  23470. */
  23471. getKind(): string;
  23472. /**
  23473. * Boolean : is the VertexBuffer updatable ?
  23474. */
  23475. isUpdatable(): boolean;
  23476. /**
  23477. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  23478. */
  23479. getData(): Nullable<DataArray>;
  23480. /**
  23481. * Returns the WebGLBuffer associated to the VertexBuffer.
  23482. */
  23483. getBuffer(): Nullable<WebGLBuffer>;
  23484. /**
  23485. * Returns the stride as a multiple of the type byte length.
  23486. * DEPRECATED. Use byteStride instead.
  23487. */
  23488. getStrideSize(): number;
  23489. /**
  23490. * Returns the offset as a multiple of the type byte length.
  23491. * DEPRECATED. Use byteOffset instead.
  23492. */
  23493. getOffset(): number;
  23494. /**
  23495. * Returns the number of components per vertex attribute (integer).
  23496. */
  23497. getSize(): number;
  23498. /**
  23499. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  23500. */
  23501. getIsInstanced(): boolean;
  23502. /**
  23503. * Returns the instancing divisor, zero for non-instanced (integer).
  23504. */
  23505. getInstanceDivisor(): number;
  23506. /**
  23507. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  23508. * Returns the created WebGLBuffer.
  23509. */
  23510. create(data?: DataArray): void;
  23511. /**
  23512. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23513. * This function will create a new buffer if the current one is not updatable
  23514. * Returns the updated WebGLBuffer.
  23515. */
  23516. update(data: DataArray): void;
  23517. /**
  23518. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23519. * Returns the directly updated WebGLBuffer.
  23520. * @param data the new data
  23521. * @param offset the new offset
  23522. * @param useBytes set to true if the offset is in bytes
  23523. */
  23524. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  23525. /**
  23526. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  23527. */
  23528. dispose(): void;
  23529. /**
  23530. * Enumerates each value of this vertex buffer as numbers.
  23531. * @param count the number of values to enumerate
  23532. * @param callback the callback function called for each value
  23533. */
  23534. forEach(count: number, callback: (value: number, index: number) => void): void;
  23535. private static _PositionKind;
  23536. private static _NormalKind;
  23537. private static _TangentKind;
  23538. private static _UVKind;
  23539. private static _UV2Kind;
  23540. private static _UV3Kind;
  23541. private static _UV4Kind;
  23542. private static _UV5Kind;
  23543. private static _UV6Kind;
  23544. private static _ColorKind;
  23545. private static _MatricesIndicesKind;
  23546. private static _MatricesWeightsKind;
  23547. private static _MatricesIndicesExtraKind;
  23548. private static _MatricesWeightsExtraKind;
  23549. static readonly PositionKind: string;
  23550. static readonly NormalKind: string;
  23551. static readonly TangentKind: string;
  23552. static readonly UVKind: string;
  23553. static readonly UV2Kind: string;
  23554. static readonly UV3Kind: string;
  23555. static readonly UV4Kind: string;
  23556. static readonly UV5Kind: string;
  23557. static readonly UV6Kind: string;
  23558. static readonly ColorKind: string;
  23559. static readonly MatricesIndicesKind: string;
  23560. static readonly MatricesWeightsKind: string;
  23561. static readonly MatricesIndicesExtraKind: string;
  23562. static readonly MatricesWeightsExtraKind: string;
  23563. /**
  23564. * Deduces the stride given a kind.
  23565. * @param kind The kind string to deduce
  23566. * @returns The deduced stride
  23567. */
  23568. static DeduceStride(kind: string): number;
  23569. /**
  23570. * Gets the byte length of the given type.
  23571. * @param type the type
  23572. * @returns the number of bytes
  23573. */
  23574. static GetTypeByteLength(type: number): number;
  23575. /**
  23576. * Enumerates each value of the given parameters as numbers.
  23577. * @param data the data to enumerate
  23578. * @param byteOffset the byte offset of the data
  23579. * @param byteStride the byte stride of the data
  23580. * @param componentCount the number of components per element
  23581. * @param componentType the type of the component
  23582. * @param count the total number of components
  23583. * @param normalized whether the data is normalized
  23584. * @param callback the callback function called for each value
  23585. */
  23586. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  23587. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  23588. }
  23589. }
  23590. declare module BABYLON {
  23591. interface PhysicsImpostorJoint {
  23592. mainImpostor: PhysicsImpostor;
  23593. connectedImpostor: PhysicsImpostor;
  23594. joint: PhysicsJoint;
  23595. }
  23596. class PhysicsEngine {
  23597. private _physicsPlugin;
  23598. gravity: Vector3;
  23599. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  23600. setGravity(gravity: Vector3): void;
  23601. /**
  23602. * Set the time step of the physics engine.
  23603. * default is 1/60.
  23604. * To slow it down, enter 1/600 for example.
  23605. * To speed it up, 1/30
  23606. * @param {number} newTimeStep the new timestep to apply to this world.
  23607. */
  23608. setTimeStep(newTimeStep?: number): void;
  23609. /**
  23610. * Get the time step of the physics engine.
  23611. */
  23612. getTimeStep(): number;
  23613. dispose(): void;
  23614. getPhysicsPluginName(): string;
  23615. static Epsilon: number;
  23616. private _impostors;
  23617. private _joints;
  23618. /**
  23619. * Adding a new impostor for the impostor tracking.
  23620. * This will be done by the impostor itself.
  23621. * @param {PhysicsImpostor} impostor the impostor to add
  23622. */
  23623. addImpostor(impostor: PhysicsImpostor): void;
  23624. /**
  23625. * Remove an impostor from the engine.
  23626. * This impostor and its mesh will not longer be updated by the physics engine.
  23627. * @param {PhysicsImpostor} impostor the impostor to remove
  23628. */
  23629. removeImpostor(impostor: PhysicsImpostor): void;
  23630. /**
  23631. * Add a joint to the physics engine
  23632. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  23633. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  23634. * @param {PhysicsJoint} the joint that will connect both impostors.
  23635. */
  23636. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23637. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23638. /**
  23639. * Called by the scene. no need to call it.
  23640. */
  23641. _step(delta: number): void;
  23642. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23643. getImpostors(): Array<PhysicsImpostor>;
  23644. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23645. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23646. }
  23647. interface IPhysicsEnginePlugin {
  23648. world: any;
  23649. name: string;
  23650. setGravity(gravity: Vector3): void;
  23651. setTimeStep(timeStep: number): void;
  23652. getTimeStep(): number;
  23653. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23654. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23655. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23656. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23657. removePhysicsBody(impostor: PhysicsImpostor): void;
  23658. generateJoint(joint: PhysicsImpostorJoint): void;
  23659. removeJoint(joint: PhysicsImpostorJoint): void;
  23660. isSupported(): boolean;
  23661. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23662. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23663. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23664. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23665. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23666. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23667. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23668. getBodyMass(impostor: PhysicsImpostor): number;
  23669. getBodyFriction(impostor: PhysicsImpostor): number;
  23670. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23671. getBodyRestitution(impostor: PhysicsImpostor): number;
  23672. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23673. sleepBody(impostor: PhysicsImpostor): void;
  23674. wakeUpBody(impostor: PhysicsImpostor): void;
  23675. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23676. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23677. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23678. getRadius(impostor: PhysicsImpostor): number;
  23679. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23680. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23681. dispose(): void;
  23682. }
  23683. }
  23684. declare module BABYLON {
  23685. class PhysicsHelper {
  23686. private _scene;
  23687. private _physicsEngine;
  23688. constructor(scene: Scene);
  23689. /**
  23690. * @param {Vector3} origin the origin of the explosion
  23691. * @param {number} radius the explosion radius
  23692. * @param {number} strength the explosion strength
  23693. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  23694. */
  23695. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  23696. /**
  23697. * @param {Vector3} origin the origin of the explosion
  23698. * @param {number} radius the explosion radius
  23699. * @param {number} strength the explosion strength
  23700. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  23701. */
  23702. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  23703. /**
  23704. * @param {Vector3} origin the origin of the explosion
  23705. * @param {number} radius the explosion radius
  23706. * @param {number} strength the explosion strength
  23707. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  23708. */
  23709. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  23710. /**
  23711. * @param {Vector3} origin the origin of the updraft
  23712. * @param {number} radius the radius of the updraft
  23713. * @param {number} strength the strength of the updraft
  23714. * @param {number} height the height of the updraft
  23715. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  23716. */
  23717. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  23718. /**
  23719. * @param {Vector3} origin the of the vortex
  23720. * @param {number} radius the radius of the vortex
  23721. * @param {number} strength the strength of the vortex
  23722. * @param {number} height the height of the vortex
  23723. */
  23724. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  23725. }
  23726. /***** Radial explosion *****/
  23727. class PhysicsRadialExplosionEvent {
  23728. private _scene;
  23729. private _sphere;
  23730. private _sphereOptions;
  23731. private _rays;
  23732. private _dataFetched;
  23733. constructor(scene: Scene);
  23734. /**
  23735. * Returns the data related to the radial explosion event (sphere & rays).
  23736. * @returns {PhysicsRadialExplosionEventData}
  23737. */
  23738. getData(): PhysicsRadialExplosionEventData;
  23739. /**
  23740. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  23741. * @param impostor
  23742. * @param {Vector3} origin the origin of the explosion
  23743. * @param {number} radius the explosion radius
  23744. * @param {number} strength the explosion strength
  23745. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  23746. * @returns {Nullable<PhysicsForceAndContactPoint>}
  23747. */
  23748. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  23749. /**
  23750. * Disposes the sphere.
  23751. * @param {bolean} force
  23752. */
  23753. dispose(force?: boolean): void;
  23754. /*** Helpers ***/
  23755. private _prepareSphere();
  23756. private _intersectsWithSphere(impostor, origin, radius);
  23757. }
  23758. /***** Gravitational Field *****/
  23759. class PhysicsGravitationalFieldEvent {
  23760. private _physicsHelper;
  23761. private _scene;
  23762. private _origin;
  23763. private _radius;
  23764. private _strength;
  23765. private _falloff;
  23766. private _tickCallback;
  23767. private _sphere;
  23768. private _dataFetched;
  23769. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  23770. /**
  23771. * Returns the data related to the gravitational field event (sphere).
  23772. * @returns {PhysicsGravitationalFieldEventData}
  23773. */
  23774. getData(): PhysicsGravitationalFieldEventData;
  23775. /**
  23776. * Enables the gravitational field.
  23777. */
  23778. enable(): void;
  23779. /**
  23780. * Disables the gravitational field.
  23781. */
  23782. disable(): void;
  23783. /**
  23784. * Disposes the sphere.
  23785. * @param {bolean} force
  23786. */
  23787. dispose(force?: boolean): void;
  23788. private _tick();
  23789. }
  23790. /***** Updraft *****/
  23791. class PhysicsUpdraftEvent {
  23792. private _scene;
  23793. private _origin;
  23794. private _radius;
  23795. private _strength;
  23796. private _height;
  23797. private _updraftMode;
  23798. private _physicsEngine;
  23799. private _originTop;
  23800. private _originDirection;
  23801. private _tickCallback;
  23802. private _cylinder;
  23803. private _cylinderPosition;
  23804. private _dataFetched;
  23805. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  23806. /**
  23807. * Returns the data related to the updraft event (cylinder).
  23808. * @returns {PhysicsUpdraftEventData}
  23809. */
  23810. getData(): PhysicsUpdraftEventData;
  23811. /**
  23812. * Enables the updraft.
  23813. */
  23814. enable(): void;
  23815. /**
  23816. * Disables the cortex.
  23817. */
  23818. disable(): void;
  23819. /**
  23820. * Disposes the sphere.
  23821. * @param {bolean} force
  23822. */
  23823. dispose(force?: boolean): void;
  23824. private getImpostorForceAndContactPoint(impostor);
  23825. private _tick();
  23826. /*** Helpers ***/
  23827. private _prepareCylinder();
  23828. private _intersectsWithCylinder(impostor);
  23829. }
  23830. /***** Vortex *****/
  23831. class PhysicsVortexEvent {
  23832. private _scene;
  23833. private _origin;
  23834. private _radius;
  23835. private _strength;
  23836. private _height;
  23837. private _physicsEngine;
  23838. private _originTop;
  23839. private _centripetalForceThreshold;
  23840. private _updraftMultiplier;
  23841. private _tickCallback;
  23842. private _cylinder;
  23843. private _cylinderPosition;
  23844. private _dataFetched;
  23845. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  23846. /**
  23847. * Returns the data related to the vortex event (cylinder).
  23848. * @returns {PhysicsVortexEventData}
  23849. */
  23850. getData(): PhysicsVortexEventData;
  23851. /**
  23852. * Enables the vortex.
  23853. */
  23854. enable(): void;
  23855. /**
  23856. * Disables the cortex.
  23857. */
  23858. disable(): void;
  23859. /**
  23860. * Disposes the sphere.
  23861. * @param {bolean} force
  23862. */
  23863. dispose(force?: boolean): void;
  23864. private getImpostorForceAndContactPoint(impostor);
  23865. private _tick();
  23866. /*** Helpers ***/
  23867. private _prepareCylinder();
  23868. private _intersectsWithCylinder(impostor);
  23869. }
  23870. /***** Enums *****/
  23871. /**
  23872. * The strenght of the force in correspondence to the distance of the affected object
  23873. */
  23874. enum PhysicsRadialImpulseFalloff {
  23875. /** Defines that impulse is constant in strength across it's whole radius */
  23876. Constant = 0,
  23877. /** DEfines that impulse gets weaker if it's further from the origin */
  23878. Linear = 1,
  23879. }
  23880. /**
  23881. * The strenght of the force in correspondence to the distance of the affected object
  23882. */
  23883. enum PhysicsUpdraftMode {
  23884. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  23885. Center = 0,
  23886. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  23887. Perpendicular = 1,
  23888. }
  23889. /***** Data interfaces *****/
  23890. interface PhysicsForceAndContactPoint {
  23891. force: Vector3;
  23892. contactPoint: Vector3;
  23893. }
  23894. interface PhysicsRadialExplosionEventData {
  23895. sphere: Mesh;
  23896. rays: Array<Ray>;
  23897. }
  23898. interface PhysicsGravitationalFieldEventData {
  23899. sphere: Mesh;
  23900. }
  23901. interface PhysicsUpdraftEventData {
  23902. cylinder: Mesh;
  23903. }
  23904. interface PhysicsVortexEventData {
  23905. cylinder: Mesh;
  23906. }
  23907. }
  23908. declare module BABYLON {
  23909. interface PhysicsImpostorParameters {
  23910. mass: number;
  23911. friction?: number;
  23912. restitution?: number;
  23913. nativeOptions?: any;
  23914. ignoreParent?: boolean;
  23915. disableBidirectionalTransformation?: boolean;
  23916. }
  23917. interface IPhysicsEnabledObject {
  23918. position: Vector3;
  23919. rotationQuaternion: Nullable<Quaternion>;
  23920. scaling: Vector3;
  23921. rotation?: Vector3;
  23922. parent?: any;
  23923. getBoundingInfo(): BoundingInfo;
  23924. computeWorldMatrix(force: boolean): Matrix;
  23925. getWorldMatrix?(): Matrix;
  23926. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23927. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23928. getIndices?(): Nullable<IndicesArray>;
  23929. getScene?(): Scene;
  23930. getAbsolutePosition(): Vector3;
  23931. getAbsolutePivotPoint(): Vector3;
  23932. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23933. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23934. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23935. getClassName(): string;
  23936. }
  23937. class PhysicsImpostor {
  23938. object: IPhysicsEnabledObject;
  23939. type: number;
  23940. private _options;
  23941. private _scene;
  23942. static DEFAULT_OBJECT_SIZE: Vector3;
  23943. static IDENTITY_QUATERNION: Quaternion;
  23944. private _physicsEngine;
  23945. private _physicsBody;
  23946. private _bodyUpdateRequired;
  23947. private _onBeforePhysicsStepCallbacks;
  23948. private _onAfterPhysicsStepCallbacks;
  23949. private _onPhysicsCollideCallbacks;
  23950. private _deltaPosition;
  23951. private _deltaRotation;
  23952. private _deltaRotationConjugated;
  23953. private _parent;
  23954. private _isDisposed;
  23955. private static _tmpVecs;
  23956. private static _tmpQuat;
  23957. readonly isDisposed: boolean;
  23958. mass: number;
  23959. friction: number;
  23960. restitution: number;
  23961. uniqueId: number;
  23962. private _joints;
  23963. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23964. /**
  23965. * This function will completly initialize this impostor.
  23966. * It will create a new body - but only if this mesh has no parent.
  23967. * If it has, this impostor will not be used other than to define the impostor
  23968. * of the child mesh.
  23969. */
  23970. _init(): void;
  23971. private _getPhysicsParent();
  23972. /**
  23973. * Should a new body be generated.
  23974. */
  23975. isBodyInitRequired(): boolean;
  23976. setScalingUpdated(updated: boolean): void;
  23977. /**
  23978. * Force a regeneration of this or the parent's impostor's body.
  23979. * Use under cautious - This will remove all joints already implemented.
  23980. */
  23981. forceUpdate(): void;
  23982. /**
  23983. * Gets the body that holds this impostor. Either its own, or its parent.
  23984. */
  23985. /**
  23986. * Set the physics body. Used mainly by the physics engine/plugin
  23987. */
  23988. physicsBody: any;
  23989. parent: Nullable<PhysicsImpostor>;
  23990. resetUpdateFlags(): void;
  23991. getObjectExtendSize(): Vector3;
  23992. getObjectCenter(): Vector3;
  23993. /**
  23994. * Get a specific parametes from the options parameter.
  23995. */
  23996. getParam(paramName: string): any;
  23997. /**
  23998. * Sets a specific parameter in the options given to the physics plugin
  23999. */
  24000. setParam(paramName: string, value: number): void;
  24001. /**
  24002. * Specifically change the body's mass option. Won't recreate the physics body object
  24003. */
  24004. setMass(mass: number): void;
  24005. getLinearVelocity(): Nullable<Vector3>;
  24006. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24007. getAngularVelocity(): Nullable<Vector3>;
  24008. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24009. /**
  24010. * Execute a function with the physics plugin native code.
  24011. * Provide a function the will have two variables - the world object and the physics body object.
  24012. */
  24013. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24014. /**
  24015. * Register a function that will be executed before the physics world is stepping forward.
  24016. */
  24017. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24018. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24019. /**
  24020. * Register a function that will be executed after the physics step
  24021. */
  24022. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24023. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24024. /**
  24025. * register a function that will be executed when this impostor collides against a different body.
  24026. */
  24027. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24028. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24029. private _tmpQuat;
  24030. private _tmpQuat2;
  24031. getParentsRotation(): Quaternion;
  24032. /**
  24033. * this function is executed by the physics engine.
  24034. */
  24035. beforeStep: () => void;
  24036. /**
  24037. * this function is executed by the physics engine.
  24038. */
  24039. afterStep: () => void;
  24040. /**
  24041. * Legacy collision detection event support
  24042. */
  24043. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24044. onCollide: (e: {
  24045. body: any;
  24046. }) => void;
  24047. /**
  24048. * Apply a force
  24049. */
  24050. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24051. /**
  24052. * Apply an impulse
  24053. */
  24054. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24055. /**
  24056. * A help function to create a joint.
  24057. */
  24058. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24059. /**
  24060. * Add a joint to this impostor with a different impostor.
  24061. */
  24062. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24063. /**
  24064. * Will keep this body still, in a sleep mode.
  24065. */
  24066. sleep(): PhysicsImpostor;
  24067. /**
  24068. * Wake the body up.
  24069. */
  24070. wakeUp(): PhysicsImpostor;
  24071. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24072. dispose(): void;
  24073. setDeltaPosition(position: Vector3): void;
  24074. setDeltaRotation(rotation: Quaternion): void;
  24075. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24076. getRadius(): number;
  24077. /**
  24078. * Sync a bone with this impostor
  24079. * @param bone The bone to sync to the impostor.
  24080. * @param boneMesh The mesh that the bone is influencing.
  24081. * @param jointPivot The pivot of the joint / bone in local space.
  24082. * @param distToJoint Optional distance from the impostor to the joint.
  24083. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24084. */
  24085. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24086. /**
  24087. * Sync impostor to a bone
  24088. * @param bone The bone that the impostor will be synced to.
  24089. * @param boneMesh The mesh that the bone is influencing.
  24090. * @param jointPivot The pivot of the joint / bone in local space.
  24091. * @param distToJoint Optional distance from the impostor to the joint.
  24092. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24093. * @param boneAxis Optional vector3 axis the bone is aligned with
  24094. */
  24095. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24096. static NoImpostor: number;
  24097. static SphereImpostor: number;
  24098. static BoxImpostor: number;
  24099. static PlaneImpostor: number;
  24100. static MeshImpostor: number;
  24101. static CylinderImpostor: number;
  24102. static ParticleImpostor: number;
  24103. static HeightmapImpostor: number;
  24104. }
  24105. }
  24106. declare module BABYLON {
  24107. interface PhysicsJointData {
  24108. mainPivot?: Vector3;
  24109. connectedPivot?: Vector3;
  24110. mainAxis?: Vector3;
  24111. connectedAxis?: Vector3;
  24112. collision?: boolean;
  24113. nativeParams?: any;
  24114. }
  24115. /**
  24116. * This is a holder class for the physics joint created by the physics plugin.
  24117. * It holds a set of functions to control the underlying joint.
  24118. */
  24119. class PhysicsJoint {
  24120. type: number;
  24121. jointData: PhysicsJointData;
  24122. private _physicsJoint;
  24123. protected _physicsPlugin: IPhysicsEnginePlugin;
  24124. constructor(type: number, jointData: PhysicsJointData);
  24125. physicsJoint: any;
  24126. physicsPlugin: IPhysicsEnginePlugin;
  24127. /**
  24128. * Execute a function that is physics-plugin specific.
  24129. * @param {Function} func the function that will be executed.
  24130. * It accepts two parameters: the physics world and the physics joint.
  24131. */
  24132. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24133. static DistanceJoint: number;
  24134. static HingeJoint: number;
  24135. static BallAndSocketJoint: number;
  24136. static WheelJoint: number;
  24137. static SliderJoint: number;
  24138. static PrismaticJoint: number;
  24139. static UniversalJoint: number;
  24140. static Hinge2Joint: number;
  24141. static PointToPointJoint: number;
  24142. static SpringJoint: number;
  24143. static LockJoint: number;
  24144. }
  24145. /**
  24146. * A class representing a physics distance joint.
  24147. */
  24148. class DistanceJoint extends PhysicsJoint {
  24149. constructor(jointData: DistanceJointData);
  24150. /**
  24151. * Update the predefined distance.
  24152. */
  24153. updateDistance(maxDistance: number, minDistance?: number): void;
  24154. }
  24155. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24156. constructor(type: number, jointData: PhysicsJointData);
  24157. /**
  24158. * Set the motor values.
  24159. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24160. * @param {number} force the force to apply
  24161. * @param {number} maxForce max force for this motor.
  24162. */
  24163. setMotor(force?: number, maxForce?: number): void;
  24164. /**
  24165. * Set the motor's limits.
  24166. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24167. */
  24168. setLimit(upperLimit: number, lowerLimit?: number): void;
  24169. }
  24170. /**
  24171. * This class represents a single hinge physics joint
  24172. */
  24173. class HingeJoint extends MotorEnabledJoint {
  24174. constructor(jointData: PhysicsJointData);
  24175. /**
  24176. * Set the motor values.
  24177. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24178. * @param {number} force the force to apply
  24179. * @param {number} maxForce max force for this motor.
  24180. */
  24181. setMotor(force?: number, maxForce?: number): void;
  24182. /**
  24183. * Set the motor's limits.
  24184. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24185. */
  24186. setLimit(upperLimit: number, lowerLimit?: number): void;
  24187. }
  24188. /**
  24189. * This class represents a dual hinge physics joint (same as wheel joint)
  24190. */
  24191. class Hinge2Joint extends MotorEnabledJoint {
  24192. constructor(jointData: PhysicsJointData);
  24193. /**
  24194. * Set the motor values.
  24195. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24196. * @param {number} force the force to apply
  24197. * @param {number} maxForce max force for this motor.
  24198. * @param {motorIndex} the motor's index, 0 or 1.
  24199. */
  24200. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24201. /**
  24202. * Set the motor limits.
  24203. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24204. * @param {number} upperLimit the upper limit
  24205. * @param {number} lowerLimit lower limit
  24206. * @param {motorIndex} the motor's index, 0 or 1.
  24207. */
  24208. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24209. }
  24210. interface IMotorEnabledJoint {
  24211. physicsJoint: any;
  24212. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24213. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24214. }
  24215. interface DistanceJointData extends PhysicsJointData {
  24216. maxDistance: number;
  24217. }
  24218. interface SpringJointData extends PhysicsJointData {
  24219. length: number;
  24220. stiffness: number;
  24221. damping: number;
  24222. }
  24223. }
  24224. declare module BABYLON {
  24225. /**
  24226. * This represents a GPU particle system in Babylon
  24227. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  24228. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  24229. */
  24230. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  24231. /**
  24232. * The id of the Particle system.
  24233. */
  24234. id: string;
  24235. /**
  24236. * The friendly name of the Particle system.
  24237. */
  24238. name: string;
  24239. /**
  24240. * The emitter represents the Mesh or position we are attaching the particle system to.
  24241. */
  24242. emitter: Nullable<AbstractMesh | Vector3>;
  24243. /**
  24244. * The rendering group used by the Particle system to chose when to render.
  24245. */
  24246. renderingGroupId: number;
  24247. /**
  24248. * The layer mask we are rendering the particles through.
  24249. */
  24250. layerMask: number;
  24251. private _capacity;
  24252. private _activeCount;
  24253. private _currentActiveCount;
  24254. private _accumulatedCount;
  24255. private _renderEffect;
  24256. private _updateEffect;
  24257. private _buffer0;
  24258. private _buffer1;
  24259. private _spriteBuffer;
  24260. private _updateVAO;
  24261. private _renderVAO;
  24262. private _targetIndex;
  24263. private _sourceBuffer;
  24264. private _targetBuffer;
  24265. private _scene;
  24266. private _engine;
  24267. private _currentRenderId;
  24268. private _started;
  24269. private _stopped;
  24270. private _timeDelta;
  24271. private _randomTexture;
  24272. private _randomTexture2;
  24273. private _attributesStrideSize;
  24274. private _updateEffectOptions;
  24275. private _randomTextureSize;
  24276. private _actualFrame;
  24277. /**
  24278. * List of animations used by the particle system.
  24279. */
  24280. animations: Animation[];
  24281. /**
  24282. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  24283. */
  24284. static readonly IsSupported: boolean;
  24285. /**
  24286. * An event triggered when the system is disposed.
  24287. */
  24288. onDisposeObservable: Observable<GPUParticleSystem>;
  24289. /**
  24290. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24291. */
  24292. updateSpeed: number;
  24293. /**
  24294. * The amount of time the particle system is running (depends of the overall update speed).
  24295. */
  24296. targetStopDuration: number;
  24297. /**
  24298. * The texture used to render each particle. (this can be a spritesheet)
  24299. */
  24300. particleTexture: Nullable<Texture>;
  24301. /**
  24302. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  24303. */
  24304. blendMode: number;
  24305. /**
  24306. * Minimum life time of emitting particles.
  24307. */
  24308. minLifeTime: number;
  24309. /**
  24310. * Maximum life time of emitting particles.
  24311. */
  24312. maxLifeTime: number;
  24313. /**
  24314. * Minimum Size of emitting particles.
  24315. */
  24316. minSize: number;
  24317. /**
  24318. * Maximum Size of emitting particles.
  24319. */
  24320. maxSize: number;
  24321. /**
  24322. * Minimum scale of emitting particles on X axis.
  24323. */
  24324. minScaleX: number;
  24325. /**
  24326. * Maximum scale of emitting particles on X axis.
  24327. */
  24328. maxScaleX: number;
  24329. /**
  24330. * Minimum scale of emitting particles on Y axis.
  24331. */
  24332. minScaleY: number;
  24333. /**
  24334. * Maximum scale of emitting particles on Y axis.
  24335. */
  24336. maxScaleY: number;
  24337. /**
  24338. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24339. */
  24340. color1: Color4;
  24341. /**
  24342. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24343. */
  24344. color2: Color4;
  24345. /**
  24346. * Color the particle will have at the end of its lifetime.
  24347. */
  24348. colorDead: Color4;
  24349. /**
  24350. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  24351. */
  24352. emitRate: number;
  24353. /**
  24354. * You can use gravity if you want to give an orientation to your particles.
  24355. */
  24356. gravity: Vector3;
  24357. /**
  24358. * Minimum power of emitting particles.
  24359. */
  24360. minEmitPower: number;
  24361. /**
  24362. * Maximum power of emitting particles.
  24363. */
  24364. maxEmitPower: number;
  24365. /**
  24366. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24367. */
  24368. minAngularSpeed: number;
  24369. /**
  24370. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24371. */
  24372. maxAngularSpeed: number;
  24373. /**
  24374. * The particle emitter type defines the emitter used by the particle system.
  24375. * It can be for example box, sphere, or cone...
  24376. */
  24377. particleEmitterType: Nullable<IParticleEmitterType>;
  24378. /**
  24379. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24380. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24381. */
  24382. direction1: Vector3;
  24383. /**
  24384. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24385. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24386. */
  24387. direction2: Vector3;
  24388. /**
  24389. * 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.
  24390. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24391. */
  24392. minEmitBox: Vector3;
  24393. /**
  24394. * 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.
  24395. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24396. */
  24397. maxEmitBox: Vector3;
  24398. /**
  24399. * Gets the maximum number of particles active at the same time.
  24400. * @returns The max number of active particles.
  24401. */
  24402. getCapacity(): number;
  24403. /**
  24404. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24405. * to override the particles.
  24406. */
  24407. forceDepthWrite: boolean;
  24408. /**
  24409. * Gets or set the number of active particles
  24410. */
  24411. activeParticleCount: number;
  24412. private _preWarmDone;
  24413. /** 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 */
  24414. preWarmCycles: number;
  24415. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  24416. preWarmStepOffset: number;
  24417. /**
  24418. * Gets or sets the minimal initial rotation in radians.
  24419. */
  24420. minInitialRotation: number;
  24421. /**
  24422. * Gets or sets the maximal initial rotation in radians.
  24423. */
  24424. maxInitialRotation: number;
  24425. /**
  24426. * 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)
  24427. */
  24428. spriteCellChangeSpeed: number;
  24429. /**
  24430. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  24431. */
  24432. startSpriteCellID: number;
  24433. /**
  24434. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  24435. */
  24436. endSpriteCellID: number;
  24437. /**
  24438. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24439. */
  24440. spriteCellWidth: number;
  24441. /**
  24442. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24443. */
  24444. spriteCellHeight: number;
  24445. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  24446. translationPivot: Vector2;
  24447. /**
  24448. * Gets or sets the billboard mode to use when isBillboardBased = true.
  24449. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  24450. */
  24451. billboardMode: number;
  24452. private _isAnimationSheetEnabled;
  24453. /**
  24454. * Gets whether an animation sprite sheet is enabled or not on the particle system
  24455. */
  24456. readonly isAnimationSheetEnabled: boolean;
  24457. /**
  24458. * Is this system ready to be used/rendered
  24459. * @return true if the system is ready
  24460. */
  24461. isReady(): boolean;
  24462. /**
  24463. * Gets Wether the system has been started.
  24464. * @returns True if it has been started, otherwise false.
  24465. */
  24466. isStarted(): boolean;
  24467. /**
  24468. * Starts the particle system and begins to emit.
  24469. */
  24470. start(): void;
  24471. /**
  24472. * Stops the particle system.
  24473. */
  24474. stop(): void;
  24475. /**
  24476. * Remove all active particles
  24477. */
  24478. reset(): void;
  24479. /**
  24480. * Returns the string "GPUParticleSystem"
  24481. * @returns a string containing the class name
  24482. */
  24483. getClassName(): string;
  24484. private _isBillboardBased;
  24485. /**
  24486. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  24487. */
  24488. isBillboardBased: boolean;
  24489. private _colorGradients;
  24490. private _colorGradientsTexture;
  24491. /**
  24492. * Gets the current list of color gradients.
  24493. * You must use addColorGradient and removeColorGradient to udpate this list
  24494. * @returns the list of color gradients
  24495. */
  24496. getColorGradients(): Nullable<Array<ColorGradient>>;
  24497. /**
  24498. * Gets the current list of size gradients.
  24499. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24500. * @returns the list of size gradients
  24501. */
  24502. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24503. /**
  24504. * Adds a new color gradient
  24505. * @param gradient defines the gradient to use (between 0 and 1)
  24506. * @param color defines the color to affect to the specified gradient
  24507. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  24508. */
  24509. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  24510. /**
  24511. * Remove a specific color gradient
  24512. * @param gradient defines the gradient to remove
  24513. */
  24514. removeColorGradient(gradient: number): GPUParticleSystem;
  24515. private _sizeGradients;
  24516. private _sizeGradientsTexture;
  24517. /**
  24518. * Adds a new size gradient
  24519. * @param gradient defines the gradient to use (between 0 and 1)
  24520. * @param factor defines the size factor to affect to the specified gradient
  24521. */
  24522. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  24523. /**
  24524. * Remove a specific size gradient
  24525. * @param gradient defines the gradient to remove
  24526. */
  24527. removeSizeGradient(gradient: number): GPUParticleSystem;
  24528. /**
  24529. * Instantiates a GPU particle system.
  24530. * 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.
  24531. * @param name The name of the particle system
  24532. * @param options The options used to create the system
  24533. * @param scene The scene the particle system belongs to
  24534. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  24535. */
  24536. constructor(name: string, options: Partial<{
  24537. capacity: number;
  24538. randomTextureSize: number;
  24539. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  24540. private _createUpdateVAO(source);
  24541. private _createRenderVAO(source, spriteSource);
  24542. private _initialize(force?);
  24543. /** @hidden */
  24544. _recreateUpdateEffect(): void;
  24545. /** @hidden */
  24546. _recreateRenderEffect(): void;
  24547. /**
  24548. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  24549. * @param preWarm defines if we are in the pre-warmimg phase
  24550. */
  24551. animate(preWarm?: boolean): void;
  24552. private _createSizeGradientTexture();
  24553. private _createColorGradientTexture();
  24554. /**
  24555. * Renders the particle system in its current state
  24556. * @param preWarm defines if the system should only update the particles but not render them
  24557. * @returns the current number of particles
  24558. */
  24559. render(preWarm?: boolean): number;
  24560. /**
  24561. * Rebuilds the particle system
  24562. */
  24563. rebuild(): void;
  24564. private _releaseBuffers();
  24565. private _releaseVAOs();
  24566. /**
  24567. * Disposes the particle system and free the associated resources
  24568. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  24569. */
  24570. dispose(disposeTexture?: boolean): void;
  24571. /**
  24572. * Clones the particle system.
  24573. * @param name The name of the cloned object
  24574. * @param newEmitter The new emitter to use
  24575. * @returns the cloned particle system
  24576. */
  24577. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  24578. /**
  24579. * Serializes the particle system to a JSON object.
  24580. * @returns the JSON object
  24581. */
  24582. serialize(): any;
  24583. /**
  24584. * Parses a JSON object to create a GPU particle system.
  24585. * @param parsedParticleSystem The JSON object to parse
  24586. * @param scene The scene to create the particle system in
  24587. * @param rootUrl The root url to use to load external dependencies like texture
  24588. * @returns the parsed GPU particle system
  24589. */
  24590. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  24591. }
  24592. }
  24593. declare module BABYLON {
  24594. /**
  24595. * Interface representing a particle system in Babylon.
  24596. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  24597. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  24598. */
  24599. interface IParticleSystem {
  24600. /**
  24601. * List of animations used by the particle system.
  24602. */
  24603. animations: Animation[];
  24604. /**
  24605. * The id of the Particle system.
  24606. */
  24607. id: string;
  24608. /**
  24609. * The name of the Particle system.
  24610. */
  24611. name: string;
  24612. /**
  24613. * The emitter represents the Mesh or position we are attaching the particle system to.
  24614. */
  24615. emitter: Nullable<AbstractMesh | Vector3>;
  24616. /**
  24617. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  24618. */
  24619. isBillboardBased: boolean;
  24620. /**
  24621. * The rendering group used by the Particle system to chose when to render.
  24622. */
  24623. renderingGroupId: number;
  24624. /**
  24625. * The layer mask we are rendering the particles through.
  24626. */
  24627. layerMask: number;
  24628. /**
  24629. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24630. */
  24631. updateSpeed: number;
  24632. /**
  24633. * The amount of time the particle system is running (depends of the overall update speed).
  24634. */
  24635. targetStopDuration: number;
  24636. /**
  24637. * The texture used to render each particle. (this can be a spritesheet)
  24638. */
  24639. particleTexture: Nullable<Texture>;
  24640. /**
  24641. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  24642. */
  24643. blendMode: number;
  24644. /**
  24645. * Minimum life time of emitting particles.
  24646. */
  24647. minLifeTime: number;
  24648. /**
  24649. * Maximum life time of emitting particles.
  24650. */
  24651. maxLifeTime: number;
  24652. /**
  24653. * Minimum Size of emitting particles.
  24654. */
  24655. minSize: number;
  24656. /**
  24657. * Maximum Size of emitting particles.
  24658. */
  24659. maxSize: number;
  24660. /**
  24661. * Minimum scale of emitting particles on X axis.
  24662. */
  24663. minScaleX: number;
  24664. /**
  24665. * Maximum scale of emitting particles on X axis.
  24666. */
  24667. maxScaleX: number;
  24668. /**
  24669. * Minimum scale of emitting particles on Y axis.
  24670. */
  24671. minScaleY: number;
  24672. /**
  24673. * Maximum scale of emitting particles on Y axis.
  24674. */
  24675. maxScaleY: number;
  24676. /**
  24677. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24678. */
  24679. color1: Color4;
  24680. /**
  24681. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24682. */
  24683. color2: Color4;
  24684. /**
  24685. * Color the particle will have at the end of its lifetime.
  24686. */
  24687. colorDead: Color4;
  24688. /**
  24689. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  24690. */
  24691. emitRate: number;
  24692. /**
  24693. * You can use gravity if you want to give an orientation to your particles.
  24694. */
  24695. gravity: Vector3;
  24696. /**
  24697. * Minimum power of emitting particles.
  24698. */
  24699. minEmitPower: number;
  24700. /**
  24701. * Maximum power of emitting particles.
  24702. */
  24703. maxEmitPower: number;
  24704. /**
  24705. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24706. */
  24707. minAngularSpeed: number;
  24708. /**
  24709. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24710. */
  24711. maxAngularSpeed: number;
  24712. /**
  24713. * Gets or sets the minimal initial rotation in radians.
  24714. */
  24715. minInitialRotation: number;
  24716. /**
  24717. * Gets or sets the maximal initial rotation in radians.
  24718. */
  24719. maxInitialRotation: number;
  24720. /**
  24721. * The particle emitter type defines the emitter used by the particle system.
  24722. * It can be for example box, sphere, or cone...
  24723. */
  24724. particleEmitterType: Nullable<IParticleEmitterType>;
  24725. /**
  24726. * 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
  24727. */
  24728. preWarmCycles: number;
  24729. /**
  24730. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  24731. */
  24732. preWarmStepOffset: number;
  24733. /**
  24734. * 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)
  24735. */
  24736. spriteCellChangeSpeed: number;
  24737. /**
  24738. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  24739. */
  24740. startSpriteCellID: number;
  24741. /**
  24742. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  24743. */
  24744. endSpriteCellID: number;
  24745. /**
  24746. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24747. */
  24748. spriteCellWidth: number;
  24749. /**
  24750. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24751. */
  24752. spriteCellHeight: number;
  24753. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  24754. translationPivot: Vector2;
  24755. /**
  24756. * Gets or sets the billboard mode to use when isBillboardBased = true.
  24757. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  24758. */
  24759. billboardMode: number;
  24760. /**
  24761. * Gets the maximum number of particles active at the same time.
  24762. * @returns The max number of active particles.
  24763. */
  24764. getCapacity(): number;
  24765. /**
  24766. * Gets Wether the system has been started.
  24767. * @returns True if it has been started, otherwise false.
  24768. */
  24769. isStarted(): boolean;
  24770. /**
  24771. * Gets if the particle system has been started.
  24772. * @return true if the system has been started, otherwise false.
  24773. */
  24774. isStarted(): boolean;
  24775. /**
  24776. * Animates the particle system for this frame.
  24777. */
  24778. animate(): void;
  24779. /**
  24780. * Renders the particle system in its current state.
  24781. * @returns the current number of particles
  24782. */
  24783. render(): number;
  24784. /**
  24785. * Dispose the particle system and frees its associated resources.
  24786. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  24787. */
  24788. dispose(disposeTexture?: boolean): void;
  24789. /**
  24790. * Clones the particle system.
  24791. * @param name The name of the cloned object
  24792. * @param newEmitter The new emitter to use
  24793. * @returns the cloned particle system
  24794. */
  24795. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  24796. /**
  24797. * Serializes the particle system to a JSON object.
  24798. * @returns the JSON object
  24799. */
  24800. serialize(): any;
  24801. /**
  24802. * Rebuild the particle system
  24803. */
  24804. rebuild(): void;
  24805. /**
  24806. * Starts the particle system and begins to emit.
  24807. */
  24808. start(): void;
  24809. /**
  24810. * Stops the particle system.
  24811. */
  24812. stop(): void;
  24813. /**
  24814. * Remove all active particles
  24815. */
  24816. reset(): void;
  24817. /**
  24818. * Is this system ready to be used/rendered
  24819. * @return true if the system is ready
  24820. */
  24821. isReady(): boolean;
  24822. /**
  24823. * Adds a new color gradient
  24824. * @param gradient defines the gradient to use (between 0 and 1)
  24825. * @param color defines the color to affect to the specified gradient
  24826. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  24827. */
  24828. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  24829. /**
  24830. * Remove a specific color gradient
  24831. * @param gradient defines the gradient to remove
  24832. */
  24833. removeColorGradient(gradient: number): IParticleSystem;
  24834. /**
  24835. * Adds a new size gradient
  24836. * @param gradient defines the gradient to use (between 0 and 1)
  24837. * @param factor defines the size factor to affect to the specified gradient
  24838. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  24839. */
  24840. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  24841. /**
  24842. * Remove a specific size gradient
  24843. * @param gradient defines the gradient to remove
  24844. */
  24845. removeSizeGradient(gradient: number): IParticleSystem;
  24846. /**
  24847. * Gets the current list of color gradients.
  24848. * You must use addColorGradient and removeColorGradient to udpate this list
  24849. * @returns the list of color gradients
  24850. */
  24851. getColorGradients(): Nullable<Array<ColorGradient>>;
  24852. /**
  24853. * Gets the current list of size gradients.
  24854. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24855. * @returns the list of size gradients
  24856. */
  24857. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24858. }
  24859. }
  24860. declare module BABYLON {
  24861. /**
  24862. * A particle represents one of the element emitted by a particle system.
  24863. * This is mainly define by its coordinates, direction, velocity and age.
  24864. */
  24865. class Particle {
  24866. /**
  24867. * particleSystem the particle system the particle belongs to.
  24868. */
  24869. particleSystem: ParticleSystem;
  24870. /**
  24871. * The world position of the particle in the scene.
  24872. */
  24873. position: Vector3;
  24874. /**
  24875. * The world direction of the particle in the scene.
  24876. */
  24877. direction: Vector3;
  24878. /**
  24879. * The color of the particle.
  24880. */
  24881. color: Color4;
  24882. /**
  24883. * The color change of the particle per step.
  24884. */
  24885. colorStep: Color4;
  24886. /**
  24887. * Defines how long will the life of the particle be.
  24888. */
  24889. lifeTime: number;
  24890. /**
  24891. * The current age of the particle.
  24892. */
  24893. age: number;
  24894. /**
  24895. * The current size of the particle.
  24896. */
  24897. size: number;
  24898. /**
  24899. * The current scale of the particle.
  24900. */
  24901. scale: Vector2;
  24902. /**
  24903. * The current angle of the particle.
  24904. */
  24905. angle: number;
  24906. /**
  24907. * Defines how fast is the angle changing.
  24908. */
  24909. angularSpeed: number;
  24910. /**
  24911. * Defines the cell index used by the particle to be rendered from a sprite.
  24912. */
  24913. cellIndex: number;
  24914. /** @hidden */
  24915. _initialDirection: Nullable<Vector3>;
  24916. /** @hidden */
  24917. _initialStartSpriteCellID: number;
  24918. _initialEndSpriteCellID: number;
  24919. /** @hidden */
  24920. _currentColorGradient: Nullable<ColorGradient>;
  24921. /** @hidden */
  24922. _currentColor1: Color4;
  24923. /** @hidden */
  24924. _currentColor2: Color4;
  24925. /** @hidden */
  24926. _currentSizeGradient: Nullable<FactorGradient>;
  24927. /** @hidden */
  24928. _currentSize1: number;
  24929. /** @hidden */
  24930. _currentSize2: number;
  24931. /**
  24932. * Creates a new instance Particle
  24933. * @param particleSystem the particle system the particle belongs to
  24934. */
  24935. constructor(
  24936. /**
  24937. * particleSystem the particle system the particle belongs to.
  24938. */
  24939. particleSystem: ParticleSystem);
  24940. private updateCellInfoFromSystem();
  24941. /**
  24942. * Defines how the sprite cell index is updated for the particle
  24943. */
  24944. updateCellIndex(): void;
  24945. /**
  24946. * Copy the properties of particle to another one.
  24947. * @param other the particle to copy the information to.
  24948. */
  24949. copyTo(other: Particle): void;
  24950. }
  24951. }
  24952. declare module BABYLON {
  24953. /**
  24954. * This class is made for on one-liner static method to help creating particle system set.
  24955. */
  24956. class ParticleHelper {
  24957. /**
  24958. * Gets or sets base Assets URL
  24959. */
  24960. static BaseAssetsUrl: string;
  24961. /**
  24962. * This is the main static method (one-liner) of this helper to create different particle systems
  24963. * @param type This string represents the type to the particle system to create
  24964. * @param scene The scene where the particle system should live
  24965. * @param gpu If the system will use gpu
  24966. * @returns the ParticleSystemSet created
  24967. */
  24968. static CreateAsync(type: string, scene?: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  24969. /**
  24970. * Static function used to export a particle system to a ParticleSystemSet variable.
  24971. * Please note that the emitter shape is not exported
  24972. * @param system defines the particle systems to export
  24973. */
  24974. static ExportSet(systems: ParticleSystem[]): ParticleSystemSet;
  24975. }
  24976. }
  24977. declare module BABYLON {
  24978. /**
  24979. * This represents a particle system in Babylon.
  24980. * 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.
  24981. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  24982. * @example https://doc.babylonjs.com/babylon101/particles
  24983. */
  24984. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  24985. /**
  24986. * Source color is added to the destination color without alpha affecting the result.
  24987. */
  24988. static BLENDMODE_ONEONE: number;
  24989. /**
  24990. * Blend current color and particle color using particle’s alpha.
  24991. */
  24992. static BLENDMODE_STANDARD: number;
  24993. /**
  24994. * Add current color and particle color multiplied by particle’s alpha.
  24995. */
  24996. static BLENDMODE_ADD: number;
  24997. /**
  24998. * List of animations used by the particle system.
  24999. */
  25000. animations: Animation[];
  25001. /**
  25002. * The id of the Particle system.
  25003. */
  25004. id: string;
  25005. /**
  25006. * The friendly name of the Particle system.
  25007. */
  25008. name: string;
  25009. /**
  25010. * The rendering group used by the Particle system to chose when to render.
  25011. */
  25012. renderingGroupId: number;
  25013. /**
  25014. * The emitter represents the Mesh or position we are attaching the particle system to.
  25015. */
  25016. emitter: Nullable<AbstractMesh | Vector3>;
  25017. /**
  25018. * The maximum number of particles to emit per frame
  25019. */
  25020. emitRate: number;
  25021. /**
  25022. * If you want to launch only a few particles at once, that can be done, as well.
  25023. */
  25024. manualEmitCount: number;
  25025. /**
  25026. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  25027. */
  25028. updateSpeed: number;
  25029. /**
  25030. * The amount of time the particle system is running (depends of the overall update speed).
  25031. */
  25032. targetStopDuration: number;
  25033. /**
  25034. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  25035. */
  25036. disposeOnStop: boolean;
  25037. /**
  25038. * Minimum power of emitting particles.
  25039. */
  25040. minEmitPower: number;
  25041. /**
  25042. * Maximum power of emitting particles.
  25043. */
  25044. maxEmitPower: number;
  25045. /**
  25046. * Minimum life time of emitting particles.
  25047. */
  25048. minLifeTime: number;
  25049. /**
  25050. * Maximum life time of emitting particles.
  25051. */
  25052. maxLifeTime: number;
  25053. /**
  25054. * Minimum Size of emitting particles.
  25055. */
  25056. minSize: number;
  25057. /**
  25058. * Maximum Size of emitting particles.
  25059. */
  25060. maxSize: number;
  25061. /**
  25062. * Minimum scale of emitting particles on X axis.
  25063. */
  25064. minScaleX: number;
  25065. /**
  25066. * Maximum scale of emitting particles on X axis.
  25067. */
  25068. maxScaleX: number;
  25069. /**
  25070. * Minimum scale of emitting particles on Y axis.
  25071. */
  25072. minScaleY: number;
  25073. /**
  25074. * Maximum scale of emitting particles on Y axis.
  25075. */
  25076. maxScaleY: number;
  25077. /**
  25078. * Gets or sets the minimal initial rotation in radians.
  25079. */
  25080. minInitialRotation: number;
  25081. /**
  25082. * Gets or sets the maximal initial rotation in radians.
  25083. */
  25084. maxInitialRotation: number;
  25085. /**
  25086. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  25087. */
  25088. minAngularSpeed: number;
  25089. /**
  25090. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  25091. */
  25092. maxAngularSpeed: number;
  25093. /**
  25094. * The texture used to render each particle. (this can be a spritesheet)
  25095. */
  25096. particleTexture: Nullable<Texture>;
  25097. /**
  25098. * The layer mask we are rendering the particles through.
  25099. */
  25100. layerMask: number;
  25101. /**
  25102. * This can help using your own shader to render the particle system.
  25103. * The according effect will be created
  25104. */
  25105. customShader: any;
  25106. /**
  25107. * By default particle system starts as soon as they are created. This prevents the
  25108. * automatic start to happen and let you decide when to start emitting particles.
  25109. */
  25110. preventAutoStart: boolean;
  25111. /**
  25112. * This function can be defined to provide custom update for active particles.
  25113. * This function will be called instead of regular update (age, position, color, etc.).
  25114. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  25115. */
  25116. updateFunction: (particles: Particle[]) => void;
  25117. /**
  25118. * Callback triggered when the particle animation is ending.
  25119. */
  25120. onAnimationEnd: Nullable<() => void>;
  25121. /**
  25122. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  25123. */
  25124. blendMode: number;
  25125. /**
  25126. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  25127. * to override the particles.
  25128. */
  25129. forceDepthWrite: boolean;
  25130. /**
  25131. * You can use gravity if you want to give an orientation to your particles.
  25132. */
  25133. gravity: Vector3;
  25134. private _colorGradients;
  25135. private _sizeGradients;
  25136. private _lifeTimeGradients;
  25137. /**
  25138. * Gets the current list of color gradients.
  25139. * You must use addColorGradient and removeColorGradient to udpate this list
  25140. * @returns the list of color gradients
  25141. */
  25142. getColorGradients(): Nullable<Array<ColorGradient>>;
  25143. /**
  25144. * Gets the current list of size gradients.
  25145. * You must use addSizeGradient and removeSizeGradient to udpate this list
  25146. * @returns the list of size gradients
  25147. */
  25148. getSizeGradients(): Nullable<Array<FactorGradient>>;
  25149. /**
  25150. * Gets the current list of life time gradients.
  25151. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  25152. * @returns the list of life time gradients
  25153. */
  25154. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  25155. /**
  25156. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  25157. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25158. */
  25159. direction1: Vector3;
  25160. /**
  25161. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  25162. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25163. */
  25164. direction2: Vector3;
  25165. /**
  25166. * 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.
  25167. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25168. */
  25169. minEmitBox: Vector3;
  25170. /**
  25171. * 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.
  25172. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25173. */
  25174. maxEmitBox: Vector3;
  25175. /**
  25176. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  25177. */
  25178. color1: Color4;
  25179. /**
  25180. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  25181. */
  25182. color2: Color4;
  25183. /**
  25184. * Color the particle will have at the end of its lifetime
  25185. */
  25186. colorDead: Color4;
  25187. /**
  25188. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  25189. */
  25190. textureMask: Color4;
  25191. /**
  25192. * The particle emitter type defines the emitter used by the particle system.
  25193. * It can be for example box, sphere, or cone...
  25194. */
  25195. particleEmitterType: IParticleEmitterType;
  25196. /**
  25197. * This function can be defined to specify initial direction for every new particle.
  25198. * It by default use the emitterType defined function
  25199. */
  25200. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  25201. /**
  25202. * This function can be defined to specify initial position for every new particle.
  25203. * It by default use the emitterType defined function
  25204. */
  25205. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  25206. /**
  25207. * 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)
  25208. */
  25209. spriteCellChangeSpeed: number;
  25210. /**
  25211. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  25212. */
  25213. startSpriteCellID: number;
  25214. /**
  25215. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  25216. */
  25217. endSpriteCellID: number;
  25218. /**
  25219. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  25220. */
  25221. spriteCellWidth: number;
  25222. /**
  25223. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  25224. */
  25225. spriteCellHeight: number;
  25226. /** 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 */
  25227. preWarmCycles: number;
  25228. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  25229. preWarmStepOffset: number;
  25230. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  25231. translationPivot: Vector2;
  25232. /**
  25233. * An event triggered when the system is disposed
  25234. */
  25235. onDisposeObservable: Observable<ParticleSystem>;
  25236. private _onDisposeObserver;
  25237. /**
  25238. * Sets a callback that will be triggered when the system is disposed
  25239. */
  25240. onDispose: () => void;
  25241. /**
  25242. * Gets whether an animation sprite sheet is enabled or not on the particle system
  25243. */
  25244. readonly isAnimationSheetEnabled: boolean;
  25245. /**
  25246. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  25247. */
  25248. isBillboardBased: boolean;
  25249. /**
  25250. * Gets or sets the billboard mode to use when isBillboardBased = true.
  25251. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  25252. */
  25253. billboardMode: number;
  25254. private _particles;
  25255. private _epsilon;
  25256. private _capacity;
  25257. private _scene;
  25258. private _stockParticles;
  25259. private _newPartsExcess;
  25260. private _vertexData;
  25261. private _vertexBuffer;
  25262. private _vertexBuffers;
  25263. private _spriteBuffer;
  25264. private _indexBuffer;
  25265. private _effect;
  25266. private _customEffect;
  25267. private _cachedDefines;
  25268. private _scaledColorStep;
  25269. private _colorDiff;
  25270. private _scaledDirection;
  25271. private _scaledGravity;
  25272. private _currentRenderId;
  25273. private _alive;
  25274. private _useInstancing;
  25275. private _started;
  25276. private _stopped;
  25277. private _actualFrame;
  25278. private _scaledUpdateSpeed;
  25279. private _vertexBufferSize;
  25280. private _isAnimationSheetEnabled;
  25281. private _isBillboardBased;
  25282. /**
  25283. * this is the Sub-emitters templates that will be used to generate particle system when the particle dies, this property is used by the root particle system only.
  25284. */
  25285. subEmitters: ParticleSystem[];
  25286. /**
  25287. * The current active Sub-systems, this property is used by the root particle system only.
  25288. */
  25289. activeSubSystems: Array<ParticleSystem>;
  25290. private _rootParticleSystem;
  25291. /**
  25292. * Gets the current list of active particles
  25293. */
  25294. readonly particles: Particle[];
  25295. /**
  25296. * Returns the string "ParticleSystem"
  25297. * @returns a string containing the class name
  25298. */
  25299. getClassName(): string;
  25300. /**
  25301. * Instantiates a particle system.
  25302. * 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.
  25303. * @param name The name of the particle system
  25304. * @param capacity The max number of particles alive at the same time
  25305. * @param scene The scene the particle system belongs to
  25306. * @param customEffect a custom effect used to change the way particles are rendered by default
  25307. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  25308. * @param epsilon Offset used to render the particles
  25309. */
  25310. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  25311. private _addFactorGradient(factorGradients, gradient, factor, factor2?);
  25312. private _removeFactorGradient(factorGradients, gradient);
  25313. /**
  25314. * Adds a new life time gradient
  25315. * @param gradient defines the gradient to use (between 0 and 1)
  25316. * @param factor defines the life time factor to affect to the specified gradient
  25317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25318. */
  25319. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  25320. /**
  25321. * Remove a specific life time gradient
  25322. * @param gradient defines the gradient to remove
  25323. */
  25324. removeLifeTimeGradient(gradient: number): ParticleSystem;
  25325. /**
  25326. * Adds a new size gradient
  25327. * @param gradient defines the gradient to use (between 0 and 1)
  25328. * @param factor defines the size factor to affect to the specified gradient
  25329. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25330. */
  25331. addSizeGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  25332. /**
  25333. * Remove a specific size gradient
  25334. * @param gradient defines the gradient to remove
  25335. */
  25336. removeSizeGradient(gradient: number): ParticleSystem;
  25337. /**
  25338. * Adds a new color gradient
  25339. * @param gradient defines the gradient to use (between 0 and 1)
  25340. * @param color defines the color to affect to the specified gradient
  25341. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25342. */
  25343. addColorGradient(gradient: number, color: Color4, color2?: Color4): ParticleSystem;
  25344. /**
  25345. * Remove a specific color gradient
  25346. * @param gradient defines the gradient to remove
  25347. */
  25348. removeColorGradient(gradient: number): ParticleSystem;
  25349. private _resetEffect();
  25350. private _createVertexBuffers();
  25351. private _createIndexBuffer();
  25352. /**
  25353. * Gets the maximum number of particles active at the same time.
  25354. * @returns The max number of active particles.
  25355. */
  25356. getCapacity(): number;
  25357. /**
  25358. * Gets Wether there are still active particles in the system.
  25359. * @returns True if it is alive, otherwise false.
  25360. */
  25361. isAlive(): boolean;
  25362. /**
  25363. * Gets Wether the system has been started.
  25364. * @returns True if it has been started, otherwise false.
  25365. */
  25366. isStarted(): boolean;
  25367. /**
  25368. * Starts the particle system and begins to emit.
  25369. */
  25370. start(): void;
  25371. /**
  25372. * Stops the particle system.
  25373. * @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.
  25374. */
  25375. stop(stopSubEmitters?: boolean): void;
  25376. /**
  25377. * Remove all active particles
  25378. */
  25379. reset(): void;
  25380. /**
  25381. * @hidden (for internal use only)
  25382. */
  25383. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  25384. /**
  25385. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  25386. * Its lifetime will start back at 0.
  25387. */
  25388. recycleParticle: (particle: Particle) => void;
  25389. private _stopSubEmitters();
  25390. private _createParticle;
  25391. private _removeFromRoot();
  25392. private _emitFromParticle;
  25393. private _update(newParticles);
  25394. /** @hidden */
  25395. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean): string[];
  25396. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  25397. private _getEffect();
  25398. /**
  25399. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  25400. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  25401. */
  25402. animate(preWarmOnly?: boolean): void;
  25403. private _appendParticleVertices(offset, particle);
  25404. /**
  25405. * Rebuilds the particle system.
  25406. */
  25407. rebuild(): void;
  25408. /**
  25409. * Is this system ready to be used/rendered
  25410. * @return true if the system is ready
  25411. */
  25412. isReady(): boolean;
  25413. /**
  25414. * Renders the particle system in its current state.
  25415. * @returns the current number of particles
  25416. */
  25417. render(): number;
  25418. /**
  25419. * Disposes the particle system and free the associated resources
  25420. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25421. */
  25422. dispose(disposeTexture?: boolean): void;
  25423. /**
  25424. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  25425. * @param radius The radius of the sphere to emit from
  25426. * @returns the emitter
  25427. */
  25428. createSphereEmitter(radius?: number): SphereParticleEmitter;
  25429. /**
  25430. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  25431. * @param radius The radius of the sphere to emit from
  25432. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  25433. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  25434. * @returns the emitter
  25435. */
  25436. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  25437. /**
  25438. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  25439. * @param radius The radius of the cone to emit from
  25440. * @param angle The base angle of the cone
  25441. * @returns the emitter
  25442. */
  25443. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  25444. /**
  25445. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  25446. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25447. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25448. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25449. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25450. * @returns the emitter
  25451. */
  25452. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  25453. /**
  25454. * Clones the particle system.
  25455. * @param name The name of the cloned object
  25456. * @param newEmitter The new emitter to use
  25457. * @returns the cloned particle system
  25458. */
  25459. clone(name: string, newEmitter: any): ParticleSystem;
  25460. /**
  25461. * Serializes the particle system to a JSON object.
  25462. * @returns the JSON object
  25463. */
  25464. serialize(): any;
  25465. /** @hidden */
  25466. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  25467. /** @hidden */
  25468. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  25469. /**
  25470. * Parses a JSON object to create a particle system.
  25471. * @param parsedParticleSystem The JSON object to parse
  25472. * @param scene The scene to create the particle system in
  25473. * @param rootUrl The root url to use to load external dependencies like texture
  25474. * @returns the Parsed particle system
  25475. */
  25476. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  25477. }
  25478. }
  25479. declare module BABYLON {
  25480. /**
  25481. * Represents a set of particle systems working together to create a specific effect
  25482. */
  25483. class ParticleSystemSet implements IDisposable {
  25484. private _emitterCreationOptions;
  25485. private _emitterNode;
  25486. /**
  25487. * Gets the particle system list
  25488. */
  25489. systems: IParticleSystem[];
  25490. /**
  25491. * Gets the emitter node used with this set
  25492. */
  25493. readonly emitterNode: Nullable<TransformNode>;
  25494. /**
  25495. * Creates a new emitter mesh as a sphere
  25496. * @param options defines the options used to create the sphere
  25497. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  25498. * @param scene defines the hosting scene
  25499. */
  25500. setEmitterAsSphere(options: {
  25501. diameter: number;
  25502. segments: number;
  25503. color: Color3;
  25504. }, renderingGroupId: number, scene: Scene): void;
  25505. /**
  25506. * Starts all particle systems of the set
  25507. * @param emitter defines an optional mesh to use as emitter for the particle systems
  25508. */
  25509. start(emitter?: AbstractMesh): void;
  25510. /**
  25511. * Release all associated resources
  25512. */
  25513. dispose(): void;
  25514. /**
  25515. * Serialize the set into a JSON compatible object
  25516. * @returns a JSON compatible representation of the set
  25517. */
  25518. serialize(): any;
  25519. /**
  25520. * Parse a new ParticleSystemSet from a serialized source
  25521. * @param data defines a JSON compatible representation of the set
  25522. * @param scene defines the hosting scene
  25523. * @param gpu defines if we want GPU particles or CPU particles
  25524. * @returns a new ParticleSystemSet
  25525. */
  25526. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  25527. }
  25528. }
  25529. declare module BABYLON {
  25530. /**
  25531. * Represents one particle of a solid particle system.
  25532. */
  25533. class SolidParticle {
  25534. /**
  25535. * particle global index
  25536. */
  25537. idx: number;
  25538. /**
  25539. * The color of the particle
  25540. */
  25541. color: Nullable<Color4>;
  25542. /**
  25543. * The world space position of the particle.
  25544. */
  25545. position: Vector3;
  25546. /**
  25547. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25548. */
  25549. rotation: Vector3;
  25550. /**
  25551. * The world space rotation quaternion of the particle.
  25552. */
  25553. rotationQuaternion: Nullable<Quaternion>;
  25554. /**
  25555. * The scaling of the particle.
  25556. */
  25557. scaling: Vector3;
  25558. /**
  25559. * The uvs of the particle.
  25560. */
  25561. uvs: Vector4;
  25562. /**
  25563. * The current speed of the particle.
  25564. */
  25565. velocity: Vector3;
  25566. /**
  25567. * The pivot point in the particle local space.
  25568. */
  25569. pivot: Vector3;
  25570. /**
  25571. * Must the particle be translated from its pivot point in its local space ?
  25572. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25573. * Default : false
  25574. */
  25575. translateFromPivot: boolean;
  25576. /**
  25577. * Is the particle active or not ?
  25578. */
  25579. alive: boolean;
  25580. /**
  25581. * Is the particle visible or not ?
  25582. */
  25583. isVisible: boolean;
  25584. /**
  25585. * Index of this particle in the global "positions" array (Internal use)
  25586. */
  25587. _pos: number;
  25588. /**
  25589. * Index of this particle in the global "indices" array (Internal use)
  25590. */
  25591. _ind: number;
  25592. /**
  25593. * ModelShape of this particle (Internal use)
  25594. */
  25595. _model: ModelShape;
  25596. /**
  25597. * ModelShape id of this particle
  25598. */
  25599. shapeId: number;
  25600. /**
  25601. * Index of the particle in its shape id (Internal use)
  25602. */
  25603. idxInShape: number;
  25604. /**
  25605. * Reference to the shape model BoundingInfo object (Internal use)
  25606. */
  25607. _modelBoundingInfo: BoundingInfo;
  25608. /**
  25609. * Particle BoundingInfo object (Internal use)
  25610. */
  25611. _boundingInfo: BoundingInfo;
  25612. /**
  25613. * Reference to the SPS what the particle belongs to (Internal use)
  25614. */
  25615. _sps: SolidParticleSystem;
  25616. /**
  25617. * Still set as invisible in order to skip useless computations (Internal use)
  25618. */
  25619. _stillInvisible: boolean;
  25620. /**
  25621. * Last computed particle rotation matrix
  25622. */
  25623. _rotationMatrix: number[];
  25624. /**
  25625. * Parent particle Id, if any.
  25626. * Default null.
  25627. */
  25628. parentId: Nullable<number>;
  25629. /**
  25630. * Internal global position in the SPS.
  25631. */
  25632. _globalPosition: Vector3;
  25633. /**
  25634. * Creates a Solid Particle object.
  25635. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25636. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25637. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25638. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25639. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25640. * @param shapeId (integer) is the model shape identifier in the SPS.
  25641. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25642. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25643. */
  25644. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25645. /**
  25646. * Legacy support, changed scale to scaling
  25647. */
  25648. /**
  25649. * Legacy support, changed scale to scaling
  25650. */
  25651. scale: Vector3;
  25652. /**
  25653. * Legacy support, changed quaternion to rotationQuaternion
  25654. */
  25655. /**
  25656. * Legacy support, changed quaternion to rotationQuaternion
  25657. */
  25658. quaternion: Nullable<Quaternion>;
  25659. /**
  25660. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25661. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25662. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25663. * @returns true if it intersects
  25664. */
  25665. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25666. }
  25667. /**
  25668. * Represents the shape of the model used by one particle of a solid particle system.
  25669. * SPS internal tool, don't use it manually.
  25670. */
  25671. class ModelShape {
  25672. /**
  25673. * The shape id.
  25674. */
  25675. shapeID: number;
  25676. /**
  25677. * flat array of model positions (internal use)
  25678. */
  25679. _shape: Vector3[];
  25680. /**
  25681. * flat array of model UVs (internal use)
  25682. */
  25683. _shapeUV: number[];
  25684. /**
  25685. * length of the shape in the model indices array (internal use)
  25686. */
  25687. _indicesLength: number;
  25688. /**
  25689. * Custom position function (internal use)
  25690. */
  25691. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25692. /**
  25693. * Custom vertex function (internal use)
  25694. */
  25695. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25696. /**
  25697. * 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.
  25698. * SPS internal tool, don't use it manually.
  25699. * @hidden
  25700. */
  25701. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25702. }
  25703. /**
  25704. * Represents a Depth Sorted Particle in the solid particle system.
  25705. */
  25706. class DepthSortedParticle {
  25707. /**
  25708. * Index of the particle in the "indices" array
  25709. */
  25710. ind: number;
  25711. /**
  25712. * Length of the particle shape in the "indices" array
  25713. */
  25714. indicesLength: number;
  25715. /**
  25716. * Squared distance from the particle to the camera
  25717. */
  25718. sqDistance: number;
  25719. }
  25720. }
  25721. declare module BABYLON {
  25722. /**
  25723. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25724. *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.
  25725. * The SPS is also a particle system. It provides some methods to manage the particles.
  25726. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25727. *
  25728. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  25729. */
  25730. class SolidParticleSystem implements IDisposable {
  25731. /**
  25732. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25733. * Example : var p = SPS.particles[i];
  25734. */
  25735. particles: SolidParticle[];
  25736. /**
  25737. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25738. */
  25739. nbParticles: number;
  25740. /**
  25741. * If the particles must ever face the camera (default false). Useful for planar particles.
  25742. */
  25743. billboard: boolean;
  25744. /**
  25745. * Recompute normals when adding a shape
  25746. */
  25747. recomputeNormals: boolean;
  25748. /**
  25749. * This a counter ofr your own usage. It's not set by any SPS functions.
  25750. */
  25751. counter: number;
  25752. /**
  25753. * The SPS name. This name is also given to the underlying mesh.
  25754. */
  25755. name: string;
  25756. /**
  25757. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25758. */
  25759. mesh: Mesh;
  25760. /**
  25761. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25762. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  25763. */
  25764. vars: any;
  25765. /**
  25766. * This array is populated when the SPS is set as 'pickable'.
  25767. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25768. * Each element of this array is an object `{idx: int, faceId: int}`.
  25769. * `idx` is the picked particle index in the `SPS.particles` array
  25770. * `faceId` is the picked face index counted within this particle.
  25771. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  25772. */
  25773. pickedParticles: {
  25774. idx: number;
  25775. faceId: number;
  25776. }[];
  25777. /**
  25778. * This array is populated when `enableDepthSort` is set to true.
  25779. * Each element of this array is an instance of the class DepthSortedParticle.
  25780. */
  25781. depthSortedParticles: DepthSortedParticle[];
  25782. /**
  25783. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25784. */
  25785. _bSphereOnly: boolean;
  25786. /**
  25787. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25788. */
  25789. _bSphereRadiusFactor: number;
  25790. private _scene;
  25791. private _positions;
  25792. private _indices;
  25793. private _normals;
  25794. private _colors;
  25795. private _uvs;
  25796. private _indices32;
  25797. private _positions32;
  25798. private _normals32;
  25799. private _fixedNormal32;
  25800. private _colors32;
  25801. private _uvs32;
  25802. private _index;
  25803. private _updatable;
  25804. private _pickable;
  25805. private _isVisibilityBoxLocked;
  25806. private _alwaysVisible;
  25807. private _depthSort;
  25808. private _shapeCounter;
  25809. private _copy;
  25810. private _shape;
  25811. private _shapeUV;
  25812. private _color;
  25813. private _computeParticleColor;
  25814. private _computeParticleTexture;
  25815. private _computeParticleRotation;
  25816. private _computeParticleVertex;
  25817. private _computeBoundingBox;
  25818. private _depthSortParticles;
  25819. private _cam_axisZ;
  25820. private _cam_axisY;
  25821. private _cam_axisX;
  25822. private _axisZ;
  25823. private _camera;
  25824. private _particle;
  25825. private _camDir;
  25826. private _camInvertedPosition;
  25827. private _rotMatrix;
  25828. private _invertMatrix;
  25829. private _rotated;
  25830. private _quaternion;
  25831. private _vertex;
  25832. private _normal;
  25833. private _yaw;
  25834. private _pitch;
  25835. private _roll;
  25836. private _halfroll;
  25837. private _halfpitch;
  25838. private _halfyaw;
  25839. private _sinRoll;
  25840. private _cosRoll;
  25841. private _sinPitch;
  25842. private _cosPitch;
  25843. private _sinYaw;
  25844. private _cosYaw;
  25845. private _mustUnrotateFixedNormals;
  25846. private _minimum;
  25847. private _maximum;
  25848. private _minBbox;
  25849. private _maxBbox;
  25850. private _particlesIntersect;
  25851. private _depthSortFunction;
  25852. private _needs32Bits;
  25853. private _pivotBackTranslation;
  25854. private _scaledPivot;
  25855. private _particleHasParent;
  25856. private _parent;
  25857. /**
  25858. * Creates a SPS (Solid Particle System) object.
  25859. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25860. * @param scene (Scene) is the scene in which the SPS is added.
  25861. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25862. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25863. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25864. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25865. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25866. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25867. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25868. */
  25869. constructor(name: string, scene: Scene, options?: {
  25870. updatable?: boolean;
  25871. isPickable?: boolean;
  25872. enableDepthSort?: boolean;
  25873. particleIntersection?: boolean;
  25874. boundingSphereOnly?: boolean;
  25875. bSphereRadiusFactor?: number;
  25876. });
  25877. /**
  25878. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25879. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25880. * @returns the created mesh
  25881. */
  25882. buildMesh(): Mesh;
  25883. /**
  25884. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25885. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25886. * Thus the particles generated from `digest()` have their property `position` set yet.
  25887. * @param mesh ( Mesh ) is the mesh to be digested
  25888. * @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
  25889. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25890. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25891. * @returns the current SPS
  25892. */
  25893. digest(mesh: Mesh, options?: {
  25894. facetNb?: number;
  25895. number?: number;
  25896. delta?: number;
  25897. }): SolidParticleSystem;
  25898. private _unrotateFixedNormals();
  25899. private _resetCopy();
  25900. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  25901. private _posToShape(positions);
  25902. private _uvsToShapeUV(uvs);
  25903. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  25904. /**
  25905. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25906. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  25907. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25908. * @param nb (positive integer) the number of particles to be created from this model
  25909. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25910. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25911. * @returns the number of shapes in the system
  25912. */
  25913. addShape(mesh: Mesh, nb: number, options?: {
  25914. positionFunction?: any;
  25915. vertexFunction?: any;
  25916. }): number;
  25917. private _rebuildParticle(particle);
  25918. /**
  25919. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25920. * @returns the SPS.
  25921. */
  25922. rebuildMesh(): SolidParticleSystem;
  25923. /**
  25924. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25925. * This method calls `updateParticle()` for each particle of the SPS.
  25926. * For an animated SPS, it is usually called within the render loop.
  25927. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25928. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25929. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25930. * @returns the SPS.
  25931. */
  25932. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25933. private _quaternionRotationYPR();
  25934. private _quaternionToRotationMatrix();
  25935. /**
  25936. * Disposes the SPS.
  25937. */
  25938. dispose(): void;
  25939. /**
  25940. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25941. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25942. * @returns the SPS.
  25943. */
  25944. refreshVisibleSize(): SolidParticleSystem;
  25945. /**
  25946. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25947. * @param size the size (float) of the visibility box
  25948. * note : this doesn't lock the SPS mesh bounding box.
  25949. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25950. */
  25951. setVisibilityBox(size: number): void;
  25952. /**
  25953. * Gets whether the SPS as always visible or not
  25954. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25955. */
  25956. /**
  25957. * Sets the SPS as always visible or not
  25958. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25959. */
  25960. isAlwaysVisible: boolean;
  25961. /**
  25962. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25963. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25964. */
  25965. /**
  25966. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25967. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25968. */
  25969. isVisibilityBoxLocked: boolean;
  25970. /**
  25971. * Gets if `setParticles()` computes the particle rotations or not.
  25972. * Default value : true. The SPS is faster when it's set to false.
  25973. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25974. */
  25975. /**
  25976. * Tells to `setParticles()` to compute the particle rotations or not.
  25977. * Default value : true. The SPS is faster when it's set to false.
  25978. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25979. */
  25980. computeParticleRotation: boolean;
  25981. /**
  25982. * Gets if `setParticles()` computes the particle colors or not.
  25983. * Default value : true. The SPS is faster when it's set to false.
  25984. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25985. */
  25986. /**
  25987. * Tells to `setParticles()` to compute the particle colors or not.
  25988. * Default value : true. The SPS is faster when it's set to false.
  25989. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25990. */
  25991. computeParticleColor: boolean;
  25992. /**
  25993. * Gets if `setParticles()` computes the particle textures or not.
  25994. * Default value : true. The SPS is faster when it's set to false.
  25995. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25996. */
  25997. computeParticleTexture: boolean;
  25998. /**
  25999. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26000. * Default value : false. The SPS is faster when it's set to false.
  26001. * Note : the particle custom vertex positions aren't stored values.
  26002. */
  26003. /**
  26004. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26005. * Default value : false. The SPS is faster when it's set to false.
  26006. * Note : the particle custom vertex positions aren't stored values.
  26007. */
  26008. computeParticleVertex: boolean;
  26009. /**
  26010. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26011. */
  26012. /**
  26013. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26014. */
  26015. computeBoundingBox: boolean;
  26016. /**
  26017. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26018. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26019. * Default : `true`
  26020. */
  26021. /**
  26022. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26023. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26024. * Default : `true`
  26025. */
  26026. depthSortParticles: boolean;
  26027. /**
  26028. * This function does nothing. It may be overwritten to set all the particle first values.
  26029. * The SPS doesn't call this function, you may have to call it by your own.
  26030. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26031. */
  26032. initParticles(): void;
  26033. /**
  26034. * This function does nothing. It may be overwritten to recycle a particle.
  26035. * The SPS doesn't call this function, you may have to call it by your own.
  26036. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26037. * @param particle The particle to recycle
  26038. * @returns the recycled particle
  26039. */
  26040. recycleParticle(particle: SolidParticle): SolidParticle;
  26041. /**
  26042. * Updates a particle : this function should be overwritten by the user.
  26043. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26044. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26045. * @example : just set a particle position or velocity and recycle conditions
  26046. * @param particle The particle to update
  26047. * @returns the updated particle
  26048. */
  26049. updateParticle(particle: SolidParticle): SolidParticle;
  26050. /**
  26051. * Updates a vertex of a particle : it can be overwritten by the user.
  26052. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26053. * @param particle the current particle
  26054. * @param vertex the current index of the current particle
  26055. * @param pt the index of the current vertex in the particle shape
  26056. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  26057. * @example : just set a vertex particle position
  26058. * @returns the updated vertex
  26059. */
  26060. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26061. /**
  26062. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26063. * This does nothing and may be overwritten by the user.
  26064. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26065. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26066. * @param update the boolean update value actually passed to setParticles()
  26067. */
  26068. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26069. /**
  26070. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26071. * This will be passed three parameters.
  26072. * This does nothing and may be overwritten by the user.
  26073. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26074. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26075. * @param update the boolean update value actually passed to setParticles()
  26076. */
  26077. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26078. }
  26079. }
  26080. declare module BABYLON {
  26081. class ReflectionProbe {
  26082. name: string;
  26083. private _scene;
  26084. private _renderTargetTexture;
  26085. private _projectionMatrix;
  26086. private _viewMatrix;
  26087. private _target;
  26088. private _add;
  26089. private _attachedMesh;
  26090. private _invertYAxis;
  26091. position: Vector3;
  26092. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  26093. samples: number;
  26094. refreshRate: number;
  26095. getScene(): Scene;
  26096. readonly cubeTexture: RenderTargetTexture;
  26097. readonly renderList: Nullable<AbstractMesh[]>;
  26098. attachToMesh(mesh: AbstractMesh): void;
  26099. /**
  26100. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26101. *
  26102. * @param renderingGroupId The rendering group id corresponding to its index
  26103. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26104. */
  26105. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  26106. dispose(): void;
  26107. }
  26108. }
  26109. declare module BABYLON {
  26110. class BoundingBoxRenderer {
  26111. frontColor: Color3;
  26112. backColor: Color3;
  26113. showBackLines: boolean;
  26114. renderList: SmartArray<BoundingBox>;
  26115. private _scene;
  26116. private _colorShader;
  26117. private _vertexBuffers;
  26118. private _indexBuffer;
  26119. constructor(scene: Scene);
  26120. private _prepareRessources();
  26121. private _createIndexBuffer();
  26122. _rebuild(): void;
  26123. reset(): void;
  26124. render(): void;
  26125. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  26126. dispose(): void;
  26127. }
  26128. }
  26129. declare module BABYLON {
  26130. /**
  26131. * This represents a depth renderer in Babylon.
  26132. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  26133. */
  26134. class DepthRenderer {
  26135. private _scene;
  26136. private _depthMap;
  26137. private _effect;
  26138. private _cachedDefines;
  26139. private _camera;
  26140. /**
  26141. * Instantiates a depth renderer
  26142. * @param scene The scene the renderer belongs to
  26143. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  26144. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  26145. */
  26146. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  26147. /**
  26148. * Creates the depth rendering effect and checks if the effect is ready.
  26149. * @param subMesh The submesh to be used to render the depth map of
  26150. * @param useInstances If multiple world instances should be used
  26151. * @returns if the depth renderer is ready to render the depth map
  26152. */
  26153. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26154. /**
  26155. * Gets the texture which the depth map will be written to.
  26156. * @returns The depth map texture
  26157. */
  26158. getDepthMap(): RenderTargetTexture;
  26159. /**
  26160. * Disposes of the depth renderer.
  26161. */
  26162. dispose(): void;
  26163. }
  26164. }
  26165. declare module BABYLON {
  26166. class EdgesRenderer {
  26167. edgesWidthScalerForOrthographic: number;
  26168. edgesWidthScalerForPerspective: number;
  26169. private _source;
  26170. private _linesPositions;
  26171. private _linesNormals;
  26172. private _linesIndices;
  26173. private _epsilon;
  26174. private _indicesCount;
  26175. private _lineShader;
  26176. private _ib;
  26177. private _buffers;
  26178. private _checkVerticesInsteadOfIndices;
  26179. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  26180. isEnabled: boolean;
  26181. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  26182. private _prepareRessources();
  26183. _rebuild(): void;
  26184. dispose(): void;
  26185. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  26186. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  26187. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  26188. _generateEdgesLines(): void;
  26189. render(): void;
  26190. }
  26191. }
  26192. declare module BABYLON {
  26193. /**
  26194. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  26195. */
  26196. class GeometryBufferRenderer {
  26197. private _scene;
  26198. private _multiRenderTarget;
  26199. private _ratio;
  26200. private _enablePosition;
  26201. protected _effect: Effect;
  26202. protected _cachedDefines: string;
  26203. /**
  26204. * Set the render list (meshes to be rendered) used in the G buffer.
  26205. */
  26206. renderList: Mesh[];
  26207. /**
  26208. * Gets wether or not G buffer are supported by the running hardware.
  26209. * This requires draw buffer supports
  26210. */
  26211. readonly isSupported: boolean;
  26212. /**
  26213. * Gets wether or not position are enabled for the G buffer.
  26214. */
  26215. /**
  26216. * Sets wether or not position are enabled for the G buffer.
  26217. */
  26218. enablePosition: boolean;
  26219. /**
  26220. * Gets the scene associated with the buffer.
  26221. */
  26222. readonly scene: Scene;
  26223. /**
  26224. * Gets the ratio used by the buffer during its creation.
  26225. * How big is the buffer related to the main canvas.
  26226. */
  26227. readonly ratio: number;
  26228. /**
  26229. * Creates a new G Buffer for the scene
  26230. * @param scene The scene the buffer belongs to
  26231. * @param ratio How big is the buffer related to the main canvas.
  26232. */
  26233. constructor(scene: Scene, ratio?: number);
  26234. /**
  26235. * Checks wether everything is ready to render a submesh to the G buffer.
  26236. * @param subMesh the submesh to check readiness for
  26237. * @param useInstances is the mesh drawn using instance or not
  26238. * @returns true if ready otherwise false
  26239. */
  26240. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26241. /**
  26242. * Gets the current underlying G Buffer.
  26243. * @returns the buffer
  26244. */
  26245. getGBuffer(): MultiRenderTarget;
  26246. /**
  26247. * Gets the number of samples used to render the buffer (anti aliasing).
  26248. */
  26249. /**
  26250. * Sets the number of samples used to render the buffer (anti aliasing).
  26251. */
  26252. samples: number;
  26253. /**
  26254. * Disposes the renderer and frees up associated resources.
  26255. */
  26256. dispose(): void;
  26257. protected _createRenderTargets(): void;
  26258. }
  26259. }
  26260. declare module BABYLON {
  26261. class OutlineRenderer {
  26262. private _scene;
  26263. private _effect;
  26264. private _cachedDefines;
  26265. zOffset: number;
  26266. constructor(scene: Scene);
  26267. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  26268. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26269. }
  26270. }
  26271. declare module BABYLON {
  26272. class RenderingGroup {
  26273. index: number;
  26274. private _scene;
  26275. private _opaqueSubMeshes;
  26276. private _transparentSubMeshes;
  26277. private _alphaTestSubMeshes;
  26278. private _depthOnlySubMeshes;
  26279. private _particleSystems;
  26280. private _spriteManagers;
  26281. private _opaqueSortCompareFn;
  26282. private _alphaTestSortCompareFn;
  26283. private _transparentSortCompareFn;
  26284. private _renderOpaque;
  26285. private _renderAlphaTest;
  26286. private _renderTransparent;
  26287. private _edgesRenderers;
  26288. onBeforeTransparentRendering: () => void;
  26289. /**
  26290. * Set the opaque sort comparison function.
  26291. * If null the sub meshes will be render in the order they were created
  26292. */
  26293. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26294. /**
  26295. * Set the alpha test sort comparison function.
  26296. * If null the sub meshes will be render in the order they were created
  26297. */
  26298. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26299. /**
  26300. * Set the transparent sort comparison function.
  26301. * If null the sub meshes will be render in the order they were created
  26302. */
  26303. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26304. /**
  26305. * Creates a new rendering group.
  26306. * @param index The rendering group index
  26307. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  26308. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  26309. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  26310. */
  26311. 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>);
  26312. /**
  26313. * Render all the sub meshes contained in the group.
  26314. * @param customRenderFunction Used to override the default render behaviour of the group.
  26315. * @returns true if rendered some submeshes.
  26316. */
  26317. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  26318. /**
  26319. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  26320. * @param subMeshes The submeshes to render
  26321. */
  26322. private renderOpaqueSorted(subMeshes);
  26323. /**
  26324. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  26325. * @param subMeshes The submeshes to render
  26326. */
  26327. private renderAlphaTestSorted(subMeshes);
  26328. /**
  26329. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  26330. * @param subMeshes The submeshes to render
  26331. */
  26332. private renderTransparentSorted(subMeshes);
  26333. /**
  26334. * Renders the submeshes in a specified order.
  26335. * @param subMeshes The submeshes to sort before render
  26336. * @param sortCompareFn The comparison function use to sort
  26337. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  26338. * @param transparent Specifies to activate blending if true
  26339. */
  26340. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  26341. /**
  26342. * Renders the submeshes in the order they were dispatched (no sort applied).
  26343. * @param subMeshes The submeshes to render
  26344. */
  26345. private static renderUnsorted(subMeshes);
  26346. /**
  26347. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26348. * are rendered back to front if in the same alpha index.
  26349. *
  26350. * @param a The first submesh
  26351. * @param b The second submesh
  26352. * @returns The result of the comparison
  26353. */
  26354. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  26355. /**
  26356. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26357. * are rendered back to front.
  26358. *
  26359. * @param a The first submesh
  26360. * @param b The second submesh
  26361. * @returns The result of the comparison
  26362. */
  26363. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  26364. /**
  26365. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26366. * are rendered front to back (prevent overdraw).
  26367. *
  26368. * @param a The first submesh
  26369. * @param b The second submesh
  26370. * @returns The result of the comparison
  26371. */
  26372. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  26373. /**
  26374. * Resets the different lists of submeshes to prepare a new frame.
  26375. */
  26376. prepare(): void;
  26377. dispose(): void;
  26378. /**
  26379. * Inserts the submesh in its correct queue depending on its material.
  26380. * @param subMesh The submesh to dispatch
  26381. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26382. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26383. */
  26384. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26385. dispatchSprites(spriteManager: SpriteManager): void;
  26386. dispatchParticles(particleSystem: IParticleSystem): void;
  26387. private _renderParticles(activeMeshes);
  26388. private _renderSprites();
  26389. }
  26390. }
  26391. declare module BABYLON {
  26392. class RenderingManager {
  26393. /**
  26394. * The max id used for rendering groups (not included)
  26395. */
  26396. static MAX_RENDERINGGROUPS: number;
  26397. /**
  26398. * The min id used for rendering groups (included)
  26399. */
  26400. static MIN_RENDERINGGROUPS: number;
  26401. /**
  26402. * Used to globally prevent autoclearing scenes.
  26403. */
  26404. static AUTOCLEAR: boolean;
  26405. private _scene;
  26406. private _renderingGroups;
  26407. private _depthStencilBufferAlreadyCleaned;
  26408. private _autoClearDepthStencil;
  26409. private _customOpaqueSortCompareFn;
  26410. private _customAlphaTestSortCompareFn;
  26411. private _customTransparentSortCompareFn;
  26412. private _renderinGroupInfo;
  26413. constructor(scene: Scene);
  26414. private _clearDepthStencilBuffer(depth?, stencil?);
  26415. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  26416. reset(): void;
  26417. dispose(): void;
  26418. /**
  26419. * Clear the info related to rendering groups preventing retention points during dispose.
  26420. */
  26421. freeRenderingGroups(): void;
  26422. private _prepareRenderingGroup(renderingGroupId);
  26423. dispatchSprites(spriteManager: SpriteManager): void;
  26424. dispatchParticles(particleSystem: IParticleSystem): void;
  26425. /**
  26426. * @param subMesh The submesh to dispatch
  26427. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26428. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26429. */
  26430. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26431. /**
  26432. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  26433. * This allowed control for front to back rendering or reversly depending of the special needs.
  26434. *
  26435. * @param renderingGroupId The rendering group id corresponding to its index
  26436. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  26437. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  26438. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  26439. */
  26440. 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;
  26441. /**
  26442. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26443. *
  26444. * @param renderingGroupId The rendering group id corresponding to its index
  26445. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26446. * @param depth Automatically clears depth between groups if true and autoClear is true.
  26447. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  26448. */
  26449. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  26450. }
  26451. }
  26452. declare module BABYLON {
  26453. /**
  26454. * Renders a layer on top of an existing scene
  26455. */
  26456. class UtilityLayerRenderer implements IDisposable {
  26457. /** the original scene that will be rendered on top of */ originalScene: Scene;
  26458. private _pointerCaptures;
  26459. private _lastPointerEvents;
  26460. private static _DefaultUtilityLayer;
  26461. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  26462. /**
  26463. * The scene that is rendered on top of the original scene
  26464. */
  26465. utilityLayerScene: Scene;
  26466. /**
  26467. * If the utility layer should automatically be rendered on top of existing scene
  26468. */
  26469. shouldRender: boolean;
  26470. /**
  26471. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  26472. */
  26473. onlyCheckPointerDownEvents: boolean;
  26474. /**
  26475. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  26476. */
  26477. processAllEvents: boolean;
  26478. /**
  26479. * Observable raised when the pointer move from the utility layer scene to the main scene
  26480. */
  26481. onPointerOutObservable: Observable<number>;
  26482. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  26483. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  26484. private _afterRenderObserver;
  26485. private _sceneDisposeObserver;
  26486. private _originalPointerObserver;
  26487. /**
  26488. * Instantiates a UtilityLayerRenderer
  26489. * @param originalScene the original scene that will be rendered on top of
  26490. */
  26491. constructor(/** the original scene that will be rendered on top of */ originalScene: Scene);
  26492. private _notifyObservers(prePointerInfo, pickInfo, pointerEvent);
  26493. /**
  26494. * Renders the utility layers scene on top of the original scene
  26495. */
  26496. render(): void;
  26497. /**
  26498. * Disposes of the renderer
  26499. */
  26500. dispose(): void;
  26501. private _updateCamera();
  26502. }
  26503. }
  26504. declare module BABYLON {
  26505. /**
  26506. * Postprocess used to generate anaglyphic rendering
  26507. */
  26508. class AnaglyphPostProcess extends PostProcess {
  26509. private _passedProcess;
  26510. /**
  26511. * Creates a new AnaglyphPostProcess
  26512. * @param name defines postprocess name
  26513. * @param options defines creation options or target ratio scale
  26514. * @param rigCameras defines cameras using this postprocess
  26515. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  26516. * @param engine defines hosting engine
  26517. * @param reusable defines if the postprocess will be reused multiple times per frame
  26518. */
  26519. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  26520. }
  26521. }
  26522. declare module BABYLON {
  26523. class BlackAndWhitePostProcess extends PostProcess {
  26524. degree: number;
  26525. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26526. }
  26527. }
  26528. declare module BABYLON {
  26529. /**
  26530. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  26531. */
  26532. class BloomEffect extends PostProcessRenderEffect {
  26533. private bloomScale;
  26534. /**
  26535. * Internal
  26536. */
  26537. _effects: Array<PostProcess>;
  26538. /**
  26539. * Internal
  26540. */
  26541. _downscale: ExtractHighlightsPostProcess;
  26542. private _blurX;
  26543. private _blurY;
  26544. private _merge;
  26545. /**
  26546. * The luminance threshold to find bright areas of the image to bloom.
  26547. */
  26548. threshold: number;
  26549. /**
  26550. * The strength of the bloom.
  26551. */
  26552. weight: number;
  26553. /**
  26554. * Specifies the size of the bloom blur kernel, relative to the final output size
  26555. */
  26556. kernel: number;
  26557. /**
  26558. * Creates a new instance of @see BloomEffect
  26559. * @param scene The scene the effect belongs to.
  26560. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  26561. * @param bloomKernel The size of the kernel to be used when applying the blur.
  26562. * @param bloomWeight The the strength of bloom.
  26563. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  26564. * @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)
  26565. */
  26566. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  26567. /**
  26568. * Disposes each of the internal effects for a given camera.
  26569. * @param camera The camera to dispose the effect on.
  26570. */
  26571. disposeEffects(camera: Camera): void;
  26572. /**
  26573. * Internal
  26574. */
  26575. _updateEffects(): void;
  26576. /**
  26577. * Internal
  26578. * @returns if all the contained post processes are ready.
  26579. */
  26580. _isReady(): boolean;
  26581. }
  26582. }
  26583. declare module BABYLON {
  26584. /**
  26585. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  26586. */
  26587. class BloomMergePostProcess extends PostProcess {
  26588. /** Weight of the bloom to be added to the original input. */ weight: number;
  26589. /**
  26590. * Creates a new instance of @see BloomMergePostProcess
  26591. * @param name The name of the effect.
  26592. * @param originalFromInput Post process which's input will be used for the merge.
  26593. * @param blurred Blurred highlights post process which's output will be used.
  26594. * @param weight Weight of the bloom to be added to the original input.
  26595. * @param options The required width/height ratio to downsize to before computing the render pass.
  26596. * @param camera The camera to apply the render pass to.
  26597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26598. * @param engine The engine which the post process will be applied. (default: current engine)
  26599. * @param reusable If the post process can be reused on the same frame. (default: false)
  26600. * @param textureType Type of textures used when performing the post process. (default: 0)
  26601. * @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)
  26602. */
  26603. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess, /** Weight of the bloom to be added to the original input. */ weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26604. }
  26605. }
  26606. declare module BABYLON {
  26607. /**
  26608. * The Blur Post Process which blurs an image based on a kernel and direction.
  26609. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  26610. */
  26611. class BlurPostProcess extends PostProcess {
  26612. /** The direction in which to blur the image. */ direction: Vector2;
  26613. private blockCompilation;
  26614. protected _kernel: number;
  26615. protected _idealKernel: number;
  26616. protected _packedFloat: boolean;
  26617. private _staticDefines;
  26618. /**
  26619. * Gets the length in pixels of the blur sample region
  26620. */
  26621. /**
  26622. * Sets the length in pixels of the blur sample region
  26623. */
  26624. kernel: number;
  26625. /**
  26626. * Gets wether or not the blur is unpacking/repacking floats
  26627. */
  26628. /**
  26629. * Sets wether or not the blur needs to unpack/repack floats
  26630. */
  26631. packedFloat: boolean;
  26632. /**
  26633. * Creates a new instance BlurPostProcess
  26634. * @param name The name of the effect.
  26635. * @param direction The direction in which to blur the image.
  26636. * @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.
  26637. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  26638. * @param camera The camera to apply the render pass to.
  26639. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26640. * @param engine The engine which the post process will be applied. (default: current engine)
  26641. * @param reusable If the post process can be reused on the same frame. (default: false)
  26642. * @param textureType Type of textures used when performing the post process. (default: 0)
  26643. * @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)
  26644. */
  26645. constructor(name: string, /** The direction in which to blur the image. */ direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  26646. /**
  26647. * Updates the effect with the current post process compile time values and recompiles the shader.
  26648. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26649. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26650. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26651. * @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
  26652. * @param onCompiled Called when the shader has been compiled.
  26653. * @param onError Called if there is an error when compiling a shader.
  26654. */
  26655. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26656. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26657. /**
  26658. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  26659. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  26660. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  26661. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  26662. * The gaps between physical kernels are compensated for in the weighting of the samples
  26663. * @param idealKernel Ideal blur kernel.
  26664. * @return Nearest best kernel.
  26665. */
  26666. protected _nearestBestKernel(idealKernel: number): number;
  26667. /**
  26668. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  26669. * @param x The point on the Gaussian distribution to sample.
  26670. * @return the value of the Gaussian function at x.
  26671. */
  26672. protected _gaussianWeight(x: number): number;
  26673. /**
  26674. * Generates a string that can be used as a floating point number in GLSL.
  26675. * @param x Value to print.
  26676. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  26677. * @return GLSL float string.
  26678. */
  26679. protected _glslFloat(x: number, decimalFigures?: number): string;
  26680. }
  26681. }
  26682. declare module BABYLON {
  26683. /**
  26684. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  26685. */
  26686. class ChromaticAberrationPostProcess extends PostProcess {
  26687. /**
  26688. * The amount of seperation of rgb channels (default: 30)
  26689. */
  26690. aberrationAmount: number;
  26691. /**
  26692. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  26693. */
  26694. radialIntensity: number;
  26695. /**
  26696. * 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))
  26697. */
  26698. direction: Vector2;
  26699. /**
  26700. * 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))
  26701. */
  26702. centerPosition: Vector2;
  26703. /**
  26704. * Creates a new instance ChromaticAberrationPostProcess
  26705. * @param name The name of the effect.
  26706. * @param screenWidth The width of the screen to apply the effect on.
  26707. * @param screenHeight The height of the screen to apply the effect on.
  26708. * @param options The required width/height ratio to downsize to before computing the render pass.
  26709. * @param camera The camera to apply the render pass to.
  26710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26711. * @param engine The engine which the post process will be applied. (default: current engine)
  26712. * @param reusable If the post process can be reused on the same frame. (default: false)
  26713. * @param textureType Type of textures used when performing the post process. (default: 0)
  26714. * @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)
  26715. */
  26716. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26717. }
  26718. }
  26719. declare module BABYLON {
  26720. /**
  26721. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  26722. */
  26723. class CircleOfConfusionPostProcess extends PostProcess {
  26724. /**
  26725. * 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.
  26726. */
  26727. lensSize: number;
  26728. /**
  26729. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  26730. */
  26731. fStop: number;
  26732. /**
  26733. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  26734. */
  26735. focusDistance: number;
  26736. /**
  26737. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  26738. */
  26739. focalLength: number;
  26740. private _depthTexture;
  26741. /**
  26742. * Creates a new instance CircleOfConfusionPostProcess
  26743. * @param name The name of the effect.
  26744. * @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.
  26745. * @param options The required width/height ratio to downsize to before computing the render pass.
  26746. * @param camera The camera to apply the render pass to.
  26747. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26748. * @param engine The engine which the post process will be applied. (default: current engine)
  26749. * @param reusable If the post process can be reused on the same frame. (default: false)
  26750. * @param textureType Type of textures used when performing the post process. (default: 0)
  26751. * @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)
  26752. */
  26753. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26754. /**
  26755. * 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.
  26756. */
  26757. depthTexture: RenderTargetTexture;
  26758. }
  26759. }
  26760. declare module BABYLON {
  26761. class ColorCorrectionPostProcess extends PostProcess {
  26762. private _colorTableTexture;
  26763. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26764. }
  26765. }
  26766. declare module BABYLON {
  26767. /**
  26768. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  26769. * input texture to perform effects such as edge detection or sharpening
  26770. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  26771. */
  26772. class ConvolutionPostProcess extends PostProcess {
  26773. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  26774. /**
  26775. * Creates a new instance ConvolutionPostProcess
  26776. * @param name The name of the effect.
  26777. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  26778. * @param options The required width/height ratio to downsize to before computing the render pass.
  26779. * @param camera The camera to apply the render pass to.
  26780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26781. * @param engine The engine which the post process will be applied. (default: current engine)
  26782. * @param reusable If the post process can be reused on the same frame. (default: false)
  26783. * @param textureType Type of textures used when performing the post process. (default: 0)
  26784. */
  26785. constructor(name: string, /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  26786. /**
  26787. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26788. */
  26789. static EdgeDetect0Kernel: number[];
  26790. /**
  26791. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26792. */
  26793. static EdgeDetect1Kernel: number[];
  26794. /**
  26795. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26796. */
  26797. static EdgeDetect2Kernel: number[];
  26798. /**
  26799. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26800. */
  26801. static SharpenKernel: number[];
  26802. /**
  26803. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26804. */
  26805. static EmbossKernel: number[];
  26806. /**
  26807. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  26808. */
  26809. static GaussianKernel: number[];
  26810. }
  26811. }
  26812. declare module BABYLON {
  26813. /**
  26814. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  26815. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  26816. * based on samples that have a large difference in distance than the center pixel.
  26817. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  26818. */
  26819. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  26820. direction: Vector2;
  26821. /**
  26822. * Creates a new instance CircleOfConfusionPostProcess
  26823. * @param name The name of the effect.
  26824. * @param scene The scene the effect belongs to.
  26825. * @param direction The direction the blur should be applied.
  26826. * @param kernel The size of the kernel used to blur.
  26827. * @param options The required width/height ratio to downsize to before computing the render pass.
  26828. * @param camera The camera to apply the render pass to.
  26829. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  26830. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  26831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26832. * @param engine The engine which the post process will be applied. (default: current engine)
  26833. * @param reusable If the post process can be reused on the same frame. (default: false)
  26834. * @param textureType Type of textures used when performing the post process. (default: 0)
  26835. * @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)
  26836. */
  26837. 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);
  26838. }
  26839. }
  26840. declare module BABYLON {
  26841. /**
  26842. * Specifies the level of max blur that should be applied when using the depth of field effect
  26843. */
  26844. enum DepthOfFieldEffectBlurLevel {
  26845. /**
  26846. * Subtle blur
  26847. */
  26848. Low = 0,
  26849. /**
  26850. * Medium blur
  26851. */
  26852. Medium = 1,
  26853. /**
  26854. * Large blur
  26855. */
  26856. High = 2,
  26857. }
  26858. /**
  26859. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  26860. */
  26861. class DepthOfFieldEffect extends PostProcessRenderEffect {
  26862. private _circleOfConfusion;
  26863. /**
  26864. * Internal, blurs from high to low
  26865. */
  26866. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  26867. private _depthOfFieldBlurY;
  26868. private _dofMerge;
  26869. /**
  26870. * Internal post processes in depth of field effect
  26871. */
  26872. _effects: Array<PostProcess>;
  26873. /**
  26874. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  26875. */
  26876. focalLength: number;
  26877. /**
  26878. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  26879. */
  26880. fStop: number;
  26881. /**
  26882. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  26883. */
  26884. focusDistance: number;
  26885. /**
  26886. * 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.
  26887. */
  26888. lensSize: number;
  26889. /**
  26890. * Creates a new instance DepthOfFieldEffect
  26891. * @param scene The scene the effect belongs to.
  26892. * @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.
  26893. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  26894. * @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)
  26895. */
  26896. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  26897. /**
  26898. * 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.
  26899. */
  26900. depthTexture: RenderTargetTexture;
  26901. /**
  26902. * Disposes each of the internal effects for a given camera.
  26903. * @param camera The camera to dispose the effect on.
  26904. */
  26905. disposeEffects(camera: Camera): void;
  26906. /**
  26907. * Internal
  26908. */
  26909. _updateEffects(): void;
  26910. /**
  26911. * Internal
  26912. * @returns if all the contained post processes are ready.
  26913. */
  26914. _isReady(): boolean;
  26915. }
  26916. }
  26917. declare module BABYLON {
  26918. /**
  26919. * Options to be set when merging outputs from the default pipeline.
  26920. */
  26921. class DepthOfFieldMergePostProcessOptions {
  26922. /**
  26923. * The original image to merge on top of
  26924. */
  26925. originalFromInput: PostProcess;
  26926. /**
  26927. * Parameters to perform the merge of the depth of field effect
  26928. */
  26929. depthOfField?: {
  26930. circleOfConfusion: PostProcess;
  26931. blurSteps: Array<PostProcess>;
  26932. };
  26933. /**
  26934. * Parameters to perform the merge of bloom effect
  26935. */
  26936. bloom?: {
  26937. blurred: PostProcess;
  26938. weight: number;
  26939. };
  26940. }
  26941. /**
  26942. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  26943. */
  26944. class DepthOfFieldMergePostProcess extends PostProcess {
  26945. private blurSteps;
  26946. /**
  26947. * Creates a new instance of DepthOfFieldMergePostProcess
  26948. * @param name The name of the effect.
  26949. * @param originalFromInput Post process which's input will be used for the merge.
  26950. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  26951. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  26952. * @param options The required width/height ratio to downsize to before computing the render pass.
  26953. * @param camera The camera to apply the render pass to.
  26954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26955. * @param engine The engine which the post process will be applied. (default: current engine)
  26956. * @param reusable If the post process can be reused on the same frame. (default: false)
  26957. * @param textureType Type of textures used when performing the post process. (default: 0)
  26958. * @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)
  26959. */
  26960. 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);
  26961. /**
  26962. * Updates the effect with the current post process compile time values and recompiles the shader.
  26963. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26964. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26965. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26966. * @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
  26967. * @param onCompiled Called when the shader has been compiled.
  26968. * @param onError Called if there is an error when compiling a shader.
  26969. */
  26970. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26971. }
  26972. }
  26973. declare module BABYLON {
  26974. class DisplayPassPostProcess extends PostProcess {
  26975. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26976. }
  26977. }
  26978. declare module BABYLON {
  26979. /**
  26980. * 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.
  26981. */
  26982. class ExtractHighlightsPostProcess extends PostProcess {
  26983. /**
  26984. * The luminance threshold, pixels below this value will be set to black.
  26985. */
  26986. threshold: number;
  26987. /**
  26988. * Internal
  26989. */
  26990. _exposure: number;
  26991. /**
  26992. * Post process which has the input texture to be used when performing highlight extraction
  26993. */
  26994. _inputPostProcess: Nullable<PostProcess>;
  26995. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26996. }
  26997. }
  26998. declare module BABYLON {
  26999. class FilterPostProcess extends PostProcess {
  27000. kernelMatrix: Matrix;
  27001. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27002. }
  27003. }
  27004. declare module BABYLON {
  27005. class FxaaPostProcess extends PostProcess {
  27006. texelWidth: number;
  27007. texelHeight: number;
  27008. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27009. private _getDefines();
  27010. }
  27011. }
  27012. declare module BABYLON {
  27013. /**
  27014. * The GrainPostProcess adds noise to the image at mid luminance levels
  27015. */
  27016. class GrainPostProcess extends PostProcess {
  27017. /**
  27018. * The intensity of the grain added (default: 30)
  27019. */
  27020. intensity: number;
  27021. /**
  27022. * If the grain should be randomized on every frame
  27023. */
  27024. animated: boolean;
  27025. /**
  27026. * Creates a new instance of @see GrainPostProcess
  27027. * @param name The name of the effect.
  27028. * @param options The required width/height ratio to downsize to before computing the render pass.
  27029. * @param camera The camera to apply the render pass to.
  27030. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27031. * @param engine The engine which the post process will be applied. (default: current engine)
  27032. * @param reusable If the post process can be reused on the same frame. (default: false)
  27033. * @param textureType Type of textures used when performing the post process. (default: 0)
  27034. * @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)
  27035. */
  27036. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27037. }
  27038. }
  27039. declare module BABYLON {
  27040. class HighlightsPostProcess extends PostProcess {
  27041. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27042. }
  27043. }
  27044. declare module BABYLON {
  27045. class ImageProcessingPostProcess extends PostProcess {
  27046. /**
  27047. * Default configuration related to image processing available in the PBR Material.
  27048. */
  27049. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27050. /**
  27051. * Gets the image processing configuration used either in this material.
  27052. */
  27053. /**
  27054. * Sets the Default image processing configuration used either in the this material.
  27055. *
  27056. * If sets to null, the scene one is in use.
  27057. */
  27058. imageProcessingConfiguration: ImageProcessingConfiguration;
  27059. /**
  27060. * Keep track of the image processing observer to allow dispose and replace.
  27061. */
  27062. private _imageProcessingObserver;
  27063. /**
  27064. * Attaches a new image processing configuration to the PBR Material.
  27065. * @param configuration
  27066. */
  27067. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  27068. /**
  27069. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27070. */
  27071. /**
  27072. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27073. */
  27074. colorCurves: Nullable<ColorCurves>;
  27075. /**
  27076. * Gets wether the color curves effect is enabled.
  27077. */
  27078. /**
  27079. * Sets wether the color curves effect is enabled.
  27080. */
  27081. colorCurvesEnabled: boolean;
  27082. /**
  27083. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27084. */
  27085. /**
  27086. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27087. */
  27088. colorGradingTexture: Nullable<BaseTexture>;
  27089. /**
  27090. * Gets wether the color grading effect is enabled.
  27091. */
  27092. /**
  27093. * Gets wether the color grading effect is enabled.
  27094. */
  27095. colorGradingEnabled: boolean;
  27096. /**
  27097. * Gets exposure used in the effect.
  27098. */
  27099. /**
  27100. * Sets exposure used in the effect.
  27101. */
  27102. exposure: number;
  27103. /**
  27104. * Gets wether tonemapping is enabled or not.
  27105. */
  27106. /**
  27107. * Sets wether tonemapping is enabled or not
  27108. */
  27109. toneMappingEnabled: boolean;
  27110. /**
  27111. * Gets contrast used in the effect.
  27112. */
  27113. /**
  27114. * Sets contrast used in the effect.
  27115. */
  27116. contrast: number;
  27117. /**
  27118. * Gets Vignette stretch size.
  27119. */
  27120. /**
  27121. * Sets Vignette stretch size.
  27122. */
  27123. vignetteStretch: number;
  27124. /**
  27125. * Gets Vignette centre X Offset.
  27126. */
  27127. /**
  27128. * Sets Vignette centre X Offset.
  27129. */
  27130. vignetteCentreX: number;
  27131. /**
  27132. * Gets Vignette centre Y Offset.
  27133. */
  27134. /**
  27135. * Sets Vignette centre Y Offset.
  27136. */
  27137. vignetteCentreY: number;
  27138. /**
  27139. * Gets Vignette weight or intensity of the vignette effect.
  27140. */
  27141. /**
  27142. * Sets Vignette weight or intensity of the vignette effect.
  27143. */
  27144. vignetteWeight: number;
  27145. /**
  27146. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27147. * if vignetteEnabled is set to true.
  27148. */
  27149. /**
  27150. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27151. * if vignetteEnabled is set to true.
  27152. */
  27153. vignetteColor: Color4;
  27154. /**
  27155. * Gets Camera field of view used by the Vignette effect.
  27156. */
  27157. /**
  27158. * Sets Camera field of view used by the Vignette effect.
  27159. */
  27160. vignetteCameraFov: number;
  27161. /**
  27162. * Gets the vignette blend mode allowing different kind of effect.
  27163. */
  27164. /**
  27165. * Sets the vignette blend mode allowing different kind of effect.
  27166. */
  27167. vignetteBlendMode: number;
  27168. /**
  27169. * Gets wether the vignette effect is enabled.
  27170. */
  27171. /**
  27172. * Sets wether the vignette effect is enabled.
  27173. */
  27174. vignetteEnabled: boolean;
  27175. private _fromLinearSpace;
  27176. /**
  27177. * Gets wether the input of the processing is in Gamma or Linear Space.
  27178. */
  27179. /**
  27180. * Sets wether the input of the processing is in Gamma or Linear Space.
  27181. */
  27182. fromLinearSpace: boolean;
  27183. /**
  27184. * Defines cache preventing GC.
  27185. */
  27186. private _defines;
  27187. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  27188. getClassName(): string;
  27189. protected _updateParameters(): void;
  27190. dispose(camera?: Camera): void;
  27191. }
  27192. }
  27193. declare module BABYLON {
  27194. class PassPostProcess extends PostProcess {
  27195. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27196. }
  27197. }
  27198. declare module BABYLON {
  27199. type PostProcessOptions = {
  27200. width: number;
  27201. height: number;
  27202. };
  27203. /**
  27204. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27205. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27206. */
  27207. class PostProcess {
  27208. /** Name of the PostProcess. */ name: string;
  27209. /**
  27210. * Width of the texture to apply the post process on
  27211. */
  27212. width: number;
  27213. /**
  27214. * Height of the texture to apply the post process on
  27215. */
  27216. height: number;
  27217. /**
  27218. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27219. */
  27220. _outputTexture: Nullable<InternalTexture>;
  27221. /**
  27222. * Sampling mode used by the shader
  27223. * See https://doc.babylonjs.com/classes/3.1/texture
  27224. */
  27225. renderTargetSamplingMode: number;
  27226. /**
  27227. * Clear color to use when screen clearing
  27228. */
  27229. clearColor: Color4;
  27230. /**
  27231. * If the buffer needs to be cleared before applying the post process. (default: true)
  27232. * Should be set to false if shader will overwrite all previous pixels.
  27233. */
  27234. autoClear: boolean;
  27235. /**
  27236. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27237. */
  27238. alphaMode: number;
  27239. /**
  27240. * Sets the setAlphaBlendConstants of the babylon engine
  27241. */
  27242. alphaConstants: Color4;
  27243. /**
  27244. * Animations to be used for the post processing
  27245. */
  27246. animations: Animation[];
  27247. /**
  27248. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27249. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27250. */
  27251. enablePixelPerfectMode: boolean;
  27252. /**
  27253. * Force the postprocess to be applied without taking in account viewport
  27254. */
  27255. forceFullscreenViewport: boolean;
  27256. /**
  27257. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27258. *
  27259. * | Value | Type | Description |
  27260. * | ----- | ----------------------------------- | ----------- |
  27261. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27262. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27263. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27264. *
  27265. */
  27266. scaleMode: number;
  27267. /**
  27268. * Force textures to be a power of two (default: false)
  27269. */
  27270. alwaysForcePOT: boolean;
  27271. /**
  27272. * Number of sample textures (default: 1)
  27273. */
  27274. samples: number;
  27275. /**
  27276. * Modify the scale of the post process to be the same as the viewport (default: false)
  27277. */
  27278. adaptScaleToCurrentViewport: boolean;
  27279. private _camera;
  27280. private _scene;
  27281. private _engine;
  27282. private _options;
  27283. private _reusable;
  27284. private _textureType;
  27285. /**
  27286. * Smart array of input and output textures for the post process.
  27287. */
  27288. _textures: SmartArray<InternalTexture>;
  27289. /**
  27290. * The index in _textures that corresponds to the output texture.
  27291. */
  27292. _currentRenderTextureInd: number;
  27293. private _effect;
  27294. private _samplers;
  27295. private _fragmentUrl;
  27296. private _vertexUrl;
  27297. private _parameters;
  27298. private _scaleRatio;
  27299. protected _indexParameters: any;
  27300. private _shareOutputWithPostProcess;
  27301. private _texelSize;
  27302. private _forcedOutputTexture;
  27303. /**
  27304. * An event triggered when the postprocess is activated.
  27305. */
  27306. onActivateObservable: Observable<Camera>;
  27307. private _onActivateObserver;
  27308. /**
  27309. * A function that is added to the onActivateObservable
  27310. */
  27311. onActivate: Nullable<(camera: Camera) => void>;
  27312. /**
  27313. * An event triggered when the postprocess changes its size.
  27314. */
  27315. onSizeChangedObservable: Observable<PostProcess>;
  27316. private _onSizeChangedObserver;
  27317. /**
  27318. * A function that is added to the onSizeChangedObservable
  27319. */
  27320. onSizeChanged: (postProcess: PostProcess) => void;
  27321. /**
  27322. * An event triggered when the postprocess applies its effect.
  27323. */
  27324. onApplyObservable: Observable<Effect>;
  27325. private _onApplyObserver;
  27326. /**
  27327. * A function that is added to the onApplyObservable
  27328. */
  27329. onApply: (effect: Effect) => void;
  27330. /**
  27331. * An event triggered before rendering the postprocess
  27332. */
  27333. onBeforeRenderObservable: Observable<Effect>;
  27334. private _onBeforeRenderObserver;
  27335. /**
  27336. * A function that is added to the onBeforeRenderObservable
  27337. */
  27338. onBeforeRender: (effect: Effect) => void;
  27339. /**
  27340. * An event triggered after rendering the postprocess
  27341. */
  27342. onAfterRenderObservable: Observable<Effect>;
  27343. private _onAfterRenderObserver;
  27344. /**
  27345. * A function that is added to the onAfterRenderObservable
  27346. */
  27347. onAfterRender: (efect: Effect) => void;
  27348. /**
  27349. * 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
  27350. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27351. */
  27352. inputTexture: InternalTexture;
  27353. /**
  27354. * Gets the camera which post process is applied to.
  27355. * @returns The camera the post process is applied to.
  27356. */
  27357. getCamera(): Camera;
  27358. /**
  27359. * Gets the texel size of the postprocess.
  27360. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27361. */
  27362. readonly texelSize: Vector2;
  27363. /**
  27364. * Creates a new instance PostProcess
  27365. * @param name The name of the PostProcess.
  27366. * @param fragmentUrl The url of the fragment shader to be used.
  27367. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27368. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27369. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27370. * @param camera The camera to apply the render pass to.
  27371. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27372. * @param engine The engine which the post process will be applied. (default: current engine)
  27373. * @param reusable If the post process can be reused on the same frame. (default: false)
  27374. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27375. * @param textureType Type of textures used when performing the post process. (default: 0)
  27376. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27377. * @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
  27378. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  27379. */
  27380. constructor(/** Name of the PostProcess. */ 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);
  27381. /**
  27382. * Gets the engine which this post process belongs to.
  27383. * @returns The engine the post process was enabled with.
  27384. */
  27385. getEngine(): Engine;
  27386. /**
  27387. * The effect that is created when initializing the post process.
  27388. * @returns The created effect corrisponding the the postprocess.
  27389. */
  27390. getEffect(): Effect;
  27391. /**
  27392. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27393. * @param postProcess The post process to share the output with.
  27394. * @returns This post process.
  27395. */
  27396. shareOutputWith(postProcess: PostProcess): PostProcess;
  27397. /**
  27398. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  27399. * This should be called if the post process that shares output with this post process is disabled/disposed.
  27400. */
  27401. useOwnOutput(): void;
  27402. /**
  27403. * Updates the effect with the current post process compile time values and recompiles the shader.
  27404. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27405. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27406. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27407. * @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
  27408. * @param onCompiled Called when the shader has been compiled.
  27409. * @param onError Called if there is an error when compiling a shader.
  27410. */
  27411. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27412. /**
  27413. * The post process is reusable if it can be used multiple times within one frame.
  27414. * @returns If the post process is reusable
  27415. */
  27416. isReusable(): boolean;
  27417. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  27418. markTextureDirty(): void;
  27419. /**
  27420. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  27421. * 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.
  27422. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  27423. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  27424. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  27425. * @returns The target texture that was bound to be written to.
  27426. */
  27427. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  27428. /**
  27429. * If the post process is supported.
  27430. */
  27431. readonly isSupported: boolean;
  27432. /**
  27433. * The aspect ratio of the output texture.
  27434. */
  27435. readonly aspectRatio: number;
  27436. /**
  27437. * Get a value indicating if the post-process is ready to be used
  27438. * @returns true if the post-process is ready (shader is compiled)
  27439. */
  27440. isReady(): boolean;
  27441. /**
  27442. * Binds all textures and uniforms to the shader, this will be run on every pass.
  27443. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  27444. */
  27445. apply(): Nullable<Effect>;
  27446. private _disposeTextures();
  27447. /**
  27448. * Disposes the post process.
  27449. * @param camera The camera to dispose the post process on.
  27450. */
  27451. dispose(camera?: Camera): void;
  27452. }
  27453. }
  27454. declare module BABYLON {
  27455. /**
  27456. * PostProcessManager is used to manage one or more post processes or post process pipelines
  27457. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27458. */
  27459. class PostProcessManager {
  27460. private _scene;
  27461. private _indexBuffer;
  27462. private _vertexBuffers;
  27463. /**
  27464. * Creates a new instance PostProcess
  27465. * @param scene The scene that the post process is associated with.
  27466. */
  27467. constructor(scene: Scene);
  27468. private _prepareBuffers();
  27469. private _buildIndexBuffer();
  27470. /**
  27471. * Rebuilds the vertex buffers of the manager.
  27472. */
  27473. _rebuild(): void;
  27474. /**
  27475. * Prepares a frame to be run through a post process.
  27476. * @param sourceTexture The input texture to the post procesess. (default: null)
  27477. * @param postProcesses An array of post processes to be run. (default: null)
  27478. * @returns True if the post processes were able to be run.
  27479. */
  27480. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  27481. /**
  27482. * Manually render a set of post processes to a texture.
  27483. * @param postProcesses An array of post processes to be run.
  27484. * @param targetTexture The target texture to render to.
  27485. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  27486. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  27487. * @param lodLevel defines which lod of the texture to render to
  27488. */
  27489. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  27490. /**
  27491. * Finalize the result of the output of the postprocesses.
  27492. * @param doNotPresent If true the result will not be displayed to the screen.
  27493. * @param targetTexture The target texture to render to.
  27494. * @param faceIndex The index of the face to bind the target texture to.
  27495. * @param postProcesses The array of post processes to render.
  27496. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  27497. */
  27498. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  27499. /**
  27500. * Disposes of the post process manager.
  27501. */
  27502. dispose(): void;
  27503. }
  27504. }
  27505. declare module BABYLON {
  27506. class RefractionPostProcess extends PostProcess {
  27507. color: Color3;
  27508. depth: number;
  27509. colorLevel: number;
  27510. private _refTexture;
  27511. private _ownRefractionTexture;
  27512. /**
  27513. * Gets or sets the refraction texture
  27514. * Please note that you are responsible for disposing the texture if you set it manually
  27515. */
  27516. refractionTexture: Texture;
  27517. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27518. dispose(camera: Camera): void;
  27519. }
  27520. }
  27521. declare module BABYLON {
  27522. /**
  27523. * The SharpenPostProcess applies a sharpen kernel to every pixel
  27524. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27525. */
  27526. class SharpenPostProcess extends PostProcess {
  27527. /**
  27528. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  27529. */
  27530. colorAmount: number;
  27531. /**
  27532. * How much sharpness should be applied (default: 0.3)
  27533. */
  27534. edgeAmount: number;
  27535. /**
  27536. * Creates a new instance ConvolutionPostProcess
  27537. * @param name The name of the effect.
  27538. * @param options The required width/height ratio to downsize to before computing the render pass.
  27539. * @param camera The camera to apply the render pass to.
  27540. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27541. * @param engine The engine which the post process will be applied. (default: current engine)
  27542. * @param reusable If the post process can be reused on the same frame. (default: false)
  27543. * @param textureType Type of textures used when performing the post process. (default: 0)
  27544. * @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)
  27545. */
  27546. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27547. }
  27548. }
  27549. declare module BABYLON {
  27550. class StereoscopicInterlacePostProcess extends PostProcess {
  27551. private _stepSize;
  27552. private _passedProcess;
  27553. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27554. }
  27555. }
  27556. declare module BABYLON {
  27557. /** Defines operator used for tonemapping */
  27558. enum TonemappingOperator {
  27559. /** Hable */
  27560. Hable = 0,
  27561. /** Reinhard */
  27562. Reinhard = 1,
  27563. /** HejiDawson */
  27564. HejiDawson = 2,
  27565. /** Photographic */
  27566. Photographic = 3,
  27567. }
  27568. /**
  27569. * Defines a post process to apply tone mapping
  27570. */
  27571. class TonemapPostProcess extends PostProcess {
  27572. private _operator;
  27573. /** Defines the required exposure adjustement */
  27574. exposureAdjustment: number;
  27575. /**
  27576. * Creates a new TonemapPostProcess
  27577. * @param name defines the name of the postprocess
  27578. * @param _operator defines the operator to use
  27579. * @param exposureAdjustment defines the required exposure adjustement
  27580. * @param camera defines the camera to use (can be null)
  27581. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  27582. * @param engine defines the hosting engine (can be ignore if camera is set)
  27583. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27584. */
  27585. constructor(name: string, _operator: TonemappingOperator,
  27586. /** Defines the required exposure adjustement */
  27587. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  27588. }
  27589. }
  27590. declare module BABYLON {
  27591. class VolumetricLightScatteringPostProcess extends PostProcess {
  27592. private _volumetricLightScatteringPass;
  27593. private _volumetricLightScatteringRTT;
  27594. private _viewPort;
  27595. private _screenCoordinates;
  27596. private _cachedDefines;
  27597. /**
  27598. * If not undefined, the mesh position is computed from the attached node position
  27599. */
  27600. attachedNode: {
  27601. position: Vector3;
  27602. };
  27603. /**
  27604. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  27605. */
  27606. customMeshPosition: Vector3;
  27607. /**
  27608. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  27609. */
  27610. useCustomMeshPosition: boolean;
  27611. /**
  27612. * If the post-process should inverse the light scattering direction
  27613. */
  27614. invert: boolean;
  27615. /**
  27616. * The internal mesh used by the post-process
  27617. */
  27618. mesh: Mesh;
  27619. useDiffuseColor: boolean;
  27620. /**
  27621. * Array containing the excluded meshes not rendered in the internal pass
  27622. */
  27623. excludedMeshes: AbstractMesh[];
  27624. /**
  27625. * Controls the overall intensity of the post-process
  27626. */
  27627. exposure: number;
  27628. /**
  27629. * Dissipates each sample's contribution in range [0, 1]
  27630. */
  27631. decay: number;
  27632. /**
  27633. * Controls the overall intensity of each sample
  27634. */
  27635. weight: number;
  27636. /**
  27637. * Controls the density of each sample
  27638. */
  27639. density: number;
  27640. /**
  27641. * @constructor
  27642. * @param {string} name - The post-process name
  27643. * @param {any} 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)
  27644. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  27645. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  27646. * @param {number} samples - The post-process quality, default 100
  27647. * @param {number} samplingMode - The post-process filtering mode
  27648. * @param {BABYLON.Engine} engine - The babylon engine
  27649. * @param {boolean} reusable - If the post-process is reusable
  27650. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  27651. */
  27652. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  27653. getClassName(): string;
  27654. private _isReady(subMesh, useInstances);
  27655. /**
  27656. * Sets the new light position for light scattering effect
  27657. * @param {BABYLON.Vector3} The new custom light position
  27658. */
  27659. setCustomMeshPosition(position: Vector3): void;
  27660. /**
  27661. * Returns the light position for light scattering effect
  27662. * @return {BABYLON.Vector3} The custom light position
  27663. */
  27664. getCustomMeshPosition(): Vector3;
  27665. /**
  27666. * Disposes the internal assets and detaches the post-process from the camera
  27667. */
  27668. dispose(camera: Camera): void;
  27669. /**
  27670. * Returns the render target texture used by the post-process
  27671. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  27672. */
  27673. getPass(): RenderTargetTexture;
  27674. private _meshExcluded(mesh);
  27675. private _createPass(scene, ratio);
  27676. private _updateMeshScreenCoordinates(scene);
  27677. /**
  27678. * Creates a default mesh for the Volumeric Light Scattering post-process
  27679. * @param {string} The mesh name
  27680. * @param {BABYLON.Scene} The scene where to create the mesh
  27681. * @return {BABYLON.Mesh} the default mesh
  27682. */
  27683. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  27684. }
  27685. }
  27686. declare module BABYLON {
  27687. class VRDistortionCorrectionPostProcess extends PostProcess {
  27688. private _isRightEye;
  27689. private _distortionFactors;
  27690. private _postProcessScaleFactor;
  27691. private _lensCenterOffset;
  27692. private _scaleIn;
  27693. private _scaleFactor;
  27694. private _lensCenter;
  27695. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  27696. }
  27697. }
  27698. declare module BABYLON {
  27699. class Sprite {
  27700. name: string;
  27701. position: Vector3;
  27702. color: Color4;
  27703. width: number;
  27704. height: number;
  27705. angle: number;
  27706. cellIndex: number;
  27707. invertU: number;
  27708. invertV: number;
  27709. disposeWhenFinishedAnimating: boolean;
  27710. animations: Animation[];
  27711. isPickable: boolean;
  27712. actionManager: ActionManager;
  27713. private _animationStarted;
  27714. private _loopAnimation;
  27715. private _fromIndex;
  27716. private _toIndex;
  27717. private _delay;
  27718. private _direction;
  27719. private _manager;
  27720. private _time;
  27721. private _onAnimationEnd;
  27722. /**
  27723. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  27724. */
  27725. isVisible: boolean;
  27726. size: number;
  27727. constructor(name: string, manager: SpriteManager);
  27728. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  27729. stopAnimation(): void;
  27730. _animate(deltaTime: number): void;
  27731. dispose(): void;
  27732. }
  27733. }
  27734. declare module BABYLON {
  27735. class SpriteManager {
  27736. name: string;
  27737. sprites: Sprite[];
  27738. renderingGroupId: number;
  27739. layerMask: number;
  27740. fogEnabled: boolean;
  27741. isPickable: boolean;
  27742. cellWidth: number;
  27743. cellHeight: number;
  27744. /**
  27745. * An event triggered when the manager is disposed.
  27746. */
  27747. onDisposeObservable: Observable<SpriteManager>;
  27748. private _onDisposeObserver;
  27749. onDispose: () => void;
  27750. private _capacity;
  27751. private _spriteTexture;
  27752. private _epsilon;
  27753. private _scene;
  27754. private _vertexData;
  27755. private _buffer;
  27756. private _vertexBuffers;
  27757. private _indexBuffer;
  27758. private _effectBase;
  27759. private _effectFog;
  27760. texture: Texture;
  27761. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  27762. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  27763. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  27764. render(): void;
  27765. dispose(): void;
  27766. }
  27767. }
  27768. declare module BABYLON {
  27769. /**
  27770. * @hidden
  27771. **/
  27772. class _AlphaState {
  27773. private _isAlphaBlendDirty;
  27774. private _isBlendFunctionParametersDirty;
  27775. private _isBlendEquationParametersDirty;
  27776. private _isBlendConstantsDirty;
  27777. private _alphaBlend;
  27778. private _blendFunctionParameters;
  27779. private _blendEquationParameters;
  27780. private _blendConstants;
  27781. /**
  27782. * Initializes the state.
  27783. */
  27784. constructor();
  27785. readonly isDirty: boolean;
  27786. alphaBlend: boolean;
  27787. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  27788. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  27789. setAlphaEquationParameters(rgb: number, alpha: number): void;
  27790. reset(): void;
  27791. apply(gl: WebGLRenderingContext): void;
  27792. }
  27793. }
  27794. declare module BABYLON {
  27795. /**
  27796. * @hidden
  27797. **/
  27798. class _DepthCullingState {
  27799. private _isDepthTestDirty;
  27800. private _isDepthMaskDirty;
  27801. private _isDepthFuncDirty;
  27802. private _isCullFaceDirty;
  27803. private _isCullDirty;
  27804. private _isZOffsetDirty;
  27805. private _isFrontFaceDirty;
  27806. private _depthTest;
  27807. private _depthMask;
  27808. private _depthFunc;
  27809. private _cull;
  27810. private _cullFace;
  27811. private _zOffset;
  27812. private _frontFace;
  27813. /**
  27814. * Initializes the state.
  27815. */
  27816. constructor();
  27817. readonly isDirty: boolean;
  27818. zOffset: number;
  27819. cullFace: Nullable<number>;
  27820. cull: Nullable<boolean>;
  27821. depthFunc: Nullable<number>;
  27822. depthMask: boolean;
  27823. depthTest: boolean;
  27824. frontFace: Nullable<number>;
  27825. reset(): void;
  27826. apply(gl: WebGLRenderingContext): void;
  27827. }
  27828. }
  27829. declare module BABYLON {
  27830. /**
  27831. * @hidden
  27832. **/
  27833. class _StencilState {
  27834. private _isStencilTestDirty;
  27835. private _isStencilMaskDirty;
  27836. private _isStencilFuncDirty;
  27837. private _isStencilOpDirty;
  27838. private _stencilTest;
  27839. private _stencilMask;
  27840. private _stencilFunc;
  27841. private _stencilFuncRef;
  27842. private _stencilFuncMask;
  27843. private _stencilOpStencilFail;
  27844. private _stencilOpDepthFail;
  27845. private _stencilOpStencilDepthPass;
  27846. readonly isDirty: boolean;
  27847. stencilFunc: number;
  27848. stencilFuncRef: number;
  27849. stencilFuncMask: number;
  27850. stencilOpStencilFail: number;
  27851. stencilOpDepthFail: number;
  27852. stencilOpStencilDepthPass: number;
  27853. stencilMask: number;
  27854. stencilTest: boolean;
  27855. constructor();
  27856. reset(): void;
  27857. apply(gl: WebGLRenderingContext): void;
  27858. }
  27859. }
  27860. declare module BABYLON {
  27861. /**
  27862. * Class used to evalaute queries containing `and` and `or` operators
  27863. */
  27864. class AndOrNotEvaluator {
  27865. /**
  27866. * Evaluate a query
  27867. * @param query defines the query to evaluate
  27868. * @param evaluateCallback defines the callback used to filter result
  27869. * @returns true if the query matches
  27870. */
  27871. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  27872. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  27873. private static _SimplifyNegation(booleanString);
  27874. }
  27875. }
  27876. declare module BABYLON {
  27877. /**
  27878. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  27879. */
  27880. enum AssetTaskState {
  27881. /**
  27882. * Initialization
  27883. */
  27884. INIT = 0,
  27885. /**
  27886. * Running
  27887. */
  27888. RUNNING = 1,
  27889. /**
  27890. * Done
  27891. */
  27892. DONE = 2,
  27893. /**
  27894. * Error
  27895. */
  27896. ERROR = 3,
  27897. }
  27898. /**
  27899. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  27900. */
  27901. abstract class AbstractAssetTask {
  27902. /**
  27903. * Task name
  27904. */ name: string;
  27905. /**
  27906. * Callback called when the task is successful
  27907. */
  27908. onSuccess: (task: any) => void;
  27909. /**
  27910. * Callback called when the task is not successful
  27911. */
  27912. onError: (task: any, message?: string, exception?: any) => void;
  27913. /**
  27914. * Creates a new {BABYLON.AssetsManager}
  27915. * @param name defines the name of the task
  27916. */
  27917. constructor(
  27918. /**
  27919. * Task name
  27920. */ name: string);
  27921. private _isCompleted;
  27922. private _taskState;
  27923. private _errorObject;
  27924. /**
  27925. * Get if the task is completed
  27926. */
  27927. readonly isCompleted: boolean;
  27928. /**
  27929. * Gets the current state of the task
  27930. */
  27931. readonly taskState: AssetTaskState;
  27932. /**
  27933. * Gets the current error object (if task is in error)
  27934. */
  27935. readonly errorObject: {
  27936. message?: string;
  27937. exception?: any;
  27938. };
  27939. /**
  27940. * Internal only
  27941. * @hidden
  27942. */
  27943. _setErrorObject(message?: string, exception?: any): void;
  27944. /**
  27945. * Execute the current task
  27946. * @param scene defines the scene where you want your assets to be loaded
  27947. * @param onSuccess is a callback called when the task is successfully executed
  27948. * @param onError is a callback called if an error occurs
  27949. */
  27950. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27951. /**
  27952. * Execute the current task
  27953. * @param scene defines the scene where you want your assets to be loaded
  27954. * @param onSuccess is a callback called when the task is successfully executed
  27955. * @param onError is a callback called if an error occurs
  27956. */
  27957. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27958. /**
  27959. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  27960. * This can be used with failed tasks that have the reason for failure fixed.
  27961. */
  27962. reset(): void;
  27963. private onErrorCallback(onError, message?, exception?);
  27964. private onDoneCallback(onSuccess, onError);
  27965. }
  27966. /**
  27967. * Define the interface used by progress events raised during assets loading
  27968. */
  27969. interface IAssetsProgressEvent {
  27970. /**
  27971. * Defines the number of remaining tasks to process
  27972. */
  27973. remainingCount: number;
  27974. /**
  27975. * Defines the total number of tasks
  27976. */
  27977. totalCount: number;
  27978. /**
  27979. * Defines the task that was just processed
  27980. */
  27981. task: AbstractAssetTask;
  27982. }
  27983. /**
  27984. * Class used to share progress information about assets loading
  27985. */
  27986. class AssetsProgressEvent implements IAssetsProgressEvent {
  27987. /**
  27988. * Defines the number of remaining tasks to process
  27989. */
  27990. remainingCount: number;
  27991. /**
  27992. * Defines the total number of tasks
  27993. */
  27994. totalCount: number;
  27995. /**
  27996. * Defines the task that was just processed
  27997. */
  27998. task: AbstractAssetTask;
  27999. /**
  28000. * Creates a {BABYLON.AssetsProgressEvent}
  28001. * @param remainingCount defines the number of remaining tasks to process
  28002. * @param totalCount defines the total number of tasks
  28003. * @param task defines the task that was just processed
  28004. */
  28005. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  28006. }
  28007. /**
  28008. * Define a task used by {BABYLON.AssetsManager} to load meshes
  28009. */
  28010. class MeshAssetTask extends AbstractAssetTask {
  28011. /**
  28012. * Defines the name of the task
  28013. */
  28014. name: string;
  28015. /**
  28016. * Defines the list of mesh's names you want to load
  28017. */
  28018. meshesNames: any;
  28019. /**
  28020. * Defines the root url to use as a base to load your meshes and associated resources
  28021. */
  28022. rootUrl: string;
  28023. /**
  28024. * Defines the filename of the scene to load from
  28025. */
  28026. sceneFilename: string;
  28027. /**
  28028. * Gets the list of loaded meshes
  28029. */
  28030. loadedMeshes: Array<AbstractMesh>;
  28031. /**
  28032. * Gets the list of loaded particle systems
  28033. */
  28034. loadedParticleSystems: Array<ParticleSystem>;
  28035. /**
  28036. * Gets the list of loaded skeletons
  28037. */
  28038. loadedSkeletons: Array<Skeleton>;
  28039. /**
  28040. * Callback called when the task is successful
  28041. */
  28042. onSuccess: (task: MeshAssetTask) => void;
  28043. /**
  28044. * Callback called when the task is successful
  28045. */
  28046. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  28047. /**
  28048. * Creates a new {BABYLON.MeshAssetTask}
  28049. * @param name defines the name of the task
  28050. * @param meshesNames defines the list of mesh's names you want to load
  28051. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  28052. * @param sceneFilename defines the filename of the scene to load from
  28053. */
  28054. constructor(
  28055. /**
  28056. * Defines the name of the task
  28057. */
  28058. name: string,
  28059. /**
  28060. * Defines the list of mesh's names you want to load
  28061. */
  28062. meshesNames: any,
  28063. /**
  28064. * Defines the root url to use as a base to load your meshes and associated resources
  28065. */
  28066. rootUrl: string,
  28067. /**
  28068. * Defines the filename of the scene to load from
  28069. */
  28070. sceneFilename: string);
  28071. /**
  28072. * Execute the current task
  28073. * @param scene defines the scene where you want your assets to be loaded
  28074. * @param onSuccess is a callback called when the task is successfully executed
  28075. * @param onError is a callback called if an error occurs
  28076. */
  28077. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28078. }
  28079. /**
  28080. * Define a task used by {BABYLON.AssetsManager} to load text content
  28081. */
  28082. class TextFileAssetTask extends AbstractAssetTask {
  28083. /**
  28084. * Defines the name of the task
  28085. */
  28086. name: string;
  28087. /**
  28088. * Defines the location of the file to load
  28089. */
  28090. url: string;
  28091. /**
  28092. * Gets the loaded text string
  28093. */
  28094. text: string;
  28095. /**
  28096. * Callback called when the task is successful
  28097. */
  28098. onSuccess: (task: TextFileAssetTask) => void;
  28099. /**
  28100. * Callback called when the task is successful
  28101. */
  28102. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  28103. /**
  28104. * Creates a new TextFileAssetTask object
  28105. * @param name defines the name of the task
  28106. * @param url defines the location of the file to load
  28107. */
  28108. constructor(
  28109. /**
  28110. * Defines the name of the task
  28111. */
  28112. name: string,
  28113. /**
  28114. * Defines the location of the file to load
  28115. */
  28116. url: string);
  28117. /**
  28118. * Execute the current task
  28119. * @param scene defines the scene where you want your assets to be loaded
  28120. * @param onSuccess is a callback called when the task is successfully executed
  28121. * @param onError is a callback called if an error occurs
  28122. */
  28123. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28124. }
  28125. /**
  28126. * Define a task used by {BABYLON.AssetsManager} to load binary data
  28127. */
  28128. class BinaryFileAssetTask extends AbstractAssetTask {
  28129. /**
  28130. * Defines the name of the task
  28131. */
  28132. name: string;
  28133. /**
  28134. * Defines the location of the file to load
  28135. */
  28136. url: string;
  28137. /**
  28138. * Gets the lodaded data (as an array buffer)
  28139. */
  28140. data: ArrayBuffer;
  28141. /**
  28142. * Callback called when the task is successful
  28143. */
  28144. onSuccess: (task: BinaryFileAssetTask) => void;
  28145. /**
  28146. * Callback called when the task is successful
  28147. */
  28148. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  28149. /**
  28150. * Creates a new BinaryFileAssetTask object
  28151. * @param name defines the name of the new task
  28152. * @param url defines the location of the file to load
  28153. */
  28154. constructor(
  28155. /**
  28156. * Defines the name of the task
  28157. */
  28158. name: string,
  28159. /**
  28160. * Defines the location of the file to load
  28161. */
  28162. url: string);
  28163. /**
  28164. * Execute the current task
  28165. * @param scene defines the scene where you want your assets to be loaded
  28166. * @param onSuccess is a callback called when the task is successfully executed
  28167. * @param onError is a callback called if an error occurs
  28168. */
  28169. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28170. }
  28171. /**
  28172. * Define a task used by {BABYLON.AssetsManager} to load images
  28173. */
  28174. class ImageAssetTask extends AbstractAssetTask {
  28175. /**
  28176. * Defines the name of the task
  28177. */
  28178. name: string;
  28179. /**
  28180. * Defines the location of the image to load
  28181. */
  28182. url: string;
  28183. /**
  28184. * Gets the loaded images
  28185. */
  28186. image: HTMLImageElement;
  28187. /**
  28188. * Callback called when the task is successful
  28189. */
  28190. onSuccess: (task: ImageAssetTask) => void;
  28191. /**
  28192. * Callback called when the task is successful
  28193. */
  28194. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  28195. /**
  28196. * Creates a new ImageAssetTask
  28197. * @param name defines the name of the task
  28198. * @param url defines the location of the image to load
  28199. */
  28200. constructor(
  28201. /**
  28202. * Defines the name of the task
  28203. */
  28204. name: string,
  28205. /**
  28206. * Defines the location of the image to load
  28207. */
  28208. url: string);
  28209. /**
  28210. * Execute the current task
  28211. * @param scene defines the scene where you want your assets to be loaded
  28212. * @param onSuccess is a callback called when the task is successfully executed
  28213. * @param onError is a callback called if an error occurs
  28214. */
  28215. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28216. }
  28217. /**
  28218. * Defines the interface used by texture loading tasks
  28219. */
  28220. interface ITextureAssetTask<TEX extends BaseTexture> {
  28221. /**
  28222. * Gets the loaded texture
  28223. */
  28224. texture: TEX;
  28225. }
  28226. /**
  28227. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  28228. */
  28229. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  28230. /**
  28231. * Defines the name of the task
  28232. */
  28233. name: string;
  28234. /**
  28235. * Defines the location of the file to load
  28236. */
  28237. url: string;
  28238. /**
  28239. * Defines if mipmap should not be generated (default is false)
  28240. */
  28241. noMipmap: boolean | undefined;
  28242. /**
  28243. * Defines if texture must be inverted on Y axis (default is false)
  28244. */
  28245. invertY: boolean | undefined;
  28246. /**
  28247. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28248. */
  28249. samplingMode: number;
  28250. /**
  28251. * Gets the loaded texture
  28252. */
  28253. texture: Texture;
  28254. /**
  28255. * Callback called when the task is successful
  28256. */
  28257. onSuccess: (task: TextureAssetTask) => void;
  28258. /**
  28259. * Callback called when the task is successful
  28260. */
  28261. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  28262. /**
  28263. * Creates a new TextureAssetTask object
  28264. * @param name defines the name of the task
  28265. * @param url defines the location of the file to load
  28266. * @param noMipmap defines if mipmap should not be generated (default is false)
  28267. * @param invertY defines if texture must be inverted on Y axis (default is false)
  28268. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28269. */
  28270. constructor(
  28271. /**
  28272. * Defines the name of the task
  28273. */
  28274. name: string,
  28275. /**
  28276. * Defines the location of the file to load
  28277. */
  28278. url: string,
  28279. /**
  28280. * Defines if mipmap should not be generated (default is false)
  28281. */
  28282. noMipmap?: boolean | undefined,
  28283. /**
  28284. * Defines if texture must be inverted on Y axis (default is false)
  28285. */
  28286. invertY?: boolean | undefined,
  28287. /**
  28288. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28289. */
  28290. samplingMode?: number);
  28291. /**
  28292. * Execute the current task
  28293. * @param scene defines the scene where you want your assets to be loaded
  28294. * @param onSuccess is a callback called when the task is successfully executed
  28295. * @param onError is a callback called if an error occurs
  28296. */
  28297. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28298. }
  28299. /**
  28300. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  28301. */
  28302. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  28303. /**
  28304. * Defines the name of the task
  28305. */
  28306. name: string;
  28307. /**
  28308. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  28309. */
  28310. url: string;
  28311. /**
  28312. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  28313. */
  28314. extensions: string[] | undefined;
  28315. /**
  28316. * Defines if mipmaps should not be generated (default is false)
  28317. */
  28318. noMipmap: boolean | undefined;
  28319. /**
  28320. * Defines the explicit list of files (undefined by default)
  28321. */
  28322. files: string[] | undefined;
  28323. /**
  28324. * Gets the loaded texture
  28325. */
  28326. texture: CubeTexture;
  28327. /**
  28328. * Callback called when the task is successful
  28329. */
  28330. onSuccess: (task: CubeTextureAssetTask) => void;
  28331. /**
  28332. * Callback called when the task is successful
  28333. */
  28334. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  28335. /**
  28336. * Creates a new CubeTextureAssetTask
  28337. * @param name defines the name of the task
  28338. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  28339. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  28340. * @param noMipmap defines if mipmaps should not be generated (default is false)
  28341. * @param files defines the explicit list of files (undefined by default)
  28342. */
  28343. constructor(
  28344. /**
  28345. * Defines the name of the task
  28346. */
  28347. name: string,
  28348. /**
  28349. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  28350. */
  28351. url: string,
  28352. /**
  28353. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  28354. */
  28355. extensions?: string[] | undefined,
  28356. /**
  28357. * Defines if mipmaps should not be generated (default is false)
  28358. */
  28359. noMipmap?: boolean | undefined,
  28360. /**
  28361. * Defines the explicit list of files (undefined by default)
  28362. */
  28363. files?: string[] | undefined);
  28364. /**
  28365. * Execute the current task
  28366. * @param scene defines the scene where you want your assets to be loaded
  28367. * @param onSuccess is a callback called when the task is successfully executed
  28368. * @param onError is a callback called if an error occurs
  28369. */
  28370. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28371. }
  28372. /**
  28373. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  28374. */
  28375. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  28376. /**
  28377. * Defines the name of the task
  28378. */
  28379. name: string;
  28380. /**
  28381. * Defines the location of the file to load
  28382. */
  28383. url: string;
  28384. /**
  28385. * Defines the desired size (the more it increases the longer the generation will be)
  28386. */
  28387. size: number;
  28388. /**
  28389. * Defines if mipmaps should not be generated (default is false)
  28390. */
  28391. noMipmap: boolean;
  28392. /**
  28393. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  28394. */
  28395. generateHarmonics: boolean;
  28396. /**
  28397. * 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)
  28398. */
  28399. gammaSpace: boolean;
  28400. /**
  28401. * Internal Use Only
  28402. */
  28403. reserved: boolean;
  28404. /**
  28405. * Gets the loaded texture
  28406. */
  28407. texture: HDRCubeTexture;
  28408. /**
  28409. * Callback called when the task is successful
  28410. */
  28411. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  28412. /**
  28413. * Callback called when the task is successful
  28414. */
  28415. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  28416. /**
  28417. * Creates a new HDRCubeTextureAssetTask object
  28418. * @param name defines the name of the task
  28419. * @param url defines the location of the file to load
  28420. * @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.
  28421. * @param noMipmap defines if mipmaps should not be generated (default is false)
  28422. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  28423. * @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)
  28424. * @param reserved Internal use only
  28425. */
  28426. constructor(
  28427. /**
  28428. * Defines the name of the task
  28429. */
  28430. name: string,
  28431. /**
  28432. * Defines the location of the file to load
  28433. */
  28434. url: string,
  28435. /**
  28436. * Defines the desired size (the more it increases the longer the generation will be)
  28437. */
  28438. size: number,
  28439. /**
  28440. * Defines if mipmaps should not be generated (default is false)
  28441. */
  28442. noMipmap?: boolean,
  28443. /**
  28444. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  28445. */
  28446. generateHarmonics?: boolean,
  28447. /**
  28448. * 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)
  28449. */
  28450. gammaSpace?: boolean,
  28451. /**
  28452. * Internal Use Only
  28453. */
  28454. reserved?: boolean);
  28455. /**
  28456. * Execute the current task
  28457. * @param scene defines the scene where you want your assets to be loaded
  28458. * @param onSuccess is a callback called when the task is successfully executed
  28459. * @param onError is a callback called if an error occurs
  28460. */
  28461. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28462. }
  28463. /**
  28464. * This class can be used to easily import assets into a scene
  28465. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  28466. */
  28467. class AssetsManager {
  28468. private _scene;
  28469. private _isLoading;
  28470. protected _tasks: AbstractAssetTask[];
  28471. protected _waitingTasksCount: number;
  28472. protected _totalTasksCount: number;
  28473. /**
  28474. * Callback called when all tasks are processed
  28475. */
  28476. onFinish: (tasks: AbstractAssetTask[]) => void;
  28477. /**
  28478. * Callback called when a task is successful
  28479. */
  28480. onTaskSuccess: (task: AbstractAssetTask) => void;
  28481. /**
  28482. * Callback called when a task had an error
  28483. */
  28484. onTaskError: (task: AbstractAssetTask) => void;
  28485. /**
  28486. * Callback called when a task is done (whatever the result is)
  28487. */
  28488. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  28489. /**
  28490. * Observable called when all tasks are processed
  28491. */
  28492. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  28493. /**
  28494. * Observable called when a task had an error
  28495. */
  28496. onTaskErrorObservable: Observable<AbstractAssetTask>;
  28497. /**
  28498. * Observable called when a task is successful
  28499. */
  28500. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  28501. /**
  28502. * Observable called when a task is done (whatever the result is)
  28503. */
  28504. onProgressObservable: Observable<IAssetsProgressEvent>;
  28505. /**
  28506. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  28507. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28508. */
  28509. useDefaultLoadingScreen: boolean;
  28510. /**
  28511. * Creates a new AssetsManager
  28512. * @param scene defines the scene to work on
  28513. */
  28514. constructor(scene: Scene);
  28515. /**
  28516. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  28517. * @param taskName defines the name of the new task
  28518. * @param meshesNames defines the name of meshes to load
  28519. * @param rootUrl defines the root url to use to locate files
  28520. * @param sceneFilename defines the filename of the scene file
  28521. * @returns a new {BABYLON.MeshAssetTask} object
  28522. */
  28523. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  28524. /**
  28525. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  28526. * @param taskName defines the name of the new task
  28527. * @param url defines the url of the file to load
  28528. * @returns a new {BABYLON.TextFileAssetTask} object
  28529. */
  28530. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  28531. /**
  28532. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  28533. * @param taskName defines the name of the new task
  28534. * @param url defines the url of the file to load
  28535. * @returns a new {BABYLON.BinaryFileAssetTask} object
  28536. */
  28537. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  28538. /**
  28539. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  28540. * @param taskName defines the name of the new task
  28541. * @param url defines the url of the file to load
  28542. * @returns a new {BABYLON.ImageAssetTask} object
  28543. */
  28544. addImageTask(taskName: string, url: string): ImageAssetTask;
  28545. /**
  28546. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  28547. * @param taskName defines the name of the new task
  28548. * @param url defines the url of the file to load
  28549. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  28550. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  28551. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  28552. * @returns a new {BABYLON.TextureAssetTask} object
  28553. */
  28554. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  28555. /**
  28556. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  28557. * @param taskName defines the name of the new task
  28558. * @param url defines the url of the file to load
  28559. * @param extensions defines the extension to use to load the cube map (can be null)
  28560. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  28561. * @param files defines the list of files to load (can be null)
  28562. * @returns a new {BABYLON.CubeTextureAssetTask} object
  28563. */
  28564. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  28565. /**
  28566. *
  28567. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  28568. * @param taskName defines the name of the new task
  28569. * @param url defines the url of the file to load
  28570. * @param size defines the size you want for the cubemap (can be null)
  28571. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  28572. * @param generateHarmonics defines if you want to automatically generate (true by default)
  28573. * @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)
  28574. * @param reserved Internal use only
  28575. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  28576. */
  28577. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  28578. /**
  28579. * Remove a task from the assets manager.
  28580. * @param task the task to remove
  28581. */
  28582. removeTask(task: AbstractAssetTask): void;
  28583. private _decreaseWaitingTasksCount(task);
  28584. private _runTask(task);
  28585. /**
  28586. * Reset the {BABYLON.AssetsManager} and remove all tasks
  28587. * @return the current instance of the {BABYLON.AssetsManager}
  28588. */
  28589. reset(): AssetsManager;
  28590. /**
  28591. * Start the loading process
  28592. * @return the current instance of the {BABYLON.AssetsManager}
  28593. */
  28594. load(): AssetsManager;
  28595. }
  28596. }
  28597. declare module BABYLON {
  28598. /**
  28599. * Class used to enable access to IndexedDB
  28600. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  28601. */
  28602. class Database {
  28603. private callbackManifestChecked;
  28604. private currentSceneUrl;
  28605. private db;
  28606. private _enableSceneOffline;
  28607. private _enableTexturesOffline;
  28608. private manifestVersionFound;
  28609. private mustUpdateRessources;
  28610. private hasReachedQuota;
  28611. private isSupported;
  28612. private idbFactory;
  28613. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  28614. static IsUASupportingBlobStorage: boolean;
  28615. /** Gets a boolean indicating if Database storate is enabled */
  28616. static IDBStorageEnabled: boolean;
  28617. /**
  28618. * Gets a boolean indicating if scene must be saved in the database
  28619. */
  28620. readonly enableSceneOffline: boolean;
  28621. /**
  28622. * Gets a boolean indicating if textures must be saved in the database
  28623. */
  28624. readonly enableTexturesOffline: boolean;
  28625. /**
  28626. * Creates a new Database
  28627. * @param urlToScene defines the url to load the scene
  28628. * @param callbackManifestChecked defines the callback to use when manifest is checked
  28629. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  28630. */
  28631. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  28632. private static _ParseURL;
  28633. private static _ReturnFullUrlLocation;
  28634. private _checkManifestFile();
  28635. /**
  28636. * Open the database and make it available
  28637. * @param successCallback defines the callback to call on success
  28638. * @param errorCallback defines the callback to call on error
  28639. */
  28640. openAsync(successCallback: () => void, errorCallback: () => void): void;
  28641. /**
  28642. * Loads an image from the database
  28643. * @param url defines the url to load from
  28644. * @param image defines the target DOM image
  28645. */
  28646. loadImageFromDB(url: string, image: HTMLImageElement): void;
  28647. private _loadImageFromDBAsync(url, image, notInDBCallback);
  28648. private _saveImageIntoDBAsync(url, image);
  28649. private _checkVersionFromDB(url, versionLoaded);
  28650. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  28651. private _saveVersionIntoDBAsync(url, callback);
  28652. /**
  28653. * Loads a file from database
  28654. * @param url defines the URL to load from
  28655. * @param sceneLoaded defines a callback to call on success
  28656. * @param progressCallBack defines a callback to call when progress changed
  28657. * @param errorCallback defines a callback to call on error
  28658. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  28659. */
  28660. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  28661. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  28662. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  28663. }
  28664. }
  28665. declare module BABYLON {
  28666. interface DDSInfo {
  28667. width: number;
  28668. height: number;
  28669. mipmapCount: number;
  28670. isFourCC: boolean;
  28671. isRGB: boolean;
  28672. isLuminance: boolean;
  28673. isCube: boolean;
  28674. isCompressed: boolean;
  28675. dxgiFormat: number;
  28676. textureType: number;
  28677. /** Sphericle polynomial created for the dds texture */
  28678. sphericalPolynomial?: SphericalPolynomial;
  28679. }
  28680. class DDSTools {
  28681. static StoreLODInAlphaChannel: boolean;
  28682. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  28683. private static _FloatView;
  28684. private static _Int32View;
  28685. private static _ToHalfFloat(value);
  28686. private static _FromHalfFloat(value);
  28687. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28688. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28689. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28690. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28691. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  28692. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  28693. private static _ExtractLongWordOrder(value);
  28694. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  28695. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  28696. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  28697. }
  28698. }
  28699. declare module BABYLON {
  28700. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28701. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28702. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28703. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28704. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28705. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28706. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28707. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28708. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28709. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28710. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28711. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28712. /**
  28713. * Decorator used to define property that can be serialized as reference to a camera
  28714. * @param sourceName defines the name of the property to decorate
  28715. */
  28716. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28717. class SerializationHelper {
  28718. static Serialize<T>(entity: T, serializationObject?: any): any;
  28719. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28720. static Clone<T>(creationFunction: () => T, source: T): T;
  28721. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28722. }
  28723. }
  28724. declare module BABYLON {
  28725. /**
  28726. * Wrapper class for promise with external resolve and reject.
  28727. */
  28728. class Deferred<T> {
  28729. /**
  28730. * The promise associated with this deferred object.
  28731. */
  28732. readonly promise: Promise<T>;
  28733. private _resolve;
  28734. private _reject;
  28735. /**
  28736. * The resolve method of the promise associated with this deferred object.
  28737. */
  28738. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  28739. /**
  28740. * The reject method of the promise associated with this deferred object.
  28741. */
  28742. readonly reject: (reason?: any) => void;
  28743. /**
  28744. * Constructor for this deferred object.
  28745. */
  28746. constructor();
  28747. }
  28748. }
  28749. declare module BABYLON {
  28750. /**
  28751. * Raw texture data and descriptor sufficient for WebGL texture upload
  28752. */
  28753. interface EnvironmentTextureInfo {
  28754. /**
  28755. * Version of the environment map
  28756. */
  28757. version: number;
  28758. /**
  28759. * Width of image
  28760. */
  28761. width: number;
  28762. /**
  28763. * Irradiance information stored in the file.
  28764. */
  28765. irradiance: any;
  28766. /**
  28767. * Specular information stored in the file.
  28768. */
  28769. specular: any;
  28770. }
  28771. /**
  28772. * Sets of helpers addressing the serialization and deserialization of environment texture
  28773. * stored in a BabylonJS env file.
  28774. * Those files are usually stored as .env files.
  28775. */
  28776. class EnvironmentTextureTools {
  28777. /**
  28778. * Magic number identifying the env file.
  28779. */
  28780. private static _MagicBytes;
  28781. /**
  28782. * Gets the environment info from an env file.
  28783. * @param data The array buffer containing the .env bytes.
  28784. * @returns the environment file info (the json header) if successfully parsed.
  28785. */
  28786. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  28787. /**
  28788. * Creates an environment texture from a loaded cube texture.
  28789. * @param texture defines the cube texture to convert in env file
  28790. * @return a promise containing the environment data if succesfull.
  28791. */
  28792. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  28793. /**
  28794. * Creates a JSON representation of the spherical data.
  28795. * @param texture defines the texture containing the polynomials
  28796. * @return the JSON representation of the spherical info
  28797. */
  28798. private static _CreateEnvTextureIrradiance(texture);
  28799. /**
  28800. * Uploads the texture info contained in the env file to te GPU.
  28801. * @param texture defines the internal texture to upload to
  28802. * @param arrayBuffer defines the buffer cotaining the data to load
  28803. * @param info defines the texture info retrieved through the GetEnvInfo method
  28804. * @returns a promise
  28805. */
  28806. static UploadLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  28807. /**
  28808. * Uploads spherical polynomials information to the texture.
  28809. * @param texture defines the texture we are trying to upload the information to
  28810. * @param arrayBuffer defines the array buffer holding the data
  28811. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  28812. */
  28813. static UploadPolynomials(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): void;
  28814. /**
  28815. * Upload spherical polynomial coefficients to the texture
  28816. * @param polynmials Spherical polynmial coefficients (9)
  28817. * @param outPolynomialCoefficents Polynomial coefficients (9) object to store result
  28818. */
  28819. private static _UploadSP(polynmials, outPolynomialCoefficents);
  28820. /**
  28821. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  28822. * L = (1/pi) * E * rho
  28823. *
  28824. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  28825. * @param harmonics Spherical harmonic coefficients (9)
  28826. */
  28827. private static _ConvertSHIrradianceToLambertianRadiance(harmonics);
  28828. /**
  28829. * Convert spherical harmonics to spherical polynomial coefficients
  28830. * @param harmonics Spherical harmonic coefficients (9)
  28831. * @param outPolynomialCoefficents Polynomial coefficients (9) object to store result
  28832. */
  28833. private static _ConvertSHToSP(harmonics, outPolynomialCoefficents);
  28834. }
  28835. }
  28836. declare module BABYLON {
  28837. class FilesInput {
  28838. static FilesToLoad: {
  28839. [key: string]: File;
  28840. };
  28841. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  28842. private _engine;
  28843. private _currentScene;
  28844. private _sceneLoadedCallback;
  28845. private _progressCallback;
  28846. private _additionalRenderLoopLogicCallback;
  28847. private _textureLoadingCallback;
  28848. private _startingProcessingFilesCallback;
  28849. private _onReloadCallback;
  28850. private _errorCallback;
  28851. private _elementToMonitor;
  28852. private _sceneFileToLoad;
  28853. private _filesToLoad;
  28854. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: () => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  28855. private _dragEnterHandler;
  28856. private _dragOverHandler;
  28857. private _dropHandler;
  28858. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  28859. dispose(): void;
  28860. private renderFunction();
  28861. private drag(e);
  28862. private drop(eventDrop);
  28863. private _traverseFolder(folder, files, remaining, callback);
  28864. private _processFiles(files);
  28865. loadFiles(event: any): void;
  28866. private _processReload();
  28867. reload(): void;
  28868. }
  28869. }
  28870. declare module BABYLON {
  28871. /**
  28872. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28873. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28874. */
  28875. class KhronosTextureContainer {
  28876. arrayBuffer: any;
  28877. static HEADER_LEN: number;
  28878. static COMPRESSED_2D: number;
  28879. static COMPRESSED_3D: number;
  28880. static TEX_2D: number;
  28881. static TEX_3D: number;
  28882. glType: number;
  28883. glTypeSize: number;
  28884. glFormat: number;
  28885. glInternalFormat: number;
  28886. glBaseInternalFormat: number;
  28887. pixelWidth: number;
  28888. pixelHeight: number;
  28889. pixelDepth: number;
  28890. numberOfArrayElements: number;
  28891. numberOfFaces: number;
  28892. numberOfMipmapLevels: number;
  28893. bytesOfKeyValueData: number;
  28894. loadType: number;
  28895. /**
  28896. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  28897. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  28898. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  28899. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  28900. */
  28901. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  28902. switchEndainness(val: number): number;
  28903. /**
  28904. * It is assumed that the texture has already been created & is currently bound
  28905. */
  28906. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  28907. private _upload2DCompressedLevels(gl, loadMipmaps);
  28908. }
  28909. }
  28910. declare module BABYLON {
  28911. /**
  28912. * A class serves as a medium between the observable and its observers
  28913. */
  28914. class EventState {
  28915. /**
  28916. * Create a new EventState
  28917. * @param mask defines the mask associated with this state
  28918. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  28919. * @param target defines the original target of the state
  28920. * @param currentTarget defines the current target of the state
  28921. */
  28922. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  28923. /**
  28924. * Initialize the current event state
  28925. * @param mask defines the mask associated with this state
  28926. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  28927. * @param target defines the original target of the state
  28928. * @param currentTarget defines the current target of the state
  28929. * @returns the current event state
  28930. */
  28931. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  28932. /**
  28933. * An Observer can set this property to true to prevent subsequent observers of being notified
  28934. */
  28935. skipNextObservers: boolean;
  28936. /**
  28937. * Get the mask value that were used to trigger the event corresponding to this EventState object
  28938. */
  28939. mask: number;
  28940. /**
  28941. * The object that originally notified the event
  28942. */
  28943. target?: any;
  28944. /**
  28945. * The current object in the bubbling phase
  28946. */
  28947. currentTarget?: any;
  28948. /**
  28949. * This will be populated with the return value of the last function that was executed.
  28950. * If it is the first function in the callback chain it will be the event data.
  28951. */
  28952. lastReturnValue?: any;
  28953. }
  28954. /**
  28955. * Represent an Observer registered to a given Observable object.
  28956. */
  28957. class Observer<T> {
  28958. /**
  28959. * Defines the callback to call when the observer is notified
  28960. */
  28961. callback: (eventData: T, eventState: EventState) => void;
  28962. /**
  28963. * Defines the mask of the observer (used to filter notifications)
  28964. */
  28965. mask: number;
  28966. /**
  28967. * Defines the current scope used to restore the JS context
  28968. */
  28969. scope: any;
  28970. /** @hidden */
  28971. _willBeUnregistered: boolean;
  28972. /**
  28973. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  28974. */
  28975. unregisterOnNextCall: boolean;
  28976. /**
  28977. * Creates a new observer
  28978. * @param callback defines the callback to call when the observer is notified
  28979. * @param mask defines the mask of the observer (used to filter notifications)
  28980. * @param scope defines the current scope used to restore the JS context
  28981. */
  28982. constructor(
  28983. /**
  28984. * Defines the callback to call when the observer is notified
  28985. */
  28986. callback: (eventData: T, eventState: EventState) => void,
  28987. /**
  28988. * Defines the mask of the observer (used to filter notifications)
  28989. */
  28990. mask: number,
  28991. /**
  28992. * Defines the current scope used to restore the JS context
  28993. */
  28994. scope?: any);
  28995. }
  28996. /**
  28997. * Represent a list of observers registered to multiple Observables object.
  28998. */
  28999. class MultiObserver<T> {
  29000. private _observers;
  29001. private _observables;
  29002. /**
  29003. * Release associated resources
  29004. */
  29005. dispose(): void;
  29006. /**
  29007. * Raise a callback when one of the observable will notify
  29008. * @param observables defines a list of observables to watch
  29009. * @param callback defines the callback to call on notification
  29010. * @param mask defines the mask used to filter notifications
  29011. * @param scope defines the current scope used to restore the JS context
  29012. * @returns the new MultiObserver
  29013. */
  29014. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  29015. }
  29016. /**
  29017. * The Observable class is a simple implementation of the Observable pattern.
  29018. *
  29019. * 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.
  29020. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  29021. * 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).
  29022. * 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.
  29023. */
  29024. class Observable<T> {
  29025. private _observers;
  29026. private _eventState;
  29027. private _onObserverAdded;
  29028. /**
  29029. * Creates a new observable
  29030. * @param onObserverAdded defines a callback to call when a new observer is added
  29031. */
  29032. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  29033. /**
  29034. * Create a new Observer with the specified callback
  29035. * @param callback the callback that will be executed for that Observer
  29036. * @param mask the mask used to filter observers
  29037. * @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.
  29038. * @param scope optional scope for the callback to be called from
  29039. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  29040. * @returns the new observer created for the callback
  29041. */
  29042. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  29043. /**
  29044. * Create a new Observer with the specified callback and unregisters after the next notification
  29045. * @param callback the callback that will be executed for that Observer
  29046. * @returns the new observer created for the callback
  29047. */
  29048. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  29049. /**
  29050. * Remove an Observer from the Observable object
  29051. * @param observer the instance of the Observer to remove
  29052. * @returns false if it doesn't belong to this Observable
  29053. */
  29054. remove(observer: Nullable<Observer<T>>): boolean;
  29055. /**
  29056. * Remove a callback from the Observable object
  29057. * @param callback the callback to remove
  29058. * @param scope optional scope. If used only the callbacks with this scope will be removed
  29059. * @returns false if it doesn't belong to this Observable
  29060. */
  29061. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  29062. private _deferUnregister(observer);
  29063. /**
  29064. * Notify all Observers by calling their respective callback with the given data
  29065. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  29066. * @param eventData defines the data to send to all observers
  29067. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  29068. * @param target defines the original target of the state
  29069. * @param currentTarget defines the current target of the state
  29070. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  29071. */
  29072. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  29073. /**
  29074. * Calling this will execute each callback, expecting it to be a promise or return a value.
  29075. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  29076. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  29077. * and it is crucial that all callbacks will be executed.
  29078. * The order of the callbacks is kept, callbacks are not executed parallel.
  29079. *
  29080. * @param eventData The data to be sent to each callback
  29081. * @param mask is used to filter observers defaults to -1
  29082. * @param target defines the callback target (see EventState)
  29083. * @param currentTarget defines he current object in the bubbling phase
  29084. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  29085. */
  29086. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  29087. /**
  29088. * Notify a specific observer
  29089. * @param observer defines the observer to notify
  29090. * @param eventData defines the data to be sent to each callback
  29091. * @param mask is used to filter observers defaults to -1
  29092. */
  29093. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  29094. /**
  29095. * Gets a boolean indicating if the observable has at least one observer
  29096. * @returns true is the Observable has at least one Observer registered
  29097. */
  29098. hasObservers(): boolean;
  29099. /**
  29100. * Clear the list of observers
  29101. */
  29102. clear(): void;
  29103. /**
  29104. * Clone the current observable
  29105. * @returns a new observable
  29106. */
  29107. clone(): Observable<T>;
  29108. /**
  29109. * Does this observable handles observer registered with a given mask
  29110. * @param mask defines the mask to be tested
  29111. * @return whether or not one observer registered with the given mask is handeled
  29112. **/
  29113. hasSpecificMask(mask?: number): boolean;
  29114. }
  29115. }
  29116. declare module BABYLON {
  29117. /**
  29118. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  29119. */
  29120. class PerformanceMonitor {
  29121. private _enabled;
  29122. private _rollingFrameTime;
  29123. private _lastFrameTimeMs;
  29124. /**
  29125. * constructor
  29126. * @param frameSampleSize The number of samples required to saturate the sliding window
  29127. */
  29128. constructor(frameSampleSize?: number);
  29129. /**
  29130. * Samples current frame
  29131. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  29132. */
  29133. sampleFrame(timeMs?: number): void;
  29134. /**
  29135. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  29136. * @return Average frame time in milliseconds
  29137. */
  29138. readonly averageFrameTime: number;
  29139. /**
  29140. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  29141. * @return Frame time variance in milliseconds squared
  29142. */
  29143. readonly averageFrameTimeVariance: number;
  29144. /**
  29145. * Returns the frame time of the most recent frame
  29146. * @return Frame time in milliseconds
  29147. */
  29148. readonly instantaneousFrameTime: number;
  29149. /**
  29150. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  29151. * @return Framerate in frames per second
  29152. */
  29153. readonly averageFPS: number;
  29154. /**
  29155. * Returns the average framerate in frames per second using the most recent frame time
  29156. * @return Framerate in frames per second
  29157. */
  29158. readonly instantaneousFPS: number;
  29159. /**
  29160. * Returns true if enough samples have been taken to completely fill the sliding window
  29161. * @return true if saturated
  29162. */
  29163. readonly isSaturated: boolean;
  29164. /**
  29165. * Enables contributions to the sliding window sample set
  29166. */
  29167. enable(): void;
  29168. /**
  29169. * Disables contributions to the sliding window sample set
  29170. * Samples will not be interpolated over the disabled period
  29171. */
  29172. disable(): void;
  29173. /**
  29174. * Returns true if sampling is enabled
  29175. * @return true if enabled
  29176. */
  29177. readonly isEnabled: boolean;
  29178. /**
  29179. * Resets performance monitor
  29180. */
  29181. reset(): void;
  29182. }
  29183. /**
  29184. * RollingAverage
  29185. *
  29186. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  29187. */
  29188. class RollingAverage {
  29189. /**
  29190. * Current average
  29191. */
  29192. average: number;
  29193. /**
  29194. * Current variance
  29195. */
  29196. variance: number;
  29197. protected _samples: Array<number>;
  29198. protected _sampleCount: number;
  29199. protected _pos: number;
  29200. protected _m2: number;
  29201. /**
  29202. * constructor
  29203. * @param length The number of samples required to saturate the sliding window
  29204. */
  29205. constructor(length: number);
  29206. /**
  29207. * Adds a sample to the sample set
  29208. * @param v The sample value
  29209. */
  29210. add(v: number): void;
  29211. /**
  29212. * Returns previously added values or null if outside of history or outside the sliding window domain
  29213. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  29214. * @return Value previously recorded with add() or null if outside of range
  29215. */
  29216. history(i: number): number;
  29217. /**
  29218. * Returns true if enough samples have been taken to completely fill the sliding window
  29219. * @return true if sample-set saturated
  29220. */
  29221. isSaturated(): boolean;
  29222. /**
  29223. * Resets the rolling average (equivalent to 0 samples taken so far)
  29224. */
  29225. reset(): void;
  29226. /**
  29227. * Wraps a value around the sample range boundaries
  29228. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  29229. * @return Wrapped position in sample range
  29230. */
  29231. protected _wrapPosition(i: number): number;
  29232. }
  29233. }
  29234. declare module BABYLON {
  29235. /**
  29236. * Helper class that provides a small promise polyfill
  29237. */
  29238. class PromisePolyfill {
  29239. /**
  29240. * Static function used to check if the polyfill is required
  29241. * If this is the case then the function will inject the polyfill to window.Promise
  29242. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  29243. */
  29244. static Apply(force?: boolean): void;
  29245. }
  29246. }
  29247. declare module BABYLON {
  29248. /**
  29249. * Defines the root class used to create scene optimization to use with SceneOptimizer
  29250. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29251. */
  29252. class SceneOptimization {
  29253. /**
  29254. * Defines the priority of this optimization (0 by default which means first in the list)
  29255. */
  29256. priority: number;
  29257. /**
  29258. * Gets a string describing the action executed by the current optimization
  29259. * @returns description string
  29260. */
  29261. getDescription(): string;
  29262. /**
  29263. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29264. * @param scene defines the current scene where to apply this optimization
  29265. * @param optimizer defines the current optimizer
  29266. * @returns true if everything that can be done was applied
  29267. */
  29268. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29269. /**
  29270. * Creates the SceneOptimization object
  29271. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29272. * @param desc defines the description associated with the optimization
  29273. */
  29274. constructor(
  29275. /**
  29276. * Defines the priority of this optimization (0 by default which means first in the list)
  29277. */
  29278. priority?: number);
  29279. }
  29280. /**
  29281. * Defines an optimization used to reduce the size of render target textures
  29282. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29283. */
  29284. class TextureOptimization extends SceneOptimization {
  29285. /**
  29286. * Defines the priority of this optimization (0 by default which means first in the list)
  29287. */
  29288. priority: number;
  29289. /**
  29290. * 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
  29291. */
  29292. maximumSize: number;
  29293. /**
  29294. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29295. */
  29296. step: number;
  29297. /**
  29298. * Gets a string describing the action executed by the current optimization
  29299. * @returns description string
  29300. */
  29301. getDescription(): string;
  29302. /**
  29303. * Creates the TextureOptimization object
  29304. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29305. * @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
  29306. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29307. */
  29308. constructor(
  29309. /**
  29310. * Defines the priority of this optimization (0 by default which means first in the list)
  29311. */
  29312. priority?: number,
  29313. /**
  29314. * 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
  29315. */
  29316. maximumSize?: number,
  29317. /**
  29318. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29319. */
  29320. step?: number);
  29321. /**
  29322. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29323. * @param scene defines the current scene where to apply this optimization
  29324. * @param optimizer defines the current optimizer
  29325. * @returns true if everything that can be done was applied
  29326. */
  29327. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29328. }
  29329. /**
  29330. * Defines an optimization used to increase or decrease the rendering resolution
  29331. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29332. */
  29333. class HardwareScalingOptimization extends SceneOptimization {
  29334. /**
  29335. * Defines the priority of this optimization (0 by default which means first in the list)
  29336. */
  29337. priority: number;
  29338. /**
  29339. * Defines the maximum scale to use (2 by default)
  29340. */
  29341. maximumScale: number;
  29342. /**
  29343. * Defines the step to use between two passes (0.5 by default)
  29344. */
  29345. step: number;
  29346. private _currentScale;
  29347. private _directionOffset;
  29348. /**
  29349. * Gets a string describing the action executed by the current optimization
  29350. * @return description string
  29351. */
  29352. getDescription(): string;
  29353. /**
  29354. * Creates the HardwareScalingOptimization object
  29355. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29356. * @param maximumScale defines the maximum scale to use (2 by default)
  29357. * @param step defines the step to use between two passes (0.5 by default)
  29358. */
  29359. constructor(
  29360. /**
  29361. * Defines the priority of this optimization (0 by default which means first in the list)
  29362. */
  29363. priority?: number,
  29364. /**
  29365. * Defines the maximum scale to use (2 by default)
  29366. */
  29367. maximumScale?: number,
  29368. /**
  29369. * Defines the step to use between two passes (0.5 by default)
  29370. */
  29371. step?: number);
  29372. /**
  29373. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29374. * @param scene defines the current scene where to apply this optimization
  29375. * @param optimizer defines the current optimizer
  29376. * @returns true if everything that can be done was applied
  29377. */
  29378. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29379. }
  29380. /**
  29381. * Defines an optimization used to remove shadows
  29382. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29383. */
  29384. class ShadowsOptimization extends SceneOptimization {
  29385. /**
  29386. * Gets a string describing the action executed by the current optimization
  29387. * @return description string
  29388. */
  29389. getDescription(): string;
  29390. /**
  29391. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29392. * @param scene defines the current scene where to apply this optimization
  29393. * @param optimizer defines the current optimizer
  29394. * @returns true if everything that can be done was applied
  29395. */
  29396. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29397. }
  29398. /**
  29399. * Defines an optimization used to turn post-processes off
  29400. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29401. */
  29402. class PostProcessesOptimization extends SceneOptimization {
  29403. /**
  29404. * Gets a string describing the action executed by the current optimization
  29405. * @return description string
  29406. */
  29407. getDescription(): string;
  29408. /**
  29409. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29410. * @param scene defines the current scene where to apply this optimization
  29411. * @param optimizer defines the current optimizer
  29412. * @returns true if everything that can be done was applied
  29413. */
  29414. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29415. }
  29416. /**
  29417. * Defines an optimization used to turn lens flares off
  29418. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29419. */
  29420. class LensFlaresOptimization extends SceneOptimization {
  29421. /**
  29422. * Gets a string describing the action executed by the current optimization
  29423. * @return description string
  29424. */
  29425. getDescription(): string;
  29426. /**
  29427. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29428. * @param scene defines the current scene where to apply this optimization
  29429. * @param optimizer defines the current optimizer
  29430. * @returns true if everything that can be done was applied
  29431. */
  29432. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29433. }
  29434. /**
  29435. * Defines an optimization based on user defined callback.
  29436. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29437. */
  29438. class CustomOptimization extends SceneOptimization {
  29439. /**
  29440. * Callback called to apply the custom optimization.
  29441. */
  29442. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  29443. /**
  29444. * Callback called to get custom description
  29445. */
  29446. onGetDescription: () => string;
  29447. /**
  29448. * Gets a string describing the action executed by the current optimization
  29449. * @returns description string
  29450. */
  29451. getDescription(): string;
  29452. /**
  29453. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29454. * @param scene defines the current scene where to apply this optimization
  29455. * @param optimizer defines the current optimizer
  29456. * @returns true if everything that can be done was applied
  29457. */
  29458. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29459. }
  29460. /**
  29461. * Defines an optimization used to turn particles off
  29462. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29463. */
  29464. class ParticlesOptimization extends SceneOptimization {
  29465. /**
  29466. * Gets a string describing the action executed by the current optimization
  29467. * @return description string
  29468. */
  29469. getDescription(): string;
  29470. /**
  29471. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29472. * @param scene defines the current scene where to apply this optimization
  29473. * @param optimizer defines the current optimizer
  29474. * @returns true if everything that can be done was applied
  29475. */
  29476. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29477. }
  29478. /**
  29479. * Defines an optimization used to turn render targets off
  29480. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29481. */
  29482. class RenderTargetsOptimization extends SceneOptimization {
  29483. /**
  29484. * Gets a string describing the action executed by the current optimization
  29485. * @return description string
  29486. */
  29487. getDescription(): string;
  29488. /**
  29489. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29490. * @param scene defines the current scene where to apply this optimization
  29491. * @param optimizer defines the current optimizer
  29492. * @returns true if everything that can be done was applied
  29493. */
  29494. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29495. }
  29496. /**
  29497. * Defines an optimization used to merge meshes with compatible materials
  29498. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29499. */
  29500. class MergeMeshesOptimization extends SceneOptimization {
  29501. private static _UpdateSelectionTree;
  29502. /**
  29503. * Gets or sets a boolean which defines if optimization octree has to be updated
  29504. */
  29505. /**
  29506. * Gets or sets a boolean which defines if optimization octree has to be updated
  29507. */
  29508. static UpdateSelectionTree: boolean;
  29509. /**
  29510. * Gets a string describing the action executed by the current optimization
  29511. * @return description string
  29512. */
  29513. getDescription(): string;
  29514. private _canBeMerged;
  29515. /**
  29516. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29517. * @param scene defines the current scene where to apply this optimization
  29518. * @param optimizer defines the current optimizer
  29519. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  29520. * @returns true if everything that can be done was applied
  29521. */
  29522. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  29523. }
  29524. /**
  29525. * Defines a list of options used by SceneOptimizer
  29526. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29527. */
  29528. class SceneOptimizerOptions {
  29529. /**
  29530. * Defines the target frame rate to reach (60 by default)
  29531. */
  29532. targetFrameRate: number;
  29533. /**
  29534. * Defines the interval between two checkes (2000ms by default)
  29535. */
  29536. trackerDuration: number;
  29537. /**
  29538. * Gets the list of optimizations to apply
  29539. */
  29540. optimizations: SceneOptimization[];
  29541. /**
  29542. * Creates a new list of options used by SceneOptimizer
  29543. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  29544. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  29545. */
  29546. constructor(
  29547. /**
  29548. * Defines the target frame rate to reach (60 by default)
  29549. */
  29550. targetFrameRate?: number,
  29551. /**
  29552. * Defines the interval between two checkes (2000ms by default)
  29553. */
  29554. trackerDuration?: number);
  29555. /**
  29556. * Add a new optimization
  29557. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  29558. * @returns the current SceneOptimizerOptions
  29559. */
  29560. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  29561. /**
  29562. * Add a new custom optimization
  29563. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  29564. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  29565. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29566. * @returns the current SceneOptimizerOptions
  29567. */
  29568. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  29569. /**
  29570. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  29571. * @param targetFrameRate defines the target frame rate (60 by default)
  29572. * @returns a SceneOptimizerOptions object
  29573. */
  29574. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  29575. /**
  29576. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  29577. * @param targetFrameRate defines the target frame rate (60 by default)
  29578. * @returns a SceneOptimizerOptions object
  29579. */
  29580. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  29581. /**
  29582. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  29583. * @param targetFrameRate defines the target frame rate (60 by default)
  29584. * @returns a SceneOptimizerOptions object
  29585. */
  29586. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  29587. }
  29588. /**
  29589. * Class used to run optimizations in order to reach a target frame rate
  29590. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29591. */
  29592. class SceneOptimizer implements IDisposable {
  29593. private _isRunning;
  29594. private _options;
  29595. private _scene;
  29596. private _currentPriorityLevel;
  29597. private _targetFrameRate;
  29598. private _trackerDuration;
  29599. private _currentFrameRate;
  29600. private _sceneDisposeObserver;
  29601. private _improvementMode;
  29602. /**
  29603. * Defines an observable called when the optimizer reaches the target frame rate
  29604. */
  29605. onSuccessObservable: Observable<SceneOptimizer>;
  29606. /**
  29607. * Defines an observable called when the optimizer enables an optimization
  29608. */
  29609. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  29610. /**
  29611. * Defines an observable called when the optimizer is not able to reach the target frame rate
  29612. */
  29613. onFailureObservable: Observable<SceneOptimizer>;
  29614. /**
  29615. * Gets a boolean indicating if the optimizer is in improvement mode
  29616. */
  29617. readonly isInImprovementMode: boolean;
  29618. /**
  29619. * Gets the current priority level (0 at start)
  29620. */
  29621. readonly currentPriorityLevel: number;
  29622. /**
  29623. * Gets the current frame rate checked by the SceneOptimizer
  29624. */
  29625. readonly currentFrameRate: number;
  29626. /**
  29627. * Gets or sets the current target frame rate (60 by default)
  29628. */
  29629. /**
  29630. * Gets or sets the current target frame rate (60 by default)
  29631. */
  29632. targetFrameRate: number;
  29633. /**
  29634. * Gets or sets the current interval between two checks (every 2000ms by default)
  29635. */
  29636. /**
  29637. * Gets or sets the current interval between two checks (every 2000ms by default)
  29638. */
  29639. trackerDuration: number;
  29640. /**
  29641. * Gets the list of active optimizations
  29642. */
  29643. readonly optimizations: SceneOptimization[];
  29644. /**
  29645. * Creates a new SceneOptimizer
  29646. * @param scene defines the scene to work on
  29647. * @param options defines the options to use with the SceneOptimizer
  29648. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  29649. * @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)
  29650. */
  29651. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  29652. /**
  29653. * Stops the current optimizer
  29654. */
  29655. stop(): void;
  29656. /**
  29657. * Reset the optimizer to initial step (current priority level = 0)
  29658. */
  29659. reset(): void;
  29660. /**
  29661. * Start the optimizer. By default it will try to reach a specific framerate
  29662. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  29663. */
  29664. start(): void;
  29665. private _checkCurrentState();
  29666. /**
  29667. * Release all resources
  29668. */
  29669. dispose(): void;
  29670. /**
  29671. * Helper function to create a SceneOptimizer with one single line of code
  29672. * @param scene defines the scene to work on
  29673. * @param options defines the options to use with the SceneOptimizer
  29674. * @param onSuccess defines a callback to call on success
  29675. * @param onFailure defines a callback to call on failure
  29676. * @returns the new SceneOptimizer object
  29677. */
  29678. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  29679. }
  29680. }
  29681. declare module BABYLON {
  29682. class SceneSerializer {
  29683. static ClearCache(): void;
  29684. static Serialize(scene: Scene): any;
  29685. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  29686. }
  29687. }
  29688. declare module BABYLON {
  29689. class SmartArray<T> {
  29690. data: Array<T>;
  29691. length: number;
  29692. protected _id: number;
  29693. [index: number]: T;
  29694. constructor(capacity: number);
  29695. push(value: T): void;
  29696. forEach(func: (content: T) => void): void;
  29697. sort(compareFn: (a: T, b: T) => number): void;
  29698. reset(): void;
  29699. dispose(): void;
  29700. concat(array: any): void;
  29701. indexOf(value: T): number;
  29702. contains(value: T): boolean;
  29703. private static _GlobalId;
  29704. }
  29705. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  29706. private _duplicateId;
  29707. [index: number]: T;
  29708. push(value: T): void;
  29709. pushNoDuplicate(value: T): boolean;
  29710. reset(): void;
  29711. concatWithNoDuplicate(array: any): void;
  29712. }
  29713. }
  29714. declare module BABYLON {
  29715. /**
  29716. * This class implement a typical dictionary using a string as key and the generic type T as value.
  29717. * The underlying implementation relies on an associative array to ensure the best performances.
  29718. * The value can be anything including 'null' but except 'undefined'
  29719. */
  29720. class StringDictionary<T> {
  29721. /**
  29722. * This will clear this dictionary and copy the content from the 'source' one.
  29723. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  29724. * @param source the dictionary to take the content from and copy to this dictionary
  29725. */
  29726. copyFrom(source: StringDictionary<T>): void;
  29727. /**
  29728. * Get a value based from its key
  29729. * @param key the given key to get the matching value from
  29730. * @return the value if found, otherwise undefined is returned
  29731. */
  29732. get(key: string): T | undefined;
  29733. /**
  29734. * Get a value from its key or add it if it doesn't exist.
  29735. * This method will ensure you that a given key/data will be present in the dictionary.
  29736. * @param key the given key to get the matching value from
  29737. * @param factory the factory that will create the value if the key is not present in the dictionary.
  29738. * The factory will only be invoked if there's no data for the given key.
  29739. * @return the value corresponding to the key.
  29740. */
  29741. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  29742. /**
  29743. * Get a value from its key if present in the dictionary otherwise add it
  29744. * @param key the key to get the value from
  29745. * @param val if there's no such key/value pair in the dictionary add it with this value
  29746. * @return the value corresponding to the key
  29747. */
  29748. getOrAdd(key: string, val: T): T;
  29749. /**
  29750. * Check if there's a given key in the dictionary
  29751. * @param key the key to check for
  29752. * @return true if the key is present, false otherwise
  29753. */
  29754. contains(key: string): boolean;
  29755. /**
  29756. * Add a new key and its corresponding value
  29757. * @param key the key to add
  29758. * @param value the value corresponding to the key
  29759. * @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
  29760. */
  29761. add(key: string, value: T): boolean;
  29762. set(key: string, value: T): boolean;
  29763. /**
  29764. * Get the element of the given key and remove it from the dictionary
  29765. * @param key
  29766. */
  29767. getAndRemove(key: string): Nullable<T>;
  29768. /**
  29769. * Remove a key/value from the dictionary.
  29770. * @param key the key to remove
  29771. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  29772. */
  29773. remove(key: string): boolean;
  29774. /**
  29775. * Clear the whole content of the dictionary
  29776. */
  29777. clear(): void;
  29778. readonly count: number;
  29779. /**
  29780. * Execute a callback on each key/val of the dictionary.
  29781. * Note that you can remove any element in this dictionary in the callback implementation
  29782. * @param callback the callback to execute on a given key/value pair
  29783. */
  29784. forEach(callback: (key: string, val: T) => void): void;
  29785. /**
  29786. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  29787. * If the callback returns null or undefined the method will iterate to the next key/value pair
  29788. * Note that you can remove any element in this dictionary in the callback implementation
  29789. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  29790. */
  29791. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  29792. private _count;
  29793. private _data;
  29794. }
  29795. }
  29796. declare module BABYLON {
  29797. class Tags {
  29798. static EnableFor(obj: any): void;
  29799. static DisableFor(obj: any): void;
  29800. static HasTags(obj: any): boolean;
  29801. static GetTags(obj: any, asString?: boolean): any;
  29802. static AddTagsTo(obj: any, tagsString: string): void;
  29803. static _AddTagTo(obj: any, tag: string): void;
  29804. static RemoveTagsFrom(obj: any, tagsString: string): void;
  29805. static _RemoveTagFrom(obj: any, tag: string): void;
  29806. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  29807. }
  29808. }
  29809. declare module BABYLON {
  29810. class TextureTools {
  29811. /**
  29812. * Uses the GPU to create a copy texture rescaled at a given size
  29813. * @param texture Texture to copy from
  29814. * @param width Desired width
  29815. * @param height Desired height
  29816. * @return Generated texture
  29817. */
  29818. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  29819. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  29820. private static _environmentBRDFBase64Texture;
  29821. }
  29822. }
  29823. declare module BABYLON {
  29824. class TGATools {
  29825. private static _TYPE_INDEXED;
  29826. private static _TYPE_RGB;
  29827. private static _TYPE_GREY;
  29828. private static _TYPE_RLE_INDEXED;
  29829. private static _TYPE_RLE_RGB;
  29830. private static _TYPE_RLE_GREY;
  29831. private static _ORIGIN_MASK;
  29832. private static _ORIGIN_SHIFT;
  29833. private static _ORIGIN_BL;
  29834. private static _ORIGIN_BR;
  29835. private static _ORIGIN_UL;
  29836. private static _ORIGIN_UR;
  29837. static GetTGAHeader(data: Uint8Array): any;
  29838. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  29839. 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;
  29840. 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;
  29841. 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;
  29842. 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;
  29843. 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;
  29844. 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;
  29845. }
  29846. }
  29847. declare module BABYLON {
  29848. interface IAnimatable {
  29849. animations: Array<Animation>;
  29850. }
  29851. /** Interface used by value gradients (color, factor, ...) */
  29852. interface IValueGradient {
  29853. /**
  29854. * Gets or sets the gradient value (between 0 and 1)
  29855. */
  29856. gradient: number;
  29857. }
  29858. /** Class used to store color gradient */
  29859. class ColorGradient implements IValueGradient {
  29860. /**
  29861. * Gets or sets the gradient value (between 0 and 1)
  29862. */
  29863. gradient: number;
  29864. /**
  29865. * Gets or sets first associated color
  29866. */
  29867. color1: Color4;
  29868. /**
  29869. * Gets or sets second associated color
  29870. */
  29871. color2?: Color4;
  29872. /**
  29873. * Will get a color picked randomly between color1 and color2.
  29874. * If color2 is undefined then color1 will be used
  29875. * @param result defines the target Color4 to store the result in
  29876. */
  29877. getColorToRef(result: Color4): void;
  29878. }
  29879. /** Class used to store factor gradient */
  29880. class FactorGradient implements IValueGradient {
  29881. /**
  29882. * Gets or sets the gradient value (between 0 and 1)
  29883. */
  29884. gradient: number;
  29885. /**
  29886. * Gets or sets first associated factor
  29887. */
  29888. factor1: number;
  29889. /**
  29890. * Gets or sets second associated factor
  29891. */
  29892. factor2?: number;
  29893. /**
  29894. * Will get a number picked randomly between factor1 and factor2.
  29895. * If factor2 is undefined then factor1 will be used
  29896. * @returns the picked number
  29897. */
  29898. getFactor(): number;
  29899. }
  29900. class LoadFileError extends Error {
  29901. request: XMLHttpRequest | undefined;
  29902. private static _setPrototypeOf;
  29903. constructor(message: string, request?: XMLHttpRequest | undefined);
  29904. }
  29905. class RetryStrategy {
  29906. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29907. }
  29908. interface IFileRequest {
  29909. /**
  29910. * Raised when the request is complete (success or error).
  29911. */
  29912. onCompleteObservable: Observable<IFileRequest>;
  29913. /**
  29914. * Aborts the request for a file.
  29915. */
  29916. abort: () => void;
  29917. }
  29918. class Tools {
  29919. static BaseUrl: string;
  29920. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29921. /**
  29922. * Default behaviour for cors in the application.
  29923. * It can be a string if the expected behavior is identical in the entire app.
  29924. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  29925. */
  29926. static CorsBehavior: string | ((url: string | string[]) => string);
  29927. static UseFallbackTexture: boolean;
  29928. /**
  29929. * Use this object to register external classes like custom textures or material
  29930. * to allow the laoders to instantiate them
  29931. */
  29932. static RegisteredExternalClasses: {
  29933. [key: string]: Object;
  29934. };
  29935. static fallbackTexture: string;
  29936. /**
  29937. * Interpolates between a and b via alpha
  29938. * @param a The lower value (returned when alpha = 0)
  29939. * @param b The upper value (returned when alpha = 1)
  29940. * @param alpha The interpolation-factor
  29941. * @return The mixed value
  29942. */
  29943. static Mix(a: number, b: number, alpha: number): number;
  29944. static Instantiate(className: string): any;
  29945. /**
  29946. * Provides a slice function that will work even on IE
  29947. * @param data defines the array to slice
  29948. * @param start defines the start of the data (optional)
  29949. * @param end defines the end of the data (optional)
  29950. * @returns the new sliced array
  29951. */
  29952. static Slice<T>(data: T, start?: number, end?: number): T;
  29953. static SetImmediate(action: () => void): void;
  29954. static IsExponentOfTwo(value: number): boolean;
  29955. private static _tmpFloatArray;
  29956. /**
  29957. * Returns the nearest 32-bit single precision float representation of a Number
  29958. * @param value A Number. If the parameter is of a different type, it will get converted
  29959. * to a number or to NaN if it cannot be converted
  29960. * @returns number
  29961. */
  29962. static FloatRound(value: number): number;
  29963. /**
  29964. * Find the next highest power of two.
  29965. * @param x Number to start search from.
  29966. * @return Next highest power of two.
  29967. */
  29968. static CeilingPOT(x: number): number;
  29969. /**
  29970. * Find the next lowest power of two.
  29971. * @param x Number to start search from.
  29972. * @return Next lowest power of two.
  29973. */
  29974. static FloorPOT(x: number): number;
  29975. /**
  29976. * Find the nearest power of two.
  29977. * @param x Number to start search from.
  29978. * @return Next nearest power of two.
  29979. */
  29980. static NearestPOT(x: number): number;
  29981. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29982. static GetFilename(path: string): string;
  29983. /**
  29984. * Extracts the "folder" part of a path (everything before the filename).
  29985. * @param uri The URI to extract the info from
  29986. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  29987. * @returns The "folder" part of the path
  29988. */
  29989. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  29990. static GetDOMTextContent(element: HTMLElement): string;
  29991. static ToDegrees(angle: number): number;
  29992. static ToRadians(angle: number): number;
  29993. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  29994. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  29995. minimum: Vector3;
  29996. maximum: Vector3;
  29997. };
  29998. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  29999. minimum: Vector3;
  30000. maximum: Vector3;
  30001. };
  30002. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  30003. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  30004. minimum: Vector2;
  30005. maximum: Vector2;
  30006. };
  30007. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30008. static GetPointerPrefix(): string;
  30009. /**
  30010. * @param func - the function to be called
  30011. * @param requester - the object that will request the next frame. Falls back to window.
  30012. */
  30013. static QueueNewFrame(func: () => void, requester?: any): number;
  30014. static RequestFullscreen(element: HTMLElement): void;
  30015. static ExitFullscreen(): void;
  30016. static SetCorsBehavior(url: string | string[], element: {
  30017. crossOrigin: string | null;
  30018. }): void;
  30019. static CleanUrl(url: string): string;
  30020. static PreprocessUrl: (url: string) => string;
  30021. /**
  30022. * Loads an image as an HTMLImageElement.
  30023. * @param input url string, ArrayBuffer, or Blob to load
  30024. * @param onLoad callback called when the image successfully loads
  30025. * @param onError callback called when the image fails to load
  30026. * @param database database for caching
  30027. * @returns the HTMLImageElement of the loaded image
  30028. */
  30029. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  30030. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, database?: Database, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  30031. /**
  30032. * Load a script (identified by an url). When the url returns, the
  30033. * content of this file is added into a new script element, attached to the DOM (body element)
  30034. */
  30035. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30036. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30037. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30038. static FileAsURL(content: string): string;
  30039. static Format(value: number, decimals?: number): string;
  30040. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30041. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30042. static IsEmpty(obj: any): boolean;
  30043. static RegisterTopRootEvents(events: {
  30044. name: string;
  30045. handler: Nullable<(e: FocusEvent) => any>;
  30046. }[]): void;
  30047. static UnregisterTopRootEvents(events: {
  30048. name: string;
  30049. handler: Nullable<(e: FocusEvent) => any>;
  30050. }[]): void;
  30051. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30052. /**
  30053. * Converts the canvas data to blob.
  30054. * This acts as a polyfill for browsers not supporting the to blob function.
  30055. * @param canvas Defines the canvas to extract the data from
  30056. * @param successCallback Defines the callback triggered once the data are available
  30057. * @param mimeType Defines the mime type of the result
  30058. */
  30059. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30060. /**
  30061. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30062. * @param successCallback Defines the callback triggered once the data are available
  30063. * @param mimeType Defines the mime type of the result
  30064. * @param fileName The filename to download. If present, the result will automatically be downloaded
  30065. */
  30066. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30067. /**
  30068. * Downloads a blob in the browser
  30069. * @param blob defines the blob to download
  30070. * @param fileName defines the name of the downloaded file
  30071. */
  30072. static Download(blob: Blob, fileName: string): void;
  30073. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30074. /**
  30075. * Generates an image screenshot from the specified camera.
  30076. *
  30077. * @param engine The engine to use for rendering
  30078. * @param camera The camera to use for rendering
  30079. * @param size This parameter can be set to a single number or to an object with the
  30080. * following (optional) properties: precision, width, height. If a single number is passed,
  30081. * it will be used for both width and height. If an object is passed, the screenshot size
  30082. * will be derived from the parameters. The precision property is a multiplier allowing
  30083. * rendering at a higher or lower resolution.
  30084. * @param successCallback The callback receives a single parameter which contains the
  30085. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30086. * src parameter of an <img> to display it.
  30087. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30088. * Check your browser for supported MIME types.
  30089. * @param samples Texture samples (default: 1)
  30090. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30091. * @param fileName A name for for the downloaded file.
  30092. * @constructor
  30093. */
  30094. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30095. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  30096. /**
  30097. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30098. * Be aware Math.random() could cause collisions, but:
  30099. * "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"
  30100. */
  30101. static RandomId(): string;
  30102. /**
  30103. * Test if the given uri is a base64 string.
  30104. * @param uri The uri to test
  30105. * @return True if the uri is a base64 string or false otherwise.
  30106. */
  30107. static IsBase64(uri: string): boolean;
  30108. /**
  30109. * Decode the given base64 uri.
  30110. * @param uri The uri to decode
  30111. * @return The decoded base64 data.
  30112. */
  30113. static DecodeBase64(uri: string): ArrayBuffer;
  30114. private static _NoneLogLevel;
  30115. private static _MessageLogLevel;
  30116. private static _WarningLogLevel;
  30117. private static _ErrorLogLevel;
  30118. private static _LogCache;
  30119. static errorsCount: number;
  30120. static OnNewCacheEntry: (entry: string) => void;
  30121. static readonly NoneLogLevel: number;
  30122. static readonly MessageLogLevel: number;
  30123. static readonly WarningLogLevel: number;
  30124. static readonly ErrorLogLevel: number;
  30125. static readonly AllLogLevel: number;
  30126. private static _AddLogEntry(entry);
  30127. private static _FormatMessage(message);
  30128. private static _LogDisabled(message);
  30129. private static _LogEnabled(message);
  30130. private static _WarnDisabled(message);
  30131. private static _WarnEnabled(message);
  30132. private static _ErrorDisabled(message);
  30133. private static _ErrorEnabled(message);
  30134. static Log: (message: string) => void;
  30135. static Warn: (message: string) => void;
  30136. static Error: (message: string) => void;
  30137. static readonly LogCache: string;
  30138. static ClearLogCache(): void;
  30139. static LogLevels: number;
  30140. static IsWindowObjectExist(): boolean;
  30141. private static _PerformanceNoneLogLevel;
  30142. private static _PerformanceUserMarkLogLevel;
  30143. private static _PerformanceConsoleLogLevel;
  30144. private static _performance;
  30145. static readonly PerformanceNoneLogLevel: number;
  30146. static readonly PerformanceUserMarkLogLevel: number;
  30147. static readonly PerformanceConsoleLogLevel: number;
  30148. static PerformanceLogLevel: number;
  30149. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  30150. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  30151. static _StartUserMark(counterName: string, condition?: boolean): void;
  30152. static _EndUserMark(counterName: string, condition?: boolean): void;
  30153. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  30154. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  30155. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30156. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30157. static readonly Now: number;
  30158. /**
  30159. * This method will return the name of the class used to create the instance of the given object.
  30160. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30161. * @param object the object to get the class name from
  30162. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  30163. */
  30164. static GetClassName(object: any, isType?: boolean): string;
  30165. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30166. /**
  30167. * This method will return the name of the full name of the class, including its owning module (if any).
  30168. * 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).
  30169. * @param object the object to get the class name from
  30170. * @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.
  30171. */
  30172. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30173. /**
  30174. * This method can be used with hashCodeFromStream when your input is an array of values that are either: number, string, boolean or custom type implementing the getHashCode():number method.
  30175. * @param array
  30176. */
  30177. static arrayOrStringFeeder(array: any): (i: number) => number;
  30178. /**
  30179. * Compute the hashCode of a stream of number
  30180. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  30181. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  30182. * @return the hash code computed
  30183. */
  30184. static hashCodeFromStream(feeder: (index: number) => number): number;
  30185. /**
  30186. * Returns a promise that resolves after the given amount of time.
  30187. * @param delay Number of milliseconds to delay
  30188. * @returns Promise that resolves after the given amount of time
  30189. */
  30190. static DelayAsync(delay: number): Promise<void>;
  30191. /**
  30192. * Gets the current gradient from an array of IValueGradient
  30193. * @param ratio defines the current ratio to get
  30194. * @param gradients defines the array of IValueGradient
  30195. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30196. */
  30197. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30198. }
  30199. /**
  30200. * This class is used to track a performance counter which is number based.
  30201. * The user has access to many properties which give statistics of different nature
  30202. *
  30203. * The implementer can track two kinds of Performance Counter: time and count
  30204. * 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.
  30205. * 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.
  30206. */
  30207. class PerfCounter {
  30208. static Enabled: boolean;
  30209. /**
  30210. * Returns the smallest value ever
  30211. */
  30212. readonly min: number;
  30213. /**
  30214. * Returns the biggest value ever
  30215. */
  30216. readonly max: number;
  30217. /**
  30218. * Returns the average value since the performance counter is running
  30219. */
  30220. readonly average: number;
  30221. /**
  30222. * Returns the average value of the last second the counter was monitored
  30223. */
  30224. readonly lastSecAverage: number;
  30225. /**
  30226. * Returns the current value
  30227. */
  30228. readonly current: number;
  30229. readonly total: number;
  30230. readonly count: number;
  30231. constructor();
  30232. /**
  30233. * Call this method to start monitoring a new frame.
  30234. * 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.
  30235. */
  30236. fetchNewFrame(): void;
  30237. /**
  30238. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30239. * @param newCount the count value to add to the monitored count
  30240. * @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.
  30241. */
  30242. addCount(newCount: number, fetchResult: boolean): void;
  30243. /**
  30244. * Start monitoring this performance counter
  30245. */
  30246. beginMonitoring(): void;
  30247. /**
  30248. * Compute the time lapsed since the previous beginMonitoring() call.
  30249. * @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
  30250. */
  30251. endMonitoring(newFrame?: boolean): void;
  30252. private _fetchResult();
  30253. private _startMonitoringTime;
  30254. private _min;
  30255. private _max;
  30256. private _average;
  30257. private _current;
  30258. private _totalValueCount;
  30259. private _totalAccumulated;
  30260. private _lastSecAverage;
  30261. private _lastSecAccumulated;
  30262. private _lastSecTime;
  30263. private _lastSecValueCount;
  30264. }
  30265. /**
  30266. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30267. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30268. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30269. * @param name The name of the class, case should be preserved
  30270. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30271. */
  30272. function className(name: string, module?: string): (target: Object) => void;
  30273. /**
  30274. * An implementation of a loop for asynchronous functions.
  30275. */
  30276. class AsyncLoop {
  30277. iterations: number;
  30278. private _fn;
  30279. private _successCallback;
  30280. index: number;
  30281. private _done;
  30282. /**
  30283. * Constroctor.
  30284. * @param iterations the number of iterations.
  30285. * @param _fn the function to run each iteration
  30286. * @param _successCallback the callback that will be called upon succesful execution
  30287. * @param offset starting offset.
  30288. */
  30289. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  30290. /**
  30291. * Execute the next iteration. Must be called after the last iteration was finished.
  30292. */
  30293. executeNext(): void;
  30294. /**
  30295. * Break the loop and run the success callback.
  30296. */
  30297. breakLoop(): void;
  30298. /**
  30299. * Helper function
  30300. */
  30301. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  30302. /**
  30303. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30304. * @param iterations total number of iterations
  30305. * @param syncedIterations number of synchronous iterations in each async iteration.
  30306. * @param fn the function to call each iteration.
  30307. * @param callback a success call back that will be called when iterating stops.
  30308. * @param breakFunction a break condition (optional)
  30309. * @param timeout timeout settings for the setTimeout function. default - 0.
  30310. * @constructor
  30311. */
  30312. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  30313. }
  30314. }
  30315. declare module BABYLON {
  30316. /**
  30317. * Defines the potential axis of a Joystick
  30318. */
  30319. enum JoystickAxis {
  30320. /** X axis */
  30321. X = 0,
  30322. /** Y axis */
  30323. Y = 1,
  30324. /** Z axis */
  30325. Z = 2,
  30326. }
  30327. /**
  30328. * Class used to define virtual joystick (used in touch mode)
  30329. */
  30330. class VirtualJoystick {
  30331. /**
  30332. * Gets or sets a boolean indicating that left and right values must be inverted
  30333. */
  30334. reverseLeftRight: boolean;
  30335. /**
  30336. * Gets or sets a boolean indicating that up and down values must be inverted
  30337. */
  30338. reverseUpDown: boolean;
  30339. /**
  30340. * Gets the offset value for the position (ie. the change of the position value)
  30341. */
  30342. deltaPosition: Vector3;
  30343. /**
  30344. * Gets a boolean indicating if the virtual joystick was pressed
  30345. */
  30346. pressed: boolean;
  30347. private static _globalJoystickIndex;
  30348. private static vjCanvas;
  30349. private static vjCanvasContext;
  30350. private static vjCanvasWidth;
  30351. private static vjCanvasHeight;
  30352. private static halfWidth;
  30353. private _action;
  30354. private _axisTargetedByLeftAndRight;
  30355. private _axisTargetedByUpAndDown;
  30356. private _joystickSensibility;
  30357. private _inversedSensibility;
  30358. private _joystickPointerID;
  30359. private _joystickColor;
  30360. private _joystickPointerPos;
  30361. private _joystickPreviousPointerPos;
  30362. private _joystickPointerStartPos;
  30363. private _deltaJoystickVector;
  30364. private _leftJoystick;
  30365. private _touches;
  30366. private _onPointerDownHandlerRef;
  30367. private _onPointerMoveHandlerRef;
  30368. private _onPointerUpHandlerRef;
  30369. private _onResize;
  30370. /**
  30371. * Creates a new virtual joystick
  30372. * @param leftJoystick defines that the joystick is for left hand (false by default)
  30373. */
  30374. constructor(leftJoystick?: boolean);
  30375. /**
  30376. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  30377. * @param newJoystickSensibility defines the new sensibility
  30378. */
  30379. setJoystickSensibility(newJoystickSensibility: number): void;
  30380. private _onPointerDown(e);
  30381. private _onPointerMove(e);
  30382. private _onPointerUp(e);
  30383. /**
  30384. * Change the color of the virtual joystick
  30385. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  30386. */
  30387. setJoystickColor(newColor: string): void;
  30388. /**
  30389. * Defines a callback to call when the joystick is touched
  30390. * @param action defines the callback
  30391. */
  30392. setActionOnTouch(action: () => any): void;
  30393. /**
  30394. * Defines which axis you'd like to control for left & right
  30395. * @param axis defines the axis to use
  30396. */
  30397. setAxisForLeftRight(axis: JoystickAxis): void;
  30398. /**
  30399. * Defines which axis you'd like to control for up & down
  30400. * @param axis defines the axis to use
  30401. */
  30402. setAxisForUpDown(axis: JoystickAxis): void;
  30403. private _drawVirtualJoystick();
  30404. /**
  30405. * Release internal HTML canvas
  30406. */
  30407. releaseCanvas(): void;
  30408. }
  30409. }
  30410. declare module BABYLON {
  30411. /**
  30412. * Helper class to push actions to a pool of workers.
  30413. */
  30414. class WorkerPool implements IDisposable {
  30415. private _workerInfos;
  30416. private _pendingActions;
  30417. /**
  30418. * Constructor
  30419. * @param workers Array of workers to use for actions
  30420. */
  30421. constructor(workers: Array<Worker>);
  30422. /**
  30423. * Terminates all workers and clears any pending actions.
  30424. */
  30425. dispose(): void;
  30426. /**
  30427. * Pushes an action to the worker pool. If all the workers are active, the action will be
  30428. * pended until a worker has completed its action.
  30429. * @param action The action to perform. Call onComplete when the action is complete.
  30430. */
  30431. push(action: (worker: Worker, onComplete: () => void) => void): void;
  30432. private _execute(workerInfo, action);
  30433. }
  30434. }
  30435. declare module BABYLON {
  30436. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  30437. readonly name: string;
  30438. private _zoomStopsAnimation;
  30439. private _idleRotationSpeed;
  30440. private _idleRotationWaitTime;
  30441. private _idleRotationSpinupTime;
  30442. /**
  30443. * Gets the flag that indicates if user zooming should stop animation.
  30444. */
  30445. /**
  30446. * Sets the flag that indicates if user zooming should stop animation.
  30447. */
  30448. zoomStopsAnimation: boolean;
  30449. /**
  30450. * Gets the default speed at which the camera rotates around the model.
  30451. */
  30452. /**
  30453. * Sets the default speed at which the camera rotates around the model.
  30454. */
  30455. idleRotationSpeed: number;
  30456. /**
  30457. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  30458. */
  30459. /**
  30460. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  30461. */
  30462. idleRotationWaitTime: number;
  30463. /**
  30464. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  30465. */
  30466. /**
  30467. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  30468. */
  30469. idleRotationSpinupTime: number;
  30470. /**
  30471. * Gets a value indicating if the camera is currently rotating because of this behavior
  30472. */
  30473. readonly rotationInProgress: boolean;
  30474. private _onPrePointerObservableObserver;
  30475. private _onAfterCheckInputsObserver;
  30476. private _attachedCamera;
  30477. private _isPointerDown;
  30478. private _lastFrameTime;
  30479. private _lastInteractionTime;
  30480. private _cameraRotationSpeed;
  30481. init(): void;
  30482. attach(camera: ArcRotateCamera): void;
  30483. detach(): void;
  30484. /**
  30485. * Returns true if user is scrolling.
  30486. * @return true if user is scrolling.
  30487. */
  30488. private _userIsZooming();
  30489. private _lastFrameRadius;
  30490. private _shouldAnimationStopForInteraction();
  30491. /**
  30492. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  30493. */
  30494. private _applyUserInteraction();
  30495. private _userIsMoving();
  30496. }
  30497. }
  30498. declare module BABYLON {
  30499. /**
  30500. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  30501. */
  30502. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  30503. readonly name: string;
  30504. /**
  30505. * The easing function used by animations
  30506. */
  30507. static EasingFunction: BackEase;
  30508. /**
  30509. * The easing mode used by animations
  30510. */
  30511. static EasingMode: number;
  30512. /**
  30513. * The duration of the animation, in milliseconds
  30514. */
  30515. transitionDuration: number;
  30516. /**
  30517. * Length of the distance animated by the transition when lower radius is reached
  30518. */
  30519. lowerRadiusTransitionRange: number;
  30520. /**
  30521. * Length of the distance animated by the transition when upper radius is reached
  30522. */
  30523. upperRadiusTransitionRange: number;
  30524. private _autoTransitionRange;
  30525. /**
  30526. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  30527. */
  30528. /**
  30529. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  30530. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  30531. */
  30532. autoTransitionRange: boolean;
  30533. private _attachedCamera;
  30534. private _onAfterCheckInputsObserver;
  30535. private _onMeshTargetChangedObserver;
  30536. init(): void;
  30537. attach(camera: ArcRotateCamera): void;
  30538. detach(): void;
  30539. private _radiusIsAnimating;
  30540. private _radiusBounceTransition;
  30541. private _animatables;
  30542. private _cachedWheelPrecision;
  30543. /**
  30544. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  30545. * @param radiusLimit The limit to check against.
  30546. * @return Bool to indicate if at limit.
  30547. */
  30548. private _isRadiusAtLimit(radiusLimit);
  30549. /**
  30550. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  30551. * @param radiusDelta The delta by which to animate to. Can be negative.
  30552. */
  30553. private _applyBoundRadiusAnimation(radiusDelta);
  30554. /**
  30555. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  30556. */
  30557. protected _clearAnimationLocks(): void;
  30558. /**
  30559. * Stops and removes all animations that have been applied to the camera
  30560. */
  30561. stopAllAnimations(): void;
  30562. }
  30563. }
  30564. declare module BABYLON {
  30565. class FramingBehavior implements Behavior<ArcRotateCamera> {
  30566. readonly name: string;
  30567. private _mode;
  30568. private _radiusScale;
  30569. private _positionScale;
  30570. private _defaultElevation;
  30571. private _elevationReturnTime;
  30572. private _elevationReturnWaitTime;
  30573. private _zoomStopsAnimation;
  30574. private _framingTime;
  30575. /**
  30576. * The easing function used by animations
  30577. */
  30578. static EasingFunction: ExponentialEase;
  30579. /**
  30580. * The easing mode used by animations
  30581. */
  30582. static EasingMode: number;
  30583. /**
  30584. * Gets current mode used by the behavior.
  30585. */
  30586. /**
  30587. * Sets the current mode used by the behavior
  30588. */
  30589. mode: number;
  30590. /**
  30591. * Gets the scale applied to the radius
  30592. */
  30593. /**
  30594. * Sets the scale applied to the radius (1 by default)
  30595. */
  30596. radiusScale: number;
  30597. /**
  30598. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  30599. */
  30600. /**
  30601. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  30602. */
  30603. positionScale: number;
  30604. /**
  30605. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  30606. * behaviour is triggered, in radians.
  30607. */
  30608. /**
  30609. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  30610. * behaviour is triggered, in radians.
  30611. */
  30612. defaultElevation: number;
  30613. /**
  30614. * Gets the time (in milliseconds) taken to return to the default beta position.
  30615. * Negative value indicates camera should not return to default.
  30616. */
  30617. /**
  30618. * Sets the time (in milliseconds) taken to return to the default beta position.
  30619. * Negative value indicates camera should not return to default.
  30620. */
  30621. elevationReturnTime: number;
  30622. /**
  30623. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  30624. */
  30625. /**
  30626. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  30627. */
  30628. elevationReturnWaitTime: number;
  30629. /**
  30630. * Gets the flag that indicates if user zooming should stop animation.
  30631. */
  30632. /**
  30633. * Sets the flag that indicates if user zooming should stop animation.
  30634. */
  30635. zoomStopsAnimation: boolean;
  30636. /**
  30637. * Gets the transition time when framing the mesh, in milliseconds
  30638. */
  30639. /**
  30640. * Sets the transition time when framing the mesh, in milliseconds
  30641. */
  30642. framingTime: number;
  30643. private _onPrePointerObservableObserver;
  30644. private _onAfterCheckInputsObserver;
  30645. private _onMeshTargetChangedObserver;
  30646. private _attachedCamera;
  30647. private _isPointerDown;
  30648. private _lastInteractionTime;
  30649. init(): void;
  30650. attach(camera: ArcRotateCamera): void;
  30651. detach(): void;
  30652. private _animatables;
  30653. private _betaIsAnimating;
  30654. private _betaTransition;
  30655. private _radiusTransition;
  30656. private _vectorTransition;
  30657. /**
  30658. * Targets the given mesh and updates zoom level accordingly.
  30659. * @param mesh The mesh to target.
  30660. * @param radius Optional. If a cached radius position already exists, overrides default.
  30661. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  30662. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  30663. * @param onAnimationEnd Callback triggered at the end of the framing animation
  30664. */
  30665. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  30666. /**
  30667. * Targets the given mesh with its children and updates zoom level accordingly.
  30668. * @param mesh The mesh to target.
  30669. * @param radius Optional. If a cached radius position already exists, overrides default.
  30670. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  30671. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  30672. * @param onAnimationEnd Callback triggered at the end of the framing animation
  30673. */
  30674. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  30675. /**
  30676. * Targets the given meshes with their children and updates zoom level accordingly.
  30677. * @param meshes The mesh to target.
  30678. * @param radius Optional. If a cached radius position already exists, overrides default.
  30679. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  30680. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  30681. * @param onAnimationEnd Callback triggered at the end of the framing animation
  30682. */
  30683. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  30684. /**
  30685. * Targets the given mesh and updates zoom level accordingly.
  30686. * @param mesh The mesh to target.
  30687. * @param radius Optional. If a cached radius position already exists, overrides default.
  30688. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  30689. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  30690. * @param onAnimationEnd Callback triggered at the end of the framing animation
  30691. */
  30692. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  30693. /**
  30694. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  30695. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  30696. * frustum width.
  30697. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  30698. * to fully enclose the mesh in the viewing frustum.
  30699. */
  30700. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  30701. /**
  30702. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  30703. * is automatically returned to its default position (expected to be above ground plane).
  30704. */
  30705. private _maintainCameraAboveGround();
  30706. /**
  30707. * Returns the frustum slope based on the canvas ratio and camera FOV
  30708. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  30709. */
  30710. private _getFrustumSlope();
  30711. /**
  30712. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  30713. */
  30714. private _clearAnimationLocks();
  30715. /**
  30716. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  30717. */
  30718. private _applyUserInteraction();
  30719. /**
  30720. * Stops and removes all animations that have been applied to the camera
  30721. */
  30722. stopAllAnimations(): void;
  30723. /**
  30724. * Gets a value indicating if the user is moving the camera
  30725. */
  30726. readonly isUserIsMoving: boolean;
  30727. /**
  30728. * The camera can move all the way towards the mesh.
  30729. */
  30730. static IgnoreBoundsSizeMode: number;
  30731. /**
  30732. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  30733. */
  30734. static FitFrustumSidesMode: number;
  30735. }
  30736. }
  30737. declare module BABYLON {
  30738. /**
  30739. * A behavior that when attached to a mesh will allow the mesh to be scaled
  30740. */
  30741. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  30742. private _dragBehaviorA;
  30743. private _dragBehaviorB;
  30744. private _startDistance;
  30745. private _initialScale;
  30746. private _targetScale;
  30747. private _ownerNode;
  30748. private _sceneRenderObserver;
  30749. constructor();
  30750. /**
  30751. * The name of the behavior
  30752. */
  30753. readonly name: string;
  30754. /**
  30755. * Initializes the behavior
  30756. */
  30757. init(): void;
  30758. private _getCurrentDistance();
  30759. /**
  30760. * Attaches the scale behavior the passed in mesh
  30761. * @param ownerNode The mesh that will be scaled around once attached
  30762. */
  30763. attach(ownerNode: Mesh): void;
  30764. /**
  30765. * Detaches the behavior from the mesh
  30766. */
  30767. detach(): void;
  30768. }
  30769. }
  30770. declare module BABYLON {
  30771. /**
  30772. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  30773. */
  30774. class PointerDragBehavior implements Behavior<Mesh> {
  30775. private options;
  30776. private _attachedNode;
  30777. private _dragPlane;
  30778. private _scene;
  30779. private _pointerObserver;
  30780. private static _planeScene;
  30781. /**
  30782. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  30783. */
  30784. currentDraggingPointerID: number;
  30785. /**
  30786. * The last position where the pointer hit the drag plane in world space
  30787. */
  30788. lastDragPosition: Vector3;
  30789. /**
  30790. * If the behavior is currently in a dragging state
  30791. */
  30792. dragging: boolean;
  30793. /**
  30794. * 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)
  30795. */
  30796. dragDeltaRatio: number;
  30797. /**
  30798. * If the drag plane orientation should be updated during the dragging (Default: true)
  30799. */
  30800. updateDragPlane: boolean;
  30801. private _debugMode;
  30802. private _moving;
  30803. /**
  30804. * Fires each time the attached mesh is dragged with the pointer
  30805. * * delta between last drag position and current drag position in world space
  30806. * * dragDistance along the drag axis
  30807. * * dragPlaneNormal normal of the current drag plane used during the drag
  30808. * * dragPlanePoint in world space where the drag intersects the drag plane
  30809. */
  30810. onDragObservable: Observable<{
  30811. delta: Vector3;
  30812. dragPlanePoint: Vector3;
  30813. dragPlaneNormal: Vector3;
  30814. dragDistance: number;
  30815. pointerId: number;
  30816. }>;
  30817. /**
  30818. * Fires each time a drag begins (eg. mouse down on mesh)
  30819. */
  30820. onDragStartObservable: Observable<{
  30821. dragPlanePoint: Vector3;
  30822. pointerId: number;
  30823. }>;
  30824. /**
  30825. * Fires each time a drag ends (eg. mouse release after drag)
  30826. */
  30827. onDragEndObservable: Observable<{
  30828. dragPlanePoint: Vector3;
  30829. pointerId: number;
  30830. }>;
  30831. /**
  30832. * If the attached mesh should be moved when dragged
  30833. */
  30834. moveAttached: boolean;
  30835. /**
  30836. * If the drag behavior will react to drag events (Default: true)
  30837. */
  30838. enabled: boolean;
  30839. /**
  30840. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  30841. */
  30842. useObjectOrienationForDragging: boolean;
  30843. /**
  30844. * Creates a pointer drag behavior that can be attached to a mesh
  30845. * @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)
  30846. */
  30847. constructor(options: {
  30848. dragAxis?: Vector3;
  30849. dragPlaneNormal?: Vector3;
  30850. });
  30851. /**
  30852. * The name of the behavior
  30853. */
  30854. readonly name: string;
  30855. /**
  30856. * Initializes the behavior
  30857. */
  30858. init(): void;
  30859. private _tmpVector;
  30860. private _worldDragAxis;
  30861. /**
  30862. * Attaches the drag behavior the passed in mesh
  30863. * @param ownerNode The mesh that will be dragged around once attached
  30864. */
  30865. attach(ownerNode: Mesh): void;
  30866. releaseDrag(): void;
  30867. private _pickWithRayOnDragPlane(ray);
  30868. private _pointA;
  30869. private _pointB;
  30870. private _pointC;
  30871. private _lineA;
  30872. private _lineB;
  30873. private _localAxis;
  30874. private _lookAt;
  30875. private _updateDragPlanePosition(ray, dragPlanePosition);
  30876. /**
  30877. * Detaches the behavior from the mesh
  30878. */
  30879. detach(): void;
  30880. }
  30881. }
  30882. declare module BABYLON {
  30883. /**
  30884. * 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
  30885. */
  30886. class SixDofDragBehavior implements Behavior<Mesh> {
  30887. private static _virtualScene;
  30888. private _ownerNode;
  30889. private _sceneRenderObserver;
  30890. private _scene;
  30891. private _targetPosition;
  30892. private _virtualOriginMesh;
  30893. private _virtualDragMesh;
  30894. private _pointerObserver;
  30895. private _moving;
  30896. private _startingOrientation;
  30897. /**
  30898. * 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: 5)
  30899. */
  30900. private zDragFactor;
  30901. /**
  30902. * If the behavior is currently in a dragging state
  30903. */
  30904. dragging: boolean;
  30905. /**
  30906. * 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)
  30907. */
  30908. dragDeltaRatio: number;
  30909. /**
  30910. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  30911. */
  30912. currentDraggingPointerID: number;
  30913. constructor();
  30914. /**
  30915. * The name of the behavior
  30916. */
  30917. readonly name: string;
  30918. /**
  30919. * Initializes the behavior
  30920. */
  30921. init(): void;
  30922. /**
  30923. * Attaches the scale behavior the passed in mesh
  30924. * @param ownerNode The mesh that will be scaled around once attached
  30925. */
  30926. attach(ownerNode: Mesh): void;
  30927. /**
  30928. * Detaches the behavior from the mesh
  30929. */
  30930. detach(): void;
  30931. }
  30932. }
  30933. declare module BABYLON {
  30934. interface IOctreeContainer<T> {
  30935. blocks: Array<OctreeBlock<T>>;
  30936. }
  30937. class Octree<T> {
  30938. maxDepth: number;
  30939. blocks: Array<OctreeBlock<T>>;
  30940. dynamicContent: T[];
  30941. private _maxBlockCapacity;
  30942. private _selectionContent;
  30943. private _creationFunc;
  30944. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  30945. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  30946. addMesh(entry: T): void;
  30947. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  30948. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  30949. intersectsRay(ray: Ray): SmartArray<T>;
  30950. 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;
  30951. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  30952. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  30953. }
  30954. }
  30955. declare module BABYLON {
  30956. class OctreeBlock<T> {
  30957. entries: T[];
  30958. blocks: Array<OctreeBlock<T>>;
  30959. private _depth;
  30960. private _maxDepth;
  30961. private _capacity;
  30962. private _minPoint;
  30963. private _maxPoint;
  30964. private _boundingVectors;
  30965. private _creationFunc;
  30966. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  30967. readonly capacity: number;
  30968. readonly minPoint: Vector3;
  30969. readonly maxPoint: Vector3;
  30970. addEntry(entry: T): void;
  30971. addEntries(entries: T[]): void;
  30972. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  30973. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  30974. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  30975. createInnerBlocks(): void;
  30976. }
  30977. }
  30978. declare module BABYLON {
  30979. class VRCameraMetrics {
  30980. hResolution: number;
  30981. vResolution: number;
  30982. hScreenSize: number;
  30983. vScreenSize: number;
  30984. vScreenCenter: number;
  30985. eyeToScreenDistance: number;
  30986. lensSeparationDistance: number;
  30987. interpupillaryDistance: number;
  30988. distortionK: number[];
  30989. chromaAbCorrection: number[];
  30990. postProcessScaleFactor: number;
  30991. lensCenterOffset: number;
  30992. compensateDistortion: boolean;
  30993. readonly aspectRatio: number;
  30994. readonly aspectRatioFov: number;
  30995. readonly leftHMatrix: Matrix;
  30996. readonly rightHMatrix: Matrix;
  30997. readonly leftPreViewMatrix: Matrix;
  30998. readonly rightPreViewMatrix: Matrix;
  30999. static GetDefault(): VRCameraMetrics;
  31000. }
  31001. }
  31002. declare module BABYLON {
  31003. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  31004. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  31005. getClassName(): string;
  31006. }
  31007. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  31008. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  31009. getClassName(): string;
  31010. }
  31011. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  31012. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  31013. getClassName(): string;
  31014. }
  31015. }
  31016. declare module BABYLON {
  31017. /**
  31018. * Options to modify the vr teleportation behavior.
  31019. */
  31020. interface VRTeleportationOptions {
  31021. /**
  31022. * The name of the mesh which should be used as the teleportation floor. (default: null)
  31023. */
  31024. floorMeshName?: string;
  31025. /**
  31026. * A list of meshes to be used as the teleportation floor. (default: empty)
  31027. */
  31028. floorMeshes?: Mesh[];
  31029. }
  31030. /**
  31031. * Options to modify the vr experience helper's behavior.
  31032. */
  31033. interface VRExperienceHelperOptions extends WebVROptions {
  31034. /**
  31035. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  31036. */
  31037. createDeviceOrientationCamera?: boolean;
  31038. /**
  31039. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  31040. */
  31041. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  31042. /**
  31043. * Uses the main button on the controller to toggle the laser casted. (default: true)
  31044. */
  31045. laserToggle?: boolean;
  31046. /**
  31047. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  31048. */
  31049. floorMeshes?: Mesh[];
  31050. }
  31051. /**
  31052. * Helps to quickly add VR support to an existing scene.
  31053. * See http://doc.babylonjs.com/how_to/webvr_helper
  31054. */
  31055. class VRExperienceHelper {
  31056. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  31057. private _scene;
  31058. private _position;
  31059. private _btnVR;
  31060. private _btnVRDisplayed;
  31061. private _webVRsupported;
  31062. private _webVRready;
  31063. private _webVRrequesting;
  31064. private _webVRpresenting;
  31065. private _fullscreenVRpresenting;
  31066. private _canvas;
  31067. private _webVRCamera;
  31068. private _vrDeviceOrientationCamera;
  31069. private _deviceOrientationCamera;
  31070. private _existingCamera;
  31071. private _onKeyDown;
  31072. private _onVrDisplayPresentChange;
  31073. private _onVRDisplayChanged;
  31074. private _onVRRequestPresentStart;
  31075. private _onVRRequestPresentComplete;
  31076. /**
  31077. * Observable raised when entering VR.
  31078. */
  31079. onEnteringVRObservable: Observable<VRExperienceHelper>;
  31080. /**
  31081. * Observable raised when exiting VR.
  31082. */
  31083. onExitingVRObservable: Observable<VRExperienceHelper>;
  31084. /**
  31085. * Observable raised when controller mesh is loaded.
  31086. */
  31087. onControllerMeshLoadedObservable: Observable<WebVRController>;
  31088. /** Return this.onEnteringVRObservable
  31089. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  31090. */
  31091. readonly onEnteringVR: Observable<VRExperienceHelper>;
  31092. /** Return this.onExitingVRObservable
  31093. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  31094. */
  31095. readonly onExitingVR: Observable<VRExperienceHelper>;
  31096. /** Return this.onControllerMeshLoadedObservable
  31097. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  31098. */
  31099. readonly onControllerMeshLoaded: Observable<WebVRController>;
  31100. private _rayLength;
  31101. private _useCustomVRButton;
  31102. private _teleportationRequested;
  31103. private _teleportActive;
  31104. private _floorMeshName;
  31105. private _floorMeshesCollection;
  31106. private _rotationAllowed;
  31107. private _teleportBackwardsVector;
  31108. private _teleportationTarget;
  31109. private _isDefaultTeleportationTarget;
  31110. private _postProcessMove;
  31111. private _teleportationFillColor;
  31112. private _teleportationBorderColor;
  31113. private _rotationAngle;
  31114. private _haloCenter;
  31115. private _cameraGazer;
  31116. private _padSensibilityUp;
  31117. private _padSensibilityDown;
  31118. private leftController;
  31119. private rightController;
  31120. /**
  31121. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  31122. */
  31123. onNewMeshSelected: Observable<AbstractMesh>;
  31124. /**
  31125. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  31126. */
  31127. onNewMeshPicked: Observable<PickingInfo>;
  31128. private _circleEase;
  31129. /**
  31130. * Observable raised before camera teleportation
  31131. */
  31132. onBeforeCameraTeleport: Observable<Vector3>;
  31133. /**
  31134. * Observable raised after camera teleportation
  31135. */
  31136. onAfterCameraTeleport: Observable<Vector3>;
  31137. /**
  31138. * Observable raised when current selected mesh gets unselected
  31139. */
  31140. onSelectedMeshUnselected: Observable<AbstractMesh>;
  31141. private _raySelectionPredicate;
  31142. /**
  31143. * To be optionaly changed by user to define custom ray selection
  31144. */
  31145. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  31146. /**
  31147. * To be optionaly changed by user to define custom selection logic (after ray selection)
  31148. */
  31149. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  31150. /**
  31151. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  31152. */
  31153. teleportationEnabled: boolean;
  31154. private _defaultHeight;
  31155. private _teleportationInitialized;
  31156. private _interactionsEnabled;
  31157. private _interactionsRequested;
  31158. private _displayGaze;
  31159. private _displayLaserPointer;
  31160. /**
  31161. * The mesh used to display where the user is going to teleport.
  31162. */
  31163. /**
  31164. * Sets the mesh to be used to display where the user is going to teleport.
  31165. */
  31166. teleportationTarget: Mesh;
  31167. /**
  31168. * The mesh used to display where the user is selecting,
  31169. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  31170. * See http://doc.babylonjs.com/resources/baking_transformations
  31171. */
  31172. gazeTrackerMesh: Mesh;
  31173. /**
  31174. * If the ray of the gaze should be displayed.
  31175. */
  31176. /**
  31177. * Sets if the ray of the gaze should be displayed.
  31178. */
  31179. displayGaze: boolean;
  31180. /**
  31181. * If the ray of the LaserPointer should be displayed.
  31182. */
  31183. /**
  31184. * Sets if the ray of the LaserPointer should be displayed.
  31185. */
  31186. displayLaserPointer: boolean;
  31187. /**
  31188. * The deviceOrientationCamera used as the camera when not in VR.
  31189. */
  31190. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  31191. /**
  31192. * Based on the current WebVR support, returns the current VR camera used.
  31193. */
  31194. readonly currentVRCamera: Nullable<Camera>;
  31195. /**
  31196. * The webVRCamera which is used when in VR.
  31197. */
  31198. readonly webVRCamera: WebVRFreeCamera;
  31199. /**
  31200. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  31201. */
  31202. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  31203. private readonly _teleportationRequestInitiated;
  31204. /**
  31205. * Instantiates a VRExperienceHelper.
  31206. * Helps to quickly add VR support to an existing scene.
  31207. * @param scene The scene the VRExperienceHelper belongs to.
  31208. * @param webVROptions Options to modify the vr experience helper's behavior.
  31209. */
  31210. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  31211. private _onDefaultMeshLoaded(webVRController);
  31212. private _onResize;
  31213. private _onFullscreenChange;
  31214. /**
  31215. * Gets a value indicating if we are currently in VR mode.
  31216. */
  31217. readonly isInVRMode: boolean;
  31218. private onVrDisplayPresentChange();
  31219. private onVRDisplayChanged(eventArgs);
  31220. private moveButtonToBottomRight();
  31221. private displayVRButton();
  31222. private updateButtonVisibility();
  31223. /**
  31224. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  31225. * Otherwise, will use the fullscreen API.
  31226. */
  31227. enterVR(): void;
  31228. /**
  31229. * Attempt to exit VR, or fullscreen.
  31230. */
  31231. exitVR(): void;
  31232. /**
  31233. * The position of the vr experience helper.
  31234. */
  31235. /**
  31236. * Sets the position of the vr experience helper.
  31237. */
  31238. position: Vector3;
  31239. /**
  31240. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  31241. */
  31242. enableInteractions(): void;
  31243. private readonly _noControllerIsActive;
  31244. private beforeRender;
  31245. private _isTeleportationFloor(mesh);
  31246. /**
  31247. * Adds a floor mesh to be used for teleportation.
  31248. * @param floorMesh the mesh to be used for teleportation.
  31249. */
  31250. addFloorMesh(floorMesh: Mesh): void;
  31251. /**
  31252. * Removes a floor mesh from being used for teleportation.
  31253. * @param floorMesh the mesh to be removed.
  31254. */
  31255. removeFloorMesh(floorMesh: Mesh): void;
  31256. /**
  31257. * Enables interactions and teleportation using the VR controllers and gaze.
  31258. * @param vrTeleportationOptions options to modify teleportation behavior.
  31259. */
  31260. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  31261. private _onNewGamepadConnected;
  31262. private _tryEnableInteractionOnController;
  31263. private _onNewGamepadDisconnected;
  31264. private _enableInteractionOnController(controller);
  31265. private _checkTeleportWithRay(stateObject, gazer);
  31266. private _checkRotate(stateObject, gazer);
  31267. private _checkTeleportBackwards(stateObject, gazer);
  31268. private _enableTeleportationOnController(controller);
  31269. private _createTeleportationCircles();
  31270. private _displayTeleportationTarget();
  31271. private _hideTeleportationTarget();
  31272. private _rotateCamera(right);
  31273. private _moveTeleportationSelectorTo(hit, gazer, ray);
  31274. private _workingVector;
  31275. private _workingQuaternion;
  31276. private _workingMatrix;
  31277. private _teleportCamera(location);
  31278. private _convertNormalToDirectionOfRay(normal, ray);
  31279. private _castRayAndSelectObject(gazer);
  31280. private _notifySelectedMeshUnselected(mesh);
  31281. /**
  31282. * Sets the color of the laser ray from the vr controllers.
  31283. * @param color new color for the ray.
  31284. */
  31285. changeLaserColor(color: Color3): void;
  31286. /**
  31287. * Sets the color of the ray from the vr headsets gaze.
  31288. * @param color new color for the ray.
  31289. */
  31290. changeGazeColor(color: Color3): void;
  31291. /**
  31292. * Exits VR and disposes of the vr experience helper
  31293. */
  31294. dispose(): void;
  31295. /**
  31296. * Gets the name of the VRExperienceHelper class
  31297. * @returns "VRExperienceHelper"
  31298. */
  31299. getClassName(): string;
  31300. }
  31301. }
  31302. declare module BABYLON {
  31303. /**
  31304. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  31305. * IMPORTANT!! The data is right-hand data.
  31306. * @export
  31307. * @interface DevicePose
  31308. */
  31309. interface DevicePose {
  31310. /**
  31311. * The position of the device, values in array are [x,y,z].
  31312. */
  31313. readonly position: Nullable<Float32Array>;
  31314. /**
  31315. * The linearVelocity of the device, values in array are [x,y,z].
  31316. */
  31317. readonly linearVelocity: Nullable<Float32Array>;
  31318. /**
  31319. * The linearAcceleration of the device, values in array are [x,y,z].
  31320. */
  31321. readonly linearAcceleration: Nullable<Float32Array>;
  31322. /**
  31323. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  31324. */
  31325. readonly orientation: Nullable<Float32Array>;
  31326. /**
  31327. * The angularVelocity of the device, values in array are [x,y,z].
  31328. */
  31329. readonly angularVelocity: Nullable<Float32Array>;
  31330. /**
  31331. * The angularAcceleration of the device, values in array are [x,y,z].
  31332. */
  31333. readonly angularAcceleration: Nullable<Float32Array>;
  31334. }
  31335. /**
  31336. * Interface representing a pose controlled object in Babylon.
  31337. * A pose controlled object has both regular pose values as well as pose values
  31338. * from an external device such as a VR head mounted display
  31339. */
  31340. interface PoseControlled {
  31341. /**
  31342. * The position of the object in babylon space.
  31343. */
  31344. position: Vector3;
  31345. /**
  31346. * The rotation quaternion of the object in babylon space.
  31347. */
  31348. rotationQuaternion: Quaternion;
  31349. /**
  31350. * The position of the device in babylon space.
  31351. */
  31352. devicePosition?: Vector3;
  31353. /**
  31354. * The rotation quaternion of the device in babylon space.
  31355. */
  31356. deviceRotationQuaternion: Quaternion;
  31357. /**
  31358. * The raw pose coming from the device.
  31359. */
  31360. rawPose: Nullable<DevicePose>;
  31361. /**
  31362. * The scale of the device to be used when translating from device space to babylon space.
  31363. */
  31364. deviceScaleFactor: number;
  31365. /**
  31366. * Updates the poseControlled values based on the input device pose.
  31367. * @param poseData the pose data to update the object with
  31368. */
  31369. updateFromDevice(poseData: DevicePose): void;
  31370. }
  31371. /**
  31372. * Set of options to customize the webVRCamera
  31373. */
  31374. interface WebVROptions {
  31375. /**
  31376. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  31377. */
  31378. trackPosition?: boolean;
  31379. /**
  31380. * Sets the scale of the vrDevice in babylon space. (default: 1)
  31381. */
  31382. positionScale?: number;
  31383. /**
  31384. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  31385. */
  31386. displayName?: string;
  31387. /**
  31388. * Should the native controller meshes be initialized. (default: true)
  31389. */
  31390. controllerMeshes?: boolean;
  31391. /**
  31392. * Creating a default HemiLight only on controllers. (default: true)
  31393. */
  31394. defaultLightingOnControllers?: boolean;
  31395. /**
  31396. * If you don't want to use the default VR button of the helper. (default: false)
  31397. */
  31398. useCustomVRButton?: boolean;
  31399. /**
  31400. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  31401. */
  31402. customVRButton?: HTMLButtonElement;
  31403. /**
  31404. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  31405. */
  31406. rayLength?: number;
  31407. /**
  31408. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  31409. */
  31410. defaultHeight?: number;
  31411. }
  31412. /**
  31413. * This represents a WebVR camera.
  31414. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  31415. * @example http://doc.babylonjs.com/how_to/webvr_camera
  31416. */
  31417. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  31418. private webVROptions;
  31419. /**
  31420. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  31421. */
  31422. _vrDevice: any;
  31423. /**
  31424. * The rawPose of the vrDevice.
  31425. */
  31426. rawPose: Nullable<DevicePose>;
  31427. private _onVREnabled;
  31428. private _specsVersion;
  31429. private _attached;
  31430. private _frameData;
  31431. protected _descendants: Array<Node>;
  31432. private _deviceRoomPosition;
  31433. private _deviceRoomRotationQuaternion;
  31434. private _standingMatrix;
  31435. /**
  31436. * Represents device position in babylon space.
  31437. */
  31438. devicePosition: Vector3;
  31439. /**
  31440. * Represents device rotation in babylon space.
  31441. */
  31442. deviceRotationQuaternion: Quaternion;
  31443. /**
  31444. * The scale of the device to be used when translating from device space to babylon space.
  31445. */
  31446. deviceScaleFactor: number;
  31447. private _deviceToWorld;
  31448. private _worldToDevice;
  31449. /**
  31450. * References to the webVR controllers for the vrDevice.
  31451. */
  31452. controllers: Array<WebVRController>;
  31453. /**
  31454. * Emits an event when a controller is attached.
  31455. */
  31456. onControllersAttachedObservable: Observable<WebVRController[]>;
  31457. /**
  31458. * Emits an event when a controller's mesh has been loaded;
  31459. */
  31460. onControllerMeshLoadedObservable: Observable<WebVRController>;
  31461. /**
  31462. * If the rig cameras be used as parent instead of this camera.
  31463. */
  31464. rigParenting: boolean;
  31465. private _lightOnControllers;
  31466. private _defaultHeight?;
  31467. /**
  31468. * Instantiates a WebVRFreeCamera.
  31469. * @param name The name of the WebVRFreeCamera
  31470. * @param position The starting anchor position for the camera
  31471. * @param scene The scene the camera belongs to
  31472. * @param webVROptions a set of customizable options for the webVRCamera
  31473. */
  31474. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  31475. /**
  31476. * Gets the device distance from the ground in meters.
  31477. * @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.
  31478. */
  31479. deviceDistanceToRoomGround(): number;
  31480. /**
  31481. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  31482. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  31483. */
  31484. useStandingMatrix(callback?: (bool: boolean) => void): void;
  31485. /**
  31486. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  31487. * @returns A promise with a boolean set to if the standing matrix is supported.
  31488. */
  31489. useStandingMatrixAsync(): Promise<boolean>;
  31490. /**
  31491. * Disposes the camera
  31492. */
  31493. dispose(): void;
  31494. /**
  31495. * Gets a vrController by name.
  31496. * @param name The name of the controller to retreive
  31497. * @returns the controller matching the name specified or null if not found
  31498. */
  31499. getControllerByName(name: string): Nullable<WebVRController>;
  31500. private _leftController;
  31501. /**
  31502. * The controller corrisponding to the users left hand.
  31503. */
  31504. readonly leftController: Nullable<WebVRController>;
  31505. private _rightController;
  31506. /**
  31507. * The controller corrisponding to the users right hand.
  31508. */
  31509. readonly rightController: Nullable<WebVRController>;
  31510. /**
  31511. * Casts a ray forward from the vrCamera's gaze.
  31512. * @param length Length of the ray (default: 100)
  31513. * @returns the ray corrisponding to the gaze
  31514. */
  31515. getForwardRay(length?: number): Ray;
  31516. /**
  31517. * Updates the camera based on device's frame data
  31518. */
  31519. _checkInputs(): void;
  31520. /**
  31521. * Updates the poseControlled values based on the input device pose.
  31522. * @param poseData Pose coming from the device
  31523. */
  31524. updateFromDevice(poseData: DevicePose): void;
  31525. /**
  31526. * WebVR's attach control will start broadcasting frames to the device.
  31527. * Note that in certain browsers (chrome for example) this function must be called
  31528. * within a user-interaction callback. Example:
  31529. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  31530. *
  31531. * @param element html element to attach the vrDevice to
  31532. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  31533. */
  31534. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31535. /**
  31536. * Detaches the camera from the html element and disables VR
  31537. *
  31538. * @param element html element to detach from
  31539. */
  31540. detachControl(element: HTMLElement): void;
  31541. /**
  31542. * @returns the name of this class
  31543. */
  31544. getClassName(): string;
  31545. /**
  31546. * Calls resetPose on the vrDisplay
  31547. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  31548. */
  31549. resetToCurrentRotation(): void;
  31550. /**
  31551. * Updates the rig cameras (left and right eye)
  31552. */
  31553. _updateRigCameras(): void;
  31554. private _workingVector;
  31555. private _oneVector;
  31556. private _workingMatrix;
  31557. private updateCacheCalled;
  31558. /**
  31559. * Updates the cached values of the camera
  31560. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  31561. */
  31562. _updateCache(ignoreParentClass?: boolean): void;
  31563. /**
  31564. * Updates the current device position and rotation in the babylon world
  31565. */
  31566. update(): void;
  31567. /**
  31568. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  31569. * @returns an identity matrix
  31570. */
  31571. _getViewMatrix(): Matrix;
  31572. /**
  31573. * This function is called by the two RIG cameras.
  31574. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  31575. */
  31576. protected _getWebVRViewMatrix(): Matrix;
  31577. protected _getWebVRProjectionMatrix(): Matrix;
  31578. private _onGamepadConnectedObserver;
  31579. private _onGamepadDisconnectedObserver;
  31580. /**
  31581. * Initializes the controllers and their meshes
  31582. */
  31583. initControllers(): void;
  31584. }
  31585. }
  31586. declare module BABYLON {
  31587. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  31588. camera: ArcRotateCamera;
  31589. gamepad: Nullable<Gamepad>;
  31590. private _onGamepadConnectedObserver;
  31591. private _onGamepadDisconnectedObserver;
  31592. gamepadRotationSensibility: number;
  31593. gamepadMoveSensibility: number;
  31594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31595. detachControl(element: Nullable<HTMLElement>): void;
  31596. checkInputs(): void;
  31597. getClassName(): string;
  31598. getSimpleName(): string;
  31599. }
  31600. }
  31601. declare module BABYLON {
  31602. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  31603. camera: ArcRotateCamera;
  31604. private _keys;
  31605. keysUp: number[];
  31606. keysDown: number[];
  31607. keysLeft: number[];
  31608. keysRight: number[];
  31609. keysReset: number[];
  31610. panningSensibility: number;
  31611. zoomingSensibility: number;
  31612. useAltToZoom: boolean;
  31613. private _ctrlPressed;
  31614. private _altPressed;
  31615. private _onCanvasBlurObserver;
  31616. private _onKeyboardObserver;
  31617. private _engine;
  31618. private _scene;
  31619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31620. detachControl(element: Nullable<HTMLElement>): void;
  31621. checkInputs(): void;
  31622. getClassName(): string;
  31623. getSimpleName(): string;
  31624. }
  31625. }
  31626. declare module BABYLON {
  31627. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  31628. camera: ArcRotateCamera;
  31629. private _wheel;
  31630. private _observer;
  31631. wheelPrecision: number;
  31632. /**
  31633. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  31634. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  31635. */
  31636. wheelDeltaPercentage: number;
  31637. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31638. detachControl(element: Nullable<HTMLElement>): void;
  31639. getClassName(): string;
  31640. getSimpleName(): string;
  31641. }
  31642. }
  31643. declare module BABYLON {
  31644. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  31645. camera: ArcRotateCamera;
  31646. buttons: number[];
  31647. angularSensibilityX: number;
  31648. angularSensibilityY: number;
  31649. pinchPrecision: number;
  31650. /**
  31651. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  31652. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  31653. */
  31654. pinchDeltaPercentage: number;
  31655. panningSensibility: number;
  31656. multiTouchPanning: boolean;
  31657. multiTouchPanAndZoom: boolean;
  31658. private _isPanClick;
  31659. pinchInwards: boolean;
  31660. private _pointerInput;
  31661. private _observer;
  31662. private _onMouseMove;
  31663. private _onGestureStart;
  31664. private _onGesture;
  31665. private _MSGestureHandler;
  31666. private _onLostFocus;
  31667. private _onContextMenu;
  31668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31669. detachControl(element: Nullable<HTMLElement>): void;
  31670. getClassName(): string;
  31671. getSimpleName(): string;
  31672. }
  31673. }
  31674. declare module BABYLON {
  31675. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  31676. camera: ArcRotateCamera;
  31677. alphaCorrection: number;
  31678. betaCorrection: number;
  31679. gammaCorrection: number;
  31680. private _alpha;
  31681. private _gamma;
  31682. private _dirty;
  31683. private _deviceOrientationHandler;
  31684. constructor();
  31685. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31686. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  31687. checkInputs(): void;
  31688. detachControl(element: Nullable<HTMLElement>): void;
  31689. getClassName(): string;
  31690. getSimpleName(): string;
  31691. }
  31692. }
  31693. declare module BABYLON {
  31694. /**
  31695. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  31696. * Screen rotation is taken into account.
  31697. */
  31698. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  31699. private _camera;
  31700. private _screenOrientationAngle;
  31701. private _constantTranform;
  31702. private _screenQuaternion;
  31703. private _alpha;
  31704. private _beta;
  31705. private _gamma;
  31706. constructor();
  31707. camera: FreeCamera;
  31708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31709. private _orientationChanged;
  31710. private _deviceOrientation;
  31711. detachControl(element: Nullable<HTMLElement>): void;
  31712. checkInputs(): void;
  31713. getClassName(): string;
  31714. getSimpleName(): string;
  31715. }
  31716. }
  31717. declare module BABYLON {
  31718. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  31719. camera: FreeCamera;
  31720. gamepad: Nullable<Gamepad>;
  31721. private _onGamepadConnectedObserver;
  31722. private _onGamepadDisconnectedObserver;
  31723. gamepadAngularSensibility: number;
  31724. gamepadMoveSensibility: number;
  31725. private _cameraTransform;
  31726. private _deltaTransform;
  31727. private _vector3;
  31728. private _vector2;
  31729. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31730. detachControl(element: Nullable<HTMLElement>): void;
  31731. checkInputs(): void;
  31732. getClassName(): string;
  31733. getSimpleName(): string;
  31734. }
  31735. }
  31736. declare module BABYLON {
  31737. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  31738. camera: FreeCamera;
  31739. private _keys;
  31740. private _onCanvasBlurObserver;
  31741. private _onKeyboardObserver;
  31742. private _engine;
  31743. private _scene;
  31744. keysUp: number[];
  31745. keysDown: number[];
  31746. keysLeft: number[];
  31747. keysRight: number[];
  31748. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31749. detachControl(element: Nullable<HTMLElement>): void;
  31750. checkInputs(): void;
  31751. getClassName(): string;
  31752. _onLostFocus(e: FocusEvent): void;
  31753. getSimpleName(): string;
  31754. }
  31755. }
  31756. declare module BABYLON {
  31757. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  31758. touchEnabled: boolean;
  31759. camera: FreeCamera;
  31760. buttons: number[];
  31761. angularSensibility: number;
  31762. private _pointerInput;
  31763. private _onMouseMove;
  31764. private _observer;
  31765. private previousPosition;
  31766. constructor(touchEnabled?: boolean);
  31767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31768. detachControl(element: Nullable<HTMLElement>): void;
  31769. getClassName(): string;
  31770. getSimpleName(): string;
  31771. }
  31772. }
  31773. declare module BABYLON {
  31774. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  31775. camera: FreeCamera;
  31776. private _offsetX;
  31777. private _offsetY;
  31778. private _pointerPressed;
  31779. private _pointerInput;
  31780. private _observer;
  31781. private _onLostFocus;
  31782. touchAngularSensibility: number;
  31783. touchMoveSensibility: number;
  31784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31785. detachControl(element: Nullable<HTMLElement>): void;
  31786. checkInputs(): void;
  31787. getClassName(): string;
  31788. getSimpleName(): string;
  31789. }
  31790. }
  31791. declare module BABYLON {
  31792. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  31793. camera: FreeCamera;
  31794. private _leftjoystick;
  31795. private _rightjoystick;
  31796. getLeftJoystick(): VirtualJoystick;
  31797. getRightJoystick(): VirtualJoystick;
  31798. checkInputs(): void;
  31799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31800. detachControl(element: Nullable<HTMLElement>): void;
  31801. getClassName(): string;
  31802. getSimpleName(): string;
  31803. }
  31804. }
  31805. declare module BABYLON {
  31806. /**
  31807. * Google Daydream controller
  31808. */
  31809. class DaydreamController extends WebVRController {
  31810. /**
  31811. * Base Url for the controller model.
  31812. */
  31813. static MODEL_BASE_URL: string;
  31814. /**
  31815. * File name for the controller model.
  31816. */
  31817. static MODEL_FILENAME: string;
  31818. /**
  31819. * Gamepad Id prefix used to identify Daydream Controller.
  31820. */
  31821. static readonly GAMEPAD_ID_PREFIX: string;
  31822. /**
  31823. * Creates a new DaydreamController from a gamepad
  31824. * @param vrGamepad the gamepad that the controller should be created from
  31825. */
  31826. constructor(vrGamepad: any);
  31827. /**
  31828. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31829. * @param scene scene in which to add meshes
  31830. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31831. */
  31832. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31833. /**
  31834. * Called once for each button that changed state since the last frame
  31835. * @param buttonIdx Which button index changed
  31836. * @param state New state of the button
  31837. * @param changes Which properties on the state changed since last frame
  31838. */
  31839. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31840. }
  31841. }
  31842. declare module BABYLON {
  31843. /**
  31844. * Gear VR Controller
  31845. */
  31846. class GearVRController extends WebVRController {
  31847. /**
  31848. * Base Url for the controller model.
  31849. */
  31850. static MODEL_BASE_URL: string;
  31851. /**
  31852. * File name for the controller model.
  31853. */
  31854. static MODEL_FILENAME: string;
  31855. /**
  31856. * Gamepad Id prefix used to identify this controller.
  31857. */
  31858. static readonly GAMEPAD_ID_PREFIX: string;
  31859. private readonly _buttonIndexToObservableNameMap;
  31860. /**
  31861. * Creates a new GearVRController from a gamepad
  31862. * @param vrGamepad the gamepad that the controller should be created from
  31863. */
  31864. constructor(vrGamepad: any);
  31865. /**
  31866. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31867. * @param scene scene in which to add meshes
  31868. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31869. */
  31870. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31871. /**
  31872. * Called once for each button that changed state since the last frame
  31873. * @param buttonIdx Which button index changed
  31874. * @param state New state of the button
  31875. * @param changes Which properties on the state changed since last frame
  31876. */
  31877. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31878. }
  31879. }
  31880. declare module BABYLON {
  31881. /**
  31882. * Generic Controller
  31883. */
  31884. class GenericController extends WebVRController {
  31885. /**
  31886. * Base Url for the controller model.
  31887. */
  31888. static readonly MODEL_BASE_URL: string;
  31889. /**
  31890. * File name for the controller model.
  31891. */
  31892. static readonly MODEL_FILENAME: string;
  31893. /**
  31894. * Creates a new GenericController from a gamepad
  31895. * @param vrGamepad the gamepad that the controller should be created from
  31896. */
  31897. constructor(vrGamepad: any);
  31898. /**
  31899. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31900. * @param scene scene in which to add meshes
  31901. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31902. */
  31903. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31904. /**
  31905. * Called once for each button that changed state since the last frame
  31906. * @param buttonIdx Which button index changed
  31907. * @param state New state of the button
  31908. * @param changes Which properties on the state changed since last frame
  31909. */
  31910. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31911. }
  31912. }
  31913. declare module BABYLON {
  31914. /**
  31915. * Oculus Touch Controller
  31916. */
  31917. class OculusTouchController extends WebVRController {
  31918. /**
  31919. * Base Url for the controller model.
  31920. */
  31921. static MODEL_BASE_URL: string;
  31922. /**
  31923. * File name for the left controller model.
  31924. */
  31925. static MODEL_LEFT_FILENAME: string;
  31926. /**
  31927. * File name for the right controller model.
  31928. */
  31929. static MODEL_RIGHT_FILENAME: string;
  31930. /**
  31931. * Fired when the secondary trigger on this controller is modified
  31932. */
  31933. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  31934. /**
  31935. * Fired when the thumb rest on this controller is modified
  31936. */
  31937. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  31938. /**
  31939. * Creates a new OculusTouchController from a gamepad
  31940. * @param vrGamepad the gamepad that the controller should be created from
  31941. */
  31942. constructor(vrGamepad: any);
  31943. /**
  31944. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31945. * @param scene scene in which to add meshes
  31946. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31947. */
  31948. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31949. /**
  31950. * Fired when the A button on this controller is modified
  31951. */
  31952. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31953. /**
  31954. * Fired when the B button on this controller is modified
  31955. */
  31956. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31957. /**
  31958. * Fired when the X button on this controller is modified
  31959. */
  31960. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31961. /**
  31962. * Fired when the Y button on this controller is modified
  31963. */
  31964. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31965. /**
  31966. * Called once for each button that changed state since the last frame
  31967. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  31968. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  31969. * 2) secondary trigger (same)
  31970. * 3) A (right) X (left), touch, pressed = value
  31971. * 4) B / Y
  31972. * 5) thumb rest
  31973. * @param buttonIdx Which button index changed
  31974. * @param state New state of the button
  31975. * @param changes Which properties on the state changed since last frame
  31976. */
  31977. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31978. }
  31979. }
  31980. declare module BABYLON {
  31981. /**
  31982. * Defines the types of pose enabled controllers that are supported
  31983. */
  31984. enum PoseEnabledControllerType {
  31985. /**
  31986. * HTC Vive
  31987. */
  31988. VIVE = 0,
  31989. /**
  31990. * Oculus Rift
  31991. */
  31992. OCULUS = 1,
  31993. /**
  31994. * Windows mixed reality
  31995. */
  31996. WINDOWS = 2,
  31997. /**
  31998. * Samsung gear VR
  31999. */
  32000. GEAR_VR = 3,
  32001. /**
  32002. * Google Daydream
  32003. */
  32004. DAYDREAM = 4,
  32005. /**
  32006. * Generic
  32007. */
  32008. GENERIC = 5,
  32009. }
  32010. /**
  32011. * Defines the MutableGamepadButton interface for the state of a gamepad button
  32012. */
  32013. interface MutableGamepadButton {
  32014. /**
  32015. * Value of the button/trigger
  32016. */
  32017. value: number;
  32018. /**
  32019. * If the button/trigger is currently touched
  32020. */
  32021. touched: boolean;
  32022. /**
  32023. * If the button/trigger is currently pressed
  32024. */
  32025. pressed: boolean;
  32026. }
  32027. /**
  32028. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  32029. * @hidden
  32030. */
  32031. interface ExtendedGamepadButton extends GamepadButton {
  32032. /**
  32033. * If the button/trigger is currently pressed
  32034. */
  32035. readonly pressed: boolean;
  32036. /**
  32037. * If the button/trigger is currently touched
  32038. */
  32039. readonly touched: boolean;
  32040. /**
  32041. * Value of the button/trigger
  32042. */
  32043. readonly value: number;
  32044. }
  32045. /**
  32046. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  32047. */
  32048. class PoseEnabledControllerHelper {
  32049. /**
  32050. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  32051. * @param vrGamepad the gamepad to initialized
  32052. * @returns a vr controller of the type the gamepad identified as
  32053. */
  32054. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  32055. }
  32056. /**
  32057. * Defines the PoseEnabledController object that contains state of a vr capable controller
  32058. */
  32059. class PoseEnabledController extends Gamepad implements PoseControlled {
  32060. private _deviceRoomPosition;
  32061. private _deviceRoomRotationQuaternion;
  32062. /**
  32063. * The device position in babylon space
  32064. */
  32065. devicePosition: Vector3;
  32066. /**
  32067. * The device rotation in babylon space
  32068. */
  32069. deviceRotationQuaternion: Quaternion;
  32070. /**
  32071. * The scale factor of the device in babylon space
  32072. */
  32073. deviceScaleFactor: number;
  32074. /**
  32075. * (Likely devicePosition should be used instead) The device position in its room space
  32076. */
  32077. position: Vector3;
  32078. /**
  32079. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  32080. */
  32081. rotationQuaternion: Quaternion;
  32082. /**
  32083. * The type of controller (Eg. Windows mixed reality)
  32084. */
  32085. controllerType: PoseEnabledControllerType;
  32086. protected _calculatedPosition: Vector3;
  32087. private _calculatedRotation;
  32088. /**
  32089. * The raw pose from the device
  32090. */
  32091. rawPose: DevicePose;
  32092. /**
  32093. * Internal, the mesh attached to the controller
  32094. */
  32095. _mesh: Nullable<AbstractMesh>;
  32096. private _poseControlledCamera;
  32097. private _leftHandSystemQuaternion;
  32098. /**
  32099. * Internal, matrix used to convert room space to babylon space
  32100. */
  32101. _deviceToWorld: Matrix;
  32102. /**
  32103. * Node to be used when casting a ray from the controller
  32104. */
  32105. _pointingPoseNode: Nullable<AbstractMesh>;
  32106. /**
  32107. * Name of the child mesh that can be used to cast a ray from the controller
  32108. */
  32109. static readonly POINTING_POSE: string;
  32110. /**
  32111. * Creates a new PoseEnabledController from a gamepad
  32112. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  32113. */
  32114. constructor(browserGamepad: any);
  32115. private _workingMatrix;
  32116. /**
  32117. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  32118. */
  32119. update(): void;
  32120. /**
  32121. * Updates only the pose device and mesh without doing any button event checking
  32122. */
  32123. protected _updatePoseAndMesh(): void;
  32124. /**
  32125. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  32126. * @param poseData raw pose fromthe device
  32127. */
  32128. updateFromDevice(poseData: DevicePose): void;
  32129. /**
  32130. * @hidden
  32131. */
  32132. _meshAttachedObservable: Observable<AbstractMesh>;
  32133. /**
  32134. * Attaches a mesh to the controller
  32135. * @param mesh the mesh to be attached
  32136. */
  32137. attachToMesh(mesh: AbstractMesh): void;
  32138. /**
  32139. * Attaches the controllers mesh to a camera
  32140. * @param camera the camera the mesh should be attached to
  32141. */
  32142. attachToPoseControlledCamera(camera: TargetCamera): void;
  32143. /**
  32144. * Disposes of the controller
  32145. */
  32146. dispose(): void;
  32147. /**
  32148. * The mesh that is attached to the controller
  32149. */
  32150. readonly mesh: Nullable<AbstractMesh>;
  32151. /**
  32152. * Gets the ray of the controller in the direction the controller is pointing
  32153. * @param length the length the resulting ray should be
  32154. * @returns a ray in the direction the controller is pointing
  32155. */
  32156. getForwardRay(length?: number): Ray;
  32157. }
  32158. }
  32159. declare module BABYLON {
  32160. /**
  32161. * Vive Controller
  32162. */
  32163. class ViveController extends WebVRController {
  32164. /**
  32165. * Base Url for the controller model.
  32166. */
  32167. static MODEL_BASE_URL: string;
  32168. /**
  32169. * File name for the controller model.
  32170. */
  32171. static MODEL_FILENAME: string;
  32172. /**
  32173. * Creates a new ViveController from a gamepad
  32174. * @param vrGamepad the gamepad that the controller should be created from
  32175. */
  32176. constructor(vrGamepad: any);
  32177. /**
  32178. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32179. * @param scene scene in which to add meshes
  32180. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32181. */
  32182. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32183. /**
  32184. * Fired when the left button on this controller is modified
  32185. */
  32186. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32187. /**
  32188. * Fired when the right button on this controller is modified
  32189. */
  32190. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32191. /**
  32192. * Fired when the menu button on this controller is modified
  32193. */
  32194. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32195. /**
  32196. * Called once for each button that changed state since the last frame
  32197. * Vive mapping:
  32198. * 0: touchpad
  32199. * 1: trigger
  32200. * 2: left AND right buttons
  32201. * 3: menu button
  32202. * @param buttonIdx Which button index changed
  32203. * @param state New state of the button
  32204. * @param changes Which properties on the state changed since last frame
  32205. */
  32206. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32207. }
  32208. }
  32209. declare module BABYLON {
  32210. /**
  32211. * Defines the WebVRController object that represents controllers tracked in 3D space
  32212. */
  32213. abstract class WebVRController extends PoseEnabledController {
  32214. /**
  32215. * Internal, the default controller model for the controller
  32216. */
  32217. protected _defaultModel: AbstractMesh;
  32218. /**
  32219. * Fired when the trigger state has changed
  32220. */
  32221. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  32222. /**
  32223. * Fired when the main button state has changed
  32224. */
  32225. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32226. /**
  32227. * Fired when the secondary button state has changed
  32228. */
  32229. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32230. /**
  32231. * Fired when the pad state has changed
  32232. */
  32233. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  32234. /**
  32235. * Fired when controllers stick values have changed
  32236. */
  32237. onPadValuesChangedObservable: Observable<StickValues>;
  32238. /**
  32239. * Array of button availible on the controller
  32240. */
  32241. protected _buttons: Array<MutableGamepadButton>;
  32242. private _onButtonStateChange;
  32243. /**
  32244. * Fired when a controller button's state has changed
  32245. * @param callback the callback containing the button that was modified
  32246. */
  32247. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  32248. /**
  32249. * X and Y axis corrisponding to the controllers joystick
  32250. */
  32251. pad: StickValues;
  32252. /**
  32253. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  32254. */
  32255. hand: string;
  32256. /**
  32257. * The default controller model for the controller
  32258. */
  32259. readonly defaultModel: AbstractMesh;
  32260. /**
  32261. * Creates a new WebVRController from a gamepad
  32262. * @param vrGamepad the gamepad that the WebVRController should be created from
  32263. */
  32264. constructor(vrGamepad: any);
  32265. /**
  32266. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  32267. */
  32268. update(): void;
  32269. /**
  32270. * Function to be called when a button is modified
  32271. */
  32272. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32273. /**
  32274. * Loads a mesh and attaches it to the controller
  32275. * @param scene the scene the mesh should be added to
  32276. * @param meshLoaded callback for when the mesh has been loaded
  32277. */
  32278. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32279. private _setButtonValue(newState, currentState, buttonIndex);
  32280. private _changes;
  32281. private _checkChanges(newState, currentState);
  32282. /**
  32283. * Disposes of th webVRCOntroller
  32284. */
  32285. dispose(): void;
  32286. }
  32287. }
  32288. declare module BABYLON {
  32289. /**
  32290. * Defines the WindowsMotionController object that the state of the windows motion controller
  32291. */
  32292. class WindowsMotionController extends WebVRController {
  32293. /**
  32294. * The base url used to load the left and right controller models
  32295. */
  32296. static MODEL_BASE_URL: string;
  32297. /**
  32298. * The name of the left controller model file
  32299. */
  32300. static MODEL_LEFT_FILENAME: string;
  32301. /**
  32302. * The name of the right controller model file
  32303. */
  32304. static MODEL_RIGHT_FILENAME: string;
  32305. /**
  32306. * The controller name prefix for this controller type
  32307. */
  32308. static readonly GAMEPAD_ID_PREFIX: string;
  32309. /**
  32310. * The controller id pattern for this controller type
  32311. */
  32312. private static readonly GAMEPAD_ID_PATTERN;
  32313. private _loadedMeshInfo;
  32314. private readonly _mapping;
  32315. /**
  32316. * Fired when the trackpad on this controller is clicked
  32317. */
  32318. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  32319. /**
  32320. * Fired when the trackpad on this controller is modified
  32321. */
  32322. onTrackpadValuesChangedObservable: Observable<StickValues>;
  32323. /**
  32324. * The current x and y values of this controller's trackpad
  32325. */
  32326. trackpad: StickValues;
  32327. /**
  32328. * Creates a new WindowsMotionController from a gamepad
  32329. * @param vrGamepad the gamepad that the controller should be created from
  32330. */
  32331. constructor(vrGamepad: any);
  32332. /**
  32333. * Fired when the trigger on this controller is modified
  32334. */
  32335. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32336. /**
  32337. * Fired when the menu button on this controller is modified
  32338. */
  32339. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32340. /**
  32341. * Fired when the grip button on this controller is modified
  32342. */
  32343. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32344. /**
  32345. * Fired when the thumbstick button on this controller is modified
  32346. */
  32347. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32348. /**
  32349. * Fired when the touchpad button on this controller is modified
  32350. */
  32351. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32352. /**
  32353. * Fired when the touchpad values on this controller are modified
  32354. */
  32355. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  32356. private _updateTrackpad();
  32357. /**
  32358. * Called once per frame by the engine.
  32359. */
  32360. update(): void;
  32361. /**
  32362. * Called once for each button that changed state since the last frame
  32363. * @param buttonIdx Which button index changed
  32364. * @param state New state of the button
  32365. * @param changes Which properties on the state changed since last frame
  32366. */
  32367. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32368. /**
  32369. * Moves the buttons on the controller mesh based on their current state
  32370. * @param buttonName the name of the button to move
  32371. * @param buttonValue the value of the button which determines the buttons new position
  32372. */
  32373. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  32374. /**
  32375. * Moves the axis on the controller mesh based on its current state
  32376. * @param axis the index of the axis
  32377. * @param axisValue the value of the axis which determines the meshes new position
  32378. * @hidden
  32379. */
  32380. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  32381. /**
  32382. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32383. * @param scene scene in which to add meshes
  32384. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32385. */
  32386. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  32387. /**
  32388. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  32389. * can be transformed by button presses and axes values, based on this._mapping.
  32390. *
  32391. * @param scene scene in which the meshes exist
  32392. * @param meshes list of meshes that make up the controller model to process
  32393. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  32394. */
  32395. private processModel(scene, meshes);
  32396. private createMeshInfo(rootNode);
  32397. /**
  32398. * Gets the ray of the controller in the direction the controller is pointing
  32399. * @param length the length the resulting ray should be
  32400. * @returns a ray in the direction the controller is pointing
  32401. */
  32402. getForwardRay(length?: number): Ray;
  32403. /**
  32404. * Disposes of the controller
  32405. */
  32406. dispose(): void;
  32407. }
  32408. }
  32409. declare module BABYLON {
  32410. /**
  32411. * Interface to implement to create a shadow generator compatible with BJS.
  32412. */
  32413. interface IShadowGenerator {
  32414. /**
  32415. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  32416. * @returns The render target texture if present otherwise, null
  32417. */
  32418. getShadowMap(): Nullable<RenderTargetTexture>;
  32419. /**
  32420. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  32421. * @returns The render target texture if the shadow map is present otherwise, null
  32422. */
  32423. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  32424. /**
  32425. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  32426. * @param subMesh The submesh we want to render in the shadow map
  32427. * @param useInstances Defines wether will draw in the map using instances
  32428. * @returns true if ready otherwise, false
  32429. */
  32430. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  32431. /**
  32432. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  32433. * @param defines Defines of the material we want to update
  32434. * @param lightIndex Index of the light in the enabled light list of the material
  32435. */
  32436. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  32437. /**
  32438. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  32439. * defined in the generator but impacting the effect).
  32440. * It implies the unifroms available on the materials are the standard BJS ones.
  32441. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  32442. * @param effect The effect we are binfing the information for
  32443. */
  32444. bindShadowLight(lightIndex: string, effect: Effect): void;
  32445. /**
  32446. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  32447. * (eq to shadow prjection matrix * light transform matrix)
  32448. * @returns The transform matrix used to create the shadow map
  32449. */
  32450. getTransformMatrix(): Matrix;
  32451. /**
  32452. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  32453. * Cube and 2D textures for instance.
  32454. */
  32455. recreateShadowMap(): void;
  32456. /**
  32457. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  32458. * @param onCompiled Callback triggered at the and of the effects compilation
  32459. * @param options Sets of optional options forcing the compilation with different modes
  32460. */
  32461. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  32462. useInstances: boolean;
  32463. }>): void;
  32464. /**
  32465. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  32466. * @param options Sets of optional options forcing the compilation with different modes
  32467. * @returns A promise that resolves when the compilation completes
  32468. */
  32469. forceCompilationAsync(options?: Partial<{
  32470. useInstances: boolean;
  32471. }>): Promise<void>;
  32472. /**
  32473. * Serializes the shadow generator setup to a json object.
  32474. * @returns The serialized JSON object
  32475. */
  32476. serialize(): any;
  32477. /**
  32478. * Disposes the Shadow map and related Textures and effects.
  32479. */
  32480. dispose(): void;
  32481. }
  32482. /**
  32483. * Default implementation IShadowGenerator.
  32484. * This is the main object responsible of generating shadows in the framework.
  32485. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  32486. */
  32487. class ShadowGenerator implements IShadowGenerator {
  32488. /**
  32489. * Shadow generator mode None: no filtering applied.
  32490. */
  32491. static readonly FILTER_NONE: number;
  32492. /**
  32493. * Shadow generator mode ESM: Exponential Shadow Mapping.
  32494. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  32495. */
  32496. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  32497. /**
  32498. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  32499. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  32500. */
  32501. static readonly FILTER_POISSONSAMPLING: number;
  32502. /**
  32503. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  32504. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  32505. */
  32506. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  32507. /**
  32508. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  32509. * edge artifacts on steep falloff.
  32510. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  32511. */
  32512. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  32513. /**
  32514. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  32515. * edge artifacts on steep falloff.
  32516. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  32517. */
  32518. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  32519. /**
  32520. * Shadow generator mode PCF: Percentage Closer Filtering
  32521. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  32522. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  32523. */
  32524. static readonly FILTER_PCF: number;
  32525. /**
  32526. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  32527. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  32528. * Contact Hardening
  32529. */
  32530. static readonly FILTER_PCSS: number;
  32531. /**
  32532. * Reserved for PCF and PCSS
  32533. * Highest Quality.
  32534. *
  32535. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  32536. *
  32537. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  32538. */
  32539. static readonly QUALITY_HIGH: number;
  32540. /**
  32541. * Reserved for PCF and PCSS
  32542. * Good tradeoff for quality/perf cross devices
  32543. *
  32544. * Execute PCF on a 3*3 kernel.
  32545. *
  32546. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  32547. */
  32548. static readonly QUALITY_MEDIUM: number;
  32549. /**
  32550. * Reserved for PCF and PCSS
  32551. * The lowest quality but the fastest.
  32552. *
  32553. * Execute PCF on a 1*1 kernel.
  32554. *
  32555. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  32556. */
  32557. static readonly QUALITY_LOW: number;
  32558. private _bias;
  32559. /**
  32560. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  32561. */
  32562. /**
  32563. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  32564. */
  32565. bias: number;
  32566. private _normalBias;
  32567. /**
  32568. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  32569. */
  32570. /**
  32571. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  32572. */
  32573. normalBias: number;
  32574. private _blurBoxOffset;
  32575. /**
  32576. * Gets the blur box offset: offset applied during the blur pass.
  32577. * Only usefull if useKernelBlur = false
  32578. */
  32579. /**
  32580. * Sets the blur box offset: offset applied during the blur pass.
  32581. * Only usefull if useKernelBlur = false
  32582. */
  32583. blurBoxOffset: number;
  32584. private _blurScale;
  32585. /**
  32586. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  32587. * 2 means half of the size.
  32588. */
  32589. /**
  32590. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  32591. * 2 means half of the size.
  32592. */
  32593. blurScale: number;
  32594. private _blurKernel;
  32595. /**
  32596. * Gets the blur kernel: kernel size of the blur pass.
  32597. * Only usefull if useKernelBlur = true
  32598. */
  32599. /**
  32600. * Sets the blur kernel: kernel size of the blur pass.
  32601. * Only usefull if useKernelBlur = true
  32602. */
  32603. blurKernel: number;
  32604. private _useKernelBlur;
  32605. /**
  32606. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  32607. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  32608. */
  32609. /**
  32610. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  32611. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  32612. */
  32613. useKernelBlur: boolean;
  32614. private _depthScale;
  32615. /**
  32616. * Gets the depth scale used in ESM mode.
  32617. */
  32618. /**
  32619. * Sets the depth scale used in ESM mode.
  32620. * This can override the scale stored on the light.
  32621. */
  32622. depthScale: number;
  32623. private _filter;
  32624. /**
  32625. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  32626. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  32627. */
  32628. /**
  32629. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  32630. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  32631. */
  32632. filter: number;
  32633. /**
  32634. * Gets if the current filter is set to Poisson Sampling.
  32635. */
  32636. /**
  32637. * Sets the current filter to Poisson Sampling.
  32638. */
  32639. usePoissonSampling: boolean;
  32640. /**
  32641. * Gets if the current filter is set to VSM.
  32642. * DEPRECATED. Should use useExponentialShadowMap instead.
  32643. */
  32644. /**
  32645. * Sets the current filter is to VSM.
  32646. * DEPRECATED. Should use useExponentialShadowMap instead.
  32647. */
  32648. useVarianceShadowMap: boolean;
  32649. /**
  32650. * Gets if the current filter is set to blurred VSM.
  32651. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  32652. */
  32653. /**
  32654. * Sets the current filter is to blurred VSM.
  32655. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  32656. */
  32657. useBlurVarianceShadowMap: boolean;
  32658. /**
  32659. * Gets if the current filter is set to ESM.
  32660. */
  32661. /**
  32662. * Sets the current filter is to ESM.
  32663. */
  32664. useExponentialShadowMap: boolean;
  32665. /**
  32666. * Gets if the current filter is set to filtered ESM.
  32667. */
  32668. /**
  32669. * Gets if the current filter is set to filtered ESM.
  32670. */
  32671. useBlurExponentialShadowMap: boolean;
  32672. /**
  32673. * Gets if the current filter is set to "close ESM" (using the inverse of the
  32674. * exponential to prevent steep falloff artifacts).
  32675. */
  32676. /**
  32677. * Sets the current filter to "close ESM" (using the inverse of the
  32678. * exponential to prevent steep falloff artifacts).
  32679. */
  32680. useCloseExponentialShadowMap: boolean;
  32681. /**
  32682. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  32683. * exponential to prevent steep falloff artifacts).
  32684. */
  32685. /**
  32686. * Sets the current filter to filtered "close ESM" (using the inverse of the
  32687. * exponential to prevent steep falloff artifacts).
  32688. */
  32689. useBlurCloseExponentialShadowMap: boolean;
  32690. /**
  32691. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  32692. */
  32693. /**
  32694. * Sets the current filter to "PCF" (percentage closer filtering).
  32695. */
  32696. usePercentageCloserFiltering: boolean;
  32697. private _filteringQuality;
  32698. /**
  32699. * Gets the PCF or PCSS Quality.
  32700. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  32701. */
  32702. /**
  32703. * Sets the PCF or PCSS Quality.
  32704. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  32705. */
  32706. filteringQuality: number;
  32707. /**
  32708. * Gets if the current filter is set to "PCSS" (contact hardening).
  32709. */
  32710. /**
  32711. * Sets the current filter to "PCSS" (contact hardening).
  32712. */
  32713. useContactHardeningShadow: boolean;
  32714. private _contactHardeningLightSizeUVRatio;
  32715. /**
  32716. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  32717. * Using a ratio helps keeping shape stability independently of the map size.
  32718. *
  32719. * It does not account for the light projection as it was having too much
  32720. * instability during the light setup or during light position changes.
  32721. *
  32722. * Only valid if useContactHardeningShadow is true.
  32723. */
  32724. /**
  32725. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  32726. * Using a ratio helps keeping shape stability independently of the map size.
  32727. *
  32728. * It does not account for the light projection as it was having too much
  32729. * instability during the light setup or during light position changes.
  32730. *
  32731. * Only valid if useContactHardeningShadow is true.
  32732. */
  32733. contactHardeningLightSizeUVRatio: number;
  32734. private _darkness;
  32735. /**
  32736. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  32737. * 0 means strongest and 1 would means no shadow.
  32738. * @returns the darkness.
  32739. */
  32740. getDarkness(): number;
  32741. /**
  32742. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  32743. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  32744. * @returns the shadow generator allowing fluent coding.
  32745. */
  32746. setDarkness(darkness: number): ShadowGenerator;
  32747. private _transparencyShadow;
  32748. /**
  32749. * Sets the ability to have transparent shadow (boolean).
  32750. * @param transparent True if transparent else False
  32751. * @returns the shadow generator allowing fluent coding
  32752. */
  32753. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  32754. private _shadowMap;
  32755. private _shadowMap2;
  32756. /**
  32757. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  32758. * @returns The render target texture if present otherwise, null
  32759. */
  32760. getShadowMap(): Nullable<RenderTargetTexture>;
  32761. /**
  32762. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  32763. * @returns The render target texture if the shadow map is present otherwise, null
  32764. */
  32765. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  32766. /**
  32767. * Helper function to add a mesh and its descendants to the list of shadow casters.
  32768. * @param mesh Mesh to add
  32769. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  32770. * @returns the Shadow Generator itself
  32771. */
  32772. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  32773. /**
  32774. * Helper function to remove a mesh and its descendants from the list of shadow casters
  32775. * @param mesh Mesh to remove
  32776. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  32777. * @returns the Shadow Generator itself
  32778. */
  32779. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  32780. /**
  32781. * Controls the extent to which the shadows fade out at the edge of the frustum
  32782. * Used only by directionals and spots
  32783. */
  32784. frustumEdgeFalloff: number;
  32785. private _light;
  32786. /**
  32787. * Returns the associated light object.
  32788. * @returns the light generating the shadow
  32789. */
  32790. getLight(): IShadowLight;
  32791. /**
  32792. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  32793. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  32794. * It might on the other hand introduce peter panning.
  32795. */
  32796. forceBackFacesOnly: boolean;
  32797. private _scene;
  32798. private _lightDirection;
  32799. private _effect;
  32800. private _viewMatrix;
  32801. private _projectionMatrix;
  32802. private _transformMatrix;
  32803. private _cachedPosition;
  32804. private _cachedDirection;
  32805. private _cachedDefines;
  32806. private _currentRenderID;
  32807. private _boxBlurPostprocess;
  32808. private _kernelBlurXPostprocess;
  32809. private _kernelBlurYPostprocess;
  32810. private _blurPostProcesses;
  32811. private _mapSize;
  32812. private _currentFaceIndex;
  32813. private _currentFaceIndexCache;
  32814. private _textureType;
  32815. private _defaultTextureMatrix;
  32816. /**
  32817. * Creates a ShadowGenerator object.
  32818. * A ShadowGenerator is the required tool to use the shadows.
  32819. * Each light casting shadows needs to use its own ShadowGenerator.
  32820. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  32821. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  32822. * @param light The light object generating the shadows.
  32823. * @param useFullFloatFirst 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.
  32824. */
  32825. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  32826. private _initializeGenerator();
  32827. private _initializeShadowMap();
  32828. private _initializeBlurRTTAndPostProcesses();
  32829. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  32830. private _renderSubMeshForShadowMap(subMesh);
  32831. private _applyFilterValues();
  32832. /**
  32833. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  32834. * @param onCompiled Callback triggered at the and of the effects compilation
  32835. * @param options Sets of optional options forcing the compilation with different modes
  32836. */
  32837. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  32838. useInstances: boolean;
  32839. }>): void;
  32840. /**
  32841. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  32842. * @param options Sets of optional options forcing the compilation with different modes
  32843. * @returns A promise that resolves when the compilation completes
  32844. */
  32845. forceCompilationAsync(options?: Partial<{
  32846. useInstances: boolean;
  32847. }>): Promise<void>;
  32848. /**
  32849. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  32850. * @param subMesh The submesh we want to render in the shadow map
  32851. * @param useInstances Defines wether will draw in the map using instances
  32852. * @returns true if ready otherwise, false
  32853. */
  32854. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  32855. /**
  32856. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  32857. * @param defines Defines of the material we want to update
  32858. * @param lightIndex Index of the light in the enabled light list of the material
  32859. */
  32860. prepareDefines(defines: any, lightIndex: number): void;
  32861. /**
  32862. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  32863. * defined in the generator but impacting the effect).
  32864. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  32865. * @param effect The effect we are binfing the information for
  32866. */
  32867. bindShadowLight(lightIndex: string, effect: Effect): void;
  32868. /**
  32869. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  32870. * (eq to shadow prjection matrix * light transform matrix)
  32871. * @returns The transform matrix used to create the shadow map
  32872. */
  32873. getTransformMatrix(): Matrix;
  32874. /**
  32875. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  32876. * Cube and 2D textures for instance.
  32877. */
  32878. recreateShadowMap(): void;
  32879. private _disposeBlurPostProcesses();
  32880. private _disposeRTTandPostProcesses();
  32881. /**
  32882. * Disposes the ShadowGenerator.
  32883. * Returns nothing.
  32884. */
  32885. dispose(): void;
  32886. /**
  32887. * Serializes the shadow generator setup to a json object.
  32888. * @returns The serialized JSON object
  32889. */
  32890. serialize(): any;
  32891. /**
  32892. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  32893. * @param parsedShadowGenerator The JSON object to parse
  32894. * @param scene The scene to create the shadow map for
  32895. * @returns The parsed shadow generator
  32896. */
  32897. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  32898. }
  32899. }
  32900. declare module BABYLON {
  32901. }
  32902. declare module BABYLON {
  32903. /**
  32904. * Background material used to create an efficient environement around your scene.
  32905. */
  32906. class BackgroundMaterial extends PushMaterial {
  32907. /**
  32908. * Standard reflectance value at parallel view angle.
  32909. */
  32910. static StandardReflectance0: number;
  32911. /**
  32912. * Standard reflectance value at grazing angle.
  32913. */
  32914. static StandardReflectance90: number;
  32915. protected _primaryColor: Color3;
  32916. /**
  32917. * Key light Color (multiply against the environement texture)
  32918. */
  32919. primaryColor: Color3;
  32920. protected __perceptualColor: Nullable<Color3>;
  32921. /**
  32922. * Experimental Internal Use Only.
  32923. *
  32924. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  32925. * This acts as a helper to set the primary color to a more "human friendly" value.
  32926. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  32927. * output color as close as possible from the chosen value.
  32928. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  32929. * part of lighting setup.)
  32930. */
  32931. _perceptualColor: Nullable<Color3>;
  32932. protected _primaryColorShadowLevel: float;
  32933. /**
  32934. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  32935. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  32936. */
  32937. primaryColorShadowLevel: float;
  32938. protected _primaryColorHighlightLevel: float;
  32939. /**
  32940. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  32941. * The primary color is used at the level chosen to define what the white area would look.
  32942. */
  32943. primaryColorHighlightLevel: float;
  32944. protected _reflectionTexture: Nullable<BaseTexture>;
  32945. /**
  32946. * Reflection Texture used in the material.
  32947. * Should be author in a specific way for the best result (refer to the documentation).
  32948. */
  32949. reflectionTexture: Nullable<BaseTexture>;
  32950. protected _reflectionBlur: float;
  32951. /**
  32952. * Reflection Texture level of blur.
  32953. *
  32954. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  32955. * texture twice.
  32956. */
  32957. reflectionBlur: float;
  32958. protected _diffuseTexture: Nullable<BaseTexture>;
  32959. /**
  32960. * Diffuse Texture used in the material.
  32961. * Should be author in a specific way for the best result (refer to the documentation).
  32962. */
  32963. diffuseTexture: Nullable<BaseTexture>;
  32964. protected _shadowLights: Nullable<IShadowLight[]>;
  32965. /**
  32966. * Specify the list of lights casting shadow on the material.
  32967. * All scene shadow lights will be included if null.
  32968. */
  32969. shadowLights: Nullable<IShadowLight[]>;
  32970. protected _shadowLevel: float;
  32971. /**
  32972. * Helps adjusting the shadow to a softer level if required.
  32973. * 0 means black shadows and 1 means no shadows.
  32974. */
  32975. shadowLevel: float;
  32976. protected _sceneCenter: Vector3;
  32977. /**
  32978. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  32979. * It is usually zero but might be interesting to modify according to your setup.
  32980. */
  32981. sceneCenter: Vector3;
  32982. protected _opacityFresnel: boolean;
  32983. /**
  32984. * This helps specifying that the material is falling off to the sky box at grazing angle.
  32985. * This helps ensuring a nice transition when the camera goes under the ground.
  32986. */
  32987. opacityFresnel: boolean;
  32988. protected _reflectionFresnel: boolean;
  32989. /**
  32990. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  32991. * This helps adding a mirror texture on the ground.
  32992. */
  32993. reflectionFresnel: boolean;
  32994. protected _reflectionFalloffDistance: number;
  32995. /**
  32996. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  32997. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  32998. */
  32999. reflectionFalloffDistance: number;
  33000. protected _reflectionAmount: number;
  33001. /**
  33002. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  33003. */
  33004. reflectionAmount: number;
  33005. protected _reflectionReflectance0: number;
  33006. /**
  33007. * This specifies the weight of the reflection at grazing angle.
  33008. */
  33009. reflectionReflectance0: number;
  33010. protected _reflectionReflectance90: number;
  33011. /**
  33012. * This specifies the weight of the reflection at a perpendicular point of view.
  33013. */
  33014. reflectionReflectance90: number;
  33015. /**
  33016. * Sets the reflection reflectance fresnel values according to the default standard
  33017. * empirically know to work well :-)
  33018. */
  33019. reflectionStandardFresnelWeight: number;
  33020. protected _useRGBColor: boolean;
  33021. /**
  33022. * Helps to directly use the maps channels instead of their level.
  33023. */
  33024. useRGBColor: boolean;
  33025. protected _enableNoise: boolean;
  33026. /**
  33027. * This helps reducing the banding effect that could occur on the background.
  33028. */
  33029. enableNoise: boolean;
  33030. /**
  33031. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  33032. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  33033. * Recommended to be keep at 1.0 except for special cases.
  33034. */
  33035. fovMultiplier: number;
  33036. private _fovMultiplier;
  33037. /**
  33038. * Enable the FOV adjustment feature controlled by fovMultiplier.
  33039. */
  33040. useEquirectangularFOV: boolean;
  33041. private _maxSimultaneousLights;
  33042. /**
  33043. * Number of Simultaneous lights allowed on the material.
  33044. */
  33045. maxSimultaneousLights: int;
  33046. /**
  33047. * Default configuration related to image processing available in the Background Material.
  33048. */
  33049. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33050. /**
  33051. * Keep track of the image processing observer to allow dispose and replace.
  33052. */
  33053. private _imageProcessingObserver;
  33054. /**
  33055. * Attaches a new image processing configuration to the PBR Material.
  33056. * @param configuration (if null the scene configuration will be use)
  33057. */
  33058. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  33059. /**
  33060. * Gets the image processing configuration used either in this material.
  33061. */
  33062. /**
  33063. * Sets the Default image processing configuration used either in the this material.
  33064. *
  33065. * If sets to null, the scene one is in use.
  33066. */
  33067. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  33068. /**
  33069. * Gets wether the color curves effect is enabled.
  33070. */
  33071. /**
  33072. * Sets wether the color curves effect is enabled.
  33073. */
  33074. cameraColorCurvesEnabled: boolean;
  33075. /**
  33076. * Gets wether the color grading effect is enabled.
  33077. */
  33078. /**
  33079. * Gets wether the color grading effect is enabled.
  33080. */
  33081. cameraColorGradingEnabled: boolean;
  33082. /**
  33083. * Gets wether tonemapping is enabled or not.
  33084. */
  33085. /**
  33086. * Sets wether tonemapping is enabled or not
  33087. */
  33088. cameraToneMappingEnabled: boolean;
  33089. /**
  33090. * The camera exposure used on this material.
  33091. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33092. * This corresponds to a photographic exposure.
  33093. */
  33094. /**
  33095. * The camera exposure used on this material.
  33096. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33097. * This corresponds to a photographic exposure.
  33098. */
  33099. cameraExposure: float;
  33100. /**
  33101. * Gets The camera contrast used on this material.
  33102. */
  33103. /**
  33104. * Sets The camera contrast used on this material.
  33105. */
  33106. cameraContrast: float;
  33107. /**
  33108. * Gets the Color Grading 2D Lookup Texture.
  33109. */
  33110. /**
  33111. * Sets the Color Grading 2D Lookup Texture.
  33112. */
  33113. cameraColorGradingTexture: Nullable<BaseTexture>;
  33114. /**
  33115. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33116. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33117. * 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;
  33118. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33119. */
  33120. /**
  33121. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33122. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33123. * 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;
  33124. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33125. */
  33126. cameraColorCurves: Nullable<ColorCurves>;
  33127. /**
  33128. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  33129. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  33130. */
  33131. switchToBGR: boolean;
  33132. private _renderTargets;
  33133. private _reflectionControls;
  33134. private _white;
  33135. private _primaryShadowColor;
  33136. private _primaryHighlightColor;
  33137. /**
  33138. * Instantiates a Background Material in the given scene
  33139. * @param name The friendly name of the material
  33140. * @param scene The scene to add the material to
  33141. */
  33142. constructor(name: string, scene: Scene);
  33143. /**
  33144. * The entire material has been created in order to prevent overdraw.
  33145. * @returns false
  33146. */
  33147. needAlphaTesting(): boolean;
  33148. /**
  33149. * The entire material has been created in order to prevent overdraw.
  33150. * @returns true if blending is enable
  33151. */
  33152. needAlphaBlending(): boolean;
  33153. /**
  33154. * Checks wether the material is ready to be rendered for a given mesh.
  33155. * @param mesh The mesh to render
  33156. * @param subMesh The submesh to check against
  33157. * @param useInstances Specify wether or not the material is used with instances
  33158. * @returns true if all the dependencies are ready (Textures, Effects...)
  33159. */
  33160. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  33161. /**
  33162. * Compute the primary color according to the chosen perceptual color.
  33163. */
  33164. private _computePrimaryColorFromPerceptualColor();
  33165. /**
  33166. * Compute the highlights and shadow colors according to their chosen levels.
  33167. */
  33168. private _computePrimaryColors();
  33169. /**
  33170. * Build the uniform buffer used in the material.
  33171. */
  33172. buildUniformLayout(): void;
  33173. /**
  33174. * Unbind the material.
  33175. */
  33176. unbind(): void;
  33177. /**
  33178. * Bind only the world matrix to the material.
  33179. * @param world The world matrix to bind.
  33180. */
  33181. bindOnlyWorldMatrix(world: Matrix): void;
  33182. /**
  33183. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  33184. * @param world The world matrix to bind.
  33185. * @param subMesh The submesh to bind for.
  33186. */
  33187. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  33188. /**
  33189. * Dispose the material.
  33190. * @param forceDisposeEffect Force disposal of the associated effect.
  33191. * @param forceDisposeTextures Force disposal of the associated textures.
  33192. */
  33193. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  33194. /**
  33195. * Clones the material.
  33196. * @param name The cloned name.
  33197. * @returns The cloned material.
  33198. */
  33199. clone(name: string): BackgroundMaterial;
  33200. /**
  33201. * Serializes the current material to its JSON representation.
  33202. * @returns The JSON representation.
  33203. */
  33204. serialize(): any;
  33205. /**
  33206. * Gets the class name of the material
  33207. * @returns "BackgroundMaterial"
  33208. */
  33209. getClassName(): string;
  33210. /**
  33211. * Parse a JSON input to create back a background material.
  33212. * @param source The JSON data to parse
  33213. * @param scene The scene to create the parsed material in
  33214. * @param rootUrl The root url of the assets the material depends upon
  33215. * @returns the instantiated BackgroundMaterial.
  33216. */
  33217. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  33218. }
  33219. }
  33220. declare module BABYLON {
  33221. /**
  33222. * The Physically based material base class of BJS.
  33223. *
  33224. * This offers the main features of a standard PBR material.
  33225. * For more information, please refer to the documentation :
  33226. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  33227. */
  33228. abstract class PBRBaseMaterial extends PushMaterial {
  33229. /**
  33230. * Intensity of the direct lights e.g. the four lights available in your scene.
  33231. * This impacts both the direct diffuse and specular highlights.
  33232. */
  33233. protected _directIntensity: number;
  33234. /**
  33235. * Intensity of the emissive part of the material.
  33236. * This helps controlling the emissive effect without modifying the emissive color.
  33237. */
  33238. protected _emissiveIntensity: number;
  33239. /**
  33240. * Intensity of the environment e.g. how much the environment will light the object
  33241. * either through harmonics for rough material or through the refelction for shiny ones.
  33242. */
  33243. protected _environmentIntensity: number;
  33244. /**
  33245. * This is a special control allowing the reduction of the specular highlights coming from the
  33246. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  33247. */
  33248. protected _specularIntensity: number;
  33249. /**
  33250. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  33251. */
  33252. private _lightingInfos;
  33253. /**
  33254. * Debug Control allowing disabling the bump map on this material.
  33255. */
  33256. protected _disableBumpMap: boolean;
  33257. /**
  33258. * AKA Diffuse Texture in standard nomenclature.
  33259. */
  33260. protected _albedoTexture: BaseTexture;
  33261. /**
  33262. * AKA Occlusion Texture in other nomenclature.
  33263. */
  33264. protected _ambientTexture: BaseTexture;
  33265. /**
  33266. * AKA Occlusion Texture Intensity in other nomenclature.
  33267. */
  33268. protected _ambientTextureStrength: number;
  33269. /**
  33270. * Stores the alpha values in a texture.
  33271. */
  33272. protected _opacityTexture: BaseTexture;
  33273. /**
  33274. * Stores the reflection values in a texture.
  33275. */
  33276. protected _reflectionTexture: BaseTexture;
  33277. /**
  33278. * Stores the refraction values in a texture.
  33279. */
  33280. protected _refractionTexture: BaseTexture;
  33281. /**
  33282. * Stores the emissive values in a texture.
  33283. */
  33284. protected _emissiveTexture: BaseTexture;
  33285. /**
  33286. * AKA Specular texture in other nomenclature.
  33287. */
  33288. protected _reflectivityTexture: BaseTexture;
  33289. /**
  33290. * Used to switch from specular/glossiness to metallic/roughness workflow.
  33291. */
  33292. protected _metallicTexture: BaseTexture;
  33293. /**
  33294. * Specifies the metallic scalar of the metallic/roughness workflow.
  33295. * Can also be used to scale the metalness values of the metallic texture.
  33296. */
  33297. protected _metallic: number;
  33298. /**
  33299. * Specifies the roughness scalar of the metallic/roughness workflow.
  33300. * Can also be used to scale the roughness values of the metallic texture.
  33301. */
  33302. protected _roughness: number;
  33303. /**
  33304. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  33305. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  33306. */
  33307. protected _microSurfaceTexture: BaseTexture;
  33308. /**
  33309. * Stores surface normal data used to displace a mesh in a texture.
  33310. */
  33311. protected _bumpTexture: BaseTexture;
  33312. /**
  33313. * Stores the pre-calculated light information of a mesh in a texture.
  33314. */
  33315. protected _lightmapTexture: BaseTexture;
  33316. /**
  33317. * The color of a material in ambient lighting.
  33318. */
  33319. protected _ambientColor: Color3;
  33320. /**
  33321. * AKA Diffuse Color in other nomenclature.
  33322. */
  33323. protected _albedoColor: Color3;
  33324. /**
  33325. * AKA Specular Color in other nomenclature.
  33326. */
  33327. protected _reflectivityColor: Color3;
  33328. /**
  33329. * The color applied when light is reflected from a material.
  33330. */
  33331. protected _reflectionColor: Color3;
  33332. /**
  33333. * The color applied when light is emitted from a material.
  33334. */
  33335. protected _emissiveColor: Color3;
  33336. /**
  33337. * AKA Glossiness in other nomenclature.
  33338. */
  33339. protected _microSurface: number;
  33340. /**
  33341. * source material index of refraction (IOR)' / 'destination material IOR.
  33342. */
  33343. protected _indexOfRefraction: number;
  33344. /**
  33345. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  33346. */
  33347. protected _invertRefractionY: boolean;
  33348. /**
  33349. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  33350. * Materials half opaque for instance using refraction could benefit from this control.
  33351. */
  33352. protected _linkRefractionWithTransparency: boolean;
  33353. /**
  33354. * Specifies that the material will use the light map as a show map.
  33355. */
  33356. protected _useLightmapAsShadowmap: boolean;
  33357. /**
  33358. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  33359. * makes the reflect vector face the model (under horizon).
  33360. */
  33361. protected _useHorizonOcclusion: boolean;
  33362. /**
  33363. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  33364. * too much the area relying on ambient texture to define their ambient occlusion.
  33365. */
  33366. protected _useRadianceOcclusion: boolean;
  33367. /**
  33368. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  33369. */
  33370. protected _useAlphaFromAlbedoTexture: boolean;
  33371. /**
  33372. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  33373. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  33374. */
  33375. protected _useSpecularOverAlpha: boolean;
  33376. /**
  33377. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  33378. */
  33379. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  33380. /**
  33381. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  33382. */
  33383. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  33384. /**
  33385. * Specifies if the metallic texture contains the roughness information in its green channel.
  33386. */
  33387. protected _useRoughnessFromMetallicTextureGreen: boolean;
  33388. /**
  33389. * Specifies if the metallic texture contains the metallness information in its blue channel.
  33390. */
  33391. protected _useMetallnessFromMetallicTextureBlue: boolean;
  33392. /**
  33393. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  33394. */
  33395. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  33396. /**
  33397. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  33398. */
  33399. protected _useAmbientInGrayScale: boolean;
  33400. /**
  33401. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  33402. * The material will try to infer what glossiness each pixel should be.
  33403. */
  33404. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  33405. /**
  33406. * BJS is using an harcoded light falloff based on a manually sets up range.
  33407. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  33408. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  33409. */
  33410. protected _usePhysicalLightFalloff: boolean;
  33411. /**
  33412. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  33413. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  33414. */
  33415. protected _useRadianceOverAlpha: boolean;
  33416. /**
  33417. * Allows using an object space normal map (instead of tangent space).
  33418. */
  33419. protected _useObjectSpaceNormalMap: boolean;
  33420. /**
  33421. * Allows using the bump map in parallax mode.
  33422. */
  33423. protected _useParallax: boolean;
  33424. /**
  33425. * Allows using the bump map in parallax occlusion mode.
  33426. */
  33427. protected _useParallaxOcclusion: boolean;
  33428. /**
  33429. * Controls the scale bias of the parallax mode.
  33430. */
  33431. protected _parallaxScaleBias: number;
  33432. /**
  33433. * If sets to true, disables all the lights affecting the material.
  33434. */
  33435. protected _disableLighting: boolean;
  33436. /**
  33437. * Number of Simultaneous lights allowed on the material.
  33438. */
  33439. protected _maxSimultaneousLights: number;
  33440. /**
  33441. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  33442. */
  33443. protected _invertNormalMapX: boolean;
  33444. /**
  33445. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  33446. */
  33447. protected _invertNormalMapY: boolean;
  33448. /**
  33449. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  33450. */
  33451. protected _twoSidedLighting: boolean;
  33452. /**
  33453. * Defines the alpha limits in alpha test mode.
  33454. */
  33455. protected _alphaCutOff: number;
  33456. /**
  33457. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  33458. */
  33459. protected _forceAlphaTest: boolean;
  33460. /**
  33461. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33462. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  33463. */
  33464. protected _useAlphaFresnel: boolean;
  33465. /**
  33466. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33467. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  33468. */
  33469. protected _useLinearAlphaFresnel: boolean;
  33470. /**
  33471. * The transparency mode of the material.
  33472. */
  33473. protected _transparencyMode: Nullable<number>;
  33474. /**
  33475. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  33476. * from cos thetav and roughness:
  33477. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  33478. */
  33479. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  33480. /**
  33481. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  33482. */
  33483. protected _forceIrradianceInFragment: boolean;
  33484. /**
  33485. * Force normal to face away from face.
  33486. */
  33487. protected _forceNormalForward: boolean;
  33488. /**
  33489. * Enables specular anti aliasing in the PBR shader.
  33490. * It will both interacts on the Geometry for analytical and IBL lighting.
  33491. * It also prefilter the roughness map based on the bump values.
  33492. */
  33493. protected _enableSpecularAntiAliasing: boolean;
  33494. /**
  33495. * Default configuration related to image processing available in the PBR Material.
  33496. */
  33497. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33498. /**
  33499. * Keep track of the image processing observer to allow dispose and replace.
  33500. */
  33501. private _imageProcessingObserver;
  33502. /**
  33503. * Attaches a new image processing configuration to the PBR Material.
  33504. * @param configuration
  33505. */
  33506. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  33507. /**
  33508. * Stores the available render targets.
  33509. */
  33510. private _renderTargets;
  33511. /**
  33512. * Sets the global ambient color for the material used in lighting calculations.
  33513. */
  33514. private _globalAmbientColor;
  33515. /**
  33516. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  33517. */
  33518. private _useLogarithmicDepth;
  33519. /**
  33520. * If set to true, no lighting calculations will be applied.
  33521. */
  33522. private _unlit;
  33523. /**
  33524. * Instantiates a new PBRMaterial instance.
  33525. *
  33526. * @param name The material name
  33527. * @param scene The scene the material will be use in.
  33528. */
  33529. constructor(name: string, scene: Scene);
  33530. /**
  33531. * Gets the name of the material class.
  33532. */
  33533. getClassName(): string;
  33534. /**
  33535. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  33536. */
  33537. /**
  33538. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  33539. */
  33540. useLogarithmicDepth: boolean;
  33541. /**
  33542. * Gets the current transparency mode.
  33543. */
  33544. /**
  33545. * Sets the transparency mode of the material.
  33546. *
  33547. * | Value | Type | Description |
  33548. * | ----- | ----------------------------------- | ----------- |
  33549. * | 0 | OPAQUE | |
  33550. * | 1 | ALPHATEST | |
  33551. * | 2 | ALPHABLEND | |
  33552. * | 3 | ALPHATESTANDBLEND | |
  33553. *
  33554. */
  33555. transparencyMode: Nullable<number>;
  33556. /**
  33557. * Returns true if alpha blending should be disabled.
  33558. */
  33559. private readonly _disableAlphaBlending;
  33560. /**
  33561. * Specifies whether or not this material should be rendered in alpha blend mode.
  33562. */
  33563. needAlphaBlending(): boolean;
  33564. /**
  33565. * Specifies if the mesh will require alpha blending.
  33566. * @param mesh - BJS mesh.
  33567. */
  33568. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  33569. /**
  33570. * Specifies whether or not this material should be rendered in alpha test mode.
  33571. */
  33572. needAlphaTesting(): boolean;
  33573. /**
  33574. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  33575. */
  33576. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  33577. /**
  33578. * Gets the texture used for the alpha test.
  33579. */
  33580. getAlphaTestTexture(): BaseTexture;
  33581. /**
  33582. * Stores the reflectivity values based on metallic roughness workflow.
  33583. */
  33584. private static _scaledReflectivity;
  33585. /**
  33586. * Specifies that the submesh is ready to be used.
  33587. * @param mesh - BJS mesh.
  33588. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  33589. * @param useInstances - Specifies that instances should be used.
  33590. * @returns - boolean indicating that the submesh is ready or not.
  33591. */
  33592. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  33593. /**
  33594. * Specifies if the material uses metallic roughness workflow.
  33595. * @returns boolean specifiying if the material uses metallic roughness workflow.
  33596. */
  33597. isMetallicWorkflow(): boolean;
  33598. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  33599. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  33600. /**
  33601. * Force shader compilation
  33602. */
  33603. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  33604. clipPlane: boolean;
  33605. }>): void;
  33606. /**
  33607. * Initializes the uniform buffer layout for the shader.
  33608. */
  33609. buildUniformLayout(): void;
  33610. /**
  33611. * Unbinds the textures.
  33612. */
  33613. unbind(): void;
  33614. /**
  33615. * Binds the submesh data.
  33616. * @param world - The world matrix.
  33617. * @param mesh - The BJS mesh.
  33618. * @param subMesh - A submesh of the BJS mesh.
  33619. */
  33620. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  33621. /**
  33622. * Returns the animatable textures.
  33623. * @returns - Array of animatable textures.
  33624. */
  33625. getAnimatables(): IAnimatable[];
  33626. /**
  33627. * Returns the texture used for reflections.
  33628. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  33629. */
  33630. private _getReflectionTexture();
  33631. /**
  33632. * Returns the texture used for refraction or null if none is used.
  33633. * @returns - Refection texture if present. If no refraction texture and refraction
  33634. * is linked with transparency, returns environment texture. Otherwise, returns null.
  33635. */
  33636. private _getRefractionTexture();
  33637. /**
  33638. * Disposes the resources of the material.
  33639. * @param forceDisposeEffect - Forces the disposal of effects.
  33640. * @param forceDisposeTextures - Forces the disposal of all textures.
  33641. */
  33642. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  33643. }
  33644. }
  33645. declare module BABYLON {
  33646. /**
  33647. * The Physically based simple base material of BJS.
  33648. *
  33649. * This enables better naming and convention enforcements on top of the pbrMaterial.
  33650. * It is used as the base class for both the specGloss and metalRough conventions.
  33651. */
  33652. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  33653. /**
  33654. * Number of Simultaneous lights allowed on the material.
  33655. */
  33656. maxSimultaneousLights: number;
  33657. /**
  33658. * If sets to true, disables all the lights affecting the material.
  33659. */
  33660. disableLighting: boolean;
  33661. /**
  33662. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  33663. */
  33664. environmentTexture: BaseTexture;
  33665. /**
  33666. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  33667. */
  33668. invertNormalMapX: boolean;
  33669. /**
  33670. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  33671. */
  33672. invertNormalMapY: boolean;
  33673. /**
  33674. * Normal map used in the model.
  33675. */
  33676. normalTexture: BaseTexture;
  33677. /**
  33678. * Emissivie color used to self-illuminate the model.
  33679. */
  33680. emissiveColor: Color3;
  33681. /**
  33682. * Emissivie texture used to self-illuminate the model.
  33683. */
  33684. emissiveTexture: BaseTexture;
  33685. /**
  33686. * Occlusion Channel Strenght.
  33687. */
  33688. occlusionStrength: number;
  33689. /**
  33690. * Occlusion Texture of the material (adding extra occlusion effects).
  33691. */
  33692. occlusionTexture: BaseTexture;
  33693. /**
  33694. * Defines the alpha limits in alpha test mode.
  33695. */
  33696. alphaCutOff: number;
  33697. /**
  33698. * Gets the current double sided mode.
  33699. */
  33700. /**
  33701. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  33702. */
  33703. doubleSided: boolean;
  33704. lightmapTexture: BaseTexture;
  33705. useLightmapAsShadowmap: boolean;
  33706. /**
  33707. * Return the active textures of the material.
  33708. */
  33709. getActiveTextures(): BaseTexture[];
  33710. hasTexture(texture: BaseTexture): boolean;
  33711. /**
  33712. * Instantiates a new PBRMaterial instance.
  33713. *
  33714. * @param name The material name
  33715. * @param scene The scene the material will be use in.
  33716. */
  33717. constructor(name: string, scene: Scene);
  33718. getClassName(): string;
  33719. }
  33720. }
  33721. declare module BABYLON {
  33722. /**
  33723. * The Physically based material of BJS.
  33724. *
  33725. * This offers the main features of a standard PBR material.
  33726. * For more information, please refer to the documentation :
  33727. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  33728. */
  33729. class PBRMaterial extends PBRBaseMaterial {
  33730. private static _PBRMATERIAL_OPAQUE;
  33731. /**
  33732. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  33733. */
  33734. static readonly PBRMATERIAL_OPAQUE: number;
  33735. /**
  33736. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  33737. */
  33738. private static _PBRMATERIAL_ALPHATEST;
  33739. /**
  33740. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  33741. */
  33742. static readonly PBRMATERIAL_ALPHATEST: number;
  33743. /**
  33744. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  33745. */
  33746. private static _PBRMATERIAL_ALPHABLEND;
  33747. /**
  33748. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  33749. */
  33750. static readonly PBRMATERIAL_ALPHABLEND: number;
  33751. /**
  33752. * Represents the value for Alpha Test and Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  33753. * They are also discarded below the alpha cutoff threshold to improve performances.
  33754. */
  33755. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  33756. /**
  33757. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  33758. * They are also discarded below the alpha cutoff threshold to improve performances.
  33759. */
  33760. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  33761. /**
  33762. * Intensity of the direct lights e.g. the four lights available in your scene.
  33763. * This impacts both the direct diffuse and specular highlights.
  33764. */
  33765. directIntensity: number;
  33766. /**
  33767. * Intensity of the emissive part of the material.
  33768. * This helps controlling the emissive effect without modifying the emissive color.
  33769. */
  33770. emissiveIntensity: number;
  33771. /**
  33772. * Intensity of the environment e.g. how much the environment will light the object
  33773. * either through harmonics for rough material or through the refelction for shiny ones.
  33774. */
  33775. environmentIntensity: number;
  33776. /**
  33777. * This is a special control allowing the reduction of the specular highlights coming from the
  33778. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  33779. */
  33780. specularIntensity: number;
  33781. /**
  33782. * Debug Control allowing disabling the bump map on this material.
  33783. */
  33784. disableBumpMap: boolean;
  33785. /**
  33786. * AKA Diffuse Texture in standard nomenclature.
  33787. */
  33788. albedoTexture: BaseTexture;
  33789. /**
  33790. * AKA Occlusion Texture in other nomenclature.
  33791. */
  33792. ambientTexture: BaseTexture;
  33793. /**
  33794. * AKA Occlusion Texture Intensity in other nomenclature.
  33795. */
  33796. ambientTextureStrength: number;
  33797. /**
  33798. * Stores the alpha values in a texture.
  33799. */
  33800. opacityTexture: BaseTexture;
  33801. /**
  33802. * Stores the reflection values in a texture.
  33803. */
  33804. reflectionTexture: Nullable<BaseTexture>;
  33805. /**
  33806. * Stores the emissive values in a texture.
  33807. */
  33808. emissiveTexture: BaseTexture;
  33809. /**
  33810. * AKA Specular texture in other nomenclature.
  33811. */
  33812. reflectivityTexture: BaseTexture;
  33813. /**
  33814. * Used to switch from specular/glossiness to metallic/roughness workflow.
  33815. */
  33816. metallicTexture: BaseTexture;
  33817. /**
  33818. * Specifies the metallic scalar of the metallic/roughness workflow.
  33819. * Can also be used to scale the metalness values of the metallic texture.
  33820. */
  33821. metallic: number;
  33822. /**
  33823. * Specifies the roughness scalar of the metallic/roughness workflow.
  33824. * Can also be used to scale the roughness values of the metallic texture.
  33825. */
  33826. roughness: number;
  33827. /**
  33828. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  33829. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  33830. */
  33831. microSurfaceTexture: BaseTexture;
  33832. /**
  33833. * Stores surface normal data used to displace a mesh in a texture.
  33834. */
  33835. bumpTexture: BaseTexture;
  33836. /**
  33837. * Stores the pre-calculated light information of a mesh in a texture.
  33838. */
  33839. lightmapTexture: BaseTexture;
  33840. /**
  33841. * Stores the refracted light information in a texture.
  33842. */
  33843. refractionTexture: BaseTexture;
  33844. /**
  33845. * The color of a material in ambient lighting.
  33846. */
  33847. ambientColor: Color3;
  33848. /**
  33849. * AKA Diffuse Color in other nomenclature.
  33850. */
  33851. albedoColor: Color3;
  33852. /**
  33853. * AKA Specular Color in other nomenclature.
  33854. */
  33855. reflectivityColor: Color3;
  33856. /**
  33857. * The color reflected from the material.
  33858. */
  33859. reflectionColor: Color3;
  33860. /**
  33861. * The color emitted from the material.
  33862. */
  33863. emissiveColor: Color3;
  33864. /**
  33865. * AKA Glossiness in other nomenclature.
  33866. */
  33867. microSurface: number;
  33868. /**
  33869. * source material index of refraction (IOR)' / 'destination material IOR.
  33870. */
  33871. indexOfRefraction: number;
  33872. /**
  33873. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  33874. */
  33875. invertRefractionY: boolean;
  33876. /**
  33877. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  33878. * Materials half opaque for instance using refraction could benefit from this control.
  33879. */
  33880. linkRefractionWithTransparency: boolean;
  33881. useLightmapAsShadowmap: boolean;
  33882. /**
  33883. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  33884. */
  33885. useAlphaFromAlbedoTexture: boolean;
  33886. /**
  33887. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  33888. */
  33889. forceAlphaTest: boolean;
  33890. /**
  33891. * Defines the alpha limits in alpha test mode.
  33892. */
  33893. alphaCutOff: number;
  33894. /**
  33895. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  33896. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  33897. */
  33898. useSpecularOverAlpha: boolean;
  33899. /**
  33900. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  33901. */
  33902. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  33903. /**
  33904. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  33905. */
  33906. useRoughnessFromMetallicTextureAlpha: boolean;
  33907. /**
  33908. * Specifies if the metallic texture contains the roughness information in its green channel.
  33909. */
  33910. useRoughnessFromMetallicTextureGreen: boolean;
  33911. /**
  33912. * Specifies if the metallic texture contains the metallness information in its blue channel.
  33913. */
  33914. useMetallnessFromMetallicTextureBlue: boolean;
  33915. /**
  33916. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  33917. */
  33918. useAmbientOcclusionFromMetallicTextureRed: boolean;
  33919. /**
  33920. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  33921. */
  33922. useAmbientInGrayScale: boolean;
  33923. /**
  33924. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  33925. * The material will try to infer what glossiness each pixel should be.
  33926. */
  33927. useAutoMicroSurfaceFromReflectivityMap: boolean;
  33928. /**
  33929. * BJS is using an harcoded light falloff based on a manually sets up range.
  33930. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  33931. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  33932. */
  33933. usePhysicalLightFalloff: boolean;
  33934. /**
  33935. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  33936. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  33937. */
  33938. useRadianceOverAlpha: boolean;
  33939. /**
  33940. * Allows using an object space normal map (instead of tangent space).
  33941. */
  33942. useObjectSpaceNormalMap: boolean;
  33943. /**
  33944. * Allows using the bump map in parallax mode.
  33945. */
  33946. useParallax: boolean;
  33947. /**
  33948. * Allows using the bump map in parallax occlusion mode.
  33949. */
  33950. useParallaxOcclusion: boolean;
  33951. /**
  33952. * Controls the scale bias of the parallax mode.
  33953. */
  33954. parallaxScaleBias: number;
  33955. /**
  33956. * If sets to true, disables all the lights affecting the material.
  33957. */
  33958. disableLighting: boolean;
  33959. /**
  33960. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  33961. */
  33962. forceIrradianceInFragment: boolean;
  33963. /**
  33964. * Number of Simultaneous lights allowed on the material.
  33965. */
  33966. maxSimultaneousLights: number;
  33967. /**
  33968. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  33969. */
  33970. invertNormalMapX: boolean;
  33971. /**
  33972. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  33973. */
  33974. invertNormalMapY: boolean;
  33975. /**
  33976. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  33977. */
  33978. twoSidedLighting: boolean;
  33979. /**
  33980. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33981. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  33982. */
  33983. useAlphaFresnel: boolean;
  33984. /**
  33985. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33986. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  33987. */
  33988. useLinearAlphaFresnel: boolean;
  33989. /**
  33990. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33991. * And/Or occlude the blended part.
  33992. */
  33993. environmentBRDFTexture: Nullable<BaseTexture>;
  33994. /**
  33995. * Force normal to face away from face.
  33996. */
  33997. forceNormalForward: boolean;
  33998. /**
  33999. * Enables specular anti aliasing in the PBR shader.
  34000. * It will both interacts on the Geometry for analytical and IBL lighting.
  34001. * It also prefilter the roughness map based on the bump values.
  34002. */
  34003. enableSpecularAntiAliasing: boolean;
  34004. /**
  34005. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  34006. * makes the reflect vector face the model (under horizon).
  34007. */
  34008. useHorizonOcclusion: boolean;
  34009. /**
  34010. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  34011. * too much the area relying on ambient texture to define their ambient occlusion.
  34012. */
  34013. useRadianceOcclusion: boolean;
  34014. /**
  34015. * If set to true, no lighting calculations will be applied.
  34016. */
  34017. unlit: boolean;
  34018. /**
  34019. * Gets the image processing configuration used either in this material.
  34020. */
  34021. /**
  34022. * Sets the Default image processing configuration used either in the this material.
  34023. *
  34024. * If sets to null, the scene one is in use.
  34025. */
  34026. imageProcessingConfiguration: ImageProcessingConfiguration;
  34027. /**
  34028. * Gets wether the color curves effect is enabled.
  34029. */
  34030. /**
  34031. * Sets wether the color curves effect is enabled.
  34032. */
  34033. cameraColorCurvesEnabled: boolean;
  34034. /**
  34035. * Gets wether the color grading effect is enabled.
  34036. */
  34037. /**
  34038. * Gets wether the color grading effect is enabled.
  34039. */
  34040. cameraColorGradingEnabled: boolean;
  34041. /**
  34042. * Gets wether tonemapping is enabled or not.
  34043. */
  34044. /**
  34045. * Sets wether tonemapping is enabled or not
  34046. */
  34047. cameraToneMappingEnabled: boolean;
  34048. /**
  34049. * The camera exposure used on this material.
  34050. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  34051. * This corresponds to a photographic exposure.
  34052. */
  34053. /**
  34054. * The camera exposure used on this material.
  34055. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  34056. * This corresponds to a photographic exposure.
  34057. */
  34058. cameraExposure: number;
  34059. /**
  34060. * Gets The camera contrast used on this material.
  34061. */
  34062. /**
  34063. * Sets The camera contrast used on this material.
  34064. */
  34065. cameraContrast: number;
  34066. /**
  34067. * Gets the Color Grading 2D Lookup Texture.
  34068. */
  34069. /**
  34070. * Sets the Color Grading 2D Lookup Texture.
  34071. */
  34072. cameraColorGradingTexture: Nullable<BaseTexture>;
  34073. /**
  34074. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  34075. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  34076. * 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;
  34077. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  34078. */
  34079. /**
  34080. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  34081. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  34082. * 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;
  34083. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  34084. */
  34085. cameraColorCurves: Nullable<ColorCurves>;
  34086. /**
  34087. * Instantiates a new PBRMaterial instance.
  34088. *
  34089. * @param name The material name
  34090. * @param scene The scene the material will be use in.
  34091. */
  34092. constructor(name: string, scene: Scene);
  34093. /**
  34094. * Returns the name of this material class.
  34095. */
  34096. getClassName(): string;
  34097. /**
  34098. * Returns an array of the actively used textures.
  34099. * @returns - Array of BaseTextures
  34100. */
  34101. getActiveTextures(): BaseTexture[];
  34102. /**
  34103. * Checks to see if a texture is used in the material.
  34104. * @param texture - Base texture to use.
  34105. * @returns - Boolean specifying if a texture is used in the material.
  34106. */
  34107. hasTexture(texture: BaseTexture): boolean;
  34108. /**
  34109. * Makes a duplicate of the current material.
  34110. * @param name - name to use for the new material.
  34111. */
  34112. clone(name: string): PBRMaterial;
  34113. /**
  34114. * Serializes this PBR Material.
  34115. * @returns - An object with the serialized material.
  34116. */
  34117. serialize(): any;
  34118. /**
  34119. * Parses a PBR Material from a serialized object.
  34120. * @param source - Serialized object.
  34121. * @param scene - BJS scene instance.
  34122. * @param rootUrl - url for the scene object
  34123. * @returns - PBRMaterial
  34124. */
  34125. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  34126. }
  34127. }
  34128. declare module BABYLON {
  34129. /**
  34130. * The PBR material of BJS following the metal roughness convention.
  34131. *
  34132. * This fits to the PBR convention in the GLTF definition:
  34133. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  34134. */
  34135. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  34136. /**
  34137. * The base color has two different interpretations depending on the value of metalness.
  34138. * When the material is a metal, the base color is the specific measured reflectance value
  34139. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  34140. * of the material.
  34141. */
  34142. baseColor: Color3;
  34143. /**
  34144. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  34145. * well as opacity information in the alpha channel.
  34146. */
  34147. baseTexture: BaseTexture;
  34148. /**
  34149. * Specifies the metallic scalar value of the material.
  34150. * Can also be used to scale the metalness values of the metallic texture.
  34151. */
  34152. metallic: number;
  34153. /**
  34154. * Specifies the roughness scalar value of the material.
  34155. * Can also be used to scale the roughness values of the metallic texture.
  34156. */
  34157. roughness: number;
  34158. /**
  34159. * Texture containing both the metallic value in the B channel and the
  34160. * roughness value in the G channel to keep better precision.
  34161. */
  34162. metallicRoughnessTexture: BaseTexture;
  34163. /**
  34164. * Instantiates a new PBRMetalRoughnessMaterial instance.
  34165. *
  34166. * @param name The material name
  34167. * @param scene The scene the material will be use in.
  34168. */
  34169. constructor(name: string, scene: Scene);
  34170. /**
  34171. * Return the currrent class name of the material.
  34172. */
  34173. getClassName(): string;
  34174. /**
  34175. * Return the active textures of the material.
  34176. */
  34177. getActiveTextures(): BaseTexture[];
  34178. /**
  34179. * Checks to see if a texture is used in the material.
  34180. * @param texture - Base texture to use.
  34181. * @returns - Boolean specifying if a texture is used in the material.
  34182. */
  34183. hasTexture(texture: BaseTexture): boolean;
  34184. /**
  34185. * Makes a duplicate of the current material.
  34186. * @param name - name to use for the new material.
  34187. */
  34188. clone(name: string): PBRMetallicRoughnessMaterial;
  34189. /**
  34190. * Serialize the material to a parsable JSON object.
  34191. */
  34192. serialize(): any;
  34193. /**
  34194. * Parses a JSON object correponding to the serialize function.
  34195. */
  34196. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  34197. }
  34198. }
  34199. declare module BABYLON {
  34200. /**
  34201. * The PBR material of BJS following the specular glossiness convention.
  34202. *
  34203. * This fits to the PBR convention in the GLTF definition:
  34204. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  34205. */
  34206. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  34207. /**
  34208. * Specifies the diffuse color of the material.
  34209. */
  34210. diffuseColor: Color3;
  34211. /**
  34212. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  34213. * channel.
  34214. */
  34215. diffuseTexture: BaseTexture;
  34216. /**
  34217. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  34218. */
  34219. specularColor: Color3;
  34220. /**
  34221. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  34222. */
  34223. glossiness: number;
  34224. /**
  34225. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  34226. */
  34227. specularGlossinessTexture: BaseTexture;
  34228. /**
  34229. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  34230. *
  34231. * @param name The material name
  34232. * @param scene The scene the material will be use in.
  34233. */
  34234. constructor(name: string, scene: Scene);
  34235. /**
  34236. * Return the currrent class name of the material.
  34237. */
  34238. getClassName(): string;
  34239. /**
  34240. * Return the active textures of the material.
  34241. */
  34242. getActiveTextures(): BaseTexture[];
  34243. /**
  34244. * Checks to see if a texture is used in the material.
  34245. * @param texture - Base texture to use.
  34246. * @returns - Boolean specifying if a texture is used in the material.
  34247. */
  34248. hasTexture(texture: BaseTexture): boolean;
  34249. /**
  34250. * Makes a duplicate of the current material.
  34251. * @param name - name to use for the new material.
  34252. */
  34253. clone(name: string): PBRSpecularGlossinessMaterial;
  34254. /**
  34255. * Serialize the material to a parsable JSON object.
  34256. */
  34257. serialize(): any;
  34258. /**
  34259. * Parses a JSON object correponding to the serialize function.
  34260. */
  34261. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  34262. }
  34263. }
  34264. declare module BABYLON {
  34265. class BaseTexture {
  34266. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34267. name: string;
  34268. private _hasAlpha;
  34269. hasAlpha: boolean;
  34270. getAlphaFromRGB: boolean;
  34271. level: number;
  34272. coordinatesIndex: number;
  34273. private _coordinatesMode;
  34274. /**
  34275. * How a texture is mapped.
  34276. *
  34277. * | Value | Type | Description |
  34278. * | ----- | ----------------------------------- | ----------- |
  34279. * | 0 | EXPLICIT_MODE | |
  34280. * | 1 | SPHERICAL_MODE | |
  34281. * | 2 | PLANAR_MODE | |
  34282. * | 3 | CUBIC_MODE | |
  34283. * | 4 | PROJECTION_MODE | |
  34284. * | 5 | SKYBOX_MODE | |
  34285. * | 6 | INVCUBIC_MODE | |
  34286. * | 7 | EQUIRECTANGULAR_MODE | |
  34287. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34288. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34289. */
  34290. coordinatesMode: number;
  34291. /**
  34292. * | Value | Type | Description |
  34293. * | ----- | ------------------ | ----------- |
  34294. * | 0 | CLAMP_ADDRESSMODE | |
  34295. * | 1 | WRAP_ADDRESSMODE | |
  34296. * | 2 | MIRROR_ADDRESSMODE | |
  34297. */
  34298. wrapU: number;
  34299. /**
  34300. * | Value | Type | Description |
  34301. * | ----- | ------------------ | ----------- |
  34302. * | 0 | CLAMP_ADDRESSMODE | |
  34303. * | 1 | WRAP_ADDRESSMODE | |
  34304. * | 2 | MIRROR_ADDRESSMODE | |
  34305. */
  34306. wrapV: number;
  34307. /**
  34308. * | Value | Type | Description |
  34309. * | ----- | ------------------ | ----------- |
  34310. * | 0 | CLAMP_ADDRESSMODE | |
  34311. * | 1 | WRAP_ADDRESSMODE | |
  34312. * | 2 | MIRROR_ADDRESSMODE | |
  34313. */
  34314. wrapR: number;
  34315. anisotropicFilteringLevel: number;
  34316. isCube: boolean;
  34317. is3D: boolean;
  34318. gammaSpace: boolean;
  34319. /**
  34320. * Gets whether or not the texture contains RGBD data.
  34321. */
  34322. readonly isRGBD: boolean;
  34323. invertZ: boolean;
  34324. lodLevelInAlpha: boolean;
  34325. lodGenerationOffset: number;
  34326. lodGenerationScale: number;
  34327. isRenderTarget: boolean;
  34328. readonly uid: string;
  34329. toString(): string;
  34330. getClassName(): string;
  34331. animations: Animation[];
  34332. /**
  34333. * An event triggered when the texture is disposed.
  34334. */
  34335. onDisposeObservable: Observable<BaseTexture>;
  34336. private _onDisposeObserver;
  34337. onDispose: () => void;
  34338. delayLoadState: number;
  34339. private _scene;
  34340. _texture: Nullable<InternalTexture>;
  34341. private _uid;
  34342. readonly isBlocking: boolean;
  34343. constructor(scene: Nullable<Scene>);
  34344. getScene(): Nullable<Scene>;
  34345. getTextureMatrix(): Matrix;
  34346. getReflectionTextureMatrix(): Matrix;
  34347. getInternalTexture(): Nullable<InternalTexture>;
  34348. isReadyOrNotBlocking(): boolean;
  34349. isReady(): boolean;
  34350. private _cachedSize;
  34351. getSize(): ISize;
  34352. getBaseSize(): ISize;
  34353. scale(ratio: number): void;
  34354. readonly canRescale: boolean;
  34355. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  34356. _rebuild(): void;
  34357. delayLoad(): void;
  34358. clone(): Nullable<BaseTexture>;
  34359. readonly textureType: number;
  34360. readonly textureFormat: number;
  34361. /**
  34362. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34363. * This will returns an RGBA array buffer containing either in values (0-255) or
  34364. * float values (0-1) depending of the underlying buffer type.
  34365. * @param faceIndex The face of the texture to read (in case of cube texture)
  34366. * @param level The LOD level of the texture to read (in case of Mip Maps)
  34367. * @returns The Array buffer containing the pixels data.
  34368. */
  34369. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  34370. releaseInternalTexture(): void;
  34371. sphericalPolynomial: Nullable<SphericalPolynomial>;
  34372. readonly _lodTextureHigh: Nullable<BaseTexture>;
  34373. readonly _lodTextureMid: Nullable<BaseTexture>;
  34374. readonly _lodTextureLow: Nullable<BaseTexture>;
  34375. dispose(): void;
  34376. serialize(): any;
  34377. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34378. }
  34379. }
  34380. declare module BABYLON {
  34381. /**
  34382. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  34383. * It can help converting any input color in a desired output one. This can then be used to create effects
  34384. * from sepia, black and white to sixties or futuristic rendering...
  34385. *
  34386. * The only supported format is currently 3dl.
  34387. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  34388. */
  34389. class ColorGradingTexture extends BaseTexture {
  34390. /**
  34391. * The current texture matrix. (will always be identity in color grading texture)
  34392. */
  34393. private _textureMatrix;
  34394. /**
  34395. * The texture URL.
  34396. */
  34397. url: string;
  34398. /**
  34399. * Empty line regex stored for GC.
  34400. */
  34401. private static _noneEmptyLineRegex;
  34402. private _engine;
  34403. /**
  34404. * Instantiates a ColorGradingTexture from the following parameters.
  34405. *
  34406. * @param url The location of the color gradind data (currently only supporting 3dl)
  34407. * @param scene The scene the texture will be used in
  34408. */
  34409. constructor(url: string, scene: Scene);
  34410. /**
  34411. * Returns the texture matrix used in most of the material.
  34412. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  34413. */
  34414. getTextureMatrix(): Matrix;
  34415. /**
  34416. * Occurs when the file being loaded is a .3dl LUT file.
  34417. */
  34418. private load3dlTexture();
  34419. /**
  34420. * Starts the loading process of the texture.
  34421. */
  34422. private loadTexture();
  34423. /**
  34424. * Clones the color gradind texture.
  34425. */
  34426. clone(): ColorGradingTexture;
  34427. /**
  34428. * Called during delayed load for textures.
  34429. */
  34430. delayLoad(): void;
  34431. /**
  34432. * Parses a color grading texture serialized by Babylon.
  34433. * @param parsedTexture The texture information being parsedTexture
  34434. * @param scene The scene to load the texture in
  34435. * @param rootUrl The root url of the data assets to load
  34436. * @return A color gradind texture
  34437. */
  34438. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  34439. /**
  34440. * Serializes the LUT texture to json format.
  34441. */
  34442. serialize(): any;
  34443. }
  34444. }
  34445. declare module BABYLON {
  34446. class CubeTexture extends BaseTexture {
  34447. url: string;
  34448. coordinatesMode: number;
  34449. /**
  34450. * Gets or sets the center of the bounding box associated with the cube texture
  34451. * It must define where the camera used to render the texture was set
  34452. */
  34453. boundingBoxPosition: Vector3;
  34454. private _boundingBoxSize;
  34455. /**
  34456. * Gets or sets the size of the bounding box associated with the cube texture
  34457. * When defined, the cubemap will switch to local mode
  34458. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  34459. * @example https://www.babylonjs-playground.com/#RNASML
  34460. */
  34461. boundingBoxSize: Vector3;
  34462. protected _rotationY: number;
  34463. /**
  34464. * Gets texture matrix rotation angle around Y axis radians.
  34465. */
  34466. /**
  34467. * Sets texture matrix rotation angle around Y axis in radians.
  34468. */
  34469. rotationY: number;
  34470. private _noMipmap;
  34471. private _files;
  34472. private _extensions;
  34473. private _textureMatrix;
  34474. private _format;
  34475. private _createPolynomials;
  34476. /** @hidden */
  34477. readonly _prefiltered: boolean;
  34478. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  34479. /**
  34480. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  34481. * @param url defines the url of the prefiltered texture
  34482. * @param scene defines the scene the texture is attached to
  34483. * @param forcedExtension defines the extension of the file if different from the url
  34484. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  34485. * @return the prefiltered texture
  34486. */
  34487. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  34488. /**
  34489. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  34490. * as prefiltered data.
  34491. * @param rootUrl defines the url of the texture or the root name of the six images
  34492. * @param scene defines the scene the texture is attached to
  34493. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  34494. * @param noMipmap defines if mipmaps should be created or not
  34495. * @param files defines the six files to load for the different faces
  34496. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  34497. * @param onError defines a callback triggered in case of error during load
  34498. * @param format defines the internal format to use for the texture once loaded
  34499. * @param prefiltered defines whether or not the texture is created from prefiltered data
  34500. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  34501. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  34502. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  34503. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  34504. * @return the cube texture
  34505. */
  34506. 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);
  34507. delayLoad(): void;
  34508. getReflectionTextureMatrix(): Matrix;
  34509. setReflectionTextureMatrix(value: Matrix): void;
  34510. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  34511. clone(): CubeTexture;
  34512. }
  34513. }
  34514. declare module BABYLON {
  34515. /**
  34516. * A class extending {BABYLON.Texture} allowing drawing on a texture
  34517. * @see http://doc.babylonjs.com/how_to/dynamictexture
  34518. */
  34519. class DynamicTexture extends Texture {
  34520. private _generateMipMaps;
  34521. private _canvas;
  34522. private _context;
  34523. private _engine;
  34524. /**
  34525. * Creates a {BABYLON.DynamicTexture}
  34526. * @param name defines the name of the texture
  34527. * @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
  34528. * @param scene defines the scene where you want the texture
  34529. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  34530. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  34531. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  34532. */
  34533. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  34534. /**
  34535. * Gets the current state of canRescale
  34536. */
  34537. readonly canRescale: boolean;
  34538. private _recreate(textureSize);
  34539. /**
  34540. * Scales the texture
  34541. * @param ratio the scale factor to apply to both width and height
  34542. */
  34543. scale(ratio: number): void;
  34544. /**
  34545. * Resizes the texture
  34546. * @param width the new width
  34547. * @param height the new height
  34548. */
  34549. scaleTo(width: number, height: number): void;
  34550. /**
  34551. * Gets the context of the canvas used by the texture
  34552. * @returns the canvas context of the dynamic texture
  34553. */
  34554. getContext(): CanvasRenderingContext2D;
  34555. /**
  34556. * Clears the texture
  34557. */
  34558. clear(): void;
  34559. /**
  34560. * Updates the texture
  34561. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  34562. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  34563. */
  34564. update(invertY?: boolean, premulAlpha?: boolean): void;
  34565. /**
  34566. * Draws text onto the texture
  34567. * @param text defines the text to be drawn
  34568. * @param x defines the placement of the text from the left
  34569. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  34570. * @param font defines the font to be used with font-style, font-size, font-name
  34571. * @param color defines the color used for the text
  34572. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  34573. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  34574. * @param update defines whether texture is immediately update (default is true)
  34575. */
  34576. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  34577. /**
  34578. * Clones the texture
  34579. * @returns the clone of the texture.
  34580. */
  34581. clone(): DynamicTexture;
  34582. /** @hidden */
  34583. _rebuild(): void;
  34584. }
  34585. }
  34586. declare module BABYLON {
  34587. /**
  34588. * This represents a texture coming from an HDR input.
  34589. *
  34590. * The only supported format is currently panorama picture stored in RGBE format.
  34591. * Example of such files can be found on HDRLib: http://hdrlib.com/
  34592. */
  34593. class HDRCubeTexture extends BaseTexture {
  34594. private static _facesMapping;
  34595. private _generateHarmonics;
  34596. private _noMipmap;
  34597. private _textureMatrix;
  34598. private _size;
  34599. private _onLoad;
  34600. private _onError;
  34601. /**
  34602. * The texture URL.
  34603. */
  34604. url: string;
  34605. /**
  34606. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  34607. */
  34608. coordinatesMode: number;
  34609. protected _isBlocking: boolean;
  34610. /**
  34611. * Gets wether or not the texture is blocking during loading.
  34612. */
  34613. /**
  34614. * Sets wether or not the texture is blocking during loading.
  34615. */
  34616. isBlocking: boolean;
  34617. protected _rotationY: number;
  34618. /**
  34619. * Gets texture matrix rotation angle around Y axis radians.
  34620. */
  34621. /**
  34622. * Sets texture matrix rotation angle around Y axis in radians.
  34623. */
  34624. rotationY: number;
  34625. /**
  34626. * Gets or sets the center of the bounding box associated with the cube texture
  34627. * It must define where the camera used to render the texture was set
  34628. */
  34629. boundingBoxPosition: Vector3;
  34630. private _boundingBoxSize;
  34631. /**
  34632. * Gets or sets the size of the bounding box associated with the cube texture
  34633. * When defined, the cubemap will switch to local mode
  34634. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  34635. * @example https://www.babylonjs-playground.com/#RNASML
  34636. */
  34637. boundingBoxSize: Vector3;
  34638. /**
  34639. * Instantiates an HDRTexture from the following parameters.
  34640. *
  34641. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  34642. * @param scene The scene the texture will be used in
  34643. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  34644. * @param noMipmap Forces to not generate the mipmap if true
  34645. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  34646. * @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)
  34647. * @param reserved Reserved flag for internal use.
  34648. */
  34649. 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>);
  34650. /**
  34651. * Occurs when the file is raw .hdr file.
  34652. */
  34653. private loadTexture();
  34654. clone(): HDRCubeTexture;
  34655. delayLoad(): void;
  34656. getReflectionTextureMatrix(): Matrix;
  34657. setReflectionTextureMatrix(value: Matrix): void;
  34658. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  34659. serialize(): any;
  34660. }
  34661. }
  34662. declare module BABYLON {
  34663. /**
  34664. * Class used to store data associated with WebGL texture data for the engine
  34665. * This class should not be used directly
  34666. */
  34667. class InternalTexture implements IInternalTextureTracker {
  34668. /**
  34669. * The source of the texture data is unknown
  34670. */
  34671. static DATASOURCE_UNKNOWN: number;
  34672. /**
  34673. * Texture data comes from an URL
  34674. */
  34675. static DATASOURCE_URL: number;
  34676. /**
  34677. * Texture data is only used for temporary storage
  34678. */
  34679. static DATASOURCE_TEMP: number;
  34680. /**
  34681. * Texture data comes from raw data (ArrayBuffer)
  34682. */
  34683. static DATASOURCE_RAW: number;
  34684. /**
  34685. * Texture content is dynamic (video or dynamic texture)
  34686. */
  34687. static DATASOURCE_DYNAMIC: number;
  34688. /**
  34689. * Texture content is generated by rendering to it
  34690. */
  34691. static DATASOURCE_RENDERTARGET: number;
  34692. /**
  34693. * Texture content is part of a multi render target process
  34694. */
  34695. static DATASOURCE_MULTIRENDERTARGET: number;
  34696. /**
  34697. * Texture data comes from a cube data file
  34698. */
  34699. static DATASOURCE_CUBE: number;
  34700. /**
  34701. * Texture data comes from a raw cube data
  34702. */
  34703. static DATASOURCE_CUBERAW: number;
  34704. /**
  34705. * Texture data come from a prefiltered cube data file
  34706. */
  34707. static DATASOURCE_CUBEPREFILTERED: number;
  34708. /**
  34709. * Texture content is raw 3D data
  34710. */
  34711. static DATASOURCE_RAW3D: number;
  34712. /**
  34713. * Texture content is a depth texture
  34714. */
  34715. static DATASOURCE_DEPTHTEXTURE: number;
  34716. /**
  34717. * Defines if the texture is ready
  34718. */
  34719. isReady: boolean;
  34720. /**
  34721. * Defines if the texture is a cube texture
  34722. */
  34723. isCube: boolean;
  34724. /**
  34725. * Defines if the texture contains 3D data
  34726. */
  34727. is3D: boolean;
  34728. /**
  34729. * Gets the URL used to load this texture
  34730. */
  34731. url: string;
  34732. /**
  34733. * Gets the sampling mode of the texture
  34734. */
  34735. samplingMode: number;
  34736. /**
  34737. * Gets a boolean indicating if the texture needs mipmaps generation
  34738. */
  34739. generateMipMaps: boolean;
  34740. /**
  34741. * Gets the number of samples used by the texture (WebGL2+ only)
  34742. */
  34743. samples: number;
  34744. /**
  34745. * Gets the type of the texture
  34746. */
  34747. type: number;
  34748. /**
  34749. * Gets the format of the texture
  34750. */
  34751. format: number;
  34752. /**
  34753. * Observable called when the texture is loaded
  34754. */
  34755. onLoadedObservable: Observable<InternalTexture>;
  34756. /**
  34757. * Gets the width of the texture
  34758. */
  34759. width: number;
  34760. /**
  34761. * Gets the height of the texture
  34762. */
  34763. height: number;
  34764. /**
  34765. * Gets the depth of the texture
  34766. */
  34767. depth: number;
  34768. /**
  34769. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  34770. */
  34771. baseWidth: number;
  34772. /**
  34773. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  34774. */
  34775. baseHeight: number;
  34776. /**
  34777. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  34778. */
  34779. baseDepth: number;
  34780. /**
  34781. * Gets a boolean indicating if the texture is inverted on Y axis
  34782. */
  34783. invertY: boolean;
  34784. /**
  34785. * Gets or set the previous tracker in the list
  34786. */
  34787. previous: Nullable<IInternalTextureTracker>;
  34788. /**
  34789. * Gets or set the next tracker in the list
  34790. */
  34791. next: Nullable<IInternalTextureTracker>;
  34792. /** @hidden */
  34793. _initialSlot: number;
  34794. /** @hidden */
  34795. _designatedSlot: number;
  34796. /** @hidden */
  34797. _dataSource: number;
  34798. /** @hidden */
  34799. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  34800. /** @hidden */
  34801. _bufferView: Nullable<ArrayBufferView>;
  34802. /** @hidden */
  34803. _bufferViewArray: Nullable<ArrayBufferView[]>;
  34804. /** @hidden */
  34805. _size: number;
  34806. /** @hidden */
  34807. _extension: string;
  34808. /** @hidden */
  34809. _files: Nullable<string[]>;
  34810. /** @hidden */
  34811. _workingCanvas: HTMLCanvasElement;
  34812. /** @hidden */
  34813. _workingContext: CanvasRenderingContext2D;
  34814. /** @hidden */
  34815. _framebuffer: Nullable<WebGLFramebuffer>;
  34816. /** @hidden */
  34817. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  34818. /** @hidden */
  34819. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  34820. /** @hidden */
  34821. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  34822. /** @hidden */
  34823. _attachments: Nullable<number[]>;
  34824. /** @hidden */
  34825. _cachedCoordinatesMode: Nullable<number>;
  34826. /** @hidden */
  34827. _cachedWrapU: Nullable<number>;
  34828. /** @hidden */
  34829. _cachedWrapV: Nullable<number>;
  34830. /** @hidden */
  34831. _cachedWrapR: Nullable<number>;
  34832. /** @hidden */
  34833. _cachedAnisotropicFilteringLevel: Nullable<number>;
  34834. /** @hidden */
  34835. _isDisabled: boolean;
  34836. /** @hidden */
  34837. _compression: Nullable<string>;
  34838. /** @hidden */
  34839. _generateStencilBuffer: boolean;
  34840. /** @hidden */
  34841. _generateDepthBuffer: boolean;
  34842. /** @hidden */
  34843. _comparisonFunction: number;
  34844. /** @hidden */
  34845. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  34846. /** @hidden */
  34847. _lodGenerationScale: number;
  34848. /** @hidden */
  34849. _lodGenerationOffset: number;
  34850. /** @hidden */
  34851. _lodTextureHigh: BaseTexture;
  34852. /** @hidden */
  34853. _lodTextureMid: BaseTexture;
  34854. /** @hidden */
  34855. _lodTextureLow: BaseTexture;
  34856. /** @hidden */
  34857. _isRGBD: boolean;
  34858. /** @hidden */
  34859. _webGLTexture: Nullable<WebGLTexture>;
  34860. /** @hidden */
  34861. _references: number;
  34862. private _engine;
  34863. /**
  34864. * Gets the Engine the texture belongs to.
  34865. * @returns The babylon engine
  34866. */
  34867. getEngine(): Engine;
  34868. /**
  34869. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  34870. */
  34871. readonly dataSource: number;
  34872. /**
  34873. * Creates a new InternalTexture
  34874. * @param engine defines the engine to use
  34875. * @param dataSource defines the type of data that will be used
  34876. */
  34877. constructor(engine: Engine, dataSource: number);
  34878. /**
  34879. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  34880. */
  34881. incrementReferences(): void;
  34882. /**
  34883. * Change the size of the texture (not the size of the content)
  34884. * @param width defines the new width
  34885. * @param height defines the new height
  34886. * @param depth defines the new depth (1 by default)
  34887. */
  34888. updateSize(width: int, height: int, depth?: int): void;
  34889. /** @hidden */
  34890. _rebuild(): void;
  34891. _swapAndDie(target: InternalTexture): void;
  34892. /**
  34893. * Dispose the current allocated resources
  34894. */
  34895. dispose(): void;
  34896. }
  34897. }
  34898. declare module BABYLON {
  34899. /**
  34900. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  34901. */
  34902. interface IInternalTextureTracker {
  34903. /**
  34904. * Gets or set the previous tracker in the list
  34905. */
  34906. previous: Nullable<IInternalTextureTracker>;
  34907. /**
  34908. * Gets or set the next tracker in the list
  34909. */
  34910. next: Nullable<IInternalTextureTracker>;
  34911. }
  34912. /**
  34913. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  34914. */
  34915. class DummyInternalTextureTracker {
  34916. /**
  34917. * Gets or set the previous tracker in the list
  34918. */
  34919. previous: Nullable<IInternalTextureTracker>;
  34920. /**
  34921. * Gets or set the next tracker in the list
  34922. */
  34923. next: Nullable<IInternalTextureTracker>;
  34924. }
  34925. }
  34926. declare module BABYLON {
  34927. class MirrorTexture extends RenderTargetTexture {
  34928. private scene;
  34929. mirrorPlane: Plane;
  34930. private _transformMatrix;
  34931. private _mirrorMatrix;
  34932. private _savedViewMatrix;
  34933. private _blurX;
  34934. private _blurY;
  34935. private _adaptiveBlurKernel;
  34936. private _blurKernelX;
  34937. private _blurKernelY;
  34938. private _blurRatio;
  34939. blurRatio: number;
  34940. adaptiveBlurKernel: number;
  34941. blurKernel: number;
  34942. blurKernelX: number;
  34943. blurKernelY: number;
  34944. private _autoComputeBlurKernel();
  34945. protected _onRatioRescale(): void;
  34946. private _updateGammaSpace();
  34947. private _imageProcessingConfigChangeObserver;
  34948. constructor(name: string, size: number | {
  34949. width: number;
  34950. height: number;
  34951. } | {
  34952. ratio: number;
  34953. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  34954. private _preparePostProcesses();
  34955. clone(): MirrorTexture;
  34956. serialize(): any;
  34957. dispose(): void;
  34958. }
  34959. }
  34960. declare module BABYLON {
  34961. interface IMultiRenderTargetOptions {
  34962. generateMipMaps?: boolean;
  34963. types?: number[];
  34964. samplingModes?: number[];
  34965. generateDepthBuffer?: boolean;
  34966. generateStencilBuffer?: boolean;
  34967. generateDepthTexture?: boolean;
  34968. textureCount?: number;
  34969. doNotChangeAspectRatio?: boolean;
  34970. defaultType?: number;
  34971. }
  34972. class MultiRenderTarget extends RenderTargetTexture {
  34973. private _internalTextures;
  34974. private _textures;
  34975. readonly isSupported: boolean;
  34976. private _multiRenderTargetOptions;
  34977. readonly textures: Texture[];
  34978. readonly depthTexture: Texture;
  34979. wrapU: number;
  34980. wrapV: number;
  34981. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  34982. _rebuild(): void;
  34983. private _createInternalTextures();
  34984. private _createTextures();
  34985. samples: number;
  34986. resize(size: any): void;
  34987. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  34988. dispose(): void;
  34989. releaseInternalTextures(): void;
  34990. }
  34991. }
  34992. declare module BABYLON {
  34993. class RawTexture extends Texture {
  34994. format: number;
  34995. private _engine;
  34996. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  34997. update(data: ArrayBufferView): void;
  34998. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  34999. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  35000. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  35001. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  35002. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  35003. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  35004. }
  35005. }
  35006. declare module BABYLON {
  35007. /**
  35008. * Class used to store 3D textures containing user data
  35009. */
  35010. class RawTexture3D extends Texture {
  35011. /** Gets or sets the texture format to use */
  35012. format: number;
  35013. private _engine;
  35014. /**
  35015. * Create a new RawTexture3D
  35016. * @param data defines the data of the texture
  35017. * @param width defines the width of the texture
  35018. * @param height defines the height of the texture
  35019. * @param depth defines the depth of the texture
  35020. * @param format defines the texture format to use
  35021. * @param scene defines the hosting scene
  35022. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  35023. * @param invertY defines if texture must be stored with Y axis inverted
  35024. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  35025. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  35026. */
  35027. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  35028. /** Gets or sets the texture format to use */
  35029. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  35030. /**
  35031. * Update the texture with new data
  35032. * @param data defines the data to store in the texture
  35033. */
  35034. update(data: ArrayBufferView): void;
  35035. }
  35036. }
  35037. declare module BABYLON {
  35038. /**
  35039. * Creates a refraction texture used by refraction channel of the standard material.
  35040. * @param name the texture name
  35041. * @param size size of the underlying texture
  35042. * @param scene root scene
  35043. */
  35044. class RefractionTexture extends RenderTargetTexture {
  35045. refractionPlane: Plane;
  35046. depth: number;
  35047. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  35048. clone(): RefractionTexture;
  35049. serialize(): any;
  35050. }
  35051. }
  35052. declare module BABYLON {
  35053. class RenderTargetTexture extends Texture {
  35054. isCube: boolean;
  35055. static _REFRESHRATE_RENDER_ONCE: number;
  35056. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  35057. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  35058. static readonly REFRESHRATE_RENDER_ONCE: number;
  35059. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  35060. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  35061. /**
  35062. * Use this predicate to dynamically define the list of mesh you want to render.
  35063. * If set, the renderList property will be overwritten.
  35064. */
  35065. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  35066. /**
  35067. * Use this list to define the list of mesh you want to render.
  35068. */
  35069. renderList: Nullable<Array<AbstractMesh>>;
  35070. renderParticles: boolean;
  35071. renderSprites: boolean;
  35072. coordinatesMode: number;
  35073. activeCamera: Nullable<Camera>;
  35074. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  35075. useCameraPostProcesses: boolean;
  35076. ignoreCameraViewport: boolean;
  35077. private _postProcessManager;
  35078. private _postProcesses;
  35079. private _resizeObserver;
  35080. /**
  35081. * An event triggered when the texture is unbind.
  35082. */
  35083. onBeforeBindObservable: Observable<RenderTargetTexture>;
  35084. /**
  35085. * An event triggered when the texture is unbind.
  35086. */
  35087. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  35088. private _onAfterUnbindObserver;
  35089. onAfterUnbind: () => void;
  35090. /**
  35091. * An event triggered before rendering the texture
  35092. */
  35093. onBeforeRenderObservable: Observable<number>;
  35094. private _onBeforeRenderObserver;
  35095. onBeforeRender: (faceIndex: number) => void;
  35096. /**
  35097. * An event triggered after rendering the texture
  35098. */
  35099. onAfterRenderObservable: Observable<number>;
  35100. private _onAfterRenderObserver;
  35101. onAfterRender: (faceIndex: number) => void;
  35102. /**
  35103. * An event triggered after the texture clear
  35104. */
  35105. onClearObservable: Observable<Engine>;
  35106. private _onClearObserver;
  35107. onClear: (Engine: Engine) => void;
  35108. clearColor: Color4;
  35109. protected _size: number | {
  35110. width: number;
  35111. height: number;
  35112. };
  35113. protected _initialSizeParameter: number | {
  35114. width: number;
  35115. height: number;
  35116. } | {
  35117. ratio: number;
  35118. };
  35119. protected _sizeRatio: Nullable<number>;
  35120. _generateMipMaps: boolean;
  35121. protected _renderingManager: RenderingManager;
  35122. _waitingRenderList: string[];
  35123. protected _doNotChangeAspectRatio: boolean;
  35124. protected _currentRefreshId: number;
  35125. protected _refreshRate: number;
  35126. protected _textureMatrix: Matrix;
  35127. protected _samples: number;
  35128. protected _renderTargetOptions: RenderTargetCreationOptions;
  35129. readonly renderTargetOptions: RenderTargetCreationOptions;
  35130. protected _engine: Engine;
  35131. protected _onRatioRescale(): void;
  35132. /**
  35133. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  35134. * It must define where the camera used to render the texture is set
  35135. */
  35136. boundingBoxPosition: Vector3;
  35137. private _boundingBoxSize;
  35138. /**
  35139. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  35140. * When defined, the cubemap will switch to local mode
  35141. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  35142. * @example https://www.babylonjs-playground.com/#RNASML
  35143. */
  35144. boundingBoxSize: Vector3;
  35145. /**
  35146. * In case the RTT has been created with a depth texture, get the associated
  35147. * depth texture.
  35148. * Otherwise, return null.
  35149. */
  35150. depthStencilTexture: Nullable<InternalTexture>;
  35151. /**
  35152. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  35153. * or used a shadow, depth texture...
  35154. * @param name The friendly name of the texture
  35155. * @param size The size of the RTT (number if square, or {with: number, height:number} or {ratio:} to define a ratio from the main scene)
  35156. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  35157. * @param generateMipMaps True if mip maps need to be generated after render.
  35158. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  35159. * @param type The type of the buffer in the RTT (int, half float, float...)
  35160. * @param isCube True if a cube texture needs to be created
  35161. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  35162. * @param generateDepthBuffer True to generate a depth buffer
  35163. * @param generateStencilBuffer True to generate a stencil buffer
  35164. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  35165. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  35166. */
  35167. constructor(name: string, size: number | {
  35168. width: number;
  35169. height: number;
  35170. } | {
  35171. ratio: number;
  35172. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  35173. /**
  35174. * Creates a depth stencil texture.
  35175. * This is only available in WebGL 2 or with the depth texture extension available.
  35176. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  35177. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  35178. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  35179. */
  35180. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  35181. private _processSizeParameter(size);
  35182. samples: number;
  35183. resetRefreshCounter(): void;
  35184. refreshRate: number;
  35185. addPostProcess(postProcess: PostProcess): void;
  35186. clearPostProcesses(dispose?: boolean): void;
  35187. removePostProcess(postProcess: PostProcess): void;
  35188. _shouldRender(): boolean;
  35189. getRenderSize(): number;
  35190. getRenderWidth(): number;
  35191. getRenderHeight(): number;
  35192. readonly canRescale: boolean;
  35193. scale(ratio: number): void;
  35194. getReflectionTextureMatrix(): Matrix;
  35195. resize(size: number | {
  35196. width: number;
  35197. height: number;
  35198. } | {
  35199. ratio: number;
  35200. }): void;
  35201. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  35202. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  35203. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  35204. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  35205. /**
  35206. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35207. * This allowed control for front to back rendering or reversly depending of the special needs.
  35208. *
  35209. * @param renderingGroupId The rendering group id corresponding to its index
  35210. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35211. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35212. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35213. */
  35214. 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;
  35215. /**
  35216. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35217. *
  35218. * @param renderingGroupId The rendering group id corresponding to its index
  35219. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35220. */
  35221. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  35222. clone(): RenderTargetTexture;
  35223. serialize(): any;
  35224. disposeFramebufferObjects(): void;
  35225. dispose(): void;
  35226. _rebuild(): void;
  35227. /**
  35228. * Clear the info related to rendering groups preventing retention point in material dispose.
  35229. */
  35230. freeRenderingGroups(): void;
  35231. }
  35232. }
  35233. declare module BABYLON {
  35234. class Texture extends BaseTexture {
  35235. static NEAREST_SAMPLINGMODE: number;
  35236. static NEAREST_NEAREST_MIPLINEAR: number;
  35237. static BILINEAR_SAMPLINGMODE: number;
  35238. static LINEAR_LINEAR_MIPNEAREST: number;
  35239. static TRILINEAR_SAMPLINGMODE: number;
  35240. static LINEAR_LINEAR_MIPLINEAR: number;
  35241. static NEAREST_NEAREST_MIPNEAREST: number;
  35242. static NEAREST_LINEAR_MIPNEAREST: number;
  35243. static NEAREST_LINEAR_MIPLINEAR: number;
  35244. static NEAREST_LINEAR: number;
  35245. static NEAREST_NEAREST: number;
  35246. static LINEAR_NEAREST_MIPNEAREST: number;
  35247. static LINEAR_NEAREST_MIPLINEAR: number;
  35248. static LINEAR_LINEAR: number;
  35249. static LINEAR_NEAREST: number;
  35250. static EXPLICIT_MODE: number;
  35251. static SPHERICAL_MODE: number;
  35252. static PLANAR_MODE: number;
  35253. static CUBIC_MODE: number;
  35254. static PROJECTION_MODE: number;
  35255. static SKYBOX_MODE: number;
  35256. static INVCUBIC_MODE: number;
  35257. static EQUIRECTANGULAR_MODE: number;
  35258. static FIXED_EQUIRECTANGULAR_MODE: number;
  35259. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  35260. static CLAMP_ADDRESSMODE: number;
  35261. static WRAP_ADDRESSMODE: number;
  35262. static MIRROR_ADDRESSMODE: number;
  35263. /**
  35264. * 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
  35265. */
  35266. static UseSerializedUrlIfAny: boolean;
  35267. url: Nullable<string>;
  35268. uOffset: number;
  35269. vOffset: number;
  35270. uScale: number;
  35271. vScale: number;
  35272. uAng: number;
  35273. vAng: number;
  35274. wAng: number;
  35275. /**
  35276. * Defines the center of rotation (U)
  35277. */
  35278. uRotationCenter: number;
  35279. /**
  35280. * Defines the center of rotation (V)
  35281. */
  35282. vRotationCenter: number;
  35283. /**
  35284. * Defines the center of rotation (W)
  35285. */
  35286. wRotationCenter: number;
  35287. readonly noMipmap: boolean;
  35288. private _noMipmap;
  35289. _invertY: boolean;
  35290. private _rowGenerationMatrix;
  35291. private _cachedTextureMatrix;
  35292. private _projectionModeMatrix;
  35293. private _t0;
  35294. private _t1;
  35295. private _t2;
  35296. private _cachedUOffset;
  35297. private _cachedVOffset;
  35298. private _cachedUScale;
  35299. private _cachedVScale;
  35300. private _cachedUAng;
  35301. private _cachedVAng;
  35302. private _cachedWAng;
  35303. private _cachedProjectionMatrixId;
  35304. private _cachedCoordinatesMode;
  35305. _samplingMode: number;
  35306. /** @hidden */
  35307. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  35308. private _deleteBuffer;
  35309. protected _format: Nullable<number>;
  35310. private _delayedOnLoad;
  35311. private _delayedOnError;
  35312. protected _onLoadObservable: Nullable<Observable<Texture>>;
  35313. protected _isBlocking: boolean;
  35314. isBlocking: boolean;
  35315. readonly samplingMode: number;
  35316. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  35317. /**
  35318. * Update the url (and optional buffer) of this texture if url was null during construction.
  35319. * @param url the url of the texture
  35320. * @param buffer the buffer of the texture (defaults to null)
  35321. */
  35322. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  35323. delayLoad(): void;
  35324. updateSamplingMode(samplingMode: number): void;
  35325. private _prepareRowForTextureGeneration(x, y, z, t);
  35326. getTextureMatrix(): Matrix;
  35327. getReflectionTextureMatrix(): Matrix;
  35328. clone(): Texture;
  35329. readonly onLoadObservable: Observable<Texture>;
  35330. serialize(): any;
  35331. getClassName(): string;
  35332. dispose(): void;
  35333. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  35334. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  35335. 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;
  35336. }
  35337. }
  35338. declare module BABYLON {
  35339. /**
  35340. * Settings for finer control over video usage
  35341. */
  35342. interface VideoTextureSettings {
  35343. /**
  35344. * Applies `autoplay` to video, if specified
  35345. */
  35346. autoPlay?: boolean;
  35347. /**
  35348. * Applies `loop` to video, if specified
  35349. */
  35350. loop?: boolean;
  35351. /**
  35352. * Automatically updates internal texture from video at every frame in the render loop
  35353. */
  35354. autoUpdateTexture: boolean;
  35355. /**
  35356. * Image src displayed during the video loading or until the user interacts with the video.
  35357. */
  35358. poster?: string;
  35359. }
  35360. class VideoTexture extends Texture {
  35361. /**
  35362. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35363. */
  35364. readonly autoUpdateTexture: boolean;
  35365. /**
  35366. * The video instance used by the texture internally
  35367. */
  35368. readonly video: HTMLVideoElement;
  35369. private _onUserActionRequestedObservable;
  35370. readonly onUserActionRequestedObservable: Observable<Texture>;
  35371. private _generateMipMaps;
  35372. private _engine;
  35373. private _stillImageCaptured;
  35374. /**
  35375. * Creates a video texture.
  35376. * Sample : https://doc.babylonjs.com/how_to/video_texture
  35377. * @param {string | null} name optional name, will detect from video source, if not defined
  35378. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  35379. * @param {BABYLON.Scene} scene is obviously the current scene.
  35380. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35381. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  35382. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35383. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  35384. */
  35385. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35386. private _getName(src);
  35387. private _getVideo(src);
  35388. private _createInternalTexture;
  35389. private reset;
  35390. /**
  35391. * Internal method to initiate `update`.
  35392. */
  35393. _rebuild(): void;
  35394. /**
  35395. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35396. */
  35397. update(): void;
  35398. /**
  35399. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35400. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35401. */
  35402. updateTexture(isVisible: boolean): void;
  35403. protected _updateInternalTexture: (e?: Event | undefined) => void;
  35404. /**
  35405. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35406. * @param url New url.
  35407. */
  35408. updateURL(url: string): void;
  35409. dispose(): void;
  35410. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35411. minWidth: number;
  35412. maxWidth: number;
  35413. minHeight: number;
  35414. maxHeight: number;
  35415. deviceId: string;
  35416. }): void;
  35417. }
  35418. }
  35419. declare var DracoDecoderModule: any;
  35420. declare var WebAssembly: any;
  35421. declare module BABYLON {
  35422. /**
  35423. * Configuration for Draco compression
  35424. */
  35425. interface IDracoCompressionConfiguration {
  35426. /**
  35427. * Configuration for the decoder.
  35428. */
  35429. decoder?: {
  35430. /**
  35431. * The url to the WebAssembly module.
  35432. */
  35433. wasmUrl?: string;
  35434. /**
  35435. * The url to the WebAssembly binary.
  35436. */
  35437. wasmBinaryUrl?: string;
  35438. /**
  35439. * The url to the fallback JavaScript module.
  35440. */
  35441. fallbackUrl?: string;
  35442. };
  35443. }
  35444. /**
  35445. * Draco compression (https://google.github.io/draco/)
  35446. *
  35447. * This class wraps the Draco module.
  35448. *
  35449. * **Encoder**
  35450. *
  35451. * The encoder is not currently implemented.
  35452. *
  35453. * **Decoder**
  35454. *
  35455. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  35456. *
  35457. * To update the configuration, use the following code:
  35458. * ```javascript
  35459. * BABYLON.DracoCompression.Configuration = {
  35460. * decoder: {
  35461. * wasmUrl: "<url to the WebAssembly library>",
  35462. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  35463. * fallbackUrl: "<url to the fallback JavaScript library>",
  35464. * }
  35465. * };
  35466. * ```
  35467. *
  35468. * 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.
  35469. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  35470. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  35471. *
  35472. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  35473. * ```javascript
  35474. * var dracoCompression = new BABYLON.DracoCompression();
  35475. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  35476. * [BABYLON.VertexBuffer.PositionKind]: 0
  35477. * });
  35478. * ```
  35479. *
  35480. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  35481. */
  35482. class DracoCompression implements IDisposable {
  35483. private static _DecoderModulePromise;
  35484. /**
  35485. * The configuration. Defaults to the following urls:
  35486. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  35487. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  35488. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  35489. */
  35490. static Configuration: IDracoCompressionConfiguration;
  35491. /**
  35492. * Returns true if the decoder is available.
  35493. */
  35494. static readonly DecoderAvailable: boolean;
  35495. /**
  35496. * Constructor
  35497. */
  35498. constructor();
  35499. /**
  35500. * Stop all async operations and release resources.
  35501. */
  35502. dispose(): void;
  35503. /**
  35504. * Decode Draco compressed mesh data to vertex data.
  35505. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  35506. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  35507. * @returns A promise that resolves with the decoded vertex data
  35508. */
  35509. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  35510. [kind: string]: number;
  35511. }): Promise<VertexData>;
  35512. private static _GetDecoderModule();
  35513. private static _LoadScriptAsync(url);
  35514. private static _LoadFileAsync(url);
  35515. }
  35516. }
  35517. declare module BABYLON {
  35518. class CannonJSPlugin implements IPhysicsEnginePlugin {
  35519. private _useDeltaForWorldStep;
  35520. world: any;
  35521. name: string;
  35522. private _physicsMaterials;
  35523. private _fixedTimeStep;
  35524. BJSCANNON: any;
  35525. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  35526. setGravity(gravity: Vector3): void;
  35527. setTimeStep(timeStep: number): void;
  35528. getTimeStep(): number;
  35529. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  35530. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35531. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35532. generatePhysicsBody(impostor: PhysicsImpostor): void;
  35533. private _processChildMeshes(mainImpostor);
  35534. removePhysicsBody(impostor: PhysicsImpostor): void;
  35535. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  35536. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  35537. private _addMaterial(name, friction, restitution);
  35538. private _checkWithEpsilon(value);
  35539. private _createShape(impostor);
  35540. private _createHeightmap(object, pointDepth?);
  35541. private _minus90X;
  35542. private _plus90X;
  35543. private _tmpPosition;
  35544. private _tmpDeltaPosition;
  35545. private _tmpUnityRotation;
  35546. private _updatePhysicsBodyTransformation(impostor);
  35547. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  35548. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  35549. isSupported(): boolean;
  35550. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35551. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35552. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35553. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35554. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  35555. getBodyMass(impostor: PhysicsImpostor): number;
  35556. getBodyFriction(impostor: PhysicsImpostor): number;
  35557. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  35558. getBodyRestitution(impostor: PhysicsImpostor): number;
  35559. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  35560. sleepBody(impostor: PhysicsImpostor): void;
  35561. wakeUpBody(impostor: PhysicsImpostor): void;
  35562. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  35563. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  35564. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  35565. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  35566. getRadius(impostor: PhysicsImpostor): number;
  35567. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  35568. dispose(): void;
  35569. private _extendNamespace();
  35570. }
  35571. }
  35572. declare module BABYLON {
  35573. class OimoJSPlugin implements IPhysicsEnginePlugin {
  35574. world: any;
  35575. name: string;
  35576. BJSOIMO: any;
  35577. constructor(iterations?: number);
  35578. setGravity(gravity: Vector3): void;
  35579. setTimeStep(timeStep: number): void;
  35580. getTimeStep(): number;
  35581. private _tmpImpostorsArray;
  35582. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  35583. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35584. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35585. generatePhysicsBody(impostor: PhysicsImpostor): void;
  35586. private _tmpPositionVector;
  35587. removePhysicsBody(impostor: PhysicsImpostor): void;
  35588. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  35589. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  35590. isSupported(): boolean;
  35591. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  35592. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  35593. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35594. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  35595. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35596. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  35597. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  35598. getBodyMass(impostor: PhysicsImpostor): number;
  35599. getBodyFriction(impostor: PhysicsImpostor): number;
  35600. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  35601. getBodyRestitution(impostor: PhysicsImpostor): number;
  35602. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  35603. sleepBody(impostor: PhysicsImpostor): void;
  35604. wakeUpBody(impostor: PhysicsImpostor): void;
  35605. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  35606. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  35607. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  35608. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  35609. getRadius(impostor: PhysicsImpostor): number;
  35610. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  35611. dispose(): void;
  35612. }
  35613. }
  35614. declare module BABYLON {
  35615. /**
  35616. * Particle emitter emitting particles from the inside of a box.
  35617. * It emits the particles randomly between 2 given directions.
  35618. */
  35619. class BoxParticleEmitter implements IParticleEmitterType {
  35620. /**
  35621. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  35622. */
  35623. direction1: Vector3;
  35624. /**
  35625. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  35626. */
  35627. direction2: Vector3;
  35628. /**
  35629. * 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.
  35630. */
  35631. minEmitBox: Vector3;
  35632. /**
  35633. * 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.
  35634. */
  35635. maxEmitBox: Vector3;
  35636. /**
  35637. * Creates a new instance BoxParticleEmitter
  35638. */
  35639. constructor();
  35640. /**
  35641. * Called by the particle System when the direction is computed for the created particle.
  35642. * @param worldMatrix is the world matrix of the particle system
  35643. * @param directionToUpdate is the direction vector to update with the result
  35644. * @param particle is the particle we are computed the direction for
  35645. */
  35646. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35647. /**
  35648. * Called by the particle System when the position is computed for the created particle.
  35649. * @param worldMatrix is the world matrix of the particle system
  35650. * @param positionToUpdate is the position vector to update with the result
  35651. * @param particle is the particle we are computed the position for
  35652. */
  35653. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35654. /**
  35655. * Clones the current emitter and returns a copy of it
  35656. * @returns the new emitter
  35657. */
  35658. clone(): BoxParticleEmitter;
  35659. /**
  35660. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35661. * @param effect defines the update shader
  35662. */
  35663. applyToShader(effect: Effect): void;
  35664. /**
  35665. * Returns a string to use to update the GPU particles update shader
  35666. * @returns a string containng the defines string
  35667. */
  35668. getEffectDefines(): string;
  35669. /**
  35670. * Returns the string "BoxParticleEmitter"
  35671. * @returns a string containing the class name
  35672. */
  35673. getClassName(): string;
  35674. /**
  35675. * Serializes the particle system to a JSON object.
  35676. * @returns the JSON object
  35677. */
  35678. serialize(): any;
  35679. /**
  35680. * Parse properties from a JSON object
  35681. * @param serializationObject defines the JSON object
  35682. */
  35683. parse(serializationObject: any): void;
  35684. }
  35685. }
  35686. declare module BABYLON {
  35687. /**
  35688. * Particle emitter emitting particles from the inside of a cone.
  35689. * It emits the particles alongside the cone volume from the base to the particle.
  35690. * The emission direction might be randomized.
  35691. */
  35692. class ConeParticleEmitter implements IParticleEmitterType {
  35693. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  35694. directionRandomizer: number;
  35695. private _radius;
  35696. private _angle;
  35697. private _height;
  35698. /**
  35699. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  35700. */
  35701. radiusRange: number;
  35702. /**
  35703. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  35704. */
  35705. heightRange: number;
  35706. /**
  35707. * Gets or sets the radius of the emission cone
  35708. */
  35709. radius: number;
  35710. /**
  35711. * Gets or sets the angle of the emission cone
  35712. */
  35713. angle: number;
  35714. private _buildHeight();
  35715. /**
  35716. * Creates a new instance ConeParticleEmitter
  35717. * @param radius the radius of the emission cone (1 by default)
  35718. * @param angles the cone base angle (PI by default)
  35719. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  35720. */
  35721. constructor(radius?: number, angle?: number,
  35722. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  35723. directionRandomizer?: number);
  35724. /**
  35725. * Called by the particle System when the direction is computed for the created particle.
  35726. * @param worldMatrix is the world matrix of the particle system
  35727. * @param directionToUpdate is the direction vector to update with the result
  35728. * @param particle is the particle we are computed the direction for
  35729. */
  35730. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35731. /**
  35732. * Called by the particle System when the position is computed for the created particle.
  35733. * @param worldMatrix is the world matrix of the particle system
  35734. * @param positionToUpdate is the position vector to update with the result
  35735. * @param particle is the particle we are computed the position for
  35736. */
  35737. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35738. /**
  35739. * Clones the current emitter and returns a copy of it
  35740. * @returns the new emitter
  35741. */
  35742. clone(): ConeParticleEmitter;
  35743. /**
  35744. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35745. * @param effect defines the update shader
  35746. */
  35747. applyToShader(effect: Effect): void;
  35748. /**
  35749. * Returns a string to use to update the GPU particles update shader
  35750. * @returns a string containng the defines string
  35751. */
  35752. getEffectDefines(): string;
  35753. /**
  35754. * Returns the string "ConeParticleEmitter"
  35755. * @returns a string containing the class name
  35756. */
  35757. getClassName(): string;
  35758. /**
  35759. * Serializes the particle system to a JSON object.
  35760. * @returns the JSON object
  35761. */
  35762. serialize(): any;
  35763. /**
  35764. * Parse properties from a JSON object
  35765. * @param serializationObject defines the JSON object
  35766. */
  35767. parse(serializationObject: any): void;
  35768. }
  35769. }
  35770. declare module BABYLON {
  35771. /**
  35772. * Particle emitter represents a volume emitting particles.
  35773. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  35774. */
  35775. interface IParticleEmitterType {
  35776. /**
  35777. * Called by the particle System when the direction is computed for the created particle.
  35778. * @param worldMatrix is the world matrix of the particle system
  35779. * @param directionToUpdate is the direction vector to update with the result
  35780. * @param particle is the particle we are computed the direction for
  35781. */
  35782. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35783. /**
  35784. * Called by the particle System when the position is computed for the created particle.
  35785. * @param worldMatrix is the world matrix of the particle system
  35786. * @param positionToUpdate is the position vector to update with the result
  35787. * @param particle is the particle we are computed the position for
  35788. */
  35789. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35790. /**
  35791. * Clones the current emitter and returns a copy of it
  35792. * @returns the new emitter
  35793. */
  35794. clone(): IParticleEmitterType;
  35795. /**
  35796. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35797. * @param effect defines the update shader
  35798. */
  35799. applyToShader(effect: Effect): void;
  35800. /**
  35801. * Returns a string to use to update the GPU particles update shader
  35802. * @returns the effect defines string
  35803. */
  35804. getEffectDefines(): string;
  35805. /**
  35806. * Returns a string representing the class name
  35807. * @returns a string containing the class name
  35808. */
  35809. getClassName(): string;
  35810. /**
  35811. * Serializes the particle system to a JSON object.
  35812. * @returns the JSON object
  35813. */
  35814. serialize(): any;
  35815. /**
  35816. * Parse properties from a JSON object
  35817. * @param serializationObject defines the JSON object
  35818. */
  35819. parse(serializationObject: any): void;
  35820. }
  35821. }
  35822. declare module BABYLON {
  35823. /**
  35824. * Particle emitter emitting particles from the inside of a sphere.
  35825. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  35826. */
  35827. class SphereParticleEmitter implements IParticleEmitterType {
  35828. /**
  35829. * The radius of the emission sphere.
  35830. */
  35831. radius: number;
  35832. /**
  35833. * How much to randomize the particle direction [0-1].
  35834. */
  35835. directionRandomizer: number;
  35836. /**
  35837. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  35838. */
  35839. radiusRange: number;
  35840. /**
  35841. * Creates a new instance SphereParticleEmitter
  35842. * @param radius the radius of the emission sphere (1 by default)
  35843. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  35844. */
  35845. constructor(
  35846. /**
  35847. * The radius of the emission sphere.
  35848. */
  35849. radius?: number,
  35850. /**
  35851. * How much to randomize the particle direction [0-1].
  35852. */
  35853. directionRandomizer?: number);
  35854. /**
  35855. * Called by the particle System when the direction is computed for the created particle.
  35856. * @param worldMatrix is the world matrix of the particle system
  35857. * @param directionToUpdate is the direction vector to update with the result
  35858. * @param particle is the particle we are computed the direction for
  35859. */
  35860. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35861. /**
  35862. * Called by the particle System when the position is computed for the created particle.
  35863. * @param worldMatrix is the world matrix of the particle system
  35864. * @param positionToUpdate is the position vector to update with the result
  35865. * @param particle is the particle we are computed the position for
  35866. */
  35867. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35868. /**
  35869. * Clones the current emitter and returns a copy of it
  35870. * @returns the new emitter
  35871. */
  35872. clone(): SphereParticleEmitter;
  35873. /**
  35874. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35875. * @param effect defines the update shader
  35876. */
  35877. applyToShader(effect: Effect): void;
  35878. /**
  35879. * Returns a string to use to update the GPU particles update shader
  35880. * @returns a string containng the defines string
  35881. */
  35882. getEffectDefines(): string;
  35883. /**
  35884. * Returns the string "SphereParticleEmitter"
  35885. * @returns a string containing the class name
  35886. */
  35887. getClassName(): string;
  35888. /**
  35889. * Serializes the particle system to a JSON object.
  35890. * @returns the JSON object
  35891. */
  35892. serialize(): any;
  35893. /**
  35894. * Parse properties from a JSON object
  35895. * @param serializationObject defines the JSON object
  35896. */
  35897. parse(serializationObject: any): void;
  35898. }
  35899. /**
  35900. * Particle emitter emitting particles from the inside of a sphere.
  35901. * It emits the particles randomly between two vectors.
  35902. */
  35903. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  35904. /**
  35905. * The min limit of the emission direction.
  35906. */
  35907. direction1: Vector3;
  35908. /**
  35909. * The max limit of the emission direction.
  35910. */
  35911. direction2: Vector3;
  35912. /**
  35913. * Creates a new instance SphereDirectedParticleEmitter
  35914. * @param radius the radius of the emission sphere (1 by default)
  35915. * @param direction1 the min limit of the emission direction (up vector by default)
  35916. * @param direction2 the max limit of the emission direction (up vector by default)
  35917. */
  35918. constructor(radius?: number,
  35919. /**
  35920. * The min limit of the emission direction.
  35921. */
  35922. direction1?: Vector3,
  35923. /**
  35924. * The max limit of the emission direction.
  35925. */
  35926. direction2?: Vector3);
  35927. /**
  35928. * Called by the particle System when the direction is computed for the created particle.
  35929. * @param worldMatrix is the world matrix of the particle system
  35930. * @param directionToUpdate is the direction vector to update with the result
  35931. * @param particle is the particle we are computed the direction for
  35932. */
  35933. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35934. /**
  35935. * Clones the current emitter and returns a copy of it
  35936. * @returns the new emitter
  35937. */
  35938. clone(): SphereDirectedParticleEmitter;
  35939. /**
  35940. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35941. * @param effect defines the update shader
  35942. */
  35943. applyToShader(effect: Effect): void;
  35944. /**
  35945. * Returns a string to use to update the GPU particles update shader
  35946. * @returns a string containng the defines string
  35947. */
  35948. getEffectDefines(): string;
  35949. /**
  35950. * Returns the string "SphereDirectedParticleEmitter"
  35951. * @returns a string containing the class name
  35952. */
  35953. getClassName(): string;
  35954. /**
  35955. * Serializes the particle system to a JSON object.
  35956. * @returns the JSON object
  35957. */
  35958. serialize(): any;
  35959. /**
  35960. * Parse properties from a JSON object
  35961. * @param serializationObject defines the JSON object
  35962. */
  35963. parse(serializationObject: any): void;
  35964. }
  35965. }
  35966. declare module BABYLON {
  35967. /**
  35968. * This represents a set of one or more post processes in Babylon.
  35969. * A post process can be used to apply a shader to a texture after it is rendered.
  35970. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  35971. */
  35972. class PostProcessRenderEffect {
  35973. private _postProcesses;
  35974. private _getPostProcesses;
  35975. private _singleInstance;
  35976. private _cameras;
  35977. private _indicesForCamera;
  35978. /**
  35979. * Name of the effect
  35980. */
  35981. _name: string;
  35982. /**
  35983. * Instantiates a post process render effect.
  35984. * A post process can be used to apply a shader to a texture after it is rendered.
  35985. * @param engine The engine the effect is tied to
  35986. * @param name The name of the effect
  35987. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  35988. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  35989. */
  35990. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  35991. /**
  35992. * Checks if all the post processes in the effect are supported.
  35993. */
  35994. readonly isSupported: boolean;
  35995. /**
  35996. * Updates the current state of the effect
  35997. */
  35998. _update(): void;
  35999. /**
  36000. * Attaches the effect on cameras
  36001. * @param cameras The camera to attach to.
  36002. */
  36003. _attachCameras(cameras: Camera): void;
  36004. /**
  36005. * Attaches the effect on cameras
  36006. * @param cameras The camera to attach to.
  36007. */
  36008. _attachCameras(cameras: Camera[]): void;
  36009. /**
  36010. * Detatches the effect on cameras
  36011. * @param cameras The camera to detatch from.
  36012. */
  36013. _detachCameras(cameras: Camera): void;
  36014. /**
  36015. * Detatches the effect on cameras
  36016. * @param cameras The camera to detatch from.
  36017. */
  36018. _detachCameras(cameras: Camera[]): void;
  36019. /**
  36020. * Enables the effect on given cameras
  36021. * @param cameras The camera to enable.
  36022. */
  36023. _enable(cameras: Camera): void;
  36024. /**
  36025. * Enables the effect on given cameras
  36026. * @param cameras The camera to enable.
  36027. */
  36028. _enable(cameras: Nullable<Camera[]>): void;
  36029. /**
  36030. * Disables the effect on the given cameras
  36031. * @param cameras The camera to disable.
  36032. */
  36033. _disable(cameras: Camera): void;
  36034. /**
  36035. * Disables the effect on the given cameras
  36036. * @param cameras The camera to disable.
  36037. */
  36038. _disable(cameras: Nullable<Camera[]>): void;
  36039. /**
  36040. * Gets a list of the post processes contained in the effect.
  36041. * @param camera The camera to get the post processes on.
  36042. * @returns The list of the post processes in the effect.
  36043. */
  36044. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  36045. }
  36046. }
  36047. declare module BABYLON {
  36048. class PostProcessRenderPipeline {
  36049. private engine;
  36050. private _renderEffects;
  36051. private _renderEffectsForIsolatedPass;
  36052. protected _cameras: Camera[];
  36053. _name: string;
  36054. constructor(engine: Engine, name: string);
  36055. getClassName(): string;
  36056. readonly isSupported: boolean;
  36057. addEffect(renderEffect: PostProcessRenderEffect): void;
  36058. _rebuild(): void;
  36059. _enableEffect(renderEffectName: string, cameras: Camera): void;
  36060. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  36061. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  36062. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  36063. _attachCameras(cameras: Camera, unique: boolean): void;
  36064. _attachCameras(cameras: Camera[], unique: boolean): void;
  36065. _detachCameras(cameras: Camera): void;
  36066. _detachCameras(cameras: Nullable<Camera[]>): void;
  36067. _update(): void;
  36068. _reset(): void;
  36069. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  36070. dispose(): void;
  36071. }
  36072. }
  36073. declare module BABYLON {
  36074. class PostProcessRenderPipelineManager {
  36075. private _renderPipelines;
  36076. constructor();
  36077. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  36078. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  36079. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  36080. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  36081. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  36082. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  36083. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  36084. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  36085. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  36086. update(): void;
  36087. _rebuild(): void;
  36088. dispose(): void;
  36089. }
  36090. }
  36091. declare module BABYLON {
  36092. /**
  36093. * Helper class dealing with the extraction of spherical polynomial dataArray
  36094. * from a cube map.
  36095. */
  36096. class CubeMapToSphericalPolynomialTools {
  36097. private static FileFaces;
  36098. /**
  36099. * Converts a texture to the according Spherical Polynomial data.
  36100. * This extracts the first 3 orders only as they are the only one used in the lighting.
  36101. *
  36102. * @param texture The texture to extract the information from.
  36103. * @return The Spherical Polynomial data.
  36104. */
  36105. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  36106. /**
  36107. * Converts a cubemap to the according Spherical Polynomial data.
  36108. * This extracts the first 3 orders only as they are the only one used in the lighting.
  36109. *
  36110. * @param cubeInfo The Cube map to extract the information from.
  36111. * @return The Spherical Polynomial data.
  36112. */
  36113. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  36114. }
  36115. }
  36116. declare module BABYLON {
  36117. /**
  36118. * Header information of HDR texture files.
  36119. */
  36120. interface HDRInfo {
  36121. /**
  36122. * The height of the texture in pixels.
  36123. */
  36124. height: number;
  36125. /**
  36126. * The width of the texture in pixels.
  36127. */
  36128. width: number;
  36129. /**
  36130. * The index of the beginning of the data in the binary file.
  36131. */
  36132. dataPosition: number;
  36133. }
  36134. /**
  36135. * This groups tools to convert HDR texture to native colors array.
  36136. */
  36137. class HDRTools {
  36138. private static Ldexp(mantissa, exponent);
  36139. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  36140. private static readStringLine(uint8array, startIndex);
  36141. /**
  36142. * Reads header information from an RGBE texture stored in a native array.
  36143. * More information on this format are available here:
  36144. * https://en.wikipedia.org/wiki/RGBE_image_format
  36145. *
  36146. * @param uint8array The binary file stored in native array.
  36147. * @return The header information.
  36148. */
  36149. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  36150. /**
  36151. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  36152. * This RGBE texture needs to store the information as a panorama.
  36153. *
  36154. * More information on this format are available here:
  36155. * https://en.wikipedia.org/wiki/RGBE_image_format
  36156. *
  36157. * @param buffer The binary file stored in an array buffer.
  36158. * @param size The expected size of the extracted cubemap.
  36159. * @return The Cube Map information.
  36160. */
  36161. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  36162. /**
  36163. * Returns the pixels data extracted from an RGBE texture.
  36164. * This pixels will be stored left to right up to down in the R G B order in one array.
  36165. *
  36166. * More information on this format are available here:
  36167. * https://en.wikipedia.org/wiki/RGBE_image_format
  36168. *
  36169. * @param uint8array The binary file stored in an array buffer.
  36170. * @param hdrInfo The header information of the file.
  36171. * @return The pixels data in RGB right to left up to down order.
  36172. */
  36173. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  36174. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  36175. }
  36176. }
  36177. declare module BABYLON {
  36178. /**
  36179. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  36180. */
  36181. interface CubeMapInfo {
  36182. /**
  36183. * The pixel array for the front face.
  36184. * This is stored in format, left to right, up to down format.
  36185. */
  36186. front: Nullable<ArrayBufferView>;
  36187. /**
  36188. * The pixel array for the back face.
  36189. * This is stored in format, left to right, up to down format.
  36190. */
  36191. back: Nullable<ArrayBufferView>;
  36192. /**
  36193. * The pixel array for the left face.
  36194. * This is stored in format, left to right, up to down format.
  36195. */
  36196. left: Nullable<ArrayBufferView>;
  36197. /**
  36198. * The pixel array for the right face.
  36199. * This is stored in format, left to right, up to down format.
  36200. */
  36201. right: Nullable<ArrayBufferView>;
  36202. /**
  36203. * The pixel array for the up face.
  36204. * This is stored in format, left to right, up to down format.
  36205. */
  36206. up: Nullable<ArrayBufferView>;
  36207. /**
  36208. * The pixel array for the down face.
  36209. * This is stored in format, left to right, up to down format.
  36210. */
  36211. down: Nullable<ArrayBufferView>;
  36212. /**
  36213. * The size of the cubemap stored.
  36214. *
  36215. * Each faces will be size * size pixels.
  36216. */
  36217. size: number;
  36218. /**
  36219. * The format of the texture.
  36220. *
  36221. * RGBA, RGB.
  36222. */
  36223. format: number;
  36224. /**
  36225. * The type of the texture data.
  36226. *
  36227. * UNSIGNED_INT, FLOAT.
  36228. */
  36229. type: number;
  36230. /**
  36231. * Specifies whether the texture is in gamma space.
  36232. */
  36233. gammaSpace: boolean;
  36234. }
  36235. /**
  36236. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  36237. */
  36238. class PanoramaToCubeMapTools {
  36239. private static FACE_FRONT;
  36240. private static FACE_BACK;
  36241. private static FACE_RIGHT;
  36242. private static FACE_LEFT;
  36243. private static FACE_DOWN;
  36244. private static FACE_UP;
  36245. /**
  36246. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  36247. *
  36248. * @param float32Array The source data.
  36249. * @param inputWidth The width of the input panorama.
  36250. * @param inputhHeight The height of the input panorama.
  36251. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  36252. * @return The cubemap data
  36253. */
  36254. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  36255. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  36256. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  36257. }
  36258. }
  36259. declare module BABYLON {
  36260. class CustomProceduralTexture extends ProceduralTexture {
  36261. private _animate;
  36262. private _time;
  36263. private _config;
  36264. private _texturePath;
  36265. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  36266. private loadJson(jsonUrl);
  36267. isReady(): boolean;
  36268. render(useCameraPostProcess?: boolean): void;
  36269. updateTextures(): void;
  36270. updateShaderUniforms(): void;
  36271. animate: boolean;
  36272. }
  36273. }
  36274. declare module BABYLON {
  36275. class ProceduralTexture extends Texture {
  36276. isCube: boolean;
  36277. private _size;
  36278. _generateMipMaps: boolean;
  36279. isEnabled: boolean;
  36280. private _currentRefreshId;
  36281. private _refreshRate;
  36282. onGenerated: () => void;
  36283. private _vertexBuffers;
  36284. private _indexBuffer;
  36285. private _effect;
  36286. private _uniforms;
  36287. private _samplers;
  36288. private _fragment;
  36289. _textures: {
  36290. [key: string]: Texture;
  36291. };
  36292. private _floats;
  36293. private _floatsArrays;
  36294. private _colors3;
  36295. private _colors4;
  36296. private _vectors2;
  36297. private _vectors3;
  36298. private _matrices;
  36299. private _fallbackTexture;
  36300. private _fallbackTextureUsed;
  36301. private _engine;
  36302. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  36303. private _createIndexBuffer();
  36304. _rebuild(): void;
  36305. reset(): void;
  36306. isReady(): boolean;
  36307. resetRefreshCounter(): void;
  36308. setFragment(fragment: any): void;
  36309. refreshRate: number;
  36310. _shouldRender(): boolean;
  36311. getRenderSize(): number;
  36312. resize(size: number, generateMipMaps: boolean): void;
  36313. private _checkUniform(uniformName);
  36314. setTexture(name: string, texture: Texture): ProceduralTexture;
  36315. setFloat(name: string, value: number): ProceduralTexture;
  36316. setFloats(name: string, value: number[]): ProceduralTexture;
  36317. setColor3(name: string, value: Color3): ProceduralTexture;
  36318. setColor4(name: string, value: Color4): ProceduralTexture;
  36319. setVector2(name: string, value: Vector2): ProceduralTexture;
  36320. setVector3(name: string, value: Vector3): ProceduralTexture;
  36321. setMatrix(name: string, value: Matrix): ProceduralTexture;
  36322. render(useCameraPostProcess?: boolean): void;
  36323. clone(): ProceduralTexture;
  36324. dispose(): void;
  36325. }
  36326. }
  36327. declare module BABYLON {
  36328. /**
  36329. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  36330. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  36331. */
  36332. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  36333. private _scene;
  36334. private _camerasToBeAttached;
  36335. /**
  36336. * ID of the sharpen post process,
  36337. */
  36338. private readonly SharpenPostProcessId;
  36339. /**
  36340. * ID of the image processing post process;
  36341. */
  36342. readonly ImageProcessingPostProcessId: string;
  36343. /**
  36344. * ID of the Fast Approximate Anti-Aliasing post process;
  36345. */
  36346. readonly FxaaPostProcessId: string;
  36347. /**
  36348. * ID of the chromatic aberration post process,
  36349. */
  36350. private readonly ChromaticAberrationPostProcessId;
  36351. /**
  36352. * ID of the grain post process
  36353. */
  36354. private readonly GrainPostProcessId;
  36355. /**
  36356. * Sharpen post process which will apply a sharpen convolution to enhance edges
  36357. */
  36358. sharpen: SharpenPostProcess;
  36359. private _sharpenEffect;
  36360. private bloom;
  36361. /**
  36362. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  36363. */
  36364. depthOfField: DepthOfFieldEffect;
  36365. /**
  36366. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  36367. */
  36368. fxaa: FxaaPostProcess;
  36369. /**
  36370. * Image post processing pass used to perform operations such as tone mapping or color grading.
  36371. */
  36372. imageProcessing: ImageProcessingPostProcess;
  36373. /**
  36374. * Chromatic aberration post process which will shift rgb colors in the image
  36375. */
  36376. chromaticAberration: ChromaticAberrationPostProcess;
  36377. private _chromaticAberrationEffect;
  36378. /**
  36379. * Grain post process which add noise to the image
  36380. */
  36381. grain: GrainPostProcess;
  36382. private _grainEffect;
  36383. /**
  36384. * Glow post process which adds a glow to emmisive areas of the image
  36385. */
  36386. private _glowLayer;
  36387. /**
  36388. * Animations which can be used to tweak settings over a period of time
  36389. */
  36390. animations: Animation[];
  36391. private _imageProcessingConfigurationObserver;
  36392. private _sharpenEnabled;
  36393. private _bloomEnabled;
  36394. private _depthOfFieldEnabled;
  36395. private _depthOfFieldBlurLevel;
  36396. private _fxaaEnabled;
  36397. private _imageProcessingEnabled;
  36398. private _defaultPipelineTextureType;
  36399. private _bloomScale;
  36400. private _chromaticAberrationEnabled;
  36401. private _grainEnabled;
  36402. private _buildAllowed;
  36403. /**
  36404. * Enable or disable the sharpen process from the pipeline
  36405. */
  36406. sharpenEnabled: boolean;
  36407. private _resizeObserver;
  36408. private _hardwareScaleLevel;
  36409. private _bloomKernel;
  36410. /**
  36411. * Specifies the size of the bloom blur kernel, relative to the final output size
  36412. */
  36413. bloomKernel: number;
  36414. /**
  36415. * Specifies the weight of the bloom in the final rendering
  36416. */
  36417. private _bloomWeight;
  36418. /**
  36419. * Specifies the luma threshold for the area that will be blurred by the bloom
  36420. */
  36421. private _bloomThreshold;
  36422. private _hdr;
  36423. /**
  36424. * The strength of the bloom.
  36425. */
  36426. bloomWeight: number;
  36427. /**
  36428. * The strength of the bloom.
  36429. */
  36430. bloomThreshold: number;
  36431. /**
  36432. * The scale of the bloom, lower value will provide better performance.
  36433. */
  36434. bloomScale: number;
  36435. /**
  36436. * Enable or disable the bloom from the pipeline
  36437. */
  36438. bloomEnabled: boolean;
  36439. private _rebuildBloom();
  36440. /**
  36441. * If the depth of field is enabled.
  36442. */
  36443. depthOfFieldEnabled: boolean;
  36444. /**
  36445. * Blur level of the depth of field effect. (Higher blur will effect performance)
  36446. */
  36447. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  36448. /**
  36449. * If the anti aliasing is enabled.
  36450. */
  36451. fxaaEnabled: boolean;
  36452. private _samples;
  36453. /**
  36454. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  36455. */
  36456. samples: number;
  36457. /**
  36458. * If image processing is enabled.
  36459. */
  36460. imageProcessingEnabled: boolean;
  36461. /**
  36462. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  36463. */
  36464. glowLayerEnabled: boolean;
  36465. /**
  36466. * Enable or disable the chromaticAberration process from the pipeline
  36467. */
  36468. chromaticAberrationEnabled: boolean;
  36469. /**
  36470. * Enable or disable the grain process from the pipeline
  36471. */
  36472. grainEnabled: boolean;
  36473. /**
  36474. * @constructor
  36475. * @param {string} name - The rendering pipeline name (default: "")
  36476. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  36477. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  36478. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  36479. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  36480. */
  36481. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  36482. /**
  36483. * Force the compilation of the entire pipeline.
  36484. */
  36485. prepare(): void;
  36486. private _hasCleared;
  36487. private _prevPostProcess;
  36488. private _prevPrevPostProcess;
  36489. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  36490. private _buildPipeline();
  36491. private _disposePostProcesses(disposeNonRecreated?);
  36492. /**
  36493. * Adds a camera to the pipeline
  36494. * @param camera the camera to be added
  36495. */
  36496. addCamera(camera: Camera): void;
  36497. /**
  36498. * Removes a camera from the pipeline
  36499. * @param camera the camera to remove
  36500. */
  36501. removeCamera(camera: Camera): void;
  36502. /**
  36503. * Dispose of the pipeline and stop all post processes
  36504. */
  36505. dispose(): void;
  36506. /**
  36507. * Serialize the rendering pipeline (Used when exporting)
  36508. * @returns the serialized object
  36509. */
  36510. serialize(): any;
  36511. /**
  36512. * Parse the serialized pipeline
  36513. * @param source Source pipeline.
  36514. * @param scene The scene to load the pipeline to.
  36515. * @param rootUrl The URL of the serialized pipeline.
  36516. * @returns An instantiated pipeline from the serialized object.
  36517. */
  36518. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  36519. }
  36520. }
  36521. declare module BABYLON {
  36522. class LensRenderingPipeline extends PostProcessRenderPipeline {
  36523. /**
  36524. * The chromatic aberration PostProcess id in the pipeline
  36525. */
  36526. LensChromaticAberrationEffect: string;
  36527. /**
  36528. * The highlights enhancing PostProcess id in the pipeline
  36529. */
  36530. HighlightsEnhancingEffect: string;
  36531. /**
  36532. * The depth-of-field PostProcess id in the pipeline
  36533. */
  36534. LensDepthOfFieldEffect: string;
  36535. private _scene;
  36536. private _depthTexture;
  36537. private _grainTexture;
  36538. private _chromaticAberrationPostProcess;
  36539. private _highlightsPostProcess;
  36540. private _depthOfFieldPostProcess;
  36541. private _edgeBlur;
  36542. private _grainAmount;
  36543. private _chromaticAberration;
  36544. private _distortion;
  36545. private _highlightsGain;
  36546. private _highlightsThreshold;
  36547. private _dofDistance;
  36548. private _dofAperture;
  36549. private _dofDarken;
  36550. private _dofPentagon;
  36551. private _blurNoise;
  36552. /**
  36553. * @constructor
  36554. *
  36555. * Effect parameters are as follow:
  36556. * {
  36557. * chromatic_aberration: number; // from 0 to x (1 for realism)
  36558. * edge_blur: number; // from 0 to x (1 for realism)
  36559. * distortion: number; // from 0 to x (1 for realism)
  36560. * grain_amount: number; // from 0 to 1
  36561. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  36562. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  36563. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  36564. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  36565. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  36566. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  36567. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  36568. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  36569. * }
  36570. * Note: if an effect parameter is unset, effect is disabled
  36571. *
  36572. * @param {string} name - The rendering pipeline name
  36573. * @param {object} parameters - An object containing all parameters (see above)
  36574. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  36575. * @param {number} 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)
  36576. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  36577. */
  36578. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  36579. setEdgeBlur(amount: number): void;
  36580. disableEdgeBlur(): void;
  36581. setGrainAmount(amount: number): void;
  36582. disableGrain(): void;
  36583. setChromaticAberration(amount: number): void;
  36584. disableChromaticAberration(): void;
  36585. setEdgeDistortion(amount: number): void;
  36586. disableEdgeDistortion(): void;
  36587. setFocusDistance(amount: number): void;
  36588. disableDepthOfField(): void;
  36589. setAperture(amount: number): void;
  36590. setDarkenOutOfFocus(amount: number): void;
  36591. enablePentagonBokeh(): void;
  36592. disablePentagonBokeh(): void;
  36593. enableNoiseBlur(): void;
  36594. disableNoiseBlur(): void;
  36595. setHighlightsGain(amount: number): void;
  36596. setHighlightsThreshold(amount: number): void;
  36597. disableHighlights(): void;
  36598. /**
  36599. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  36600. */
  36601. dispose(disableDepthRender?: boolean): void;
  36602. private _createChromaticAberrationPostProcess(ratio);
  36603. private _createHighlightsPostProcess(ratio);
  36604. private _createDepthOfFieldPostProcess(ratio);
  36605. private _createGrainTexture();
  36606. }
  36607. }
  36608. declare module BABYLON {
  36609. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  36610. /**
  36611. * The PassPostProcess id in the pipeline that contains the original scene color
  36612. */
  36613. SSAOOriginalSceneColorEffect: string;
  36614. /**
  36615. * The SSAO PostProcess id in the pipeline
  36616. */
  36617. SSAORenderEffect: string;
  36618. /**
  36619. * The horizontal blur PostProcess id in the pipeline
  36620. */
  36621. SSAOBlurHRenderEffect: string;
  36622. /**
  36623. * The vertical blur PostProcess id in the pipeline
  36624. */
  36625. SSAOBlurVRenderEffect: string;
  36626. /**
  36627. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  36628. */
  36629. SSAOCombineRenderEffect: string;
  36630. /**
  36631. * The output strength of the SSAO post-process. Default value is 1.0.
  36632. */
  36633. totalStrength: number;
  36634. /**
  36635. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  36636. */
  36637. maxZ: number;
  36638. /**
  36639. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  36640. */
  36641. minZAspect: number;
  36642. /**
  36643. * Number of samples used for the SSAO calculations. Default value is 8
  36644. */
  36645. private _samples;
  36646. /**
  36647. * Ratio object used for SSAO ratio and blur ratio
  36648. */
  36649. private _ratio;
  36650. /**
  36651. * Dynamically generated sphere sampler.
  36652. */
  36653. private _sampleSphere;
  36654. /**
  36655. * Blur filter offsets
  36656. */
  36657. private _samplerOffsets;
  36658. samples: number;
  36659. /**
  36660. * Are we using bilateral blur ?
  36661. */
  36662. private _expensiveBlur;
  36663. expensiveBlur: boolean;
  36664. /**
  36665. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  36666. */
  36667. radius: number;
  36668. /**
  36669. * The base color of the SSAO post-process
  36670. * The final result is "base + ssao" between [0, 1]
  36671. */
  36672. base: number;
  36673. /**
  36674. * Support test.
  36675. */
  36676. static readonly IsSupported: boolean;
  36677. private _scene;
  36678. private _depthTexture;
  36679. private _normalTexture;
  36680. private _randomTexture;
  36681. private _originalColorPostProcess;
  36682. private _ssaoPostProcess;
  36683. private _blurHPostProcess;
  36684. private _blurVPostProcess;
  36685. private _ssaoCombinePostProcess;
  36686. private _firstUpdate;
  36687. /**
  36688. * @constructor
  36689. * @param {string} name - The rendering pipeline name
  36690. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  36691. * @param {any} 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 }
  36692. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  36693. */
  36694. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  36695. /**
  36696. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  36697. */
  36698. dispose(disableGeometryBufferRenderer?: boolean): void;
  36699. private _createBlurPostProcess(ssaoRatio, blurRatio);
  36700. _rebuild(): void;
  36701. private _generateHemisphere();
  36702. private _createSSAOPostProcess(ratio);
  36703. private _createSSAOCombinePostProcess(ratio);
  36704. private _createRandomTexture();
  36705. /**
  36706. * Serialize the rendering pipeline (Used when exporting)
  36707. * @returns the serialized object
  36708. */
  36709. serialize(): any;
  36710. /**
  36711. * Parse the serialized pipeline
  36712. * @param source Source pipeline.
  36713. * @param scene The scene to load the pipeline to.
  36714. * @param rootUrl The URL of the serialized pipeline.
  36715. * @returns An instantiated pipeline from the serialized object.
  36716. */
  36717. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  36718. }
  36719. }
  36720. declare module BABYLON {
  36721. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  36722. /**
  36723. * The PassPostProcess id in the pipeline that contains the original scene color
  36724. */
  36725. SSAOOriginalSceneColorEffect: string;
  36726. /**
  36727. * The SSAO PostProcess id in the pipeline
  36728. */
  36729. SSAORenderEffect: string;
  36730. /**
  36731. * The horizontal blur PostProcess id in the pipeline
  36732. */
  36733. SSAOBlurHRenderEffect: string;
  36734. /**
  36735. * The vertical blur PostProcess id in the pipeline
  36736. */
  36737. SSAOBlurVRenderEffect: string;
  36738. /**
  36739. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  36740. */
  36741. SSAOCombineRenderEffect: string;
  36742. /**
  36743. * The output strength of the SSAO post-process. Default value is 1.0.
  36744. */
  36745. totalStrength: number;
  36746. /**
  36747. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  36748. */
  36749. radius: number;
  36750. /**
  36751. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  36752. * Must not be equal to fallOff and superior to fallOff.
  36753. * Default value is 0.975
  36754. */
  36755. area: number;
  36756. /**
  36757. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  36758. * Must not be equal to area and inferior to area.
  36759. * Default value is 0.0
  36760. */
  36761. fallOff: number;
  36762. /**
  36763. * The base color of the SSAO post-process
  36764. * The final result is "base + ssao" between [0, 1]
  36765. */
  36766. base: number;
  36767. private _scene;
  36768. private _depthTexture;
  36769. private _randomTexture;
  36770. private _originalColorPostProcess;
  36771. private _ssaoPostProcess;
  36772. private _blurHPostProcess;
  36773. private _blurVPostProcess;
  36774. private _ssaoCombinePostProcess;
  36775. private _firstUpdate;
  36776. /**
  36777. * @constructor
  36778. * @param {string} name - The rendering pipeline name
  36779. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  36780. * @param {any} 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 }
  36781. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  36782. */
  36783. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  36784. /**
  36785. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  36786. */
  36787. dispose(disableDepthRender?: boolean): void;
  36788. private _createBlurPostProcess(ratio);
  36789. _rebuild(): void;
  36790. private _createSSAOPostProcess(ratio);
  36791. private _createSSAOCombinePostProcess(ratio);
  36792. private _createRandomTexture();
  36793. }
  36794. }
  36795. declare module BABYLON {
  36796. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  36797. /**
  36798. * Public members
  36799. */
  36800. originalPostProcess: Nullable<PostProcess>;
  36801. downSampleX4PostProcess: Nullable<PostProcess>;
  36802. brightPassPostProcess: Nullable<PostProcess>;
  36803. blurHPostProcesses: PostProcess[];
  36804. blurVPostProcesses: PostProcess[];
  36805. textureAdderPostProcess: Nullable<PostProcess>;
  36806. volumetricLightPostProcess: Nullable<PostProcess>;
  36807. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  36808. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  36809. volumetricLightMergePostProces: Nullable<PostProcess>;
  36810. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  36811. luminancePostProcess: Nullable<PostProcess>;
  36812. luminanceDownSamplePostProcesses: PostProcess[];
  36813. hdrPostProcess: Nullable<PostProcess>;
  36814. textureAdderFinalPostProcess: Nullable<PostProcess>;
  36815. lensFlareFinalPostProcess: Nullable<PostProcess>;
  36816. hdrFinalPostProcess: Nullable<PostProcess>;
  36817. lensFlarePostProcess: Nullable<PostProcess>;
  36818. lensFlareComposePostProcess: Nullable<PostProcess>;
  36819. motionBlurPostProcess: Nullable<PostProcess>;
  36820. depthOfFieldPostProcess: Nullable<PostProcess>;
  36821. brightThreshold: number;
  36822. blurWidth: number;
  36823. horizontalBlur: boolean;
  36824. exposure: number;
  36825. lensTexture: Nullable<Texture>;
  36826. volumetricLightCoefficient: number;
  36827. volumetricLightPower: number;
  36828. volumetricLightBlurScale: number;
  36829. sourceLight: Nullable<SpotLight | DirectionalLight>;
  36830. hdrMinimumLuminance: number;
  36831. hdrDecreaseRate: number;
  36832. hdrIncreaseRate: number;
  36833. lensColorTexture: Nullable<Texture>;
  36834. lensFlareStrength: number;
  36835. lensFlareGhostDispersal: number;
  36836. lensFlareHaloWidth: number;
  36837. lensFlareDistortionStrength: number;
  36838. lensStarTexture: Nullable<Texture>;
  36839. lensFlareDirtTexture: Nullable<Texture>;
  36840. depthOfFieldDistance: number;
  36841. depthOfFieldBlurWidth: number;
  36842. motionStrength: number;
  36843. animations: Animation[];
  36844. /**
  36845. * Private members
  36846. */
  36847. private _scene;
  36848. private _currentDepthOfFieldSource;
  36849. private _basePostProcess;
  36850. private _hdrCurrentLuminance;
  36851. private _floatTextureType;
  36852. private _ratio;
  36853. private _bloomEnabled;
  36854. private _depthOfFieldEnabled;
  36855. private _vlsEnabled;
  36856. private _lensFlareEnabled;
  36857. private _hdrEnabled;
  36858. private _motionBlurEnabled;
  36859. private _motionBlurSamples;
  36860. private _volumetricLightStepsCount;
  36861. BloomEnabled: boolean;
  36862. DepthOfFieldEnabled: boolean;
  36863. LensFlareEnabled: boolean;
  36864. HDREnabled: boolean;
  36865. VLSEnabled: boolean;
  36866. MotionBlurEnabled: boolean;
  36867. volumetricLightStepsCount: number;
  36868. motionBlurSamples: number;
  36869. /**
  36870. * @constructor
  36871. * @param {string} name - The rendering pipeline name
  36872. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  36873. * @param {any} 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)
  36874. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  36875. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  36876. */
  36877. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  36878. private _buildPipeline();
  36879. private _createDownSampleX4PostProcess(scene, ratio);
  36880. private _createBrightPassPostProcess(scene, ratio);
  36881. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  36882. private _createTextureAdderPostProcess(scene, ratio);
  36883. private _createVolumetricLightPostProcess(scene, ratio);
  36884. private _createLuminancePostProcesses(scene, textureType);
  36885. private _createHdrPostProcess(scene, ratio);
  36886. private _createLensFlarePostProcess(scene, ratio);
  36887. private _createDepthOfFieldPostProcess(scene, ratio);
  36888. private _createMotionBlurPostProcess(scene, ratio);
  36889. private _getDepthTexture();
  36890. private _disposePostProcesses();
  36891. /**
  36892. * Dispose of the pipeline and stop all post processes
  36893. */
  36894. dispose(): void;
  36895. /**
  36896. * Serialize the rendering pipeline (Used when exporting)
  36897. * @returns the serialized object
  36898. */
  36899. serialize(): any;
  36900. /**
  36901. * Parse the serialized pipeline
  36902. * @param source Source pipeline.
  36903. * @param scene The scene to load the pipeline to.
  36904. * @param rootUrl The URL of the serialized pipeline.
  36905. * @returns An instantiated pipeline from the serialized object.
  36906. */
  36907. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  36908. static LuminanceSteps: number;
  36909. }
  36910. }