babylon.d.ts 1.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Set of assets to keep when moving a scene into an asset container.
  7. */
  8. class KeepAssets {
  9. /**
  10. * Cameras to keep.
  11. */
  12. cameras: Camera[];
  13. /**
  14. * Lights to keep.
  15. */
  16. lights: Light[];
  17. /**
  18. * Meshes to keep.
  19. */
  20. meshes: AbstractMesh[];
  21. /**
  22. * Skeletons to keep.
  23. */
  24. skeletons: Skeleton[];
  25. /**
  26. * ParticleSystems to keep.
  27. */
  28. particleSystems: IParticleSystem[];
  29. /**
  30. * Animations to keep.
  31. */
  32. animations: Animation[];
  33. /**
  34. * AnimationGroups to keep.
  35. */
  36. animationGroups: AnimationGroup[];
  37. /**
  38. * MultiMaterials to keep.
  39. */
  40. multiMaterials: MultiMaterial[];
  41. /**
  42. * Materials to keep.
  43. */
  44. materials: Material[];
  45. /**
  46. * MorphTargetManagers to keep.
  47. */
  48. morphTargetManagers: MorphTargetManager[];
  49. /**
  50. * Geometries to keep.
  51. */
  52. geometries: Geometry[];
  53. /**
  54. * TransformNodes to keep.
  55. */
  56. transformNodes: TransformNode[];
  57. /**
  58. * LensFlareSystems to keep.
  59. */
  60. lensFlareSystems: LensFlareSystem[];
  61. /**
  62. * ShadowGenerators to keep.
  63. */
  64. shadowGenerators: ShadowGenerator[];
  65. /**
  66. * ActionManagers to keep.
  67. */
  68. actionManagers: ActionManager[];
  69. /**
  70. * Sounds to keep.
  71. */
  72. sounds: Sound[];
  73. /**
  74. * Textures to keep.
  75. */
  76. textures: Texture[];
  77. }
  78. /**
  79. * Container with a set of assets that can be added or removed from a scene.
  80. */
  81. class AssetContainer {
  82. /**
  83. * The scene the AssetContainer belongs to.
  84. */
  85. scene: Scene;
  86. /**
  87. * Cameras populated in the container.
  88. */
  89. cameras: Camera[];
  90. /**
  91. * Lights populated in the container.
  92. */
  93. lights: Light[];
  94. /**
  95. * Meshes populated in the container.
  96. */
  97. meshes: AbstractMesh[];
  98. /**
  99. * Skeletons populated in the container.
  100. */
  101. skeletons: Skeleton[];
  102. /**
  103. * ParticleSystems populated in the container.
  104. */
  105. particleSystems: IParticleSystem[];
  106. /**
  107. * Animations populated in the container.
  108. */
  109. animations: Animation[];
  110. /**
  111. * AnimationGroups populated in the container.
  112. */
  113. animationGroups: AnimationGroup[];
  114. /**
  115. * MultiMaterials populated in the container.
  116. */
  117. multiMaterials: MultiMaterial[];
  118. /**
  119. * Materials populated in the container.
  120. */
  121. materials: Material[];
  122. /**
  123. * MorphTargetManagers populated in the container.
  124. */
  125. morphTargetManagers: MorphTargetManager[];
  126. /**
  127. * Geometries populated in the container.
  128. */
  129. geometries: Geometry[];
  130. /**
  131. * TransformNodes populated in the container.
  132. */
  133. transformNodes: TransformNode[];
  134. /**
  135. * LensFlareSystems populated in the container.
  136. */
  137. lensFlareSystems: LensFlareSystem[];
  138. /**
  139. * ShadowGenerators populated in the container.
  140. */
  141. shadowGenerators: ShadowGenerator[];
  142. /**
  143. * ActionManagers populated in the container.
  144. */
  145. actionManagers: ActionManager[];
  146. /**
  147. * Sounds populated in the container.
  148. */
  149. sounds: Sound[];
  150. /**
  151. * Textures populated in the container.
  152. */
  153. textures: Texture[];
  154. /**
  155. * Instantiates an AssetContainer.
  156. * @param scene The scene the AssetContainer belongs to.
  157. */
  158. constructor(scene: Scene);
  159. /**
  160. * Adds all the assets from the container to the scene.
  161. */
  162. addAllToScene(): void;
  163. /**
  164. * Removes all the assets in the container from the scene
  165. */
  166. removeAllFromScene(): void;
  167. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  168. /**
  169. * Removes all the assets contained in the scene and adds them to the container.
  170. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  171. */
  172. moveAllFromScene(keepAssets?: KeepAssets): void;
  173. }
  174. }
  175. interface Window {
  176. mozIndexedDB: IDBFactory;
  177. webkitIndexedDB: IDBFactory;
  178. msIndexedDB: IDBFactory;
  179. webkitURL: typeof URL;
  180. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  181. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  182. WebGLRenderingContext: WebGLRenderingContext;
  183. MSGesture: MSGesture;
  184. CANNON: any;
  185. AudioContext: AudioContext;
  186. webkitAudioContext: AudioContext;
  187. PointerEvent: any;
  188. Math: Math;
  189. Uint8Array: Uint8ArrayConstructor;
  190. Float32Array: Float32ArrayConstructor;
  191. mozURL: typeof URL;
  192. msURL: typeof URL;
  193. VRFrameData: any;
  194. DracoDecoderModule: any;
  195. }
  196. interface WebGLRenderingContext {
  197. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  198. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  199. vertexAttribDivisor(index: number, divisor: number): void;
  200. createVertexArray(): any;
  201. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  202. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  203. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  204. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  205. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  206. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  207. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  208. createQuery(): WebGLQuery;
  209. deleteQuery(query: WebGLQuery): void;
  210. beginQuery(target: number, query: WebGLQuery): void;
  211. endQuery(target: number): void;
  212. getQueryParameter(query: WebGLQuery, pname: number): any;
  213. getQuery(target: number, pname: number): any;
  214. MAX_SAMPLES: number;
  215. RGBA8: number;
  216. READ_FRAMEBUFFER: number;
  217. DRAW_FRAMEBUFFER: number;
  218. UNIFORM_BUFFER: number;
  219. HALF_FLOAT_OES: number;
  220. RGBA16F: number;
  221. RGBA32F: number;
  222. R32F: number;
  223. RG32F: number;
  224. RGB32F: number;
  225. RED: number;
  226. RG: number;
  227. UNSIGNED_INT_24_8: number;
  228. DEPTH24_STENCIL8: number;
  229. drawBuffers(buffers: number[]): void;
  230. readBuffer(src: number): void;
  231. readonly COLOR_ATTACHMENT0: number;
  232. readonly COLOR_ATTACHMENT1: number;
  233. readonly COLOR_ATTACHMENT2: number;
  234. readonly COLOR_ATTACHMENT3: number;
  235. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  236. ANY_SAMPLES_PASSED: number;
  237. QUERY_RESULT_AVAILABLE: number;
  238. QUERY_RESULT: number;
  239. }
  240. interface Document {
  241. mozCancelFullScreen(): void;
  242. msCancelFullScreen(): void;
  243. mozFullScreen: boolean;
  244. msIsFullScreen: boolean;
  245. fullscreen: boolean;
  246. mozPointerLockElement: HTMLElement;
  247. msPointerLockElement: HTMLElement;
  248. webkitPointerLockElement: HTMLElement;
  249. }
  250. interface HTMLCanvasElement {
  251. msRequestPointerLock?(): void;
  252. mozRequestPointerLock?(): void;
  253. webkitRequestPointerLock?(): void;
  254. }
  255. interface CanvasRenderingContext2D {
  256. msImageSmoothingEnabled: boolean;
  257. }
  258. interface WebGLBuffer {
  259. references: number;
  260. capacity: number;
  261. is32Bits: boolean;
  262. }
  263. interface WebGLProgram {
  264. transformFeedback?: WebGLTransformFeedback | null;
  265. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  266. }
  267. interface MouseEvent {
  268. mozMovementX: number;
  269. mozMovementY: number;
  270. webkitMovementX: number;
  271. webkitMovementY: number;
  272. msMovementX: number;
  273. msMovementY: number;
  274. }
  275. interface Navigator {
  276. mozGetVRDevices: (any: any) => any;
  277. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  278. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  279. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  280. webkitGetGamepads(): Gamepad[];
  281. msGetGamepads(): Gamepad[];
  282. webkitGamepads(): Gamepad[];
  283. }
  284. interface HTMLVideoElement {
  285. mozSrcObject: any;
  286. }
  287. interface Screen {
  288. orientation: string;
  289. mozOrientation: string;
  290. }
  291. interface Math {
  292. fround(x: number): number;
  293. imul(a: number, b: number): number;
  294. }
  295. interface GamepadPose {
  296. hasOrientation: boolean;
  297. hasPosition: boolean;
  298. position?: Float32Array;
  299. linearVelocity?: Float32Array;
  300. linearAcceleration?: Float32Array;
  301. orientation?: Float32Array;
  302. angularVelocity?: Float32Array;
  303. angularAcceleration?: Float32Array;
  304. }
  305. interface EXT_disjoint_timer_query {
  306. QUERY_COUNTER_BITS_EXT: number;
  307. TIME_ELAPSED_EXT: number;
  308. TIMESTAMP_EXT: number;
  309. GPU_DISJOINT_EXT: number;
  310. QUERY_RESULT_EXT: number;
  311. QUERY_RESULT_AVAILABLE_EXT: number;
  312. queryCounterEXT(query: WebGLQuery, target: number): void;
  313. createQueryEXT(): WebGLQuery;
  314. beginQueryEXT(target: number, query: WebGLQuery): void;
  315. endQueryEXT(target: number): void;
  316. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  317. deleteQueryEXT(query: WebGLQuery): void;
  318. }
  319. interface WebGLUniformLocation {
  320. _currentState: any;
  321. }
  322. declare module BABYLON {
  323. /**
  324. * Node is the basic class for all scene objects (Mesh, Light Camera).
  325. */
  326. class Node {
  327. /**
  328. * Gets or sets the name of the node
  329. */
  330. name: string;
  331. /**
  332. * Gets or sets the id of the node
  333. */
  334. id: string;
  335. /**
  336. * Gets or sets the unique id of the node
  337. */
  338. uniqueId: number;
  339. /**
  340. * Gets or sets a string used to store user defined state for the node
  341. */
  342. state: string;
  343. /**
  344. * Gets or sets an object used to store user defined information for the node
  345. */
  346. metadata: any;
  347. /**
  348. * Gets or sets a boolean used to define if the node must be serialized
  349. */
  350. doNotSerialize: boolean;
  351. /** @ignore */
  352. _isDisposed: boolean;
  353. /**
  354. * Gets a list of Animations associated with the node
  355. */
  356. animations: Animation[];
  357. private _ranges;
  358. /**
  359. * Callback raised when the node is ready to be used
  360. */
  361. onReady: (node: Node) => void;
  362. private _isEnabled;
  363. private _isReady;
  364. /** @ignore */
  365. _currentRenderId: number;
  366. private _parentRenderId;
  367. protected _childRenderId: number;
  368. /** @ignore */
  369. _waitingParentId: Nullable<string>;
  370. private _scene;
  371. /** @ignore */
  372. _cache: any;
  373. private _parentNode;
  374. private _children;
  375. /**
  376. * Gets a boolean indicating if the node has been disposed
  377. * @returns true if the node was disposed
  378. */
  379. isDisposed(): boolean;
  380. /**
  381. * Gets or sets the parent of the node
  382. */
  383. parent: Nullable<Node>;
  384. private _animationPropertiesOverride;
  385. /**
  386. * Gets or sets the animation properties override
  387. */
  388. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  389. /**
  390. * Gets a string idenfifying the name of the class
  391. * @returns "Node" string
  392. */
  393. getClassName(): string;
  394. /**
  395. * An event triggered when the mesh is disposed
  396. */
  397. onDisposeObservable: Observable<Node>;
  398. private _onDisposeObserver;
  399. /**
  400. * Sets a callback that will be raised when the node will be disposed
  401. */
  402. onDispose: () => void;
  403. /**
  404. * Creates a new Node
  405. * @param {string} name - the name and id to be given to this node
  406. * @param {BABYLON.Scene} the scene this node will be added to
  407. */
  408. constructor(name: string, scene?: Nullable<Scene>);
  409. /**
  410. * Gets the scene of the node
  411. * @returns a {BABYLON.Scene}
  412. */
  413. getScene(): Scene;
  414. /**
  415. * Gets the engine of the node
  416. * @returns a {BABYLON.Engine}
  417. */
  418. getEngine(): Engine;
  419. private _behaviors;
  420. /**
  421. * Attach a behavior to the node
  422. * @see http://doc.babylonjs.com/features/behaviour
  423. * @param behavior defines the behavior to attach
  424. * @returns the current Node
  425. */
  426. addBehavior(behavior: Behavior<Node>): Node;
  427. /**
  428. * Remove an attached behavior
  429. * @see http://doc.babylonjs.com/features/behaviour
  430. * @param behavior defines the behavior to attach
  431. * @returns the current Node
  432. */
  433. removeBehavior(behavior: Behavior<Node>): Node;
  434. /**
  435. * Gets the list of attached behaviors
  436. * @see http://doc.babylonjs.com/features/behaviour
  437. */
  438. readonly behaviors: Behavior<Node>[];
  439. /**
  440. * Gets an attached behavior by name
  441. * @param name defines the name of the behavior to look for
  442. * @see http://doc.babylonjs.com/features/behaviour
  443. * @returns null if behavior was not found else the requested behavior
  444. */
  445. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  446. /**
  447. * Returns the world matrix of the node
  448. * @returns a matrix containing the node's world matrix
  449. */
  450. getWorldMatrix(): Matrix;
  451. /** @ignore */
  452. _initCache(): void;
  453. /** @ignore */
  454. updateCache(force?: boolean): void;
  455. /** @ignore */
  456. _updateCache(ignoreParentClass?: boolean): void;
  457. /** @ignore */
  458. _isSynchronized(): boolean;
  459. /** @ignore */
  460. _markSyncedWithParent(): void;
  461. /** @ignore */
  462. isSynchronizedWithParent(): boolean;
  463. /** @ignore */
  464. isSynchronized(updateCache?: boolean): boolean;
  465. /** @ignore */
  466. hasNewParent(update?: boolean): boolean;
  467. /**
  468. * Is this node ready to be used/rendered
  469. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  470. * @return true if the node is ready
  471. */
  472. isReady(completeCheck?: boolean): boolean;
  473. /**
  474. * Is this node enabled?
  475. * 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
  476. * @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
  477. * @return whether this node (and its parent) is enabled
  478. */
  479. isEnabled(checkAncestors?: boolean): boolean;
  480. /**
  481. * Set the enabled state of this node
  482. * @param value defines the new enabled state
  483. */
  484. setEnabled(value: boolean): void;
  485. /**
  486. * Is this node a descendant of the given node?
  487. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  488. * @param ancestor defines the parent node to inspect
  489. * @returns a boolean indicating if this node is a descendant of the given node
  490. */
  491. isDescendantOf(ancestor: Node): boolean;
  492. /** @ignore */
  493. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  494. /**
  495. * Will return all nodes that have this node as ascendant
  496. * @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
  497. * @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
  498. * @return all children nodes of all types
  499. */
  500. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  501. /**
  502. * Get all child-meshes of this node
  503. * @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
  504. * @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
  505. * @returns an array of {BABYLON.AbstractMesh}
  506. */
  507. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  508. /**
  509. * Get all child-transformNodes of this node
  510. * @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
  511. * @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
  512. * @returns an array of {BABYLON.TransformNode}
  513. */
  514. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  515. /**
  516. * Get all direct children of this node
  517. * @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
  518. * @returns an array of {BABYLON.Node}
  519. */
  520. getChildren(predicate?: (node: Node) => boolean): Node[];
  521. /** @ignore */
  522. _setReady(state: boolean): void;
  523. /**
  524. * Get an animation by name
  525. * @param name defines the name of the animation to look for
  526. * @returns null if not found else the requested animation
  527. */
  528. getAnimationByName(name: string): Nullable<Animation>;
  529. /**
  530. * Creates an animation range for this node
  531. * @param name defines the name of the range
  532. * @param from defines the starting key
  533. * @param to defines the end key
  534. */
  535. createAnimationRange(name: string, from: number, to: number): void;
  536. /**
  537. * Delete a specific animation range
  538. * @param name defines the name of the range to delete
  539. * @param deleteFrames defines if animation frames from the range must be deleted as well
  540. */
  541. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  542. /**
  543. * Get an animation range by name
  544. * @param name defines the name of the animation range to look for
  545. * @returns null if not found else the requested animation range
  546. */
  547. getAnimationRange(name: string): Nullable<AnimationRange>;
  548. /**
  549. * Will start the animation sequence
  550. * @param name defines the range frames for animation sequence
  551. * @param loop defines if the animation should loop (false by default)
  552. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  553. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  554. * @returns the object created for this animation. If range does not exist, it will return null
  555. */
  556. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  557. /**
  558. * Serialize animation ranges into a JSON compatible object
  559. * @returns serialization object
  560. */
  561. serializeAnimationRanges(): any;
  562. /**
  563. * Computes the world matrix of the node
  564. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  565. * @returns the world matrix
  566. */
  567. computeWorldMatrix(force?: boolean): Matrix;
  568. /**
  569. * Releases resources associated with this node.
  570. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  571. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  572. */
  573. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  574. /**
  575. * Parse animation range data from a serialization object and store them into a given node
  576. * @param node defines where to store the animation ranges
  577. * @param parsedNode defines the serialization object to read data from
  578. * @param scene defines the hosting scene
  579. */
  580. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  581. }
  582. }
  583. declare module BABYLON {
  584. /**
  585. * Define an interface for all classes that will hold resources
  586. */
  587. interface IDisposable {
  588. /**
  589. * Releases all held resources
  590. */
  591. dispose(): void;
  592. }
  593. /**
  594. * Interface used to let developers provide their own mesh selection mechanism
  595. */
  596. interface IActiveMeshCandidateProvider {
  597. /**
  598. * Return the list of active meshes
  599. * @param scene defines the current scene
  600. * @returns the list of active meshes
  601. */
  602. getMeshes(scene: Scene): AbstractMesh[];
  603. /**
  604. * Indicates if the meshes have been checked to make sure they are isEnabled()
  605. */
  606. readonly checksIsEnabled: boolean;
  607. }
  608. /**
  609. * This class is used by the onRenderingGroupObservable
  610. */
  611. class RenderingGroupInfo {
  612. /**
  613. * The Scene that being rendered
  614. */
  615. scene: Scene;
  616. /**
  617. * The camera currently used for the rendering pass
  618. */
  619. camera: Nullable<Camera>;
  620. /**
  621. * The ID of the renderingGroup being processed
  622. */
  623. renderingGroupId: number;
  624. /**
  625. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  626. */
  627. renderStage: number;
  628. /**
  629. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  630. * This stage will be fired no matter what
  631. */
  632. static STAGE_PRECLEAR: number;
  633. /**
  634. * Called before opaque object are rendered.
  635. * This stage will be fired only if there's 3D Opaque content to render
  636. */
  637. static STAGE_PREOPAQUE: number;
  638. /**
  639. * Called after the opaque objects are rendered and before the transparent ones
  640. * This stage will be fired only if there's 3D transparent content to render
  641. */
  642. static STAGE_PRETRANSPARENT: number;
  643. /**
  644. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  645. * This stage will be fired no matter what
  646. */
  647. static STAGE_POSTTRANSPARENT: number;
  648. }
  649. /**
  650. * Represents a scene to be rendered by the engine.
  651. * @see http://doc.babylonjs.com/features/scene
  652. */
  653. class Scene implements IAnimatable {
  654. private static _FOGMODE_NONE;
  655. private static _FOGMODE_EXP;
  656. private static _FOGMODE_EXP2;
  657. private static _FOGMODE_LINEAR;
  658. private static _uniqueIdCounter;
  659. /**
  660. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  661. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  662. */
  663. static MinDeltaTime: number;
  664. /**
  665. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  666. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  667. */
  668. static MaxDeltaTime: number;
  669. /** The fog is deactivated */
  670. static readonly FOGMODE_NONE: number;
  671. /** The fog density is following an exponential function */
  672. static readonly FOGMODE_EXP: number;
  673. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  674. static readonly FOGMODE_EXP2: number;
  675. /** The fog density is following a linear function. */
  676. static readonly FOGMODE_LINEAR: number;
  677. /**
  678. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  679. */
  680. autoClear: boolean;
  681. /**
  682. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  683. */
  684. autoClearDepthAndStencil: boolean;
  685. /**
  686. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  687. */
  688. clearColor: Color4;
  689. /**
  690. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  691. */
  692. ambientColor: Color3;
  693. /** @ignore */
  694. _environmentBRDFTexture: BaseTexture;
  695. /** @ignore */
  696. protected _environmentTexture: BaseTexture;
  697. /**
  698. * Texture used in all pbr material as the reflection texture.
  699. * As in the majority of the scene they are the same (exception for multi room and so on),
  700. * this is easier to reference from here than from all the materials.
  701. */
  702. /**
  703. * Texture used in all pbr material as the reflection texture.
  704. * As in the majority of the scene they are the same (exception for multi room and so on),
  705. * this is easier to set here than in all the materials.
  706. */
  707. environmentTexture: BaseTexture;
  708. /** @ignore */
  709. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  710. /**
  711. * Default image processing configuration used either in the rendering
  712. * Forward main pass or through the imageProcessingPostProcess if present.
  713. * As in the majority of the scene they are the same (exception for multi camera),
  714. * this is easier to reference from here than from all the materials and post process.
  715. *
  716. * No setter as we it is a shared configuration, you can set the values instead.
  717. */
  718. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  719. private _forceWireframe;
  720. /**
  721. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  722. */
  723. forceWireframe: boolean;
  724. private _forcePointsCloud;
  725. /**
  726. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  727. */
  728. forcePointsCloud: boolean;
  729. /**
  730. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  731. */
  732. forceShowBoundingBoxes: boolean;
  733. /**
  734. * Gets or sets the active clipplane
  735. */
  736. clipPlane: Nullable<Plane>;
  737. /**
  738. * Gets or sets a boolean indicating if animations are enabled
  739. */
  740. animationsEnabled: boolean;
  741. /**
  742. * Gets or sets a boolean indicating if a constant deltatime has to be used
  743. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  744. */
  745. useConstantAnimationDeltaTime: boolean;
  746. /**
  747. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  748. * Please note that it requires to run a ray cast through the scene on every frame
  749. */
  750. constantlyUpdateMeshUnderPointer: boolean;
  751. /**
  752. * Defines the HTML cursor to use when hovering over interactive elements
  753. */
  754. hoverCursor: string;
  755. /**
  756. * Defines the HTML default cursor to use (empty by default)
  757. */
  758. defaultCursor: string;
  759. /**
  760. * This is used to call preventDefault() on pointer down
  761. * in order to block unwanted artifacts like system double clicks
  762. */
  763. preventDefaultOnPointerDown: boolean;
  764. /**
  765. * Gets or sets user defined metadata
  766. */
  767. metadata: any;
  768. /**
  769. * Gets the name of the plugin used to load this scene (null by default)
  770. */
  771. loadingPluginName: string;
  772. /**
  773. * Use this array to add regular expressions used to disable offline support for specific urls
  774. */
  775. disableOfflineSupportExceptionRules: RegExp[];
  776. private _spritePredicate;
  777. /**
  778. * An event triggered when the scene is disposed.
  779. */
  780. onDisposeObservable: Observable<Scene>;
  781. private _onDisposeObserver;
  782. /** Sets a function to be executed when this scene is disposed. */
  783. onDispose: () => void;
  784. /**
  785. * An event triggered before rendering the scene (right after animations and physics)
  786. */
  787. onBeforeRenderObservable: Observable<Scene>;
  788. private _onBeforeRenderObserver;
  789. /** Sets a function to be executed before rendering this scene */
  790. beforeRender: Nullable<() => void>;
  791. /**
  792. * An event triggered after rendering the scene
  793. */
  794. onAfterRenderObservable: Observable<Scene>;
  795. private _onAfterRenderObserver;
  796. /** Sets a function to be executed after rendering this scene */
  797. afterRender: Nullable<() => void>;
  798. /**
  799. * An event triggered before animating the scene
  800. */
  801. onBeforeAnimationsObservable: Observable<Scene>;
  802. /**
  803. * An event triggered after animations processing
  804. */
  805. onAfterAnimationsObservable: Observable<Scene>;
  806. /**
  807. * An event triggered before draw calls are ready to be sent
  808. */
  809. onBeforeDrawPhaseObservable: Observable<Scene>;
  810. /**
  811. * An event triggered after draw calls have been sent
  812. */
  813. onAfterDrawPhaseObservable: Observable<Scene>;
  814. /**
  815. * An event triggered when physic simulation is about to be run
  816. */
  817. onBeforePhysicsObservable: Observable<Scene>;
  818. /**
  819. * An event triggered when physic simulation has been done
  820. */
  821. onAfterPhysicsObservable: Observable<Scene>;
  822. /**
  823. * An event triggered when the scene is ready
  824. */
  825. onReadyObservable: Observable<Scene>;
  826. /**
  827. * An event triggered before rendering a camera
  828. */
  829. onBeforeCameraRenderObservable: Observable<Camera>;
  830. private _onBeforeCameraRenderObserver;
  831. /** Sets a function to be executed before rendering a camera*/
  832. beforeCameraRender: () => void;
  833. /**
  834. * An event triggered after rendering a camera
  835. */
  836. onAfterCameraRenderObservable: Observable<Camera>;
  837. private _onAfterCameraRenderObserver;
  838. /** Sets a function to be executed after rendering a camera*/
  839. afterCameraRender: () => void;
  840. /**
  841. * An event triggered when active meshes evaluation is about to start
  842. */
  843. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  844. /**
  845. * An event triggered when active meshes evaluation is done
  846. */
  847. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  848. /**
  849. * An event triggered when particles rendering is about to start
  850. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  851. */
  852. onBeforeParticlesRenderingObservable: Observable<Scene>;
  853. /**
  854. * An event triggered when particles rendering is done
  855. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  856. */
  857. onAfterParticlesRenderingObservable: Observable<Scene>;
  858. /**
  859. * An event triggered when sprites rendering is about to start
  860. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  861. */
  862. onBeforeSpritesRenderingObservable: Observable<Scene>;
  863. /**
  864. * An event triggered when sprites rendering is done
  865. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  866. */
  867. onAfterSpritesRenderingObservable: Observable<Scene>;
  868. /**
  869. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  870. */
  871. onDataLoadedObservable: Observable<Scene>;
  872. /**
  873. * An event triggered when a camera is created
  874. */
  875. onNewCameraAddedObservable: Observable<Camera>;
  876. /**
  877. * An event triggered when a camera is removed
  878. */
  879. onCameraRemovedObservable: Observable<Camera>;
  880. /**
  881. * An event triggered when a light is created
  882. */
  883. onNewLightAddedObservable: Observable<Light>;
  884. /**
  885. * An event triggered when a light is removed
  886. */
  887. onLightRemovedObservable: Observable<Light>;
  888. /**
  889. * An event triggered when a geometry is created
  890. */
  891. onNewGeometryAddedObservable: Observable<Geometry>;
  892. /**
  893. * An event triggered when a geometry is removed
  894. */
  895. onGeometryRemovedObservable: Observable<Geometry>;
  896. /**
  897. * An event triggered when a transform node is created
  898. */
  899. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  900. /**
  901. * An event triggered when a transform node is removed
  902. */
  903. onTransformNodeRemovedObservable: Observable<TransformNode>;
  904. /**
  905. * An event triggered when a mesh is created
  906. */
  907. onNewMeshAddedObservable: Observable<AbstractMesh>;
  908. /**
  909. * An event triggered when a mesh is removed
  910. */
  911. onMeshRemovedObservable: Observable<AbstractMesh>;
  912. /**
  913. * An event triggered when render targets are about to be rendered
  914. * Can happen multiple times per frame.
  915. */
  916. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  917. /**
  918. * An event triggered when render targets were rendered.
  919. * Can happen multiple times per frame.
  920. */
  921. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  922. /**
  923. * An event triggered before calculating deterministic simulation step
  924. */
  925. onBeforeStepObservable: Observable<Scene>;
  926. /**
  927. * An event triggered after calculating deterministic simulation step
  928. */
  929. onAfterStepObservable: Observable<Scene>;
  930. /**
  931. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  932. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  933. * 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)
  934. */
  935. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  936. /**
  937. * Gets a list of Animations associated with the scene
  938. */
  939. animations: Animation[];
  940. private _registeredForLateAnimationBindings;
  941. /**
  942. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  943. */
  944. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  945. /**
  946. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  947. */
  948. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  949. /**
  950. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  951. */
  952. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  953. private _onPointerMove;
  954. private _onPointerDown;
  955. private _onPointerUp;
  956. /** Deprecated. Use onPointerObservable instead */
  957. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  958. /** Deprecated. Use onPointerObservable instead */
  959. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  960. /** Deprecated. Use onPointerObservable instead */
  961. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  962. /** Deprecated. Use onPointerObservable instead */
  963. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  964. private _gamepadManager;
  965. /**
  966. * Gets the gamepad manager associated with the scene
  967. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  968. */
  969. readonly gamepadManager: GamepadManager;
  970. /**
  971. * 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).
  972. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  973. */
  974. onPrePointerObservable: Observable<PointerInfoPre>;
  975. /**
  976. * Observable event triggered each time an input event is received from the rendering canvas
  977. */
  978. onPointerObservable: Observable<PointerInfo>;
  979. /**
  980. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  981. */
  982. readonly unTranslatedPointer: Vector2;
  983. /** The distance in pixel that you have to move to prevent some events */
  984. static DragMovementThreshold: number;
  985. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  986. static LongPressDelay: number;
  987. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  988. static DoubleClickDelay: number;
  989. /** If you need to check double click without raising a single click at first click, enable this flag */
  990. static ExclusiveDoubleClickMode: boolean;
  991. private _initClickEvent;
  992. private _initActionManager;
  993. private _delayedSimpleClick;
  994. private _delayedSimpleClickTimeout;
  995. private _previousDelayedSimpleClickTimeout;
  996. private _meshPickProceed;
  997. private _previousButtonPressed;
  998. private _currentPickResult;
  999. private _previousPickResult;
  1000. private _totalPointersPressed;
  1001. private _doubleClickOccured;
  1002. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1003. cameraToUseForPointers: Nullable<Camera>;
  1004. private _pointerX;
  1005. private _pointerY;
  1006. private _unTranslatedPointerX;
  1007. private _unTranslatedPointerY;
  1008. private _startingPointerPosition;
  1009. private _previousStartingPointerPosition;
  1010. private _startingPointerTime;
  1011. private _previousStartingPointerTime;
  1012. private _timeAccumulator;
  1013. private _currentStepId;
  1014. private _currentInternalStep;
  1015. /** @ignore */
  1016. _mirroredCameraPosition: Nullable<Vector3>;
  1017. /**
  1018. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1019. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1020. */
  1021. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1022. /**
  1023. * Observable event triggered each time an keyboard event is received from the hosting window
  1024. */
  1025. onKeyboardObservable: Observable<KeyboardInfo>;
  1026. private _onKeyDown;
  1027. private _onKeyUp;
  1028. private _onCanvasFocusObserver;
  1029. private _onCanvasBlurObserver;
  1030. private _useRightHandedSystem;
  1031. /**
  1032. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1033. */
  1034. useRightHandedSystem: boolean;
  1035. /**
  1036. * Sets the step Id used by deterministic lock step
  1037. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1038. * @param newStepId defines the step Id
  1039. */
  1040. setStepId(newStepId: number): void;
  1041. /**
  1042. * Gets the step Id used by deterministic lock step
  1043. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1044. * @returns the step Id
  1045. */
  1046. getStepId(): number;
  1047. /**
  1048. * Gets the internal step used by deterministic lock step
  1049. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1050. * @returns the internal step
  1051. */
  1052. getInternalStep(): number;
  1053. private _fogEnabled;
  1054. /**
  1055. * Gets or sets a boolean indicating if fog is enabled on this scene
  1056. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1057. */
  1058. fogEnabled: boolean;
  1059. private _fogMode;
  1060. /**
  1061. * Gets or sets the fog mode to use
  1062. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1063. */
  1064. fogMode: number;
  1065. /**
  1066. * Gets or sets the fog color to use
  1067. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1068. */
  1069. fogColor: Color3;
  1070. /**
  1071. * Gets or sets the fog density to use
  1072. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1073. */
  1074. fogDensity: number;
  1075. /**
  1076. * Gets or sets the fog start distance to use
  1077. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1078. */
  1079. fogStart: number;
  1080. /**
  1081. * Gets or sets the fog end distance to use
  1082. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1083. */
  1084. fogEnd: number;
  1085. private _shadowsEnabled;
  1086. /**
  1087. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1088. */
  1089. shadowsEnabled: boolean;
  1090. private _lightsEnabled;
  1091. /**
  1092. * Gets or sets a boolean indicating if lights are enabled on this scene
  1093. */
  1094. lightsEnabled: boolean;
  1095. /**
  1096. * All of the lights added to this scene
  1097. * @see http://doc.babylonjs.com/babylon101/lights
  1098. */
  1099. lights: Light[];
  1100. /** All of the cameras added to this scene.
  1101. * @see http://doc.babylonjs.com/babylon101/cameras
  1102. */
  1103. cameras: Camera[];
  1104. /** All of the active cameras added to this scene. */
  1105. activeCameras: Camera[];
  1106. /** The current active camera */
  1107. activeCamera: Nullable<Camera>;
  1108. /**
  1109. * All of the tranform nodes added to this scene
  1110. * @see http://doc.babylonjs.com/how_to/transformnode
  1111. */
  1112. transformNodes: TransformNode[];
  1113. /**
  1114. * All of the (abstract) meshes added to this scene
  1115. */
  1116. meshes: AbstractMesh[];
  1117. /**
  1118. * All of the animation groups added to this scene
  1119. * @see http://doc.babylonjs.com/how_to/group
  1120. */
  1121. animationGroups: AnimationGroup[];
  1122. private _geometries;
  1123. /**
  1124. * All of the materials added to this scene
  1125. * @see http://doc.babylonjs.com/babylon101/materials
  1126. */
  1127. materials: Material[];
  1128. /**
  1129. * All of the multi-materials added to this scene
  1130. * @see http://doc.babylonjs.com/how_to/multi_materials
  1131. */
  1132. multiMaterials: MultiMaterial[];
  1133. private _defaultMaterial;
  1134. /** The default material used on meshes when no material is affected */
  1135. /** The default material used on meshes when no material is affected */
  1136. defaultMaterial: Material;
  1137. private _texturesEnabled;
  1138. /**
  1139. * Gets or sets a boolean indicating if textures are enabled on this scene
  1140. */
  1141. texturesEnabled: boolean;
  1142. /**
  1143. * All of the textures added to this scene
  1144. */
  1145. textures: BaseTexture[];
  1146. /**
  1147. * Gets or sets a boolean indicating if particles are enabled on this scene
  1148. */
  1149. particlesEnabled: boolean;
  1150. /**
  1151. * All of the particle systems added to this scene
  1152. * @see http://doc.babylonjs.com/babylon101/particles
  1153. */
  1154. particleSystems: IParticleSystem[];
  1155. /**
  1156. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1157. */
  1158. spritesEnabled: boolean;
  1159. /**
  1160. * All of the sprite managers added to this scene
  1161. * @see http://doc.babylonjs.com/babylon101/sprites
  1162. */
  1163. spriteManagers: SpriteManager[];
  1164. /**
  1165. * The list of layers (background and foreground) of the scene
  1166. */
  1167. layers: Layer[];
  1168. /**
  1169. * The list of effect layers (highlights/glow) added to the scene
  1170. * @see http://doc.babylonjs.com/how_to/highlight_layer
  1171. * @see http://doc.babylonjs.com/how_to/glow_layer
  1172. */
  1173. effectLayers: EffectLayer[];
  1174. private _skeletonsEnabled;
  1175. /**
  1176. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1177. */
  1178. skeletonsEnabled: boolean;
  1179. /**
  1180. * The list of skeletons added to the scene
  1181. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  1182. */
  1183. skeletons: Skeleton[];
  1184. /**
  1185. * The list of morph target managers added to the scene
  1186. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  1187. */
  1188. morphTargetManagers: MorphTargetManager[];
  1189. /**
  1190. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1191. */
  1192. lensFlaresEnabled: boolean;
  1193. /**
  1194. * The list of lens flare system added to the scene
  1195. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  1196. */
  1197. lensFlareSystems: LensFlareSystem[];
  1198. /**
  1199. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1200. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1201. */
  1202. collisionsEnabled: boolean;
  1203. private _workerCollisions;
  1204. /** @ignore */
  1205. collisionCoordinator: ICollisionCoordinator;
  1206. /**
  1207. * Defines the gravity applied to this scene (used only for collisions)
  1208. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1209. */
  1210. gravity: Vector3;
  1211. /**
  1212. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1213. */
  1214. postProcessesEnabled: boolean;
  1215. /**
  1216. * The list of postprocesses added to the scene
  1217. */
  1218. postProcesses: PostProcess[];
  1219. /**
  1220. * Gets the current postprocess manager
  1221. */
  1222. postProcessManager: PostProcessManager;
  1223. private _postProcessRenderPipelineManager;
  1224. /**
  1225. * Gets the postprocess render pipeline manager
  1226. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1227. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1228. */
  1229. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1230. /**
  1231. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1232. */
  1233. renderTargetsEnabled: boolean;
  1234. /**
  1235. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1236. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1237. */
  1238. dumpNextRenderTargets: boolean;
  1239. /**
  1240. * The list of user defined render targets added to the scene
  1241. */
  1242. customRenderTargets: RenderTargetTexture[];
  1243. /**
  1244. * Defines if texture loading must be delayed
  1245. * If true, textures will only be loaded when they need to be rendered
  1246. */
  1247. useDelayedTextureLoading: boolean;
  1248. /**
  1249. * Gets the list of meshes imported to the scene through SceneLoader
  1250. */
  1251. importedMeshesFiles: String[];
  1252. /**
  1253. * Gets or sets a boolean indicating if probes are enabled on this scene
  1254. */
  1255. probesEnabled: boolean;
  1256. /**
  1257. * The list of reflection probes added to the scene
  1258. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1259. */
  1260. reflectionProbes: ReflectionProbe[];
  1261. /**
  1262. * @ignore
  1263. */
  1264. database: Database;
  1265. /**
  1266. * Gets or sets the action manager associated with the scene
  1267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1268. */
  1269. actionManager: ActionManager;
  1270. /** @ignore */
  1271. _actionManagers: ActionManager[];
  1272. private _meshesForIntersections;
  1273. /**
  1274. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1275. */
  1276. proceduralTexturesEnabled: boolean;
  1277. /**
  1278. * The list of procedural textures added to the scene
  1279. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1280. */
  1281. proceduralTextures: ProceduralTexture[];
  1282. private _mainSoundTrack;
  1283. /**
  1284. * The list of sound tracks added to the scene
  1285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1286. */
  1287. soundTracks: SoundTrack[];
  1288. private _audioEnabled;
  1289. private _headphone;
  1290. /**
  1291. * Gets the main soundtrack associated with the scene
  1292. */
  1293. readonly mainSoundTrack: SoundTrack;
  1294. /**
  1295. * Gets or sets the VRExperienceHelper attached to the scene
  1296. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1297. * @ignoreNaming
  1298. */
  1299. VRHelper: VRExperienceHelper;
  1300. /**
  1301. * Gets or sets the simplification queue attached to the scene
  1302. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1303. */
  1304. simplificationQueue: SimplificationQueue;
  1305. private _engine;
  1306. private _totalVertices;
  1307. /** @ignore */
  1308. _activeIndices: PerfCounter;
  1309. /** @ignore */
  1310. _activeParticles: PerfCounter;
  1311. /** @ignore */
  1312. _activeBones: PerfCounter;
  1313. private _animationRatio;
  1314. private _animationTimeLast;
  1315. private _animationTime;
  1316. /**
  1317. * Gets or sets a general scale for animation speed
  1318. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1319. */
  1320. animationTimeScale: number;
  1321. /** @ignore */
  1322. _cachedMaterial: Nullable<Material>;
  1323. /** @ignore */
  1324. _cachedEffect: Nullable<Effect>;
  1325. /** @ignore */
  1326. _cachedVisibility: Nullable<number>;
  1327. private _renderId;
  1328. private _executeWhenReadyTimeoutId;
  1329. private _intermediateRendering;
  1330. private _viewUpdateFlag;
  1331. private _projectionUpdateFlag;
  1332. private _alternateViewUpdateFlag;
  1333. private _alternateProjectionUpdateFlag;
  1334. /** @ignore */
  1335. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1336. private _activeRequests;
  1337. private _pendingData;
  1338. private _isDisposed;
  1339. /**
  1340. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1341. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1342. */
  1343. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1344. private _activeMeshes;
  1345. private _processedMaterials;
  1346. private _renderTargets;
  1347. /** @ignore */
  1348. _activeParticleSystems: SmartArray<IParticleSystem>;
  1349. private _activeSkeletons;
  1350. private _softwareSkinnedMeshes;
  1351. private _renderingManager;
  1352. private _physicsEngine;
  1353. /** @ignore */
  1354. _activeAnimatables: Animatable[];
  1355. private _transformMatrix;
  1356. private _sceneUbo;
  1357. private _alternateSceneUbo;
  1358. private _pickWithRayInverseMatrix;
  1359. private _boundingBoxRenderer;
  1360. private _outlineRenderer;
  1361. private _viewMatrix;
  1362. private _projectionMatrix;
  1363. private _alternateViewMatrix;
  1364. private _alternateProjectionMatrix;
  1365. private _alternateTransformMatrix;
  1366. private _useAlternateCameraConfiguration;
  1367. private _alternateRendering;
  1368. /** @ignore */
  1369. _forcedViewPosition: Nullable<Vector3>;
  1370. /** @ignore */
  1371. readonly _isAlternateRenderingEnabled: boolean;
  1372. private _frustumPlanes;
  1373. /**
  1374. * Gets the list of frustum planes (built from the active camera)
  1375. */
  1376. readonly frustumPlanes: Plane[];
  1377. /**
  1378. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1379. * This is useful if there are more lights that the maximum simulteanous authorized
  1380. */
  1381. requireLightSorting: boolean;
  1382. private _selectionOctree;
  1383. private _pointerOverMesh;
  1384. private _pointerOverSprite;
  1385. private _debugLayer;
  1386. private _depthRenderer;
  1387. private _geometryBufferRenderer;
  1388. /**
  1389. * Gets the current geometry buffer associated to the scene.
  1390. */
  1391. /**
  1392. * Sets the current geometry buffer for the scene.
  1393. */
  1394. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1395. private _pickedDownMesh;
  1396. private _pickedUpMesh;
  1397. private _pickedDownSprite;
  1398. private _externalData;
  1399. private _uid;
  1400. /**
  1401. * Creates a new Scene
  1402. * @param engine defines the engine to use to render this scene
  1403. */
  1404. constructor(engine: Engine);
  1405. /**
  1406. * Gets the debug layer associated with the scene
  1407. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1408. */
  1409. readonly debugLayer: DebugLayer;
  1410. /**
  1411. * Gets a boolean indicating if collisions are processed on a web worker
  1412. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1413. */
  1414. workerCollisions: boolean;
  1415. /**
  1416. * Gets the octree used to boost mesh selection (picking)
  1417. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1418. */
  1419. readonly selectionOctree: Octree<AbstractMesh>;
  1420. /**
  1421. * Gets the mesh that is currently under the pointer
  1422. */
  1423. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1424. /**
  1425. * Gets the current on-screen X position of the pointer
  1426. */
  1427. readonly pointerX: number;
  1428. /**
  1429. * Gets the current on-screen Y position of the pointer
  1430. */
  1431. readonly pointerY: number;
  1432. /**
  1433. * Gets the cached material (ie. the latest rendered one)
  1434. * @returns the cached material
  1435. */
  1436. getCachedMaterial(): Nullable<Material>;
  1437. /**
  1438. * Gets the cached effect (ie. the latest rendered one)
  1439. * @returns the cached effect
  1440. */
  1441. getCachedEffect(): Nullable<Effect>;
  1442. /**
  1443. * Gets the cached visibility state (ie. the latest rendered one)
  1444. * @returns the cached visibility state
  1445. */
  1446. getCachedVisibility(): Nullable<number>;
  1447. /**
  1448. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1449. * @param material defines the current material
  1450. * @param effect defines the current effect
  1451. * @param visibility defines the current visibility state
  1452. * @returns true if one parameter is not cached
  1453. */
  1454. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1455. /**
  1456. * Gets the bounding box renderer associated with the scene
  1457. * @returns a BoundingBoxRenderer
  1458. */
  1459. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1460. /**
  1461. * Gets the outline renderer associated with the scene
  1462. * @returns a OutlineRenderer
  1463. */
  1464. getOutlineRenderer(): OutlineRenderer;
  1465. /**
  1466. * Gets the engine associated with the scene
  1467. * @returns an Engine
  1468. */
  1469. getEngine(): Engine;
  1470. /**
  1471. * Gets the total number of vertices rendered per frame
  1472. * @returns the total number of vertices rendered per frame
  1473. */
  1474. getTotalVertices(): number;
  1475. /**
  1476. * Gets the performance counter for total vertices
  1477. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1478. */
  1479. readonly totalVerticesPerfCounter: PerfCounter;
  1480. /**
  1481. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1482. * @returns the total number of active indices rendered per frame
  1483. */
  1484. getActiveIndices(): number;
  1485. /**
  1486. * Gets the performance counter for active indices
  1487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1488. */
  1489. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1490. /**
  1491. * Gets the total number of active particles rendered per frame
  1492. * @returns the total number of active particles rendered per frame
  1493. */
  1494. getActiveParticles(): number;
  1495. /**
  1496. * Gets the performance counter for active particles
  1497. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1498. */
  1499. readonly activeParticlesPerfCounter: PerfCounter;
  1500. /**
  1501. * Gets the total number of active bones rendered per frame
  1502. * @returns the total number of active bones rendered per frame
  1503. */
  1504. getActiveBones(): number;
  1505. /**
  1506. * Gets the performance counter for active bones
  1507. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1508. */
  1509. readonly activeBonesPerfCounter: PerfCounter;
  1510. /** @ignore */
  1511. getInterFramePerfCounter(): number;
  1512. /** @ignore */
  1513. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1514. /** @ignore */
  1515. getLastFrameDuration(): number;
  1516. /** @ignore */
  1517. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1518. /** @ignore */
  1519. getEvaluateActiveMeshesDuration(): number;
  1520. /** @ignore */
  1521. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1522. /**
  1523. * Gets the array of active meshes
  1524. * @returns an array of AbstractMesh
  1525. */
  1526. getActiveMeshes(): SmartArray<AbstractMesh>;
  1527. /** @ignore */
  1528. getRenderTargetsDuration(): number;
  1529. /** @ignore */
  1530. getRenderDuration(): number;
  1531. /** @ignore */
  1532. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1533. /** @ignore */
  1534. getParticlesDuration(): number;
  1535. /** @ignore */
  1536. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1537. /** @ignore */
  1538. getSpritesDuration(): number;
  1539. /** @ignore */
  1540. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1541. /**
  1542. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1543. * @returns a number
  1544. */
  1545. getAnimationRatio(): number;
  1546. /**
  1547. * Gets an unique Id for the current frame
  1548. * @returns a number
  1549. */
  1550. getRenderId(): number;
  1551. /** Call this function if you want to manually increment the render Id*/
  1552. incrementRenderId(): void;
  1553. private _updatePointerPosition(evt);
  1554. private _createUbo();
  1555. private _createAlternateUbo();
  1556. /**
  1557. * Use this method to simulate a pointer move on a mesh
  1558. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1559. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1560. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1561. * @returns the current scene
  1562. */
  1563. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1564. private _processPointerMove(pickResult, evt);
  1565. /**
  1566. * Use this method to simulate a pointer down on a mesh
  1567. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1568. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1569. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1570. * @returns the current scene
  1571. */
  1572. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1573. private _processPointerDown(pickResult, evt);
  1574. /**
  1575. * Use this method to simulate a pointer up on a mesh
  1576. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1577. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1578. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1579. * @returns the current scene
  1580. */
  1581. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1582. private _processPointerUp(pickResult, evt, clickInfo);
  1583. /**
  1584. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1585. * @param attachUp defines if you want to attach events to pointerup
  1586. * @param attachDown defines if you want to attach events to pointerdown
  1587. * @param attachMove defines if you want to attach events to pointermove
  1588. */
  1589. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1590. /** Detaches all event handlers*/
  1591. detachControl(): void;
  1592. /**
  1593. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1594. * Delay loaded resources are not taking in account
  1595. * @return true if all required resources are ready
  1596. */
  1597. isReady(): boolean;
  1598. /** Resets all cached information relative to material (including effect and visibility) */
  1599. resetCachedMaterial(): void;
  1600. /**
  1601. * Registers a function to be called before every frame render
  1602. * @param func defines the function to register
  1603. */
  1604. registerBeforeRender(func: () => void): void;
  1605. /**
  1606. * Unregisters a function called before every frame render
  1607. * @param func defines the function to unregister
  1608. */
  1609. unregisterBeforeRender(func: () => void): void;
  1610. /**
  1611. * Registers a function to be called after every frame render
  1612. * @param func defines the function to register
  1613. */
  1614. registerAfterRender(func: () => void): void;
  1615. /**
  1616. * Unregisters a function called after every frame render
  1617. * @param func defines the function to unregister
  1618. */
  1619. unregisterAfterRender(func: () => void): void;
  1620. private _executeOnceBeforeRender(func);
  1621. /**
  1622. * The provided function will run before render once and will be disposed afterwards.
  1623. * A timeout delay can be provided so that the function will be executed in N ms.
  1624. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1625. * @param func The function to be executed.
  1626. * @param timeout optional delay in ms
  1627. */
  1628. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1629. /** @ignore */
  1630. _addPendingData(data: any): void;
  1631. /** @ignore */
  1632. _removePendingData(data: any): void;
  1633. /**
  1634. * Returns the number of items waiting to be loaded
  1635. * @returns the number of items waiting to be loaded
  1636. */
  1637. getWaitingItemsCount(): number;
  1638. /**
  1639. * Returns a boolean indicating if the scene is still loading data
  1640. */
  1641. readonly isLoading: boolean;
  1642. /**
  1643. * Registers a function to be executed when the scene is ready
  1644. * @param {Function} func - the function to be executed
  1645. */
  1646. executeWhenReady(func: () => void): void;
  1647. /**
  1648. * Returns a promise that resolves when the scene is ready
  1649. * @returns A promise that resolves when the scene is ready
  1650. */
  1651. whenReadyAsync(): Promise<void>;
  1652. /** @ignore */
  1653. _checkIsReady(): void;
  1654. /**
  1655. * Will start the animation sequence of a given target
  1656. * @param target defines the target
  1657. * @param from defines from which frame should animation start
  1658. * @param to defines until which frame should animation run.
  1659. * @param weight defines the weight to apply to the animation (1.0 by default)
  1660. * @param loop defines if the animation loops
  1661. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1662. * @param onAnimationEnd defines the function to be executed when the animation ends
  1663. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1664. * @returns the animatable object created for this animation
  1665. */
  1666. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1667. /**
  1668. * Will start the animation sequence of a given target
  1669. * @param target defines the target
  1670. * @param from defines from which frame should animation start
  1671. * @param to defines until which frame should animation run.
  1672. * @param loop defines if the animation loops
  1673. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1674. * @param onAnimationEnd defines the function to be executed when the animation ends
  1675. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1676. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1677. * @returns the animatable object created for this animation
  1678. */
  1679. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1680. /**
  1681. * Begin a new animation on a given node
  1682. * @param target defines the target where the animation will take place
  1683. * @param animations defines the list of animations to start
  1684. * @param from defines the initial value
  1685. * @param to defines the final value
  1686. * @param loop defines if you want animation to loop (off by default)
  1687. * @param speedRatio defines the speed ratio to apply to all animations
  1688. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1689. * @returns the list of created animatables
  1690. */
  1691. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1692. /**
  1693. * Begin a new animation on a given node and its hierarchy
  1694. * @param target defines the root node where the animation will take place
  1695. * @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.
  1696. * @param animations defines the list of animations to start
  1697. * @param from defines the initial value
  1698. * @param to defines the final value
  1699. * @param loop defines if you want animation to loop (off by default)
  1700. * @param speedRatio defines the speed ratio to apply to all animations
  1701. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1702. * @returns the list of animatables created for all nodes
  1703. */
  1704. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1705. /**
  1706. * Gets the animatable associated with a specific target
  1707. * @param target defines the target of the animatable
  1708. * @returns the required animatable if found
  1709. */
  1710. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1711. /**
  1712. * Gets all animatables associated with a given target
  1713. * @param target defines the target to look animatables for
  1714. * @returns an array of Animatables
  1715. */
  1716. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1717. /**
  1718. * Gets all animatable attached to the scene
  1719. */
  1720. readonly animatables: Animatable[];
  1721. /**
  1722. * Will stop the animation of the given target
  1723. * @param target - the target
  1724. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1725. */
  1726. stopAnimation(target: any, animationName?: string): void;
  1727. /**
  1728. * Stops and removes all animations that have been applied to the scene
  1729. */
  1730. stopAllAnimations(): void;
  1731. private _animate();
  1732. /** @ignore */
  1733. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation): void;
  1734. private _processLateAnimationBindings();
  1735. /** @ignore */
  1736. _switchToAlternateCameraConfiguration(active: boolean): void;
  1737. /**
  1738. * Gets the current view matrix
  1739. * @returns a Matrix
  1740. */
  1741. getViewMatrix(): Matrix;
  1742. /**
  1743. * Gets the current projection matrix
  1744. * @returns a Matrix
  1745. */
  1746. getProjectionMatrix(): Matrix;
  1747. /**
  1748. * Gets the current transform matrix
  1749. * @returns a Matrix made of View * Projection
  1750. */
  1751. getTransformMatrix(): Matrix;
  1752. /**
  1753. * Sets the current transform matrix
  1754. * @param view defines the View matrix to use
  1755. * @param projection defines the Projection matrix to use
  1756. */
  1757. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1758. /** @ignore */
  1759. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1760. /**
  1761. * Gets the uniform buffer used to store scene data
  1762. * @returns a UniformBuffer
  1763. */
  1764. getSceneUniformBuffer(): UniformBuffer;
  1765. /**
  1766. * Gets an unique (relatively to the current scene) Id
  1767. * @returns an unique number for the scene
  1768. */
  1769. getUniqueId(): number;
  1770. /**
  1771. * Add a mesh to the list of scene's meshes
  1772. * @param newMesh defines the mesh to add
  1773. */
  1774. addMesh(newMesh: AbstractMesh): void;
  1775. /**
  1776. * Remove a mesh for the list of scene's meshes
  1777. * @param toRemove defines the mesh to remove
  1778. * @returns the index where the mesh was in the mesh list
  1779. */
  1780. removeMesh(toRemove: AbstractMesh): number;
  1781. /**
  1782. * Add a transform node to the list of scene's transform nodes
  1783. * @param newTransformNode defines the transform node to add
  1784. */
  1785. addTransformNode(newTransformNode: TransformNode): void;
  1786. /**
  1787. * Remove a transform node for the list of scene's transform nodes
  1788. * @param toRemove defines the transform node to remove
  1789. * @returns the index where the transform node was in the transform node list
  1790. */
  1791. removeTransformNode(toRemove: TransformNode): number;
  1792. /**
  1793. * Remove a skeleton for the list of scene's skeletons
  1794. * @param toRemove defines the skeleton to remove
  1795. * @returns the index where the skeleton was in the skeleton list
  1796. */
  1797. removeSkeleton(toRemove: Skeleton): number;
  1798. /**
  1799. * Remove a morph target for the list of scene's morph targets
  1800. * @param toRemove defines the morph target to remove
  1801. * @returns the index where the morph target was in the morph target list
  1802. */
  1803. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1804. /**
  1805. * Remove a light for the list of scene's lights
  1806. * @param toRemove defines the light to remove
  1807. * @returns the index where the light was in the light list
  1808. */
  1809. removeLight(toRemove: Light): number;
  1810. /**
  1811. * Remove a camera for the list of scene's cameras
  1812. * @param toRemove defines the camera to remove
  1813. * @returns the index where the camera was in the camera list
  1814. */
  1815. removeCamera(toRemove: Camera): number;
  1816. /**
  1817. * Remove a particle system for the list of scene's particle systems
  1818. * @param toRemove defines the particle system to remove
  1819. * @returns the index where the particle system was in the particle system list
  1820. */
  1821. removeParticleSystem(toRemove: IParticleSystem): number;
  1822. /**
  1823. * Remove a animation for the list of scene's animations
  1824. * @param toRemove defines the animation to remove
  1825. * @returns the index where the animation was in the animation list
  1826. */
  1827. removeAnimation(toRemove: Animation): number;
  1828. /**
  1829. * Removes the given animation group from this scene.
  1830. * @param toRemove The animation group to remove
  1831. * @returns The index of the removed animation group
  1832. */
  1833. removeAnimationGroup(toRemove: AnimationGroup): number;
  1834. /**
  1835. * Removes the given multi-material from this scene.
  1836. * @param toRemove The multi-material to remove
  1837. * @returns The index of the removed multi-material
  1838. */
  1839. removeMultiMaterial(toRemove: MultiMaterial): number;
  1840. /**
  1841. * Removes the given material from this scene.
  1842. * @param toRemove The material to remove
  1843. * @returns The index of the removed material
  1844. */
  1845. removeMaterial(toRemove: Material): number;
  1846. /**
  1847. * Removes the given lens flare system from this scene.
  1848. * @param toRemove The lens flare system to remove
  1849. * @returns The index of the removed lens flare system
  1850. */
  1851. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1852. /**
  1853. * Removes the given action manager from this scene.
  1854. * @param toRemove The action manager to remove
  1855. * @returns The index of the removed action manager
  1856. */
  1857. removeActionManager(toRemove: ActionManager): number;
  1858. /**
  1859. * Removes the given texture from this scene.
  1860. * @param toRemove The texture to remove
  1861. * @returns The index of the removed texture
  1862. */
  1863. removeTexture(toRemove: BaseTexture): number;
  1864. /**
  1865. * Adds the given light to this scene
  1866. * @param newLight The light to add
  1867. */
  1868. addLight(newLight: Light): void;
  1869. /**
  1870. * Sorts the list list based on light priorities
  1871. */
  1872. sortLightsByPriority(): void;
  1873. /**
  1874. * Adds the given camera to this scene
  1875. * @param newCamera The camera to add
  1876. */
  1877. addCamera(newCamera: Camera): void;
  1878. /**
  1879. * Adds the given skeleton to this scene
  1880. * @param newSkeleton The skeleton to add
  1881. */
  1882. addSkeleton(newSkeleton: Skeleton): void;
  1883. /**
  1884. * Adds the given particle system to this scene
  1885. * @param newParticleSystem The particle system to add
  1886. */
  1887. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1888. /**
  1889. * Adds the given animation to this scene
  1890. * @param newAnimation The animation to add
  1891. */
  1892. addAnimation(newAnimation: Animation): void;
  1893. /**
  1894. * Adds the given animation group to this scene.
  1895. * @param newAnimationGroup The animation group to add
  1896. */
  1897. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1898. /**
  1899. * Adds the given multi-material to this scene
  1900. * @param newMultiMaterial The multi-material to add
  1901. */
  1902. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1903. /**
  1904. * Adds the given material to this scene
  1905. * @param newMaterial The material to add
  1906. */
  1907. addMaterial(newMaterial: Material): void;
  1908. /**
  1909. * Adds the given morph target to this scene
  1910. * @param newMorphTargetManager The morph target to add
  1911. */
  1912. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1913. /**
  1914. * Adds the given geometry to this scene
  1915. * @param newGeometry The geometry to add
  1916. */
  1917. addGeometry(newGeometry: Geometry): void;
  1918. /**
  1919. * Adds the given lens flare system to this scene
  1920. * @param newLensFlareSystem The lens flare system to add
  1921. */
  1922. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1923. /**
  1924. * Adds the given action manager to this scene
  1925. * @param newActionManager The action manager to add
  1926. */
  1927. addActionManager(newActionManager: ActionManager): void;
  1928. /**
  1929. * Adds the given texture to this scene.
  1930. * @param newTexture The texture to add
  1931. */
  1932. addTexture(newTexture: BaseTexture): void;
  1933. /**
  1934. * Switch active camera
  1935. * @param newCamera defines the new active camera
  1936. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1937. */
  1938. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1939. /**
  1940. * sets the active camera of the scene using its ID
  1941. * @param id defines the camera's ID
  1942. * @return the new active camera or null if none found.
  1943. */
  1944. setActiveCameraByID(id: string): Nullable<Camera>;
  1945. /**
  1946. * sets the active camera of the scene using its name
  1947. * @param name defines the camera's name
  1948. * @returns the new active camera or null if none found.
  1949. */
  1950. setActiveCameraByName(name: string): Nullable<Camera>;
  1951. /**
  1952. * get an animation group using its name
  1953. * @param name defines the material's name
  1954. * @return the animation group or null if none found.
  1955. */
  1956. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1957. /**
  1958. * get a material using its id
  1959. * @param id defines the material's ID
  1960. * @return the material or null if none found.
  1961. */
  1962. getMaterialByID(id: string): Nullable<Material>;
  1963. /**
  1964. * Gets a material using its name
  1965. * @param name defines the material's name
  1966. * @return the material or null if none found.
  1967. */
  1968. getMaterialByName(name: string): Nullable<Material>;
  1969. /**
  1970. * Gets a lens flare system using its name
  1971. * @param name defines the name to look for
  1972. * @returns the lens flare system or null if not found
  1973. */
  1974. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  1975. /**
  1976. * Gets a lens flare system using its id
  1977. * @param id defines the id to look for
  1978. * @returns the lens flare system or null if not found
  1979. */
  1980. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  1981. /**
  1982. * Gets a camera using its id
  1983. * @param id defines the id to look for
  1984. * @returns the camera or null if not found
  1985. */
  1986. getCameraByID(id: string): Nullable<Camera>;
  1987. /**
  1988. * Gets a camera using its unique id
  1989. * @param uniqueId defines the unique id to look for
  1990. * @returns the camera or null if not found
  1991. */
  1992. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1993. /**
  1994. * Gets a camera using its name
  1995. * @param name defines the camera's name
  1996. * @return the camera or null if none found.
  1997. */
  1998. getCameraByName(name: string): Nullable<Camera>;
  1999. /**
  2000. * Gets a bone using its id
  2001. * @param id defines the bone's id
  2002. * @return the bone or null if not found
  2003. */
  2004. getBoneByID(id: string): Nullable<Bone>;
  2005. /**
  2006. * Gets a bone using its id
  2007. * @param name defines the bone's name
  2008. * @return the bone or null if not found
  2009. */
  2010. getBoneByName(name: string): Nullable<Bone>;
  2011. /**
  2012. * Gets a light node using its name
  2013. * @param name defines the the light's name
  2014. * @return the light or null if none found.
  2015. */
  2016. getLightByName(name: string): Nullable<Light>;
  2017. /**
  2018. * Gets a light node using its id
  2019. * @param id defines the light's id
  2020. * @return the light or null if none found.
  2021. */
  2022. getLightByID(id: string): Nullable<Light>;
  2023. /**
  2024. * Gets a light node using its scene-generated unique ID
  2025. * @param uniqueId defines the light's unique id
  2026. * @return the light or null if none found.
  2027. */
  2028. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2029. /**
  2030. * Gets a particle system by id
  2031. * @param id defines the particle system id
  2032. * @return the corresponding system or null if none found
  2033. */
  2034. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2035. /**
  2036. * Gets a geometry using its ID
  2037. * @param id defines the geometry's id
  2038. * @return the geometry or null if none found.
  2039. */
  2040. getGeometryByID(id: string): Nullable<Geometry>;
  2041. /**
  2042. * Add a new geometry to this scene
  2043. * @param geometry defines the geometry to be added to the scene.
  2044. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2045. * @return a boolean defining if the geometry was added or not
  2046. */
  2047. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2048. /**
  2049. * Removes an existing geometry
  2050. * @param geometry defines the geometry to be removed from the scene
  2051. * @return a boolean defining if the geometry was removed or not
  2052. */
  2053. removeGeometry(geometry: Geometry): boolean;
  2054. /**
  2055. * Gets the list of geometries attached to the scene
  2056. * @returns an array of Geometry
  2057. */
  2058. getGeometries(): Geometry[];
  2059. /**
  2060. * Gets the first added mesh found of a given ID
  2061. * @param id defines the id to search for
  2062. * @return the mesh found or null if not found at all
  2063. */
  2064. getMeshByID(id: string): Nullable<AbstractMesh>;
  2065. /**
  2066. * Gets a list of meshes using their id
  2067. * @param id defines the id to search for
  2068. * @returns a list of meshes
  2069. */
  2070. getMeshesByID(id: string): Array<AbstractMesh>;
  2071. /**
  2072. * Gets the first added transform node found of a given ID
  2073. * @param id defines the id to search for
  2074. * @return the found transform node or null if not found at all.
  2075. */
  2076. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2077. /**
  2078. * Gets a list of transform nodes using their id
  2079. * @param id defines the id to search for
  2080. * @returns a list of transform nodes
  2081. */
  2082. getTransformNodesByID(id: string): Array<TransformNode>;
  2083. /**
  2084. * Gets a mesh with its auto-generated unique id
  2085. * @param uniqueId defines the unique id to search for
  2086. * @return the found mesh or null if not found at all.
  2087. */
  2088. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2089. /**
  2090. * Gets a the last added mesh using a given id
  2091. * @param id defines the id to search for
  2092. * @return the found mesh or null if not found at all.
  2093. */
  2094. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2095. /**
  2096. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2097. * @param id defines the id to search for
  2098. * @return the found node or null if not found at all
  2099. */
  2100. getLastEntryByID(id: string): Nullable<Node>;
  2101. /**
  2102. * Gets a node (Mesh, Camera, Light) using a given id
  2103. * @param id defines the id to search for
  2104. * @return the found node or null if not found at all
  2105. */
  2106. getNodeByID(id: string): Nullable<Node>;
  2107. /**
  2108. * Gets a node (Mesh, Camera, Light) using a given name
  2109. * @param name defines the name to search for
  2110. * @return the found node or null if not found at all.
  2111. */
  2112. getNodeByName(name: string): Nullable<Node>;
  2113. /**
  2114. * Gets a mesh using a given name
  2115. * @param name defines the name to search for
  2116. * @return the found mesh or null if not found at all.
  2117. */
  2118. getMeshByName(name: string): Nullable<AbstractMesh>;
  2119. /**
  2120. * Gets a transform node using a given name
  2121. * @param name defines the name to search for
  2122. * @return the found transform node or null if not found at all.
  2123. */
  2124. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2125. /**
  2126. * Gets a sound using a given name
  2127. * @param name defines the name to search for
  2128. * @return the found sound or null if not found at all.
  2129. */
  2130. getSoundByName(name: string): Nullable<Sound>;
  2131. /**
  2132. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2133. * @param id defines the id to search for
  2134. * @return the found skeleton or null if not found at all.
  2135. */
  2136. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2137. /**
  2138. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2139. * @param id defines the id to search for
  2140. * @return the found skeleton or null if not found at all.
  2141. */
  2142. getSkeletonById(id: string): Nullable<Skeleton>;
  2143. /**
  2144. * Gets a skeleton using a given name
  2145. * @param name defines the name to search for
  2146. * @return the found skeleton or null if not found at all.
  2147. */
  2148. getSkeletonByName(name: string): Nullable<Skeleton>;
  2149. /**
  2150. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2151. * @param id defines the id to search for
  2152. * @return the found morph target manager or null if not found at all.
  2153. */
  2154. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2155. /**
  2156. * Gets a boolean indicating if the given mesh is active
  2157. * @param mesh defines the mesh to look for
  2158. * @returns true if the mesh is in the active list
  2159. */
  2160. isActiveMesh(mesh: AbstractMesh): boolean;
  2161. /**
  2162. * Return a the first highlight layer of the scene with a given name.
  2163. * @param name The name of the highlight layer to look for.
  2164. * @return The highlight layer if found otherwise null.
  2165. */
  2166. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  2167. /**
  2168. * Return a the first highlight layer of the scene with a given name.
  2169. * @param name The name of the highlight layer to look for.
  2170. * @return The highlight layer if found otherwise null.
  2171. */
  2172. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  2173. /**
  2174. * Return a unique id as a string which can serve as an identifier for the scene
  2175. */
  2176. readonly uid: string;
  2177. /**
  2178. * Add an externaly attached data from its key.
  2179. * This method call will fail and return false, if such key already exists.
  2180. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2181. * @param key the unique key that identifies the data
  2182. * @param data the data object to associate to the key for this Engine instance
  2183. * @return true if no such key were already present and the data was added successfully, false otherwise
  2184. */
  2185. addExternalData<T>(key: string, data: T): boolean;
  2186. /**
  2187. * Get an externaly attached data from its key
  2188. * @param key the unique key that identifies the data
  2189. * @return the associated data, if present (can be null), or undefined if not present
  2190. */
  2191. getExternalData<T>(key: string): Nullable<T>;
  2192. /**
  2193. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2194. * @param key the unique key that identifies the data
  2195. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2196. * @return the associated data, can be null if the factory returned null.
  2197. */
  2198. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2199. /**
  2200. * Remove an externaly attached data from the Engine instance
  2201. * @param key the unique key that identifies the data
  2202. * @return true if the data was successfully removed, false if it doesn't exist
  2203. */
  2204. removeExternalData(key: string): boolean;
  2205. private _evaluateSubMesh(subMesh, mesh);
  2206. /**
  2207. * Clear the processed materials smart array preventing retention point in material dispose.
  2208. */
  2209. freeProcessedMaterials(): void;
  2210. /**
  2211. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2212. */
  2213. freeActiveMeshes(): void;
  2214. /**
  2215. * Clear the info related to rendering groups preventing retention points during dispose.
  2216. */
  2217. freeRenderingGroups(): void;
  2218. /** @ignore */
  2219. _isInIntermediateRendering(): boolean;
  2220. private _activeMeshCandidateProvider;
  2221. /**
  2222. * Defines the current active mesh candidate provider
  2223. * @param provider defines the provider to use
  2224. */
  2225. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2226. /**
  2227. * Gets the current active mesh candidate provider
  2228. * @returns the current active mesh candidate provider
  2229. */
  2230. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2231. private _activeMeshesFrozen;
  2232. /**
  2233. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2234. * @returns the current scene
  2235. */
  2236. freezeActiveMeshes(): Scene;
  2237. /**
  2238. * Use this function to restart evaluating active meshes on every frame
  2239. * @returns the current scene
  2240. */
  2241. unfreezeActiveMeshes(): Scene;
  2242. private _evaluateActiveMeshes();
  2243. private _activeMesh(sourceMesh, mesh);
  2244. /**
  2245. * Update the transform matrix to update from the current active camera
  2246. * @param force defines a boolean used to force the update even if cache is up to date
  2247. */
  2248. updateTransformMatrix(force?: boolean): void;
  2249. /**
  2250. * 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)
  2251. * @param alternateCamera defines the camera to use
  2252. */
  2253. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2254. private _renderForCamera(camera, rigParent?);
  2255. private _processSubCameras(camera);
  2256. private _checkIntersections();
  2257. /**
  2258. * Render the scene
  2259. */
  2260. render(): void;
  2261. private _updateAudioParameters();
  2262. /**
  2263. * Gets or sets if audio support is enabled
  2264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2265. */
  2266. audioEnabled: boolean;
  2267. private _disableAudio();
  2268. private _enableAudio();
  2269. /**
  2270. * Gets or sets if audio will be output to headphones
  2271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2272. */
  2273. headphone: boolean;
  2274. private _switchAudioModeForHeadphones();
  2275. private _switchAudioModeForNormalSpeakers();
  2276. /**
  2277. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2278. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2279. * @returns the created depth renderer
  2280. */
  2281. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2282. /**
  2283. * Disables a depth renderer for a given camera
  2284. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2285. */
  2286. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2287. /**
  2288. * Enables a GeometryBufferRender and associates it with the scene
  2289. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2290. * @returns the GeometryBufferRenderer
  2291. */
  2292. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2293. /**
  2294. * Disables the GeometryBufferRender associated with the scene
  2295. */
  2296. disableGeometryBufferRenderer(): void;
  2297. /**
  2298. * Freeze all materials
  2299. * A frozen material will not be updatable but should be faster to render
  2300. */
  2301. freezeMaterials(): void;
  2302. /**
  2303. * Unfreeze all materials
  2304. * A frozen material will not be updatable but should be faster to render
  2305. */
  2306. unfreezeMaterials(): void;
  2307. /**
  2308. * Releases all held ressources
  2309. */
  2310. dispose(): void;
  2311. /**
  2312. * Gets if the scene is already disposed
  2313. */
  2314. readonly isDisposed: boolean;
  2315. /**
  2316. * Releases sounds & soundtracks
  2317. */
  2318. disposeSounds(): void;
  2319. /**
  2320. * Get the world extend vectors with an optional filter
  2321. *
  2322. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2323. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2324. */
  2325. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2326. min: Vector3;
  2327. max: Vector3;
  2328. };
  2329. /**
  2330. * Creates or updates the octree used to boost selection (picking)
  2331. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2332. * @param maxCapacity defines the maximum capacity per leaf
  2333. * @param maxDepth defines the maximum depth of the octree
  2334. * @returns an octree of AbstractMesh
  2335. */
  2336. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2337. /**
  2338. * Creates a ray that can be used to pick in the scene
  2339. * @param x defines the x coordinate of the origin (on-screen)
  2340. * @param y defines the y coordinate of the origin (on-screen)
  2341. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2342. * @param camera defines the camera to use for the picking
  2343. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2344. * @returns a Ray
  2345. */
  2346. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2347. /**
  2348. * Creates a ray that can be used to pick in the scene
  2349. * @param x defines the x coordinate of the origin (on-screen)
  2350. * @param y defines the y coordinate of the origin (on-screen)
  2351. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2352. * @param result defines the ray where to store the picking ray
  2353. * @param camera defines the camera to use for the picking
  2354. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2355. * @returns the current scene
  2356. */
  2357. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2358. /**
  2359. * Creates a ray that can be used to pick in the scene
  2360. * @param x defines the x coordinate of the origin (on-screen)
  2361. * @param y defines the y coordinate of the origin (on-screen)
  2362. * @param camera defines the camera to use for the picking
  2363. * @returns a Ray
  2364. */
  2365. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2366. /**
  2367. * Creates a ray that can be used to pick in the scene
  2368. * @param x defines the x coordinate of the origin (on-screen)
  2369. * @param y defines the y coordinate of the origin (on-screen)
  2370. * @param result defines the ray where to store the picking ray
  2371. * @param camera defines the camera to use for the picking
  2372. * @returns the current scene
  2373. */
  2374. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2375. private _internalPick(rayFunction, predicate?, fastCheck?);
  2376. private _internalMultiPick(rayFunction, predicate?);
  2377. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2378. private _tempPickingRay;
  2379. /** Launch a ray to try to pick a mesh in the scene
  2380. * @param x position on screen
  2381. * @param y position on screen
  2382. * @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
  2383. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2384. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2385. * @returns a PickingInfo
  2386. */
  2387. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2388. /** Launch a ray to try to pick a sprite in the scene
  2389. * @param x position on screen
  2390. * @param y position on screen
  2391. * @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
  2392. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2393. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2394. * @returns a PickingInfo
  2395. */
  2396. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2397. private _cachedRayForTransform;
  2398. /** Use the given ray to pick a mesh in the scene
  2399. * @param ray The ray to use to pick meshes
  2400. * @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
  2401. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2402. * @returns a PickingInfo
  2403. */
  2404. pickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2405. /**
  2406. * Launch a ray to try to pick a mesh in the scene
  2407. * @param x X position on screen
  2408. * @param y Y position on screen
  2409. * @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
  2410. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2411. * @returns an array of PickingInfo
  2412. */
  2413. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2414. /**
  2415. * Launch a ray to try to pick a mesh in the scene
  2416. * @param ray Ray to use
  2417. * @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
  2418. * @returns an array of PickingInfo
  2419. */
  2420. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2421. /**
  2422. * Force the value of meshUnderPointer
  2423. * @param mesh defines the mesh to use
  2424. */
  2425. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2426. /**
  2427. * Gets the mesh under the pointer
  2428. * @returns a Mesh or null if no mesh is under the pointer
  2429. */
  2430. getPointerOverMesh(): Nullable<AbstractMesh>;
  2431. /**
  2432. * Force the sprite under the pointer
  2433. * @param sprite defines the sprite to use
  2434. */
  2435. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2436. /**
  2437. * Gets the sprite under the pointer
  2438. * @returns a Sprite or null if no sprite is under the pointer
  2439. */
  2440. getPointerOverSprite(): Nullable<Sprite>;
  2441. /**
  2442. * Gets the current physics engine
  2443. * @returns a PhysicsEngine or null if none attached
  2444. */
  2445. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2446. /**
  2447. * Enables physics to the current scene
  2448. * @param gravity defines the scene's gravity for the physics engine
  2449. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2450. * @return a boolean indicating if the physics engine was initialized
  2451. */
  2452. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2453. /**
  2454. * Disables and disposes the physics engine associated with the scene
  2455. */
  2456. disablePhysicsEngine(): void;
  2457. /**
  2458. * Gets a boolean indicating if there is an active physics engine
  2459. * @returns a boolean indicating if there is an active physics engine
  2460. */
  2461. isPhysicsEnabled(): boolean;
  2462. /**
  2463. * Deletes a physics compound impostor
  2464. * @param compound defines the compound to delete
  2465. */
  2466. deleteCompoundImpostor(compound: any): void;
  2467. /** @ignore */
  2468. _rebuildGeometries(): void;
  2469. /** @ignore */
  2470. _rebuildTextures(): void;
  2471. /**
  2472. * Creates a default light for the scene.
  2473. * @param replace Whether to replace the existing lights in the scene.
  2474. */
  2475. createDefaultLight(replace?: boolean): void;
  2476. /**
  2477. * Creates a default camera for the scene.
  2478. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2479. * @param replace Whether to replace the existing active camera in the scene.
  2480. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2481. */
  2482. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2483. /**
  2484. * Creates a default camera and a default light
  2485. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2486. * @param replace defines if the camera and/or light will replace the existing ones
  2487. * @param attachCameraControls defines if attachControl will be called on the new camera
  2488. */
  2489. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2490. /**
  2491. * Creates a new sky box
  2492. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2493. * @param environmentTexture defines the texture to use as environment texture
  2494. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2495. * @param scale defines the overall scale of the skybox
  2496. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2497. * @returns a new mesh holding the sky box
  2498. */
  2499. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number): Nullable<Mesh>;
  2500. /**
  2501. * Creates a new environment
  2502. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2503. * @param options defines the options you can use to configure the environment
  2504. * @returns the new EnvironmentHelper
  2505. */
  2506. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2507. /**
  2508. * Creates a new VREXperienceHelper
  2509. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2510. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2511. * @returns a new VREXperienceHelper
  2512. */
  2513. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2514. private _getByTags(list, tagsQuery, forEach?);
  2515. /**
  2516. * Get a list of meshes by tags
  2517. * @param tagsQuery defines the tags query to use
  2518. * @param forEach defines a predicate used to filter results
  2519. * @returns an array of Mesh
  2520. */
  2521. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2522. /**
  2523. * Get a list of cameras by tags
  2524. * @param tagsQuery defines the tags query to use
  2525. * @param forEach defines a predicate used to filter results
  2526. * @returns an array of Camera
  2527. */
  2528. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2529. /**
  2530. * Get a list of lights by tags
  2531. * @param tagsQuery defines the tags query to use
  2532. * @param forEach defines a predicate used to filter results
  2533. * @returns an array of Light
  2534. */
  2535. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2536. /**
  2537. * Get a list of materials by tags
  2538. * @param tagsQuery defines the tags query to use
  2539. * @param forEach defines a predicate used to filter results
  2540. * @returns an array of Material
  2541. */
  2542. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2543. /**
  2544. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2545. * This allowed control for front to back rendering or reversly depending of the special needs.
  2546. *
  2547. * @param renderingGroupId The rendering group id corresponding to its index
  2548. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2549. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2550. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2551. */
  2552. 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;
  2553. /**
  2554. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2555. *
  2556. * @param renderingGroupId The rendering group id corresponding to its index
  2557. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2558. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2559. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2560. */
  2561. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2562. /**
  2563. * Will flag all materials as dirty to trigger new shader compilation
  2564. * @param flag defines the flag used to specify which material part must be marked as dirty
  2565. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2566. */
  2567. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2568. /** @ignore */
  2569. _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;
  2570. /** @ignore */
  2571. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2572. }
  2573. }
  2574. declare module BABYLON {
  2575. type Nullable<T> = T | null;
  2576. type float = number;
  2577. type double = number;
  2578. type int = number;
  2579. type FloatArray = number[] | Float32Array;
  2580. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2581. /**
  2582. * Alias for types that can be used by a Buffer or VertexBuffer.
  2583. */
  2584. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2585. }
  2586. declare module BABYLON {
  2587. /**
  2588. * The action to be carried out following a trigger
  2589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2590. */
  2591. class Action {
  2592. triggerOptions: any;
  2593. /**
  2594. * Trigger for the action
  2595. */
  2596. trigger: number;
  2597. /**
  2598. * Internal only - manager for action
  2599. * @ignore
  2600. */
  2601. _actionManager: ActionManager;
  2602. private _nextActiveAction;
  2603. private _child;
  2604. private _condition?;
  2605. private _triggerParameter;
  2606. /**
  2607. * An event triggered prior to action being executed.
  2608. */
  2609. onBeforeExecuteObservable: Observable<Action>;
  2610. /**
  2611. * Creates a new Action
  2612. * @param triggerOptions the trigger, with or without parameters, for the action
  2613. * @param condition an optional determinant of action
  2614. */
  2615. constructor(triggerOptions: any, condition?: Condition);
  2616. /**
  2617. * Internal only
  2618. * @ignore
  2619. */
  2620. _prepare(): void;
  2621. /**
  2622. * Gets the trigger parameters
  2623. * @returns the trigger parameters
  2624. */
  2625. getTriggerParameter(): any;
  2626. /**
  2627. * Internal only - executes current action event
  2628. * @ignore
  2629. */
  2630. _executeCurrent(evt?: ActionEvent): void;
  2631. /**
  2632. * Execute placeholder for child classes
  2633. * @param evt optional action event
  2634. */
  2635. execute(evt?: ActionEvent): void;
  2636. /**
  2637. * Skips to next active action
  2638. */
  2639. skipToNextActiveAction(): void;
  2640. /**
  2641. * Adds action to chain of actions, may be a DoNothingAction
  2642. * @param index The index of the attribute.
  2643. * @returns The action passed in
  2644. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2645. */
  2646. then(action: Action): Action;
  2647. /**
  2648. * Internal only
  2649. * @ignore
  2650. */
  2651. _getProperty(propertyPath: string): string;
  2652. /**
  2653. * Internal only
  2654. * @ignore
  2655. */
  2656. _getEffectiveTarget(target: any, propertyPath: string): any;
  2657. /**
  2658. * Serialize placeholder for child classes
  2659. * @param parent of child
  2660. * @returns the serialized object
  2661. */
  2662. serialize(parent: any): any;
  2663. /**
  2664. * Internal only called by serialize
  2665. * @ignore
  2666. */
  2667. protected _serialize(serializedAction: any, parent?: any): any;
  2668. /**
  2669. * Internal only
  2670. * @ignore
  2671. */
  2672. static _SerializeValueAsString: (value: any) => string;
  2673. /**
  2674. * Internal only
  2675. * @ignore
  2676. */
  2677. static _GetTargetProperty: (target: Scene | Node) => {
  2678. name: string;
  2679. targetType: string;
  2680. value: string;
  2681. };
  2682. }
  2683. }
  2684. declare module BABYLON {
  2685. /**
  2686. * ActionEvent is the event being sent when an action is triggered.
  2687. */
  2688. class ActionEvent {
  2689. source: any;
  2690. pointerX: number;
  2691. pointerY: number;
  2692. meshUnderPointer: Nullable<AbstractMesh>;
  2693. sourceEvent: any;
  2694. additionalData: any;
  2695. /**
  2696. * @param source The mesh or sprite that triggered the action.
  2697. * @param pointerX The X mouse cursor position at the time of the event
  2698. * @param pointerY The Y mouse cursor position at the time of the event
  2699. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2700. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2701. */
  2702. constructor(source: any, pointerX: number, pointerY: number, meshUnderPointer: Nullable<AbstractMesh>, sourceEvent?: any, additionalData?: any);
  2703. /**
  2704. * Helper function to auto-create an ActionEvent from a source mesh.
  2705. * @param source The source mesh that triggered the event
  2706. * @param evt {Event} The original (browser) event
  2707. */
  2708. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2709. /**
  2710. * Helper function to auto-create an ActionEvent from a source mesh.
  2711. * @param source The source sprite that triggered the event
  2712. * @param scene Scene associated with the sprite
  2713. * @param evt {Event} The original (browser) event
  2714. */
  2715. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2716. /**
  2717. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2718. * @param scene the scene where the event occurred
  2719. * @param evt {Event} The original (browser) event
  2720. */
  2721. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2722. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2723. }
  2724. /**
  2725. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2726. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2727. */
  2728. class ActionManager {
  2729. private static _NothingTrigger;
  2730. private static _OnPickTrigger;
  2731. private static _OnLeftPickTrigger;
  2732. private static _OnRightPickTrigger;
  2733. private static _OnCenterPickTrigger;
  2734. private static _OnPickDownTrigger;
  2735. private static _OnDoublePickTrigger;
  2736. private static _OnPickUpTrigger;
  2737. private static _OnLongPressTrigger;
  2738. private static _OnPointerOverTrigger;
  2739. private static _OnPointerOutTrigger;
  2740. private static _OnEveryFrameTrigger;
  2741. private static _OnIntersectionEnterTrigger;
  2742. private static _OnIntersectionExitTrigger;
  2743. private static _OnKeyDownTrigger;
  2744. private static _OnKeyUpTrigger;
  2745. private static _OnPickOutTrigger;
  2746. static readonly NothingTrigger: number;
  2747. static readonly OnPickTrigger: number;
  2748. static readonly OnLeftPickTrigger: number;
  2749. static readonly OnRightPickTrigger: number;
  2750. static readonly OnCenterPickTrigger: number;
  2751. static readonly OnPickDownTrigger: number;
  2752. static readonly OnDoublePickTrigger: number;
  2753. static readonly OnPickUpTrigger: number;
  2754. static readonly OnPickOutTrigger: number;
  2755. static readonly OnLongPressTrigger: number;
  2756. static readonly OnPointerOverTrigger: number;
  2757. static readonly OnPointerOutTrigger: number;
  2758. static readonly OnEveryFrameTrigger: number;
  2759. static readonly OnIntersectionEnterTrigger: number;
  2760. static readonly OnIntersectionExitTrigger: number;
  2761. static readonly OnKeyDownTrigger: number;
  2762. static readonly OnKeyUpTrigger: number;
  2763. static Triggers: {
  2764. [key: string]: number;
  2765. };
  2766. actions: Action[];
  2767. hoverCursor: string;
  2768. private _scene;
  2769. constructor(scene: Scene);
  2770. dispose(): void;
  2771. getScene(): Scene;
  2772. /**
  2773. * Does this action manager handles actions of any of the given triggers
  2774. * @param {number[]} triggers - the triggers to be tested
  2775. * @return {boolean} whether one (or more) of the triggers is handeled
  2776. */
  2777. hasSpecificTriggers(triggers: number[]): boolean;
  2778. /**
  2779. * Does this action manager handles actions of a given trigger
  2780. * @param {number} trigger - the trigger to be tested
  2781. * @return {boolean} whether the trigger is handeled
  2782. */
  2783. hasSpecificTrigger(trigger: number): boolean;
  2784. /**
  2785. * Does this action manager has pointer triggers
  2786. * @return {boolean} whether or not it has pointer triggers
  2787. */
  2788. readonly hasPointerTriggers: boolean;
  2789. /**
  2790. * Does this action manager has pick triggers
  2791. * @return {boolean} whether or not it has pick triggers
  2792. */
  2793. readonly hasPickTriggers: boolean;
  2794. /**
  2795. * Does exist one action manager with at least one trigger
  2796. * @return {boolean} whether or not it exists one action manager with one trigger
  2797. **/
  2798. static readonly HasTriggers: boolean;
  2799. /**
  2800. * Does exist one action manager with at least one pick trigger
  2801. * @return {boolean} whether or not it exists one action manager with one pick trigger
  2802. **/
  2803. static readonly HasPickTriggers: boolean;
  2804. /**
  2805. * Does exist one action manager that handles actions of a given trigger
  2806. * @param {number} trigger - the trigger to be tested
  2807. * @return {boolean} whether the trigger is handeled by at least one action manager
  2808. **/
  2809. static HasSpecificTrigger(trigger: number): boolean;
  2810. /**
  2811. * Registers an action to this action manager
  2812. * @param {BABYLON.Action} action - the action to be registered
  2813. * @return {BABYLON.Action} the action amended (prepared) after registration
  2814. */
  2815. registerAction(action: Action): Nullable<Action>;
  2816. /**
  2817. * Unregisters an action to this action manager
  2818. * @param action The action to be unregistered
  2819. * @return whether the action has been unregistered
  2820. */
  2821. unregisterAction(action: Action): Boolean;
  2822. /**
  2823. * Process a specific trigger
  2824. * @param {number} trigger - the trigger to process
  2825. * @param evt {BABYLON.ActionEvent} the event details to be processed
  2826. */
  2827. processTrigger(trigger: number, evt?: ActionEvent): void;
  2828. _getEffectiveTarget(target: any, propertyPath: string): any;
  2829. _getProperty(propertyPath: string): string;
  2830. serialize(name: string): any;
  2831. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  2832. static GetTriggerName(trigger: number): string;
  2833. }
  2834. }
  2835. declare module BABYLON {
  2836. /**
  2837. * A Condition applied to an Action
  2838. */
  2839. class Condition {
  2840. /**
  2841. * Internal only - manager for action
  2842. * @ignore
  2843. */
  2844. _actionManager: ActionManager;
  2845. /**
  2846. * Internal only
  2847. * @ignore
  2848. */
  2849. _evaluationId: number;
  2850. /**
  2851. * Internal only
  2852. * @ignore
  2853. */
  2854. _currentResult: boolean;
  2855. /**
  2856. * Creates a new Condition
  2857. * @param actionManager the manager of the action the condition is applied to
  2858. */
  2859. constructor(actionManager: ActionManager);
  2860. /**
  2861. * Check if the current condition is valid
  2862. * @returns a boolean
  2863. */
  2864. isValid(): boolean;
  2865. /**
  2866. * Internal only
  2867. * @ignore
  2868. */
  2869. _getProperty(propertyPath: string): string;
  2870. /**
  2871. * Internal only
  2872. * @ignore
  2873. */
  2874. _getEffectiveTarget(target: any, propertyPath: string): any;
  2875. /**
  2876. * Serialize placeholder for child classes
  2877. * @returns the serialized object
  2878. */
  2879. serialize(): any;
  2880. /**
  2881. * Internal only
  2882. * @ignore
  2883. */
  2884. protected _serialize(serializedCondition: any): any;
  2885. }
  2886. /**
  2887. * Defines specific conditional operators as extensions of Condition
  2888. */
  2889. class ValueCondition extends Condition {
  2890. propertyPath: string;
  2891. value: any;
  2892. operator: number;
  2893. /**
  2894. * Internal only
  2895. * @ignore
  2896. */
  2897. private static _IsEqual;
  2898. /**
  2899. * Internal only
  2900. * @ignore
  2901. */
  2902. private static _IsDifferent;
  2903. /**
  2904. * Internal only
  2905. * @ignore
  2906. */
  2907. private static _IsGreater;
  2908. /**
  2909. * Internal only
  2910. * @ignore
  2911. */
  2912. private static _IsLesser;
  2913. /**
  2914. * returns the number for IsEqual
  2915. */
  2916. static readonly IsEqual: number;
  2917. /**
  2918. * Returns the number for IsDifferent
  2919. */
  2920. static readonly IsDifferent: number;
  2921. /**
  2922. * Returns the number for IsGreater
  2923. */
  2924. static readonly IsGreater: number;
  2925. /**
  2926. * Returns the number for IsLesser
  2927. */
  2928. static readonly IsLesser: number;
  2929. /**
  2930. * Internal only The action manager for the condition
  2931. * @ignore
  2932. */
  2933. _actionManager: ActionManager;
  2934. /**
  2935. * Internal only
  2936. * @ignore
  2937. */
  2938. private _target;
  2939. /**
  2940. * Internal only
  2941. * @ignore
  2942. */
  2943. private _effectiveTarget;
  2944. /**
  2945. * Internal only
  2946. * @ignore
  2947. */
  2948. private _property;
  2949. /**
  2950. * Creates a new ValueCondition
  2951. * @param actionManager manager for the action the condition applies to
  2952. * @param target for the action
  2953. * @param propertyPath path to specify the property of the target the conditional operator uses
  2954. * @param value the vale compared by the conditional operator against the current value of the property
  2955. * @param operator the conditional operator, default {BABYLON.ValueCondition.IsEqual}
  2956. */
  2957. constructor(actionManager: ActionManager, target: any, propertyPath: string, value: any, operator?: number);
  2958. /**
  2959. * Compares the given value with the property value for the specified conditional operator
  2960. * @returns the result of the comparison
  2961. */
  2962. isValid(): boolean;
  2963. /**
  2964. * Serialize the ValueCondition into a JSON compatible object
  2965. * @returns serialization object
  2966. */
  2967. serialize(): any;
  2968. /**
  2969. * Gets the name of the conditional operator for the ValueCondition
  2970. * @param operator the conditional operator
  2971. * @returns the name
  2972. */
  2973. static GetOperatorName(operator: number): string;
  2974. }
  2975. /**
  2976. * Defines a predicate condition as an extension of Condition
  2977. */
  2978. class PredicateCondition extends Condition {
  2979. predicate: () => boolean;
  2980. /**
  2981. * Internal only - manager for action
  2982. * @ignore
  2983. */
  2984. _actionManager: ActionManager;
  2985. /**
  2986. * Creates a new {BABYLON.PredicateCondition}
  2987. * @param actionManager manager for the action the condition applies to
  2988. * @param predicate
  2989. */
  2990. constructor(actionManager: ActionManager, predicate: () => boolean);
  2991. /**
  2992. * @returns the validity of the predicate condition
  2993. */
  2994. isValid(): boolean;
  2995. }
  2996. /**
  2997. * Defines a state condition as an extension of {BABYLON.Condition}
  2998. */
  2999. class StateCondition extends Condition {
  3000. value: string;
  3001. /**
  3002. * Internal only - manager for action
  3003. * @ignore
  3004. */
  3005. _actionManager: ActionManager;
  3006. /**
  3007. * Internal only
  3008. * @ignore
  3009. */
  3010. private _target;
  3011. /**
  3012. * Creates a new {BABYLON.StateCondition}
  3013. * @param actionManager manager for the action the condition applies to
  3014. * @param target of the condition
  3015. * @param value to compare with target state
  3016. */
  3017. constructor(actionManager: ActionManager, target: any, value: string);
  3018. /**
  3019. * @returns the validity of the state
  3020. */
  3021. isValid(): boolean;
  3022. /**
  3023. * Serialize the {BABYLON.StateCondition} into a JSON compatible object
  3024. * @returns serialization object
  3025. */
  3026. serialize(): any;
  3027. }
  3028. }
  3029. declare module BABYLON {
  3030. class SwitchBooleanAction extends Action {
  3031. propertyPath: string;
  3032. private _target;
  3033. private _effectiveTarget;
  3034. private _property;
  3035. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3036. _prepare(): void;
  3037. execute(): void;
  3038. serialize(parent: any): any;
  3039. }
  3040. class SetStateAction extends Action {
  3041. value: string;
  3042. private _target;
  3043. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3044. execute(): void;
  3045. serialize(parent: any): any;
  3046. }
  3047. class SetValueAction extends Action {
  3048. propertyPath: string;
  3049. value: any;
  3050. private _target;
  3051. private _effectiveTarget;
  3052. private _property;
  3053. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3054. _prepare(): void;
  3055. execute(): void;
  3056. serialize(parent: any): any;
  3057. }
  3058. class IncrementValueAction extends Action {
  3059. propertyPath: string;
  3060. value: any;
  3061. private _target;
  3062. private _effectiveTarget;
  3063. private _property;
  3064. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3065. _prepare(): void;
  3066. execute(): void;
  3067. serialize(parent: any): any;
  3068. }
  3069. class PlayAnimationAction extends Action {
  3070. from: number;
  3071. to: number;
  3072. loop: boolean | undefined;
  3073. private _target;
  3074. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3075. _prepare(): void;
  3076. execute(): void;
  3077. serialize(parent: any): any;
  3078. }
  3079. class StopAnimationAction extends Action {
  3080. private _target;
  3081. constructor(triggerOptions: any, target: any, condition?: Condition);
  3082. _prepare(): void;
  3083. execute(): void;
  3084. serialize(parent: any): any;
  3085. }
  3086. class DoNothingAction extends Action {
  3087. constructor(triggerOptions?: any, condition?: Condition);
  3088. execute(): void;
  3089. serialize(parent: any): any;
  3090. }
  3091. class CombineAction extends Action {
  3092. children: Action[];
  3093. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3094. _prepare(): void;
  3095. execute(evt: ActionEvent): void;
  3096. serialize(parent: any): any;
  3097. }
  3098. class ExecuteCodeAction extends Action {
  3099. func: (evt: ActionEvent) => void;
  3100. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3101. execute(evt: ActionEvent): void;
  3102. }
  3103. class SetParentAction extends Action {
  3104. private _parent;
  3105. private _target;
  3106. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3107. _prepare(): void;
  3108. execute(): void;
  3109. serialize(parent: any): any;
  3110. }
  3111. class PlaySoundAction extends Action {
  3112. private _sound;
  3113. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3114. _prepare(): void;
  3115. execute(): void;
  3116. serialize(parent: any): any;
  3117. }
  3118. class StopSoundAction extends Action {
  3119. private _sound;
  3120. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3121. _prepare(): void;
  3122. execute(): void;
  3123. serialize(parent: any): any;
  3124. }
  3125. }
  3126. declare module BABYLON {
  3127. class InterpolateValueAction extends Action {
  3128. propertyPath: string;
  3129. value: any;
  3130. duration: number;
  3131. stopOtherAnimations: boolean | undefined;
  3132. onInterpolationDone: (() => void) | undefined;
  3133. private _target;
  3134. private _effectiveTarget;
  3135. private _property;
  3136. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3137. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3138. _prepare(): void;
  3139. execute(): void;
  3140. serialize(parent: any): any;
  3141. }
  3142. }
  3143. declare module BABYLON {
  3144. class Animatable {
  3145. target: any;
  3146. fromFrame: number;
  3147. toFrame: number;
  3148. loopAnimation: boolean;
  3149. onAnimationEnd: (() => void) | null | undefined;
  3150. private _localDelayOffset;
  3151. private _pausedDelay;
  3152. private _runtimeAnimations;
  3153. private _paused;
  3154. private _scene;
  3155. private _speedRatio;
  3156. private _weight;
  3157. private _syncRoot;
  3158. animationStarted: boolean;
  3159. /**
  3160. * Gets the root Animatable used to synchronize and normalize animations
  3161. */
  3162. readonly syncRoot: Animatable;
  3163. /**
  3164. * Gets the current frame of the first RuntimeAnimation
  3165. * Used to synchronize Animatables
  3166. */
  3167. readonly masterFrame: number;
  3168. /**
  3169. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3170. */
  3171. weight: number;
  3172. /**
  3173. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3174. */
  3175. speedRatio: number;
  3176. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3177. /**
  3178. * Synchronize and normalize current Animatable with a source Animatable.
  3179. * This is useful when using animation weights and when animations are not of the same length
  3180. * @param root defines the root Animatable to synchronize with
  3181. * @returns the current Animatable
  3182. */
  3183. syncWith(root: Animatable): Animatable;
  3184. getAnimations(): RuntimeAnimation[];
  3185. appendAnimations(target: any, animations: Animation[]): void;
  3186. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3187. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3188. reset(): void;
  3189. enableBlending(blendingSpeed: number): void;
  3190. disableBlending(): void;
  3191. goToFrame(frame: number): void;
  3192. pause(): void;
  3193. restart(): void;
  3194. stop(animationName?: string): void;
  3195. _animate(delay: number): boolean;
  3196. }
  3197. }
  3198. declare module BABYLON {
  3199. class AnimationRange {
  3200. name: string;
  3201. from: number;
  3202. to: number;
  3203. constructor(name: string, from: number, to: number);
  3204. clone(): AnimationRange;
  3205. }
  3206. /**
  3207. * Composed of a frame, and an action function
  3208. */
  3209. class AnimationEvent {
  3210. frame: number;
  3211. action: () => void;
  3212. onlyOnce: boolean | undefined;
  3213. isDone: boolean;
  3214. constructor(frame: number, action: () => void, onlyOnce?: boolean | undefined);
  3215. }
  3216. class PathCursor {
  3217. private path;
  3218. private _onchange;
  3219. value: number;
  3220. animations: Animation[];
  3221. constructor(path: Path2);
  3222. getPoint(): Vector3;
  3223. moveAhead(step?: number): PathCursor;
  3224. moveBack(step?: number): PathCursor;
  3225. move(step: number): PathCursor;
  3226. private ensureLimits();
  3227. private raiseOnChange();
  3228. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3229. }
  3230. interface IAnimationKey {
  3231. frame: number;
  3232. value: any;
  3233. inTangent?: any;
  3234. outTangent?: any;
  3235. interpolation?: AnimationKeyInterpolation;
  3236. }
  3237. enum AnimationKeyInterpolation {
  3238. /**
  3239. * Do not interpolate between keys and use the start key value only. Tangents are ignored.
  3240. */
  3241. STEP = 1,
  3242. }
  3243. class Animation {
  3244. name: string;
  3245. targetProperty: string;
  3246. framePerSecond: number;
  3247. dataType: number;
  3248. loopMode: number | undefined;
  3249. enableBlending: boolean | undefined;
  3250. static AllowMatricesInterpolation: boolean;
  3251. private _keys;
  3252. private _easingFunction;
  3253. _runtimeAnimations: RuntimeAnimation[];
  3254. private _events;
  3255. targetPropertyPath: string[];
  3256. blendingSpeed: number;
  3257. private _ranges;
  3258. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3259. /**
  3260. * Sets up an animation.
  3261. * @param property the property to animate
  3262. * @param animationType the animation type to apply
  3263. * @param easingFunction the easing function used in the animation
  3264. * @returns The created animation
  3265. */
  3266. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3267. /**
  3268. * Create and start an animation on a node
  3269. * @param {string} name defines the name of the global animation that will be run on all nodes
  3270. * @param {BABYLON.Node} node defines the root node where the animation will take place
  3271. * @param {string} targetProperty defines property to animate
  3272. * @param {number} framePerSecond defines the number of frame per second yo use
  3273. * @param {number} totalFrame defines the number of frames in total
  3274. * @param {any} from defines the initial value
  3275. * @param {any} to defines the final value
  3276. * @param {number} loopMode defines which loop mode you want to use (off by default)
  3277. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  3278. * @param onAnimationEnd defines the callback to call when animation end
  3279. * @returns the animatable created for this animation
  3280. */
  3281. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3282. /**
  3283. * Create and start an animation on a node and its descendants
  3284. * @param {string} name defines the name of the global animation that will be run on all nodes
  3285. * @param {BABYLON.Node} node defines the root node where the animation will take place
  3286. * @param {boolean} 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.
  3287. * @param {string} targetProperty defines property to animate
  3288. * @param {number} framePerSecond defines the number of frame per second yo use
  3289. * @param {number} totalFrame defines the number of frames in total
  3290. * @param {any} from defines the initial value
  3291. * @param {any} to defines the final value
  3292. * @param {number} loopMode defines which loop mode you want to use (off by default)
  3293. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  3294. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3295. * @returns the list of animatables created for all nodes
  3296. * @example https://www.babylonjs-playground.com/#MH0VLI
  3297. */
  3298. 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[]>;
  3299. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3300. /**
  3301. * Transition property of the Camera to the target Value.
  3302. * @param property The property to transition
  3303. * @param targetValue The target Value of the property
  3304. * @param host The object where the property to animate belongs
  3305. * @param scene Scene used to run the animation
  3306. * @param frameRate Framerate (in frame/s) to use
  3307. * @param transition The transition type we want to use
  3308. * @param duration The duration of the animation, in milliseconds
  3309. * @param onAnimationEnd Call back trigger at the end of the animation.
  3310. */
  3311. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3312. /**
  3313. * Return the array of runtime animations currently using this animation
  3314. */
  3315. readonly runtimeAnimations: RuntimeAnimation[];
  3316. readonly hasRunningRuntimeAnimations: boolean;
  3317. constructor(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number | undefined, enableBlending?: boolean | undefined);
  3318. /**
  3319. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  3320. */
  3321. toString(fullDetails?: boolean): string;
  3322. /**
  3323. * Add an event to this animation.
  3324. */
  3325. addEvent(event: AnimationEvent): void;
  3326. /**
  3327. * Remove all events found at the given frame
  3328. * @param frame
  3329. */
  3330. removeEvents(frame: number): void;
  3331. getEvents(): AnimationEvent[];
  3332. createRange(name: string, from: number, to: number): void;
  3333. deleteRange(name: string, deleteFrames?: boolean): void;
  3334. getRange(name: string): Nullable<AnimationRange>;
  3335. getKeys(): Array<IAnimationKey>;
  3336. getHighestFrame(): number;
  3337. getEasingFunction(): IEasingFunction;
  3338. setEasingFunction(easingFunction: EasingFunction): void;
  3339. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3340. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3341. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3342. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3343. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3344. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3345. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3346. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3347. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3348. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3349. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  3350. clone(): Animation;
  3351. setKeys(values: Array<IAnimationKey>): void;
  3352. serialize(): any;
  3353. private static _ANIMATIONTYPE_FLOAT;
  3354. private static _ANIMATIONTYPE_VECTOR3;
  3355. private static _ANIMATIONTYPE_QUATERNION;
  3356. private static _ANIMATIONTYPE_MATRIX;
  3357. private static _ANIMATIONTYPE_COLOR3;
  3358. private static _ANIMATIONTYPE_VECTOR2;
  3359. private static _ANIMATIONTYPE_SIZE;
  3360. private static _ANIMATIONLOOPMODE_RELATIVE;
  3361. private static _ANIMATIONLOOPMODE_CYCLE;
  3362. private static _ANIMATIONLOOPMODE_CONSTANT;
  3363. static readonly ANIMATIONTYPE_FLOAT: number;
  3364. static readonly ANIMATIONTYPE_VECTOR3: number;
  3365. static readonly ANIMATIONTYPE_VECTOR2: number;
  3366. static readonly ANIMATIONTYPE_SIZE: number;
  3367. static readonly ANIMATIONTYPE_QUATERNION: number;
  3368. static readonly ANIMATIONTYPE_MATRIX: number;
  3369. static readonly ANIMATIONTYPE_COLOR3: number;
  3370. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  3371. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  3372. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  3373. static Parse(parsedAnimation: any): Animation;
  3374. static AppendSerializedAnimations(source: IAnimatable, destination: any): any;
  3375. }
  3376. }
  3377. declare module BABYLON {
  3378. /**
  3379. * This class defines the direct association between an animation and a target
  3380. */
  3381. class TargetedAnimation {
  3382. animation: Animation;
  3383. target: any;
  3384. }
  3385. /**
  3386. * Use this class to create coordinated animations on multiple targets
  3387. */
  3388. class AnimationGroup implements IDisposable {
  3389. name: string;
  3390. private _scene;
  3391. private _targetedAnimations;
  3392. private _animatables;
  3393. private _from;
  3394. private _to;
  3395. private _isStarted;
  3396. private _speedRatio;
  3397. onAnimationEndObservable: Observable<TargetedAnimation>;
  3398. /**
  3399. * Define if the animations are started
  3400. */
  3401. readonly isStarted: boolean;
  3402. /**
  3403. * Gets or sets the speed ratio to use for all animations
  3404. */
  3405. /**
  3406. * Gets or sets the speed ratio to use for all animations
  3407. */
  3408. speedRatio: number;
  3409. /**
  3410. * Gets the targeted animations for this animation group
  3411. */
  3412. readonly targetedAnimations: Array<TargetedAnimation>;
  3413. /**
  3414. * returning the list of animatables controlled by this animation group.
  3415. */
  3416. readonly animatables: Array<Animatable>;
  3417. constructor(name: string, scene?: Nullable<Scene>);
  3418. /**
  3419. * Add an animation (with its target) in the group
  3420. * @param animation defines the animation we want to add
  3421. * @param target defines the target of the animation
  3422. * @returns the {BABYLON.TargetedAnimation} object
  3423. */
  3424. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  3425. /**
  3426. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  3427. * It can add constant keys at begin or end
  3428. * @param beginFrame defines the new begin frame for all animations. It can't be bigger than the smallest begin frame of all animations
  3429. * @param endFrame defines the new end frame for all animations. It can't be smaller than the largest end frame of all animations
  3430. */
  3431. normalize(beginFrame?: number, endFrame?: number): AnimationGroup;
  3432. /**
  3433. * Start all animations on given targets
  3434. * @param loop defines if animations must loop
  3435. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  3436. * @param from defines the from key (optional)
  3437. * @param to defines the to key (optional)
  3438. * @returns the current animation group
  3439. */
  3440. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  3441. /**
  3442. * Pause all animations
  3443. */
  3444. pause(): AnimationGroup;
  3445. /**
  3446. * Play all animations to initial state
  3447. * This function will start() the animations if they were not started or will restart() them if they were paused
  3448. * @param loop defines if animations must loop
  3449. */
  3450. play(loop?: boolean): AnimationGroup;
  3451. /**
  3452. * Reset all animations to initial state
  3453. */
  3454. reset(): AnimationGroup;
  3455. /**
  3456. * Restart animations from key 0
  3457. */
  3458. restart(): AnimationGroup;
  3459. /**
  3460. * Stop all animations
  3461. */
  3462. stop(): AnimationGroup;
  3463. /**
  3464. * Goes to a specific frame in this animation group
  3465. *
  3466. * @param frame the frame number to go to
  3467. * @return the animationGroup
  3468. */
  3469. goToFrame(frame: number): AnimationGroup;
  3470. /**
  3471. * Dispose all associated resources
  3472. */
  3473. dispose(): void;
  3474. }
  3475. }
  3476. declare module BABYLON {
  3477. /**
  3478. * Class used to override all child animations of a given target
  3479. */
  3480. class AnimationPropertiesOverride {
  3481. /**
  3482. * Gets or sets a value indicating if animation blending must be used
  3483. */
  3484. enableBlending: boolean;
  3485. /**
  3486. * Gets or sets the blending speed to use when enableBlending is true
  3487. */
  3488. blendingSpeed: number;
  3489. /**
  3490. * Gets or sets the default loop mode to use
  3491. */
  3492. loopMode: number;
  3493. }
  3494. }
  3495. declare module BABYLON {
  3496. interface IEasingFunction {
  3497. ease(gradient: number): number;
  3498. }
  3499. class EasingFunction implements IEasingFunction {
  3500. private static _EASINGMODE_EASEIN;
  3501. private static _EASINGMODE_EASEOUT;
  3502. private static _EASINGMODE_EASEINOUT;
  3503. static readonly EASINGMODE_EASEIN: number;
  3504. static readonly EASINGMODE_EASEOUT: number;
  3505. static readonly EASINGMODE_EASEINOUT: number;
  3506. private _easingMode;
  3507. setEasingMode(easingMode: number): void;
  3508. getEasingMode(): number;
  3509. easeInCore(gradient: number): number;
  3510. ease(gradient: number): number;
  3511. }
  3512. class CircleEase extends EasingFunction implements IEasingFunction {
  3513. easeInCore(gradient: number): number;
  3514. }
  3515. class BackEase extends EasingFunction implements IEasingFunction {
  3516. amplitude: number;
  3517. constructor(amplitude?: number);
  3518. easeInCore(gradient: number): number;
  3519. }
  3520. class BounceEase extends EasingFunction implements IEasingFunction {
  3521. bounces: number;
  3522. bounciness: number;
  3523. constructor(bounces?: number, bounciness?: number);
  3524. easeInCore(gradient: number): number;
  3525. }
  3526. class CubicEase extends EasingFunction implements IEasingFunction {
  3527. easeInCore(gradient: number): number;
  3528. }
  3529. class ElasticEase extends EasingFunction implements IEasingFunction {
  3530. oscillations: number;
  3531. springiness: number;
  3532. constructor(oscillations?: number, springiness?: number);
  3533. easeInCore(gradient: number): number;
  3534. }
  3535. class ExponentialEase extends EasingFunction implements IEasingFunction {
  3536. exponent: number;
  3537. constructor(exponent?: number);
  3538. easeInCore(gradient: number): number;
  3539. }
  3540. class PowerEase extends EasingFunction implements IEasingFunction {
  3541. power: number;
  3542. constructor(power?: number);
  3543. easeInCore(gradient: number): number;
  3544. }
  3545. class QuadraticEase extends EasingFunction implements IEasingFunction {
  3546. easeInCore(gradient: number): number;
  3547. }
  3548. class QuarticEase extends EasingFunction implements IEasingFunction {
  3549. easeInCore(gradient: number): number;
  3550. }
  3551. class QuinticEase extends EasingFunction implements IEasingFunction {
  3552. easeInCore(gradient: number): number;
  3553. }
  3554. class SineEase extends EasingFunction implements IEasingFunction {
  3555. easeInCore(gradient: number): number;
  3556. }
  3557. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  3558. x1: number;
  3559. y1: number;
  3560. x2: number;
  3561. y2: number;
  3562. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  3563. easeInCore(gradient: number): number;
  3564. }
  3565. }
  3566. declare module BABYLON {
  3567. class RuntimeAnimation {
  3568. private _currentFrame;
  3569. private _animation;
  3570. private _target;
  3571. private _host;
  3572. private _originalValue;
  3573. private _originalBlendValue;
  3574. private _offsetsCache;
  3575. private _highLimitsCache;
  3576. private _stopped;
  3577. private _blendingFactor;
  3578. private _scene;
  3579. private _currentValue;
  3580. private _activeTarget;
  3581. private _targetPath;
  3582. private _weight;
  3583. /**
  3584. * Gets the current frame
  3585. */
  3586. readonly currentFrame: number;
  3587. /**
  3588. * Gets the weight of the runtime animation
  3589. */
  3590. readonly weight: number;
  3591. /**
  3592. * Gets the original value of the runtime animation
  3593. */
  3594. readonly originalValue: any;
  3595. /**
  3596. * Gets the current value of the runtime animation
  3597. */
  3598. readonly currentValue: any;
  3599. /**
  3600. * Gets the path where to store the animated value in the target
  3601. */
  3602. readonly targetPath: string;
  3603. /**
  3604. * Gets the actual target of the runtime animation
  3605. */
  3606. readonly target: any;
  3607. /**
  3608. * Create a new RuntimeAnimation object
  3609. * @param target defines the target of the animation
  3610. * @param animation defines the source {BABYLON.Animation} object
  3611. * @param scene defines the hosting scene
  3612. * @param host defines the initiating Animatable
  3613. */
  3614. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  3615. readonly animation: Animation;
  3616. reset(): void;
  3617. isStopped(): boolean;
  3618. dispose(): void;
  3619. private _getKeyValue(value);
  3620. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  3621. /**
  3622. * Affect the interpolated value to the target
  3623. * @param currentValue defines the value computed by the animation
  3624. * @param weight defines the weight to apply to this value
  3625. */
  3626. setValue(currentValue: any, weight?: number): void;
  3627. private _getCorrectLoopMode();
  3628. /**
  3629. * Move the current animation to a given frame
  3630. * @param frame defines the frame to move to
  3631. */
  3632. goToFrame(frame: number): void;
  3633. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  3634. private _ratioOffset;
  3635. private _previousDelay;
  3636. private _previousRatio;
  3637. /**
  3638. * Execute the current animation
  3639. * @param delay defines the delay to add to the current frame
  3640. * @param from defines the lower bound of the animation range
  3641. * @param to defines the upper bound of the animation range
  3642. * @param loop defines if the current animation must loop
  3643. * @param speedRatio defines the current speed ratio
  3644. * @param weight defines the weight of the animation (default is -1 so no weight)
  3645. * @returns a boolean indicating if the animation has ended
  3646. */
  3647. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  3648. }
  3649. }
  3650. declare module BABYLON {
  3651. class Analyser {
  3652. SMOOTHING: number;
  3653. FFT_SIZE: number;
  3654. BARGRAPHAMPLITUDE: number;
  3655. DEBUGCANVASPOS: {
  3656. x: number;
  3657. y: number;
  3658. };
  3659. DEBUGCANVASSIZE: {
  3660. width: number;
  3661. height: number;
  3662. };
  3663. private _byteFreqs;
  3664. private _byteTime;
  3665. private _floatFreqs;
  3666. private _webAudioAnalyser;
  3667. private _debugCanvas;
  3668. private _debugCanvasContext;
  3669. private _scene;
  3670. private _registerFunc;
  3671. private _audioEngine;
  3672. constructor(scene: Scene);
  3673. getFrequencyBinCount(): number;
  3674. getByteFrequencyData(): Uint8Array;
  3675. getByteTimeDomainData(): Uint8Array;
  3676. getFloatFrequencyData(): Uint8Array;
  3677. drawDebugCanvas(): void;
  3678. stopDebugCanvas(): void;
  3679. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  3680. dispose(): void;
  3681. }
  3682. }
  3683. declare module BABYLON {
  3684. class AudioEngine {
  3685. private _audioContext;
  3686. private _audioContextInitialized;
  3687. canUseWebAudio: boolean;
  3688. masterGain: GainNode;
  3689. private _connectedAnalyser;
  3690. WarnedWebAudioUnsupported: boolean;
  3691. unlocked: boolean;
  3692. onAudioUnlocked: () => any;
  3693. isMP3supported: boolean;
  3694. isOGGsupported: boolean;
  3695. readonly audioContext: Nullable<AudioContext>;
  3696. constructor();
  3697. private _unlockiOSaudio();
  3698. private _initializeAudioContext();
  3699. dispose(): void;
  3700. getGlobalVolume(): number;
  3701. setGlobalVolume(newVolume: number): void;
  3702. connectToAnalyser(analyser: Analyser): void;
  3703. }
  3704. }
  3705. declare module BABYLON {
  3706. class Sound {
  3707. name: string;
  3708. autoplay: boolean;
  3709. loop: boolean;
  3710. useCustomAttenuation: boolean;
  3711. soundTrackId: number;
  3712. spatialSound: boolean;
  3713. refDistance: number;
  3714. rolloffFactor: number;
  3715. maxDistance: number;
  3716. distanceModel: string;
  3717. private _panningModel;
  3718. onended: () => any;
  3719. private _playbackRate;
  3720. private _streaming;
  3721. private _startTime;
  3722. private _startOffset;
  3723. private _position;
  3724. private _localDirection;
  3725. private _volume;
  3726. private _isReadyToPlay;
  3727. isPlaying: boolean;
  3728. isPaused: boolean;
  3729. private _isDirectional;
  3730. private _readyToPlayCallback;
  3731. private _audioBuffer;
  3732. private _soundSource;
  3733. private _streamingSource;
  3734. private _soundPanner;
  3735. private _soundGain;
  3736. private _inputAudioNode;
  3737. private _ouputAudioNode;
  3738. private _coneInnerAngle;
  3739. private _coneOuterAngle;
  3740. private _coneOuterGain;
  3741. private _scene;
  3742. private _connectedMesh;
  3743. private _customAttenuationFunction;
  3744. private _registerFunc;
  3745. private _isOutputConnected;
  3746. private _htmlAudioElement;
  3747. private _urlType;
  3748. /**
  3749. * Create a sound and attach it to a scene
  3750. * @param name Name of your sound
  3751. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  3752. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  3753. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  3754. */
  3755. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  3756. dispose(): void;
  3757. isReady(): boolean;
  3758. private _soundLoaded(audioData);
  3759. setAudioBuffer(audioBuffer: AudioBuffer): void;
  3760. updateOptions(options: any): void;
  3761. private _createSpatialParameters();
  3762. private _updateSpatialParameters();
  3763. switchPanningModelToHRTF(): void;
  3764. switchPanningModelToEqualPower(): void;
  3765. private _switchPanningModel();
  3766. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  3767. /**
  3768. * Transform this sound into a directional source
  3769. * @param coneInnerAngle Size of the inner cone in degree
  3770. * @param coneOuterAngle Size of the outer cone in degree
  3771. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  3772. */
  3773. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  3774. setPosition(newPosition: Vector3): void;
  3775. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  3776. private _updateDirection();
  3777. updateDistanceFromListener(): void;
  3778. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  3779. /**
  3780. * Play the sound
  3781. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  3782. * @param offset (optional) Start the sound setting it at a specific time
  3783. */
  3784. play(time?: number, offset?: number): void;
  3785. private _onended();
  3786. /**
  3787. * Stop the sound
  3788. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  3789. */
  3790. stop(time?: number): void;
  3791. pause(): void;
  3792. setVolume(newVolume: number, time?: number): void;
  3793. setPlaybackRate(newPlaybackRate: number): void;
  3794. getVolume(): number;
  3795. attachToMesh(meshToConnectTo: AbstractMesh): void;
  3796. detachFromMesh(): void;
  3797. private _onRegisterAfterWorldMatrixUpdate(node);
  3798. clone(): Nullable<Sound>;
  3799. getAudioBuffer(): AudioBuffer | null;
  3800. serialize(): any;
  3801. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  3802. }
  3803. }
  3804. declare module BABYLON {
  3805. class SoundTrack {
  3806. private _outputAudioNode;
  3807. private _scene;
  3808. id: number;
  3809. soundCollection: Array<Sound>;
  3810. private _isMainTrack;
  3811. private _connectedAnalyser;
  3812. private _options;
  3813. private _isInitialized;
  3814. constructor(scene: Scene, options?: any);
  3815. private _initializeSoundTrackAudioGraph();
  3816. dispose(): void;
  3817. AddSound(sound: Sound): void;
  3818. RemoveSound(sound: Sound): void;
  3819. setVolume(newVolume: number): void;
  3820. switchPanningModelToHRTF(): void;
  3821. switchPanningModelToEqualPower(): void;
  3822. connectToAnalyser(analyser: Analyser): void;
  3823. }
  3824. }
  3825. declare module BABYLON {
  3826. interface Behavior<T extends Node> {
  3827. name: string;
  3828. init(): void;
  3829. attach(node: T): void;
  3830. detach(): void;
  3831. }
  3832. }
  3833. declare module BABYLON {
  3834. class Bone extends Node {
  3835. name: string;
  3836. private static _tmpVecs;
  3837. private static _tmpQuat;
  3838. private static _tmpMats;
  3839. children: Bone[];
  3840. animations: Animation[];
  3841. length: number;
  3842. _index: Nullable<number>;
  3843. private _skeleton;
  3844. private _localMatrix;
  3845. private _restPose;
  3846. private _baseMatrix;
  3847. private _worldTransform;
  3848. private _absoluteTransform;
  3849. private _invertedAbsoluteTransform;
  3850. private _parent;
  3851. private _scaleMatrix;
  3852. private _scaleVector;
  3853. private _negateScaleChildren;
  3854. private _scalingDeterminant;
  3855. _matrix: Matrix;
  3856. constructor(name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  3857. getSkeleton(): Skeleton;
  3858. getParent(): Nullable<Bone>;
  3859. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  3860. getLocalMatrix(): Matrix;
  3861. getBaseMatrix(): Matrix;
  3862. getRestPose(): Matrix;
  3863. returnToRest(): void;
  3864. getWorldMatrix(): Matrix;
  3865. getInvertedAbsoluteTransform(): Matrix;
  3866. getAbsoluteTransform(): Matrix;
  3867. position: Vector3;
  3868. rotation: Vector3;
  3869. rotationQuaternion: Quaternion;
  3870. scaling: Vector3;
  3871. /**
  3872. * Gets the animation properties override
  3873. */
  3874. readonly animationPropertiesOverride: AnimationPropertiesOverride;
  3875. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean): void;
  3876. _updateDifferenceMatrix(rootMatrix?: Matrix): void;
  3877. markAsDirty(): void;
  3878. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  3879. /**
  3880. * Translate the bone in local or world space.
  3881. * @param vec The amount to translate the bone.
  3882. * @param space The space that the translation is in.
  3883. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3884. */
  3885. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  3886. /**
  3887. * Set the postion of the bone in local or world space.
  3888. * @param position The position to set the bone.
  3889. * @param space The space that the position is in.
  3890. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3891. */
  3892. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  3893. /**
  3894. * Set the absolute postion of the bone (world space).
  3895. * @param position The position to set the bone.
  3896. * @param mesh The mesh that this bone is attached to.
  3897. */
  3898. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  3899. /**
  3900. * Set the scale of the bone on the x, y and z axes.
  3901. * @param x The scale of the bone on the x axis.
  3902. * @param x The scale of the bone on the y axis.
  3903. * @param z The scale of the bone on the z axis.
  3904. * @param scaleChildren Set this to true if children of the bone should be scaled.
  3905. */
  3906. setScale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  3907. /**
  3908. * Scale the bone on the x, y and z axes.
  3909. * @param x The amount to scale the bone on the x axis.
  3910. * @param x The amount to scale the bone on the y axis.
  3911. * @param z The amount to scale the bone on the z axis.
  3912. * @param scaleChildren Set this to true if children of the bone should be scaled.
  3913. */
  3914. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  3915. /**
  3916. * Set the yaw, pitch, and roll of the bone in local or world space.
  3917. * @param yaw The rotation of the bone on the y axis.
  3918. * @param pitch The rotation of the bone on the x axis.
  3919. * @param roll The rotation of the bone on the z axis.
  3920. * @param space The space that the axes of rotation are in.
  3921. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3922. */
  3923. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  3924. /**
  3925. * Rotate the bone on an axis in local or world space.
  3926. * @param axis The axis to rotate the bone on.
  3927. * @param amount The amount to rotate the bone.
  3928. * @param space The space that the axis is in.
  3929. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3930. */
  3931. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  3932. /**
  3933. * Set the rotation of the bone to a particular axis angle in local or world space.
  3934. * @param axis The axis to rotate the bone on.
  3935. * @param angle The angle that the bone should be rotated to.
  3936. * @param space The space that the axis is in.
  3937. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3938. */
  3939. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  3940. /**
  3941. * Set the euler rotation of the bone in local of world space.
  3942. * @param rotation The euler rotation that the bone should be set to.
  3943. * @param space The space that the rotation is in.
  3944. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3945. */
  3946. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  3947. /**
  3948. * Set the quaternion rotation of the bone in local of world space.
  3949. * @param quat The quaternion rotation that the bone should be set to.
  3950. * @param space The space that the rotation is in.
  3951. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3952. */
  3953. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  3954. /**
  3955. * Set the rotation matrix of the bone in local of world space.
  3956. * @param rotMat The rotation matrix that the bone should be set to.
  3957. * @param space The space that the rotation is in.
  3958. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3959. */
  3960. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  3961. private _rotateWithMatrix(rmat, space?, mesh?);
  3962. private _getNegativeRotationToRef(rotMatInv, space?, mesh?);
  3963. /**
  3964. * Get the scale of the bone
  3965. * @returns the scale of the bone
  3966. */
  3967. getScale(): Vector3;
  3968. /**
  3969. * Copy the scale of the bone to a vector3.
  3970. * @param result The vector3 to copy the scale to
  3971. */
  3972. getScaleToRef(result: Vector3): void;
  3973. /**
  3974. * Get the position of the bone in local or world space.
  3975. * @param space The space that the returned position is in.
  3976. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3977. * @returns The position of the bone
  3978. */
  3979. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  3980. /**
  3981. * Copy the position of the bone to a vector3 in local or world space.
  3982. * @param space The space that the returned position is in.
  3983. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3984. * @param result The vector3 to copy the position to.
  3985. */
  3986. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  3987. /**
  3988. * Get the absolute position of the bone (world space).
  3989. * @param mesh The mesh that this bone is attached to.
  3990. * @returns The absolute position of the bone
  3991. */
  3992. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  3993. /**
  3994. * Copy the absolute position of the bone (world space) to the result param.
  3995. * @param mesh The mesh that this bone is attached to.
  3996. * @param result The vector3 to copy the absolute position to.
  3997. */
  3998. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  3999. /**
  4000. * Compute the absolute transforms of this bone and its children.
  4001. */
  4002. computeAbsoluteTransforms(): void;
  4003. private _syncScaleVector();
  4004. /**
  4005. * Get the world direction from an axis that is in the local space of the bone.
  4006. * @param localAxis The local direction that is used to compute the world direction.
  4007. * @param mesh The mesh that this bone is attached to.
  4008. * @returns The world direction
  4009. */
  4010. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4011. /**
  4012. * Copy the world direction to a vector3 from an axis that is in the local space of the bone.
  4013. * @param localAxis The local direction that is used to compute the world direction.
  4014. * @param mesh The mesh that this bone is attached to.
  4015. * @param result The vector3 that the world direction will be copied to.
  4016. */
  4017. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4018. /**
  4019. * Get the euler rotation of the bone in local or world space.
  4020. * @param space The space that the rotation should be in.
  4021. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4022. * @returns The euler rotation
  4023. */
  4024. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4025. /**
  4026. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space.
  4027. * @param space The space that the rotation should be in.
  4028. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4029. * @param result The vector3 that the rotation should be copied to.
  4030. */
  4031. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4032. /**
  4033. * Get the quaternion rotation of the bone in either local or world space.
  4034. * @param space The space that the rotation should be in.
  4035. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4036. * @returns The quaternion rotation
  4037. */
  4038. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4039. /**
  4040. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space.
  4041. * @param space The space that the rotation should be in.
  4042. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4043. * @param result The quaternion that the rotation should be copied to.
  4044. */
  4045. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4046. /**
  4047. * Get the rotation matrix of the bone in local or world space.
  4048. * @param space The space that the rotation should be in.
  4049. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4050. * @returns The rotation matrix
  4051. */
  4052. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4053. /**
  4054. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space.
  4055. * @param space The space that the rotation should be in.
  4056. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  4057. * @param result The quaternion that the rotation should be copied to.
  4058. */
  4059. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4060. /**
  4061. * Get the world position of a point that is in the local space of the bone.
  4062. * @param position The local position
  4063. * @param mesh The mesh that this bone is attached to.
  4064. * @returns The world position
  4065. */
  4066. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4067. /**
  4068. * Get the world position of a point that is in the local space of the bone and copy it to the result param.
  4069. * @param position The local position
  4070. * @param mesh The mesh that this bone is attached to.
  4071. * @param result The vector3 that the world position should be copied to.
  4072. */
  4073. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4074. /**
  4075. * Get the local position of a point that is in world space.
  4076. * @param position The world position
  4077. * @param mesh The mesh that this bone is attached to.
  4078. * @returns The local position
  4079. */
  4080. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4081. /**
  4082. * Get the local position of a point that is in world space and copy it to the result param.
  4083. * @param position The world position
  4084. * @param mesh The mesh that this bone is attached to.
  4085. * @param result The vector3 that the local position should be copied to.
  4086. */
  4087. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4088. }
  4089. }
  4090. declare module BABYLON {
  4091. class BoneIKController {
  4092. private static _tmpVecs;
  4093. private static _tmpQuat;
  4094. private static _tmpMats;
  4095. targetMesh: AbstractMesh;
  4096. poleTargetMesh: AbstractMesh;
  4097. poleTargetBone: Nullable<Bone>;
  4098. targetPosition: Vector3;
  4099. poleTargetPosition: Vector3;
  4100. poleTargetLocalOffset: Vector3;
  4101. poleAngle: number;
  4102. mesh: AbstractMesh;
  4103. slerpAmount: number;
  4104. private _bone1Quat;
  4105. private _bone1Mat;
  4106. private _bone2Ang;
  4107. private _bone1;
  4108. private _bone2;
  4109. private _bone1Length;
  4110. private _bone2Length;
  4111. private _maxAngle;
  4112. private _maxReach;
  4113. private _rightHandedSystem;
  4114. private _bendAxis;
  4115. private _slerping;
  4116. private _adjustRoll;
  4117. maxAngle: number;
  4118. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  4119. targetMesh?: AbstractMesh;
  4120. poleTargetMesh?: AbstractMesh;
  4121. poleTargetBone?: Bone;
  4122. poleTargetLocalOffset?: Vector3;
  4123. poleAngle?: number;
  4124. bendAxis?: Vector3;
  4125. maxAngle?: number;
  4126. slerpAmount?: number;
  4127. });
  4128. private _setMaxAngle(ang);
  4129. update(): void;
  4130. }
  4131. }
  4132. declare module BABYLON {
  4133. class BoneLookController {
  4134. private static _tmpVecs;
  4135. private static _tmpQuat;
  4136. private static _tmpMats;
  4137. /**
  4138. * The target Vector3 that the bone will look at.
  4139. */
  4140. target: Vector3;
  4141. /**
  4142. * The mesh that the bone is attached to.
  4143. */
  4144. mesh: AbstractMesh;
  4145. /**
  4146. * The bone that will be looking to the target.
  4147. */
  4148. bone: Bone;
  4149. /**
  4150. * The up axis of the coordinate system that is used when the bone is rotated.
  4151. */
  4152. upAxis: Vector3;
  4153. /**
  4154. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  4155. */
  4156. upAxisSpace: Space;
  4157. /**
  4158. * Used to make an adjustment to the yaw of the bone.
  4159. */
  4160. adjustYaw: number;
  4161. /**
  4162. * Used to make an adjustment to the pitch of the bone.
  4163. */
  4164. adjustPitch: number;
  4165. /**
  4166. * Used to make an adjustment to the roll of the bone.
  4167. */
  4168. adjustRoll: number;
  4169. /**
  4170. * 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).
  4171. */
  4172. slerpAmount: number;
  4173. private _minYaw;
  4174. private _maxYaw;
  4175. private _minPitch;
  4176. private _maxPitch;
  4177. private _minYawSin;
  4178. private _minYawCos;
  4179. private _maxYawSin;
  4180. private _maxYawCos;
  4181. private _midYawConstraint;
  4182. private _minPitchTan;
  4183. private _maxPitchTan;
  4184. private _boneQuat;
  4185. private _slerping;
  4186. private _transformYawPitch;
  4187. private _transformYawPitchInv;
  4188. private _firstFrameSkipped;
  4189. private _yawRange;
  4190. private _fowardAxis;
  4191. /**
  4192. * Get/set the minimum yaw angle that the bone can look to.
  4193. */
  4194. minYaw: number;
  4195. /**
  4196. * Get/set the maximum yaw angle that the bone can look to.
  4197. */
  4198. maxYaw: number;
  4199. /**
  4200. * Get/set the minimum pitch angle that the bone can look to.
  4201. */
  4202. minPitch: number;
  4203. /**
  4204. * Get/set the maximum pitch angle that the bone can look to.
  4205. */
  4206. maxPitch: number;
  4207. /**
  4208. * Create a BoneLookController
  4209. * @param mesh the mesh that the bone belongs to
  4210. * @param bone the bone that will be looking to the target
  4211. * @param target the target Vector3 to look at
  4212. * @param settings optional settings:
  4213. * - maxYaw: the maximum angle the bone will yaw to
  4214. * - minYaw: the minimum angle the bone will yaw to
  4215. * - maxPitch: the maximum angle the bone will pitch to
  4216. * - minPitch: the minimum angle the bone will yaw to
  4217. * - slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  4218. * - upAxis: the up axis of the coordinate system
  4219. * - upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  4220. * - yawAxis: set yawAxis if the bone does not yaw on the y axis
  4221. * - pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  4222. * - adjustYaw: used to make an adjustment to the yaw of the bone
  4223. * - adjustPitch: used to make an adjustment to the pitch of the bone
  4224. * - adjustRoll: used to make an adjustment to the roll of the bone
  4225. **/
  4226. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  4227. maxYaw?: number;
  4228. minYaw?: number;
  4229. maxPitch?: number;
  4230. minPitch?: number;
  4231. slerpAmount?: number;
  4232. upAxis?: Vector3;
  4233. upAxisSpace?: Space;
  4234. yawAxis?: Vector3;
  4235. pitchAxis?: Vector3;
  4236. adjustYaw?: number;
  4237. adjustPitch?: number;
  4238. adjustRoll?: number;
  4239. });
  4240. /**
  4241. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender()).
  4242. */
  4243. update(): void;
  4244. private _getAngleDiff(ang1, ang2);
  4245. private _getAngleBetween(ang1, ang2);
  4246. private _isAngleBetween(ang, ang1, ang2);
  4247. }
  4248. }
  4249. declare module BABYLON {
  4250. class Skeleton implements IAnimatable {
  4251. name: string;
  4252. id: string;
  4253. bones: Bone[];
  4254. dimensionsAtRest: Vector3;
  4255. needInitialSkinMatrix: boolean;
  4256. animations: Array<Animation>;
  4257. private _scene;
  4258. private _isDirty;
  4259. private _transformMatrices;
  4260. private _meshesWithPoseMatrix;
  4261. private _animatables;
  4262. private _identity;
  4263. private _synchronizedWithMesh;
  4264. private _ranges;
  4265. private _lastAbsoluteTransformsUpdateId;
  4266. /**
  4267. * Specifies if the skeleton should be serialized.
  4268. */
  4269. doNotSerialize: boolean;
  4270. /**
  4271. * Gets or sets the animation properties override
  4272. */
  4273. animationPropertiesOverride: AnimationPropertiesOverride;
  4274. /**
  4275. * An event triggered before computing the skeleton's matrices
  4276. */
  4277. onBeforeComputeObservable: Observable<Skeleton>;
  4278. constructor(name: string, id: string, scene: Scene);
  4279. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  4280. getScene(): Scene;
  4281. /**
  4282. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  4283. */
  4284. toString(fullDetails?: boolean): string;
  4285. /**
  4286. * Get bone's index searching by name
  4287. * @param {string} name is bone's name to search for
  4288. * @return {number} Indice of the bone. Returns -1 if not found
  4289. */
  4290. getBoneIndexByName(name: string): number;
  4291. createAnimationRange(name: string, from: number, to: number): void;
  4292. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  4293. getAnimationRange(name: string): Nullable<AnimationRange>;
  4294. /**
  4295. * Returns as an Array, all AnimationRanges defined on this skeleton
  4296. */
  4297. getAnimationRanges(): Nullable<AnimationRange>[];
  4298. /**
  4299. * note: This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  4300. */
  4301. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  4302. returnToRest(): void;
  4303. private _getHighestAnimationFrame();
  4304. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  4305. _markAsDirty(): void;
  4306. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  4307. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  4308. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  4309. prepare(): void;
  4310. getAnimatables(): IAnimatable[];
  4311. clone(name: string, id: string): Skeleton;
  4312. enableBlending(blendingSpeed?: number): void;
  4313. dispose(): void;
  4314. serialize(): any;
  4315. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  4316. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  4317. getPoseMatrix(): Nullable<Matrix>;
  4318. sortBones(): void;
  4319. private _sortBones(index, bones, visited);
  4320. }
  4321. }
  4322. declare module BABYLON {
  4323. class Collider {
  4324. /** Define if a collision was found */
  4325. collisionFound: boolean;
  4326. /**
  4327. * Define last intersection point in local space
  4328. */
  4329. intersectionPoint: Vector3;
  4330. /**
  4331. * Define last collided mesh
  4332. */
  4333. collidedMesh: Nullable<AbstractMesh>;
  4334. private _collisionPoint;
  4335. private _planeIntersectionPoint;
  4336. private _tempVector;
  4337. private _tempVector2;
  4338. private _tempVector3;
  4339. private _tempVector4;
  4340. private _edge;
  4341. private _baseToVertex;
  4342. private _destinationPoint;
  4343. private _slidePlaneNormal;
  4344. private _displacementVector;
  4345. _radius: Vector3;
  4346. _retry: number;
  4347. private _velocity;
  4348. private _basePoint;
  4349. private _epsilon;
  4350. _velocityWorldLength: number;
  4351. _basePointWorld: Vector3;
  4352. private _velocityWorld;
  4353. private _normalizedVelocity;
  4354. _initialVelocity: Vector3;
  4355. _initialPosition: Vector3;
  4356. private _nearestDistance;
  4357. private _collisionMask;
  4358. collisionMask: number;
  4359. /**
  4360. * Gets the plane normal used to compute the sliding response (in local space)
  4361. */
  4362. readonly slidePlaneNormal: Vector3;
  4363. _initialize(source: Vector3, dir: Vector3, e: number): void;
  4364. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  4365. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  4366. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  4367. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  4368. _getResponse(pos: Vector3, vel: Vector3): void;
  4369. }
  4370. }
  4371. declare module BABYLON {
  4372. var CollisionWorker: string;
  4373. interface ICollisionCoordinator {
  4374. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4375. init(scene: Scene): void;
  4376. destroy(): void;
  4377. onMeshAdded(mesh: AbstractMesh): void;
  4378. onMeshUpdated(mesh: AbstractMesh): void;
  4379. onMeshRemoved(mesh: AbstractMesh): void;
  4380. onGeometryAdded(geometry: Geometry): void;
  4381. onGeometryUpdated(geometry: Geometry): void;
  4382. onGeometryDeleted(geometry: Geometry): void;
  4383. }
  4384. interface SerializedMesh {
  4385. id: string;
  4386. name: string;
  4387. uniqueId: number;
  4388. geometryId: Nullable<string>;
  4389. sphereCenter: Array<number>;
  4390. sphereRadius: number;
  4391. boxMinimum: Array<number>;
  4392. boxMaximum: Array<number>;
  4393. worldMatrixFromCache: any;
  4394. subMeshes: Array<SerializedSubMesh>;
  4395. checkCollisions: boolean;
  4396. }
  4397. interface SerializedSubMesh {
  4398. position: number;
  4399. verticesStart: number;
  4400. verticesCount: number;
  4401. indexStart: number;
  4402. indexCount: number;
  4403. hasMaterial: boolean;
  4404. sphereCenter: Array<number>;
  4405. sphereRadius: number;
  4406. boxMinimum: Array<number>;
  4407. boxMaximum: Array<number>;
  4408. }
  4409. /**
  4410. * Interface describing the value associated with a geometry
  4411. */
  4412. interface SerializedGeometry {
  4413. /**
  4414. * Defines the unique ID of the geometry
  4415. */
  4416. id: string;
  4417. /**
  4418. * Defines the array containing the positions
  4419. */
  4420. positions: Float32Array;
  4421. /**
  4422. * Defines the array containing the indices
  4423. */
  4424. indices: Uint32Array;
  4425. /**
  4426. * Defines the array containing the normals
  4427. */
  4428. normals: Float32Array;
  4429. }
  4430. interface BabylonMessage {
  4431. taskType: WorkerTaskType;
  4432. payload: InitPayload | CollidePayload | UpdatePayload;
  4433. }
  4434. interface SerializedColliderToWorker {
  4435. position: Array<number>;
  4436. velocity: Array<number>;
  4437. radius: Array<number>;
  4438. }
  4439. enum WorkerTaskType {
  4440. INIT = 0,
  4441. UPDATE = 1,
  4442. COLLIDE = 2,
  4443. }
  4444. interface WorkerReply {
  4445. error: WorkerReplyType;
  4446. taskType: WorkerTaskType;
  4447. payload?: any;
  4448. }
  4449. interface CollisionReplyPayload {
  4450. newPosition: Array<number>;
  4451. collisionId: number;
  4452. collidedMeshUniqueId: number;
  4453. }
  4454. interface InitPayload {
  4455. }
  4456. interface CollidePayload {
  4457. collisionId: number;
  4458. collider: SerializedColliderToWorker;
  4459. maximumRetry: number;
  4460. excludedMeshUniqueId: Nullable<number>;
  4461. }
  4462. interface UpdatePayload {
  4463. updatedMeshes: {
  4464. [n: number]: SerializedMesh;
  4465. };
  4466. updatedGeometries: {
  4467. [s: string]: SerializedGeometry;
  4468. };
  4469. removedMeshes: Array<number>;
  4470. removedGeometries: Array<string>;
  4471. }
  4472. enum WorkerReplyType {
  4473. SUCCESS = 0,
  4474. UNKNOWN_ERROR = 1,
  4475. }
  4476. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  4477. private _scene;
  4478. private _scaledPosition;
  4479. private _scaledVelocity;
  4480. private _collisionsCallbackArray;
  4481. private _init;
  4482. private _runningUpdated;
  4483. private _worker;
  4484. private _addUpdateMeshesList;
  4485. private _addUpdateGeometriesList;
  4486. private _toRemoveMeshesArray;
  4487. private _toRemoveGeometryArray;
  4488. constructor();
  4489. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  4490. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  4491. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4492. init(scene: Scene): void;
  4493. destroy(): void;
  4494. onMeshAdded(mesh: AbstractMesh): void;
  4495. onMeshUpdated: (transformNode: TransformNode) => void;
  4496. onMeshRemoved(mesh: AbstractMesh): void;
  4497. onGeometryAdded(geometry: Geometry): void;
  4498. onGeometryUpdated: (geometry: Geometry) => void;
  4499. onGeometryDeleted(geometry: Geometry): void;
  4500. private _afterRender;
  4501. private _onMessageFromWorker;
  4502. }
  4503. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  4504. private _scene;
  4505. private _scaledPosition;
  4506. private _scaledVelocity;
  4507. private _finalPosition;
  4508. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4509. init(scene: Scene): void;
  4510. destroy(): void;
  4511. onMeshAdded(mesh: AbstractMesh): void;
  4512. onMeshUpdated(mesh: AbstractMesh): void;
  4513. onMeshRemoved(mesh: AbstractMesh): void;
  4514. onGeometryAdded(geometry: Geometry): void;
  4515. onGeometryUpdated(geometry: Geometry): void;
  4516. onGeometryDeleted(geometry: Geometry): void;
  4517. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  4518. }
  4519. }
  4520. declare function importScripts(...urls: string[]): void;
  4521. declare const safePostMessage: any;
  4522. declare module BABYLON {
  4523. var WorkerIncluded: boolean;
  4524. class CollisionCache {
  4525. private _meshes;
  4526. private _geometries;
  4527. getMeshes(): {
  4528. [n: number]: SerializedMesh;
  4529. };
  4530. getGeometries(): {
  4531. [s: number]: SerializedGeometry;
  4532. };
  4533. getMesh(id: any): SerializedMesh;
  4534. addMesh(mesh: SerializedMesh): void;
  4535. removeMesh(uniqueId: number): void;
  4536. getGeometry(id: string): SerializedGeometry;
  4537. addGeometry(geometry: SerializedGeometry): void;
  4538. removeGeometry(id: string): void;
  4539. }
  4540. class CollideWorker {
  4541. collider: Collider;
  4542. private _collisionCache;
  4543. private finalPosition;
  4544. private collisionsScalingMatrix;
  4545. private collisionTranformationMatrix;
  4546. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  4547. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  4548. private checkCollision(mesh);
  4549. private processCollisionsForSubMeshes(transformMatrix, mesh);
  4550. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  4551. private checkSubmeshCollision(subMesh);
  4552. }
  4553. interface ICollisionDetector {
  4554. onInit(payload: InitPayload): void;
  4555. onUpdate(payload: UpdatePayload): void;
  4556. onCollision(payload: CollidePayload): void;
  4557. }
  4558. class CollisionDetectorTransferable implements ICollisionDetector {
  4559. private _collisionCache;
  4560. onInit(payload: InitPayload): void;
  4561. onUpdate(payload: UpdatePayload): void;
  4562. onCollision(payload: CollidePayload): void;
  4563. }
  4564. }
  4565. declare module BABYLON {
  4566. class IntersectionInfo {
  4567. bu: Nullable<number>;
  4568. bv: Nullable<number>;
  4569. distance: number;
  4570. faceId: number;
  4571. subMeshId: number;
  4572. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  4573. }
  4574. class PickingInfo {
  4575. hit: boolean;
  4576. distance: number;
  4577. pickedPoint: Nullable<Vector3>;
  4578. pickedMesh: Nullable<AbstractMesh>;
  4579. bu: number;
  4580. bv: number;
  4581. faceId: number;
  4582. subMeshId: number;
  4583. pickedSprite: Nullable<Sprite>;
  4584. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  4585. getTextureCoordinates(): Nullable<Vector2>;
  4586. }
  4587. }
  4588. declare module BABYLON {
  4589. class BoundingBox implements ICullable {
  4590. minimum: Vector3;
  4591. maximum: Vector3;
  4592. vectors: Vector3[];
  4593. center: Vector3;
  4594. centerWorld: Vector3;
  4595. extendSize: Vector3;
  4596. extendSizeWorld: Vector3;
  4597. directions: Vector3[];
  4598. vectorsWorld: Vector3[];
  4599. minimumWorld: Vector3;
  4600. maximumWorld: Vector3;
  4601. private _worldMatrix;
  4602. constructor(minimum: Vector3, maximum: Vector3);
  4603. getWorldMatrix(): Matrix;
  4604. setWorldMatrix(matrix: Matrix): BoundingBox;
  4605. _update(world: Matrix): void;
  4606. isInFrustum(frustumPlanes: Plane[]): boolean;
  4607. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  4608. intersectsPoint(point: Vector3): boolean;
  4609. intersectsSphere(sphere: BoundingSphere): boolean;
  4610. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  4611. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  4612. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  4613. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  4614. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  4615. }
  4616. }
  4617. declare module BABYLON {
  4618. interface ICullable {
  4619. isInFrustum(frustumPlanes: Plane[]): boolean;
  4620. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  4621. }
  4622. class BoundingInfo implements ICullable {
  4623. minimum: Vector3;
  4624. maximum: Vector3;
  4625. boundingBox: BoundingBox;
  4626. boundingSphere: BoundingSphere;
  4627. private _isLocked;
  4628. constructor(minimum: Vector3, maximum: Vector3);
  4629. isLocked: boolean;
  4630. update(world: Matrix): void;
  4631. /**
  4632. * Recreate the bounding info to be centered around a specific point given a specific extend.
  4633. * @param center New center of the bounding info
  4634. * @param extend New extend of the bounding info
  4635. */
  4636. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  4637. isInFrustum(frustumPlanes: Plane[]): boolean;
  4638. /**
  4639. * Gets the world distance between the min and max points of the bounding box
  4640. */
  4641. readonly diagonalLength: number;
  4642. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  4643. _checkCollision(collider: Collider): boolean;
  4644. intersectsPoint(point: Vector3): boolean;
  4645. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  4646. }
  4647. }
  4648. declare module BABYLON {
  4649. class BoundingSphere {
  4650. minimum: Vector3;
  4651. maximum: Vector3;
  4652. center: Vector3;
  4653. radius: number;
  4654. centerWorld: Vector3;
  4655. radiusWorld: number;
  4656. private _tempRadiusVector;
  4657. constructor(minimum: Vector3, maximum: Vector3);
  4658. _update(world: Matrix): void;
  4659. isInFrustum(frustumPlanes: Plane[]): boolean;
  4660. intersectsPoint(point: Vector3): boolean;
  4661. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  4662. }
  4663. }
  4664. declare module BABYLON {
  4665. class Ray {
  4666. origin: Vector3;
  4667. direction: Vector3;
  4668. length: number;
  4669. private _edge1;
  4670. private _edge2;
  4671. private _pvec;
  4672. private _tvec;
  4673. private _qvec;
  4674. private _tmpRay;
  4675. constructor(origin: Vector3, direction: Vector3, length?: number);
  4676. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  4677. intersectsBox(box: BoundingBox): boolean;
  4678. intersectsSphere(sphere: BoundingSphere): boolean;
  4679. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  4680. intersectsPlane(plane: Plane): Nullable<number>;
  4681. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  4682. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  4683. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  4684. private static smallnum;
  4685. private static rayl;
  4686. /**
  4687. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  4688. * @param sega the first point of the segment to test the intersection against
  4689. * @param segb the second point of the segment to test the intersection against
  4690. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  4691. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  4692. */
  4693. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  4694. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  4695. static Zero(): Ray;
  4696. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  4697. /**
  4698. * 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
  4699. * transformed to the given world matrix.
  4700. * @param origin The origin point
  4701. * @param end The end point
  4702. * @param world a matrix to transform the ray to. Default is the identity matrix.
  4703. */
  4704. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  4705. static Transform(ray: Ray, matrix: Matrix): Ray;
  4706. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  4707. }
  4708. }
  4709. /**
  4710. * Module Debug contains the (visual) components to debug a scene correctly
  4711. */
  4712. declare module BABYLON.Debug {
  4713. /**
  4714. * The Axes viewer will show 3 axes in a specific point in space
  4715. */
  4716. class AxesViewer {
  4717. private _xline;
  4718. private _yline;
  4719. private _zline;
  4720. private _xmesh;
  4721. private _ymesh;
  4722. private _zmesh;
  4723. scene: Nullable<Scene>;
  4724. scaleLines: number;
  4725. constructor(scene: Scene, scaleLines?: number);
  4726. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  4727. dispose(): void;
  4728. }
  4729. }
  4730. declare module BABYLON.Debug {
  4731. /**
  4732. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  4733. */
  4734. class BoneAxesViewer extends AxesViewer {
  4735. mesh: Nullable<Mesh>;
  4736. bone: Nullable<Bone>;
  4737. pos: Vector3;
  4738. xaxis: Vector3;
  4739. yaxis: Vector3;
  4740. zaxis: Vector3;
  4741. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  4742. update(): void;
  4743. dispose(): void;
  4744. }
  4745. }
  4746. declare module BABYLON {
  4747. class DebugLayer {
  4748. private _scene;
  4749. static InspectorURL: string;
  4750. private _inspector;
  4751. private BJSINSPECTOR;
  4752. constructor(scene: Scene);
  4753. /** Creates the inspector window. */
  4754. private _createInspector(config?);
  4755. isVisible(): boolean;
  4756. hide(): void;
  4757. show(config?: {
  4758. popup?: boolean;
  4759. initialTab?: number;
  4760. parentElement?: HTMLElement;
  4761. newColors?: {
  4762. backgroundColor?: string;
  4763. backgroundColorLighter?: string;
  4764. backgroundColorLighter2?: string;
  4765. backgroundColorLighter3?: string;
  4766. color?: string;
  4767. colorTop?: string;
  4768. colorBot?: string;
  4769. };
  4770. }): void;
  4771. }
  4772. }
  4773. declare module BABYLON.Debug {
  4774. /**
  4775. * Used to show the physics impostor around the specific mesh.
  4776. */
  4777. class PhysicsViewer {
  4778. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  4779. protected _meshes: Array<Nullable<AbstractMesh>>;
  4780. protected _scene: Nullable<Scene>;
  4781. protected _numMeshes: number;
  4782. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  4783. private _renderFunction;
  4784. private _debugBoxMesh;
  4785. private _debugSphereMesh;
  4786. private _debugMaterial;
  4787. constructor(scene: Scene);
  4788. protected _updateDebugMeshes(): void;
  4789. showImpostor(impostor: PhysicsImpostor): void;
  4790. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  4791. private _getDebugMaterial(scene);
  4792. private _getDebugBoxMesh(scene);
  4793. private _getDebugSphereMesh(scene);
  4794. private _getDebugMesh(impostor, scene);
  4795. dispose(): void;
  4796. }
  4797. }
  4798. declare module BABYLON {
  4799. class RayHelper {
  4800. ray: Nullable<Ray>;
  4801. private _renderPoints;
  4802. private _renderLine;
  4803. private _renderFunction;
  4804. private _scene;
  4805. private _updateToMeshFunction;
  4806. private _attachedToMesh;
  4807. private _meshSpaceDirection;
  4808. private _meshSpaceOrigin;
  4809. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  4810. constructor(ray: Ray);
  4811. show(scene: Scene, color: Color3): void;
  4812. hide(): void;
  4813. private _render();
  4814. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  4815. detachFromMesh(): void;
  4816. private _updateToMesh();
  4817. dispose(): void;
  4818. }
  4819. }
  4820. declare module BABYLON.Debug {
  4821. /**
  4822. * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8
  4823. */
  4824. class SkeletonViewer {
  4825. skeleton: Skeleton;
  4826. mesh: AbstractMesh;
  4827. autoUpdateBonesMatrices: boolean;
  4828. renderingGroupId: number;
  4829. color: Color3;
  4830. private _scene;
  4831. private _debugLines;
  4832. private _debugMesh;
  4833. private _isEnabled;
  4834. private _renderFunction;
  4835. constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number);
  4836. isEnabled: boolean;
  4837. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  4838. private _getLinesForBonesWithLength(bones, meshMat);
  4839. private _getLinesForBonesNoLength(bones, meshMat);
  4840. update(): void;
  4841. dispose(): void;
  4842. }
  4843. }
  4844. declare module BABYLON {
  4845. class ArcRotateCamera extends TargetCamera {
  4846. alpha: number;
  4847. beta: number;
  4848. radius: number;
  4849. protected _target: Vector3;
  4850. protected _targetHost: Nullable<AbstractMesh>;
  4851. target: Vector3;
  4852. inertialAlphaOffset: number;
  4853. inertialBetaOffset: number;
  4854. inertialRadiusOffset: number;
  4855. lowerAlphaLimit: Nullable<number>;
  4856. upperAlphaLimit: Nullable<number>;
  4857. lowerBetaLimit: number;
  4858. upperBetaLimit: number;
  4859. lowerRadiusLimit: Nullable<number>;
  4860. upperRadiusLimit: Nullable<number>;
  4861. inertialPanningX: number;
  4862. inertialPanningY: number;
  4863. pinchToPanMaxDistance: number;
  4864. panningDistanceLimit: Nullable<number>;
  4865. panningOriginTarget: Vector3;
  4866. panningInertia: number;
  4867. angularSensibilityX: number;
  4868. angularSensibilityY: number;
  4869. pinchPrecision: number;
  4870. pinchDeltaPercentage: number;
  4871. panningSensibility: number;
  4872. keysUp: number[];
  4873. keysDown: number[];
  4874. keysLeft: number[];
  4875. keysRight: number[];
  4876. wheelPrecision: number;
  4877. wheelDeltaPercentage: number;
  4878. zoomOnFactor: number;
  4879. targetScreenOffset: Vector2;
  4880. allowUpsideDown: boolean;
  4881. _viewMatrix: Matrix;
  4882. _useCtrlForPanning: boolean;
  4883. _panningMouseButton: number;
  4884. inputs: ArcRotateCameraInputsManager;
  4885. _reset: () => void;
  4886. panningAxis: Vector3;
  4887. protected _localDirection: Vector3;
  4888. protected _transformedDirection: Vector3;
  4889. private _bouncingBehavior;
  4890. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  4891. useBouncingBehavior: boolean;
  4892. private _framingBehavior;
  4893. readonly framingBehavior: Nullable<FramingBehavior>;
  4894. useFramingBehavior: boolean;
  4895. private _autoRotationBehavior;
  4896. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  4897. useAutoRotationBehavior: boolean;
  4898. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  4899. onCollide: (collidedMesh: AbstractMesh) => void;
  4900. checkCollisions: boolean;
  4901. collisionRadius: Vector3;
  4902. protected _collider: Collider;
  4903. protected _previousPosition: Vector3;
  4904. protected _collisionVelocity: Vector3;
  4905. protected _newPosition: Vector3;
  4906. protected _previousAlpha: number;
  4907. protected _previousBeta: number;
  4908. protected _previousRadius: number;
  4909. protected _collisionTriggered: boolean;
  4910. protected _targetBoundingCenter: Nullable<Vector3>;
  4911. private _computationVector;
  4912. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene);
  4913. _initCache(): void;
  4914. _updateCache(ignoreParentClass?: boolean): void;
  4915. protected _getTargetPosition(): Vector3;
  4916. /**
  4917. * Store current camera state (fov, position, etc..)
  4918. */
  4919. private _storedAlpha;
  4920. private _storedBeta;
  4921. private _storedRadius;
  4922. private _storedTarget;
  4923. storeState(): Camera;
  4924. /**
  4925. * Restored camera state. You must call storeState() first
  4926. */
  4927. _restoreStateValues(): boolean;
  4928. _isSynchronizedViewMatrix(): boolean;
  4929. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  4930. detachControl(element: HTMLElement): void;
  4931. _checkInputs(): void;
  4932. protected _checkLimits(): void;
  4933. rebuildAnglesAndRadius(): void;
  4934. setPosition(position: Vector3): void;
  4935. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  4936. _getViewMatrix(): Matrix;
  4937. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  4938. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  4939. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  4940. min: Vector3;
  4941. max: Vector3;
  4942. distance: number;
  4943. }, doNotUpdateMaxZ?: boolean): void;
  4944. /**
  4945. * @override
  4946. * Override Camera.createRigCamera
  4947. */
  4948. createRigCamera(name: string, cameraIndex: number): Camera;
  4949. /**
  4950. * @override
  4951. * Override Camera._updateRigCameras
  4952. */
  4953. _updateRigCameras(): void;
  4954. dispose(): void;
  4955. getClassName(): string;
  4956. }
  4957. }
  4958. declare module BABYLON {
  4959. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  4960. constructor(camera: ArcRotateCamera);
  4961. addMouseWheel(): ArcRotateCameraInputsManager;
  4962. addPointers(): ArcRotateCameraInputsManager;
  4963. addKeyboard(): ArcRotateCameraInputsManager;
  4964. addGamepad(): ArcRotateCameraInputsManager;
  4965. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  4966. }
  4967. }
  4968. declare module BABYLON {
  4969. class Camera extends Node {
  4970. inputs: CameraInputsManager<Camera>;
  4971. private static _PERSPECTIVE_CAMERA;
  4972. private static _ORTHOGRAPHIC_CAMERA;
  4973. private static _FOVMODE_VERTICAL_FIXED;
  4974. private static _FOVMODE_HORIZONTAL_FIXED;
  4975. private static _RIG_MODE_NONE;
  4976. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  4977. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  4978. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  4979. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  4980. private static _RIG_MODE_VR;
  4981. private static _RIG_MODE_WEBVR;
  4982. static readonly PERSPECTIVE_CAMERA: number;
  4983. static readonly ORTHOGRAPHIC_CAMERA: number;
  4984. /**
  4985. * This is the default FOV mode for perspective cameras.
  4986. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  4987. *
  4988. */
  4989. static readonly FOVMODE_VERTICAL_FIXED: number;
  4990. /**
  4991. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  4992. *
  4993. */
  4994. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  4995. static readonly RIG_MODE_NONE: number;
  4996. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  4997. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  4998. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  4999. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5000. static readonly RIG_MODE_VR: number;
  5001. static readonly RIG_MODE_WEBVR: number;
  5002. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5003. static UseAlternateWebVRRendering: boolean;
  5004. position: Vector3;
  5005. /**
  5006. * The vector the camera should consider as up.
  5007. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5008. */
  5009. upVector: Vector3;
  5010. orthoLeft: Nullable<number>;
  5011. orthoRight: Nullable<number>;
  5012. orthoBottom: Nullable<number>;
  5013. orthoTop: Nullable<number>;
  5014. /**
  5015. * FOV is set in Radians. (default is 0.8)
  5016. */
  5017. fov: number;
  5018. minZ: number;
  5019. maxZ: number;
  5020. inertia: number;
  5021. mode: number;
  5022. isIntermediate: boolean;
  5023. viewport: Viewport;
  5024. /**
  5025. * Restricts the camera to viewing objects with the same layerMask.
  5026. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5027. */
  5028. layerMask: number;
  5029. /**
  5030. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5031. */
  5032. fovMode: number;
  5033. cameraRigMode: number;
  5034. interaxialDistance: number;
  5035. isStereoscopicSideBySide: boolean;
  5036. _cameraRigParams: any;
  5037. _rigCameras: Camera[];
  5038. _rigPostProcess: Nullable<PostProcess>;
  5039. protected _webvrViewMatrix: Matrix;
  5040. _skipRendering: boolean;
  5041. _alternateCamera: Camera;
  5042. customRenderTargets: RenderTargetTexture[];
  5043. onViewMatrixChangedObservable: Observable<Camera>;
  5044. onProjectionMatrixChangedObservable: Observable<Camera>;
  5045. onAfterCheckInputsObservable: Observable<Camera>;
  5046. onRestoreStateObservable: Observable<Camera>;
  5047. private _computedViewMatrix;
  5048. _projectionMatrix: Matrix;
  5049. private _doNotComputeProjectionMatrix;
  5050. private _worldMatrix;
  5051. _postProcesses: Nullable<PostProcess>[];
  5052. private _transformMatrix;
  5053. _activeMeshes: SmartArray<AbstractMesh>;
  5054. private _globalPosition;
  5055. private _frustumPlanes;
  5056. private _refreshFrustumPlanes;
  5057. constructor(name: string, position: Vector3, scene: Scene);
  5058. private _storedFov;
  5059. private _stateStored;
  5060. /**
  5061. * Store current camera state (fov, position, etc..)
  5062. */
  5063. storeState(): Camera;
  5064. /**
  5065. * Restores the camera state values if it has been stored. You must call storeState() first
  5066. */
  5067. protected _restoreStateValues(): boolean;
  5068. /**
  5069. * Restored camera state. You must call storeState() first
  5070. */
  5071. restoreState(): boolean;
  5072. getClassName(): string;
  5073. /**
  5074. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5075. */
  5076. toString(fullDetails?: boolean): string;
  5077. readonly globalPosition: Vector3;
  5078. getActiveMeshes(): SmartArray<AbstractMesh>;
  5079. isActiveMesh(mesh: Mesh): boolean;
  5080. /**
  5081. * Is this camera ready to be used/rendered
  5082. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  5083. * @return true if the camera is ready
  5084. */
  5085. isReady(completeCheck?: boolean): boolean;
  5086. _initCache(): void;
  5087. _updateCache(ignoreParentClass?: boolean): void;
  5088. _isSynchronized(): boolean;
  5089. _isSynchronizedViewMatrix(): boolean;
  5090. _isSynchronizedProjectionMatrix(): boolean;
  5091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5092. detachControl(element: HTMLElement): void;
  5093. update(): void;
  5094. _checkInputs(): void;
  5095. readonly rigCameras: Camera[];
  5096. readonly rigPostProcess: Nullable<PostProcess>;
  5097. /**
  5098. * Internal, gets the first post proces.
  5099. * @returns the first post process to be run on this camera.
  5100. */
  5101. _getFirstPostProcess(): Nullable<PostProcess>;
  5102. private _cascadePostProcessesToRigCams();
  5103. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  5104. detachPostProcess(postProcess: PostProcess): void;
  5105. getWorldMatrix(): Matrix;
  5106. _getViewMatrix(): Matrix;
  5107. getViewMatrix(force?: boolean): Matrix;
  5108. freezeProjectionMatrix(projection?: Matrix): void;
  5109. unfreezeProjectionMatrix(): void;
  5110. getProjectionMatrix(force?: boolean): Matrix;
  5111. getTranformationMatrix(): Matrix;
  5112. private updateFrustumPlanes();
  5113. isInFrustum(target: ICullable): boolean;
  5114. isCompletelyInFrustum(target: ICullable): boolean;
  5115. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  5116. /**
  5117. * Releases resources associated with this node.
  5118. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  5119. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  5120. */
  5121. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  5122. readonly leftCamera: Nullable<FreeCamera>;
  5123. readonly rightCamera: Nullable<FreeCamera>;
  5124. getLeftTarget(): Nullable<Vector3>;
  5125. getRightTarget(): Nullable<Vector3>;
  5126. setCameraRigMode(mode: number, rigParams: any): void;
  5127. private _getVRProjectionMatrix();
  5128. protected _updateCameraRotationMatrix(): void;
  5129. protected _updateWebVRCameraRotationMatrix(): void;
  5130. /**
  5131. * This function MUST be overwritten by the different WebVR cameras available.
  5132. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5133. */
  5134. protected _getWebVRProjectionMatrix(): Matrix;
  5135. /**
  5136. * This function MUST be overwritten by the different WebVR cameras available.
  5137. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5138. */
  5139. protected _getWebVRViewMatrix(): Matrix;
  5140. setCameraRigParameter(name: string, value: any): void;
  5141. /**
  5142. * needs to be overridden by children so sub has required properties to be copied
  5143. */
  5144. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5145. /**
  5146. * May need to be overridden by children
  5147. */
  5148. _updateRigCameras(): void;
  5149. _setupInputs(): void;
  5150. serialize(): any;
  5151. clone(name: string): Camera;
  5152. getDirection(localAxis: Vector3): Vector3;
  5153. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  5154. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  5155. computeWorldMatrix(): Matrix;
  5156. static Parse(parsedCamera: any, scene: Scene): Camera;
  5157. }
  5158. }
  5159. declare module BABYLON {
  5160. var CameraInputTypes: {};
  5161. interface ICameraInput<TCamera extends Camera> {
  5162. camera: Nullable<TCamera>;
  5163. getClassName(): string;
  5164. getSimpleName(): string;
  5165. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  5166. detachControl: (element: Nullable<HTMLElement>) => void;
  5167. checkInputs?: () => void;
  5168. }
  5169. interface CameraInputsMap<TCamera extends Camera> {
  5170. [name: string]: ICameraInput<TCamera>;
  5171. [idx: number]: ICameraInput<TCamera>;
  5172. }
  5173. class CameraInputsManager<TCamera extends Camera> {
  5174. attached: CameraInputsMap<TCamera>;
  5175. attachedElement: Nullable<HTMLElement>;
  5176. noPreventDefault: boolean;
  5177. camera: TCamera;
  5178. checkInputs: () => void;
  5179. constructor(camera: TCamera);
  5180. /**
  5181. * Add an input method to a camera.
  5182. * builtin inputs example: camera.inputs.addGamepad();
  5183. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  5184. * @param input camera input method
  5185. */
  5186. add(input: ICameraInput<TCamera>): void;
  5187. /**
  5188. * Remove a specific input method from a camera
  5189. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  5190. * @param inputToRemove camera input method
  5191. */
  5192. remove(inputToRemove: ICameraInput<TCamera>): void;
  5193. removeByType(inputType: string): void;
  5194. private _addCheckInputs(fn);
  5195. attachInput(input: ICameraInput<TCamera>): void;
  5196. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  5197. detachElement(element: HTMLElement, disconnect?: boolean): void;
  5198. rebuildInputCheck(): void;
  5199. /**
  5200. * Remove all attached input methods from a camera
  5201. */
  5202. clear(): void;
  5203. serialize(serializedCamera: any): void;
  5204. parse(parsedCamera: any): void;
  5205. }
  5206. }
  5207. declare module BABYLON {
  5208. /**
  5209. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  5210. * being tilted forward or back and left or right.
  5211. */
  5212. class DeviceOrientationCamera extends FreeCamera {
  5213. private _initialQuaternion;
  5214. private _quaternionCache;
  5215. /**
  5216. * Creates a new device orientation camera
  5217. * @param name The name of the camera
  5218. * @param position The start position camera
  5219. * @param scene The scene the camera belongs to
  5220. */
  5221. constructor(name: string, position: Vector3, scene: Scene);
  5222. /**
  5223. * Gets the current instance class name ("DeviceOrientationCamera").
  5224. * This helps avoiding instanceof at run time.
  5225. * @returns the class name
  5226. */
  5227. getClassName(): string;
  5228. /**
  5229. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  5230. */
  5231. _checkInputs(): void;
  5232. /**
  5233. * Reset the camera to its default orientation on the specified axis only.
  5234. * @param axis The axis to reset
  5235. */
  5236. resetToCurrentRotation(axis?: Axis): void;
  5237. }
  5238. }
  5239. declare module BABYLON {
  5240. class FollowCamera extends TargetCamera {
  5241. radius: number;
  5242. rotationOffset: number;
  5243. heightOffset: number;
  5244. cameraAcceleration: number;
  5245. maxCameraSpeed: number;
  5246. lockedTarget: Nullable<AbstractMesh>;
  5247. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  5248. private getRadians(degrees);
  5249. private follow(cameraTarget);
  5250. _checkInputs(): void;
  5251. getClassName(): string;
  5252. }
  5253. class ArcFollowCamera extends TargetCamera {
  5254. alpha: number;
  5255. beta: number;
  5256. radius: number;
  5257. target: Nullable<AbstractMesh>;
  5258. private _cartesianCoordinates;
  5259. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  5260. private follow();
  5261. _checkInputs(): void;
  5262. getClassName(): string;
  5263. }
  5264. }
  5265. declare module BABYLON {
  5266. class FreeCamera extends TargetCamera {
  5267. ellipsoid: Vector3;
  5268. ellipsoidOffset: Vector3;
  5269. checkCollisions: boolean;
  5270. applyGravity: boolean;
  5271. inputs: FreeCameraInputsManager;
  5272. /**
  5273. * Gets the input sensibility for a mouse input. (default is 2000.0)
  5274. * Higher values reduce sensitivity.
  5275. */
  5276. /**
  5277. * Sets the input sensibility for a mouse input. (default is 2000.0)
  5278. * Higher values reduce sensitivity.
  5279. */
  5280. angularSensibility: number;
  5281. keysUp: number[];
  5282. keysDown: number[];
  5283. keysLeft: number[];
  5284. keysRight: number[];
  5285. onCollide: (collidedMesh: AbstractMesh) => void;
  5286. private _collider;
  5287. private _needMoveForGravity;
  5288. private _oldPosition;
  5289. private _diffPosition;
  5290. private _newPosition;
  5291. _localDirection: Vector3;
  5292. _transformedDirection: Vector3;
  5293. constructor(name: string, position: Vector3, scene: Scene);
  5294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5295. detachControl(element: HTMLElement): void;
  5296. private _collisionMask;
  5297. collisionMask: number;
  5298. _collideWithWorld(displacement: Vector3): void;
  5299. private _onCollisionPositionChange;
  5300. _checkInputs(): void;
  5301. _decideIfNeedsToMove(): boolean;
  5302. _updatePosition(): void;
  5303. dispose(): void;
  5304. getClassName(): string;
  5305. }
  5306. }
  5307. declare module BABYLON {
  5308. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  5309. constructor(camera: FreeCamera);
  5310. addKeyboard(): FreeCameraInputsManager;
  5311. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  5312. addGamepad(): FreeCameraInputsManager;
  5313. addDeviceOrientation(): FreeCameraInputsManager;
  5314. addTouch(): FreeCameraInputsManager;
  5315. addVirtualJoystick(): FreeCameraInputsManager;
  5316. }
  5317. }
  5318. declare module BABYLON {
  5319. class GamepadCamera extends UniversalCamera {
  5320. gamepadAngularSensibility: number;
  5321. gamepadMoveSensibility: number;
  5322. constructor(name: string, position: Vector3, scene: Scene);
  5323. getClassName(): string;
  5324. }
  5325. }
  5326. declare module BABYLON {
  5327. class AnaglyphFreeCamera extends FreeCamera {
  5328. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  5329. getClassName(): string;
  5330. }
  5331. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  5332. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  5333. getClassName(): string;
  5334. }
  5335. class AnaglyphGamepadCamera extends GamepadCamera {
  5336. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  5337. getClassName(): string;
  5338. }
  5339. class AnaglyphUniversalCamera extends UniversalCamera {
  5340. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  5341. getClassName(): string;
  5342. }
  5343. class StereoscopicFreeCamera extends FreeCamera {
  5344. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  5345. getClassName(): string;
  5346. }
  5347. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  5348. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  5349. getClassName(): string;
  5350. }
  5351. class StereoscopicGamepadCamera extends GamepadCamera {
  5352. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  5353. getClassName(): string;
  5354. }
  5355. class StereoscopicUniversalCamera extends UniversalCamera {
  5356. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  5357. getClassName(): string;
  5358. }
  5359. }
  5360. declare module BABYLON {
  5361. class TargetCamera extends Camera {
  5362. cameraDirection: Vector3;
  5363. cameraRotation: Vector2;
  5364. rotation: Vector3;
  5365. rotationQuaternion: Quaternion;
  5366. speed: number;
  5367. noRotationConstraint: boolean;
  5368. lockedTarget: any;
  5369. _currentTarget: Vector3;
  5370. _viewMatrix: Matrix;
  5371. _camMatrix: Matrix;
  5372. _cameraTransformMatrix: Matrix;
  5373. _cameraRotationMatrix: Matrix;
  5374. private _rigCamTransformMatrix;
  5375. _referencePoint: Vector3;
  5376. private _currentUpVector;
  5377. _transformedReferencePoint: Vector3;
  5378. _lookAtTemp: Matrix;
  5379. _tempMatrix: Matrix;
  5380. _reset: () => void;
  5381. constructor(name: string, position: Vector3, scene: Scene);
  5382. getFrontPosition(distance: number): Vector3;
  5383. _getLockedTargetPosition(): Nullable<Vector3>;
  5384. /**
  5385. * Store current camera state (fov, position, etc..)
  5386. */
  5387. private _storedPosition;
  5388. private _storedRotation;
  5389. private _storedRotationQuaternion;
  5390. storeState(): Camera;
  5391. /**
  5392. * Restored camera state. You must call storeState() first
  5393. */
  5394. _restoreStateValues(): boolean;
  5395. _initCache(): void;
  5396. _updateCache(ignoreParentClass?: boolean): void;
  5397. _isSynchronizedViewMatrix(): boolean;
  5398. _computeLocalCameraSpeed(): number;
  5399. setTarget(target: Vector3): void;
  5400. /**
  5401. * Return the current target position of the camera. This value is expressed in local space.
  5402. */
  5403. getTarget(): Vector3;
  5404. _decideIfNeedsToMove(): boolean;
  5405. _updatePosition(): void;
  5406. _checkInputs(): void;
  5407. protected _updateCameraRotationMatrix(): void;
  5408. _getViewMatrix(): Matrix;
  5409. /**
  5410. * @override
  5411. * Override Camera.createRigCamera
  5412. */
  5413. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5414. /**
  5415. * @override
  5416. * Override Camera._updateRigCameras
  5417. */
  5418. _updateRigCameras(): void;
  5419. private _getRigCamPosition(halfSpace, result);
  5420. getClassName(): string;
  5421. }
  5422. }
  5423. declare module BABYLON {
  5424. class TouchCamera extends FreeCamera {
  5425. touchAngularSensibility: number;
  5426. touchMoveSensibility: number;
  5427. constructor(name: string, position: Vector3, scene: Scene);
  5428. getClassName(): string;
  5429. _setupInputs(): void;
  5430. }
  5431. }
  5432. declare module BABYLON {
  5433. class UniversalCamera extends TouchCamera {
  5434. gamepadAngularSensibility: number;
  5435. gamepadMoveSensibility: number;
  5436. constructor(name: string, position: Vector3, scene: Scene);
  5437. getClassName(): string;
  5438. }
  5439. }
  5440. declare module BABYLON {
  5441. class VirtualJoysticksCamera extends FreeCamera {
  5442. constructor(name: string, position: Vector3, scene: Scene);
  5443. getClassName(): string;
  5444. }
  5445. }
  5446. interface VRDisplay extends EventTarget {
  5447. /**
  5448. * Dictionary of capabilities describing the VRDisplay.
  5449. */
  5450. readonly capabilities: VRDisplayCapabilities;
  5451. /**
  5452. * z-depth defining the far plane of the eye view frustum
  5453. * enables mapping of values in the render target depth
  5454. * attachment to scene coordinates. Initially set to 10000.0.
  5455. */
  5456. depthFar: number;
  5457. /**
  5458. * z-depth defining the near plane of the eye view frustum
  5459. * enables mapping of values in the render target depth
  5460. * attachment to scene coordinates. Initially set to 0.01.
  5461. */
  5462. depthNear: number;
  5463. /**
  5464. * An identifier for this distinct VRDisplay. Used as an
  5465. * association point in the Gamepad API.
  5466. */
  5467. readonly displayId: number;
  5468. /**
  5469. * A display name, a user-readable name identifying it.
  5470. */
  5471. readonly displayName: string;
  5472. readonly isConnected: boolean;
  5473. readonly isPresenting: boolean;
  5474. /**
  5475. * If this VRDisplay supports room-scale experiences, the optional
  5476. * stage attribute contains details on the room-scale parameters.
  5477. */
  5478. readonly stageParameters: VRStageParameters | null;
  5479. /**
  5480. * Passing the value returned by `requestAnimationFrame` to
  5481. * `cancelAnimationFrame` will unregister the callback.
  5482. */
  5483. cancelAnimationFrame(handle: number): void;
  5484. /**
  5485. * Stops presenting to the VRDisplay.
  5486. */
  5487. exitPresent(): Promise<void>;
  5488. getEyeParameters(whichEye: string): VREyeParameters;
  5489. /**
  5490. * Populates the passed VRFrameData with the information required to render
  5491. * the current frame.
  5492. */
  5493. getFrameData(frameData: VRFrameData): boolean;
  5494. /**
  5495. * Get the layers currently being presented.
  5496. */
  5497. getLayers(): VRLayer[];
  5498. /**
  5499. * Return a VRPose containing the future predicted pose of the VRDisplay
  5500. * when the current frame will be presented. The value returned will not
  5501. * change until JavaScript has returned control to the browser.
  5502. *
  5503. * The VRPose will contain the position, orientation, velocity,
  5504. * and acceleration of each of these properties.
  5505. */
  5506. getPose(): VRPose;
  5507. /**
  5508. * Return the current instantaneous pose of the VRDisplay, with no
  5509. * prediction applied.
  5510. */
  5511. getImmediatePose(): VRPose;
  5512. /**
  5513. * The callback passed to `requestAnimationFrame` will be called
  5514. * any time a new frame should be rendered. When the VRDisplay is
  5515. * presenting the callback will be called at the native refresh
  5516. * rate of the HMD. When not presenting this function acts
  5517. * identically to how window.requestAnimationFrame acts. Content should
  5518. * make no assumptions of frame rate or vsync behavior as the HMD runs
  5519. * asynchronously from other displays and at differing refresh rates.
  5520. */
  5521. requestAnimationFrame(callback: FrameRequestCallback): number;
  5522. /**
  5523. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  5524. * Repeat calls while already presenting will update the VRLayers being displayed.
  5525. */
  5526. requestPresent(layers: VRLayer[]): Promise<void>;
  5527. /**
  5528. * Reset the pose for this display, treating its current position and
  5529. * orientation as the "origin/zero" values. VRPose.position,
  5530. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  5531. * updated when calling resetPose(). This should be called in only
  5532. * sitting-space experiences.
  5533. */
  5534. resetPose(): void;
  5535. /**
  5536. * The VRLayer provided to the VRDisplay will be captured and presented
  5537. * in the HMD. Calling this function has the same effect on the source
  5538. * canvas as any other operation that uses its source image, and canvases
  5539. * created without preserveDrawingBuffer set to true will be cleared.
  5540. */
  5541. submitFrame(pose?: VRPose): void;
  5542. }
  5543. declare var VRDisplay: {
  5544. prototype: VRDisplay;
  5545. new (): VRDisplay;
  5546. };
  5547. interface VRLayer {
  5548. leftBounds?: number[] | null;
  5549. rightBounds?: number[] | null;
  5550. source?: HTMLCanvasElement | null;
  5551. }
  5552. interface VRDisplayCapabilities {
  5553. readonly canPresent: boolean;
  5554. readonly hasExternalDisplay: boolean;
  5555. readonly hasOrientation: boolean;
  5556. readonly hasPosition: boolean;
  5557. readonly maxLayers: number;
  5558. }
  5559. interface VREyeParameters {
  5560. /** @deprecated */
  5561. readonly fieldOfView: VRFieldOfView;
  5562. readonly offset: Float32Array;
  5563. readonly renderHeight: number;
  5564. readonly renderWidth: number;
  5565. }
  5566. interface VRFieldOfView {
  5567. readonly downDegrees: number;
  5568. readonly leftDegrees: number;
  5569. readonly rightDegrees: number;
  5570. readonly upDegrees: number;
  5571. }
  5572. interface VRFrameData {
  5573. readonly leftProjectionMatrix: Float32Array;
  5574. readonly leftViewMatrix: Float32Array;
  5575. readonly pose: VRPose;
  5576. readonly rightProjectionMatrix: Float32Array;
  5577. readonly rightViewMatrix: Float32Array;
  5578. readonly timestamp: number;
  5579. }
  5580. interface VRPose {
  5581. readonly angularAcceleration: Float32Array | null;
  5582. readonly angularVelocity: Float32Array | null;
  5583. readonly linearAcceleration: Float32Array | null;
  5584. readonly linearVelocity: Float32Array | null;
  5585. readonly orientation: Float32Array | null;
  5586. readonly position: Float32Array | null;
  5587. readonly timestamp: number;
  5588. }
  5589. interface VRStageParameters {
  5590. sittingToStandingTransform?: Float32Array;
  5591. sizeX?: number;
  5592. sizeY?: number;
  5593. }
  5594. interface Navigator {
  5595. getVRDisplays(): Promise<VRDisplay[]>;
  5596. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  5597. }
  5598. interface Window {
  5599. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  5600. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  5601. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  5602. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  5603. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  5604. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  5605. }
  5606. interface Gamepad {
  5607. readonly displayId: number;
  5608. }
  5609. declare module BABYLON {
  5610. /**
  5611. * Interface for attribute information associated with buffer instanciation
  5612. */
  5613. class InstancingAttributeInfo {
  5614. /**
  5615. * Index/offset of the attribute in the vertex shader
  5616. */
  5617. index: number;
  5618. /**
  5619. * size of the attribute, 1, 2, 3 or 4
  5620. */
  5621. attributeSize: number;
  5622. /**
  5623. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  5624. * default is FLOAT
  5625. */
  5626. attribyteType: number;
  5627. /**
  5628. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  5629. */
  5630. normalized: boolean;
  5631. /**
  5632. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  5633. */
  5634. offset: number;
  5635. /**
  5636. * Name of the GLSL attribute, for debugging purpose only
  5637. */
  5638. attributeName: string;
  5639. }
  5640. /**
  5641. * Define options used to create a render target texture
  5642. */
  5643. class RenderTargetCreationOptions {
  5644. /**
  5645. * Specifies is mipmaps must be generated
  5646. */
  5647. generateMipMaps?: boolean;
  5648. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5649. generateDepthBuffer?: boolean;
  5650. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5651. generateStencilBuffer?: boolean;
  5652. /** Defines texture type (int by default) */
  5653. type?: number;
  5654. /** Defines sampling mode (trilinear by default) */
  5655. samplingMode?: number;
  5656. /** Defines format (RGBA by default) */
  5657. format?: number;
  5658. }
  5659. /**
  5660. * Define options used to create a depth texture
  5661. */
  5662. class DepthTextureCreationOptions {
  5663. /** Specifies whether or not a stencil should be allocated in the texture */
  5664. generateStencil?: boolean;
  5665. /** Specifies whether or not bilinear filtering is enable on the texture */
  5666. bilinearFiltering?: boolean;
  5667. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  5668. comparisonFunction?: number;
  5669. /** Specifies if the created texture is a cube texture */
  5670. isCube?: boolean;
  5671. }
  5672. /**
  5673. * Class used to describe the capabilities of the engine relatively to the current browser
  5674. */
  5675. class EngineCapabilities {
  5676. /** Maximum textures units per fragment shader */
  5677. maxTexturesImageUnits: number;
  5678. /** Maximum texture units per vertex shader */
  5679. maxVertexTextureImageUnits: number;
  5680. /** Maximum textures units in the entire pipeline */
  5681. maxCombinedTexturesImageUnits: number;
  5682. /** Maximum texture size */
  5683. maxTextureSize: number;
  5684. /** Maximum cube texture size */
  5685. maxCubemapTextureSize: number;
  5686. /** Maximum render texture size */
  5687. maxRenderTextureSize: number;
  5688. /** Maximum number of vertex attributes */
  5689. maxVertexAttribs: number;
  5690. /** Maximum number of varyings */
  5691. maxVaryingVectors: number;
  5692. /** Maximum number of uniforms per vertex shader */
  5693. maxVertexUniformVectors: number;
  5694. /** Maximum number of uniforms per fragment shader */
  5695. maxFragmentUniformVectors: number;
  5696. /** Defines if standard derivates (dx/dy) are supported */
  5697. standardDerivatives: boolean;
  5698. /** Defines if s3tc texture compression is supported */
  5699. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  5700. /** Defines if pvrtc texture compression is supported */
  5701. pvrtc: any;
  5702. /** Defines if etc1 texture compression is supported */
  5703. etc1: any;
  5704. /** Defines if etc2 texture compression is supported */
  5705. etc2: any;
  5706. /** Defines if astc texture compression is supported */
  5707. astc: any;
  5708. /** Defines if float textures are supported */
  5709. textureFloat: boolean;
  5710. /** Defines if vertex array objects are supported */
  5711. vertexArrayObject: boolean;
  5712. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  5713. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  5714. /** Gets the maximum level of anisotropy supported */
  5715. maxAnisotropy: number;
  5716. /** Defines if instancing is supported */
  5717. instancedArrays: boolean;
  5718. /** Defines if 32 bits indices are supported */
  5719. uintIndices: boolean;
  5720. /** Defines if high precision shaders are supported */
  5721. highPrecisionShaderSupported: boolean;
  5722. /** Defines if depth reading in the fragment shader is supported */
  5723. fragmentDepthSupported: boolean;
  5724. /** Defines if float texture linear filtering is supported*/
  5725. textureFloatLinearFiltering: boolean;
  5726. /** Defines if rendering to float textures is supported */
  5727. textureFloatRender: boolean;
  5728. /** Defines if half float textures are supported*/
  5729. textureHalfFloat: boolean;
  5730. /** Defines if half float texture linear filtering is supported*/
  5731. textureHalfFloatLinearFiltering: boolean;
  5732. /** Defines if rendering to half float textures is supported */
  5733. textureHalfFloatRender: boolean;
  5734. /** Defines if textureLOD shader command is supported */
  5735. textureLOD: boolean;
  5736. /** Defines if draw buffers extension is supported */
  5737. drawBuffersExtension: boolean;
  5738. /** Defines if depth textures are supported */
  5739. depthTextureExtension: boolean;
  5740. /** Defines if float color buffer are supported */
  5741. colorBufferFloat: boolean;
  5742. /** Gets disjoint timer query extension (null if not supported) */
  5743. timerQuery: EXT_disjoint_timer_query;
  5744. /** Defines if timestamp can be used with timer query */
  5745. canUseTimestampForTimerQuery: boolean;
  5746. }
  5747. /** Interface defining initialization parameters for Engine class */
  5748. interface EngineOptions extends WebGLContextAttributes {
  5749. /**
  5750. * Defines if the engine should no exceed a specified device ratio
  5751. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  5752. */
  5753. limitDeviceRatio?: number;
  5754. /**
  5755. * Defines if webvr should be enabled automatically
  5756. * @see http://doc.babylonjs.com/how_to/webvr_camera
  5757. */
  5758. autoEnableWebVR?: boolean;
  5759. /**
  5760. * Defines if webgl2 should be turned off even if supported
  5761. * @see http://doc.babylonjs.com/features/webgl2
  5762. */
  5763. disableWebGL2Support?: boolean;
  5764. /**
  5765. * Defines if webaudio should be initialized as well
  5766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5767. */
  5768. audioEngine?: boolean;
  5769. /**
  5770. * Defines if animations should run using a deterministic lock step
  5771. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  5772. */
  5773. deterministicLockstep?: boolean;
  5774. /** Defines the maximum steps to use with deterministic lock step mode */
  5775. lockstepMaxSteps?: number;
  5776. /**
  5777. * Defines that engine should ignore context lost events
  5778. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  5779. */
  5780. doNotHandleContextLost?: boolean;
  5781. }
  5782. /**
  5783. * Defines the interface used by display changed events
  5784. */
  5785. interface IDisplayChangedEventArgs {
  5786. /** Gets the vrDisplay object (if any) */
  5787. vrDisplay: Nullable<any>;
  5788. /** Gets a boolean indicating if webVR is supported */
  5789. vrSupported: boolean;
  5790. }
  5791. /**
  5792. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  5793. */
  5794. class Engine {
  5795. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  5796. static ExceptionList: ({
  5797. key: string;
  5798. capture: string;
  5799. captureConstraint: number;
  5800. targets: string[];
  5801. } | {
  5802. key: string;
  5803. capture: null;
  5804. captureConstraint: null;
  5805. targets: string[];
  5806. })[];
  5807. /** Gets the list of created engines */
  5808. static Instances: Engine[];
  5809. /**
  5810. * Gets the latest created engine
  5811. */
  5812. static readonly LastCreatedEngine: Nullable<Engine>;
  5813. /**
  5814. * Gets the latest created scene
  5815. */
  5816. static readonly LastCreatedScene: Nullable<Scene>;
  5817. /**
  5818. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  5819. * @param flag defines which part of the materials must be marked as dirty
  5820. * @param predicate defines a predicate used to filter which materials should be affected
  5821. */
  5822. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  5823. private static _ALPHA_DISABLE;
  5824. private static _ALPHA_ADD;
  5825. private static _ALPHA_COMBINE;
  5826. private static _ALPHA_SUBTRACT;
  5827. private static _ALPHA_MULTIPLY;
  5828. private static _ALPHA_MAXIMIZED;
  5829. private static _ALPHA_ONEONE;
  5830. private static _ALPHA_PREMULTIPLIED;
  5831. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  5832. private static _ALPHA_INTERPOLATE;
  5833. private static _ALPHA_SCREENMODE;
  5834. private static _DELAYLOADSTATE_NONE;
  5835. private static _DELAYLOADSTATE_LOADED;
  5836. private static _DELAYLOADSTATE_LOADING;
  5837. private static _DELAYLOADSTATE_NOTLOADED;
  5838. private static _TEXTUREFORMAT_ALPHA;
  5839. private static _TEXTUREFORMAT_LUMINANCE;
  5840. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  5841. private static _TEXTUREFORMAT_RGB;
  5842. private static _TEXTUREFORMAT_RGBA;
  5843. private static _TEXTUREFORMAT_R32F;
  5844. private static _TEXTUREFORMAT_RG32F;
  5845. private static _TEXTUREFORMAT_RGB32F;
  5846. private static _TEXTUREFORMAT_RGBA32F;
  5847. private static _TEXTURETYPE_UNSIGNED_INT;
  5848. private static _TEXTURETYPE_FLOAT;
  5849. private static _TEXTURETYPE_HALF_FLOAT;
  5850. private static _NEVER;
  5851. private static _ALWAYS;
  5852. private static _LESS;
  5853. private static _EQUAL;
  5854. private static _LEQUAL;
  5855. private static _GREATER;
  5856. private static _GEQUAL;
  5857. private static _NOTEQUAL;
  5858. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  5859. static readonly NEVER: number;
  5860. /** 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 */
  5861. static readonly ALWAYS: number;
  5862. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  5863. static readonly LESS: number;
  5864. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  5865. static readonly EQUAL: number;
  5866. /** 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 */
  5867. static readonly LEQUAL: number;
  5868. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  5869. static readonly GREATER: number;
  5870. /** 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 */
  5871. static readonly GEQUAL: number;
  5872. /** 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 */
  5873. static readonly NOTEQUAL: number;
  5874. private static _KEEP;
  5875. private static _REPLACE;
  5876. private static _INCR;
  5877. private static _DECR;
  5878. private static _INVERT;
  5879. private static _INCR_WRAP;
  5880. private static _DECR_WRAP;
  5881. /** Passed to stencilOperation to specify that stencil value must be kept */
  5882. static readonly KEEP: number;
  5883. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5884. static readonly REPLACE: number;
  5885. /** Passed to stencilOperation to specify that stencil value must be incremented */
  5886. static readonly INCR: number;
  5887. /** Passed to stencilOperation to specify that stencil value must be decremented */
  5888. static readonly DECR: number;
  5889. /** Passed to stencilOperation to specify that stencil value must be inverted */
  5890. static readonly INVERT: number;
  5891. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  5892. static readonly INCR_WRAP: number;
  5893. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  5894. static readonly DECR_WRAP: number;
  5895. /** Defines that alpha blending is disabled */
  5896. static readonly ALPHA_DISABLE: number;
  5897. /** Defines that alpha blending to SRC + DEST */
  5898. static readonly ALPHA_ONEONE: number;
  5899. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  5900. static readonly ALPHA_ADD: number;
  5901. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  5902. static readonly ALPHA_COMBINE: number;
  5903. /** Defines that alpha blending to DEST - SRC * DEST */
  5904. static readonly ALPHA_SUBTRACT: number;
  5905. /** Defines that alpha blending to SRC * DEST */
  5906. static readonly ALPHA_MULTIPLY: number;
  5907. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  5908. static readonly ALPHA_MAXIMIZED: number;
  5909. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  5910. static readonly ALPHA_PREMULTIPLIED: number;
  5911. /**
  5912. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  5913. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  5914. */
  5915. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  5916. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  5917. static readonly ALPHA_INTERPOLATE: number;
  5918. /**
  5919. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  5920. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  5921. */
  5922. static readonly ALPHA_SCREENMODE: number;
  5923. /** Defines that the ressource is not delayed*/
  5924. static readonly DELAYLOADSTATE_NONE: number;
  5925. /** Defines that the ressource was successfully delay loaded */
  5926. static readonly DELAYLOADSTATE_LOADED: number;
  5927. /** Defines that the ressource is currently delay loading */
  5928. static readonly DELAYLOADSTATE_LOADING: number;
  5929. /** Defines that the ressource is delayed and has not started loading */
  5930. static readonly DELAYLOADSTATE_NOTLOADED: number;
  5931. /** ALPHA */
  5932. static readonly TEXTUREFORMAT_ALPHA: number;
  5933. /** LUMINANCE */
  5934. static readonly TEXTUREFORMAT_LUMINANCE: number;
  5935. /**
  5936. * R32F
  5937. */
  5938. static readonly TEXTUREFORMAT_R32F: number;
  5939. /**
  5940. * RG32F
  5941. */
  5942. static readonly TEXTUREFORMAT_RG32F: number;
  5943. /**
  5944. * RGB32F
  5945. */
  5946. static readonly TEXTUREFORMAT_RGB32F: number;
  5947. /**
  5948. * RGBA32F
  5949. */
  5950. static readonly TEXTUREFORMAT_RGBA32F: number;
  5951. /** LUMINANCE_ALPHA */
  5952. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  5953. /** RGB */
  5954. static readonly TEXTUREFORMAT_RGB: number;
  5955. /** RGBA */
  5956. static readonly TEXTUREFORMAT_RGBA: number;
  5957. /** UNSIGNED_INT */
  5958. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  5959. /** FLOAT */
  5960. static readonly TEXTURETYPE_FLOAT: number;
  5961. /** HALF_FLOAT */
  5962. static readonly TEXTURETYPE_HALF_FLOAT: number;
  5963. private static _SCALEMODE_FLOOR;
  5964. private static _SCALEMODE_NEAREST;
  5965. private static _SCALEMODE_CEILING;
  5966. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  5967. static readonly SCALEMODE_FLOOR: number;
  5968. /** Defines that texture rescaling will look for the nearest power of 2 size */
  5969. static readonly SCALEMODE_NEAREST: number;
  5970. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  5971. static readonly SCALEMODE_CEILING: number;
  5972. /**
  5973. * Returns the current version of the framework
  5974. */
  5975. static readonly Version: string;
  5976. /**
  5977. * Gets or sets the epsilon value used by collision engine
  5978. */
  5979. static CollisionsEpsilon: number;
  5980. /**
  5981. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  5982. */
  5983. static CodeRepository: string;
  5984. /**
  5985. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  5986. */
  5987. static ShadersRepository: string;
  5988. /**
  5989. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  5990. */
  5991. forcePOTTextures: boolean;
  5992. /**
  5993. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  5994. */
  5995. isFullscreen: boolean;
  5996. /**
  5997. * Gets a boolean indicating if the pointer is currently locked
  5998. */
  5999. isPointerLock: boolean;
  6000. /**
  6001. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  6002. */
  6003. cullBackFaces: boolean;
  6004. /**
  6005. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  6006. */
  6007. renderEvenInBackground: boolean;
  6008. /**
  6009. * Gets or sets a boolean indicating that cache can be kept between frames
  6010. */
  6011. preventCacheWipeBetweenFrames: boolean;
  6012. /**
  6013. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  6014. **/
  6015. enableOfflineSupport: boolean;
  6016. /**
  6017. * Gets the list of created scenes
  6018. */
  6019. scenes: Scene[];
  6020. /**
  6021. * Gets the list of created postprocesses
  6022. */
  6023. postProcesses: PostProcess[];
  6024. /**
  6025. * Observable event triggered each time the rendering canvas is resized
  6026. */
  6027. onResizeObservable: Observable<Engine>;
  6028. /**
  6029. * Observable event triggered each time the canvas loses focus
  6030. */
  6031. onCanvasBlurObservable: Observable<Engine>;
  6032. /**
  6033. * Observable event triggered each time the canvas gains focus
  6034. */
  6035. onCanvasFocusObservable: Observable<Engine>;
  6036. /**
  6037. * Observable event triggered each time the canvas receives pointerout event
  6038. */
  6039. onCanvasPointerOutObservable: Observable<PointerEvent>;
  6040. /**
  6041. * Observable event triggered before each texture is initialized
  6042. */
  6043. onBeforeTextureInitObservable: Observable<Texture>;
  6044. private _vrDisplay;
  6045. private _vrSupported;
  6046. private _oldSize;
  6047. private _oldHardwareScaleFactor;
  6048. private _vrExclusivePointerMode;
  6049. private _webVRInitPromise;
  6050. /**
  6051. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  6052. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  6053. */
  6054. readonly isInVRExclusivePointerMode: boolean;
  6055. /**
  6056. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  6057. */
  6058. disableUniformBuffers: boolean;
  6059. /** @ignore */
  6060. _uniformBuffers: UniformBuffer[];
  6061. /**
  6062. * Gets a boolean indicating that the engine supports uniform buffers
  6063. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6064. */
  6065. readonly supportsUniformBuffers: boolean;
  6066. /**
  6067. * Observable raised when the engine begins a new frame
  6068. */
  6069. onBeginFrameObservable: Observable<Engine>;
  6070. /**
  6071. * Observable raised when the engine ends the current frame
  6072. */
  6073. onEndFrameObservable: Observable<Engine>;
  6074. /**
  6075. * Observable raised when the engine is about to compile a shader
  6076. */
  6077. onBeforeShaderCompilationObservable: Observable<Engine>;
  6078. /**
  6079. * Observable raised when the engine has jsut compiled a shader
  6080. */
  6081. onAfterShaderCompilationObservable: Observable<Engine>;
  6082. private _gl;
  6083. private _renderingCanvas;
  6084. private _windowIsBackground;
  6085. private _webGLVersion;
  6086. /**
  6087. * Gets a boolean indicating that only power of 2 textures are supported
  6088. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  6089. */
  6090. readonly needPOTTextures: boolean;
  6091. /** @ignore */
  6092. _badOS: boolean;
  6093. /** @ignore */
  6094. _badDesktopOS: boolean;
  6095. /**
  6096. * Gets or sets a value indicating if we want to disable texture binding optmization.
  6097. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  6098. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  6099. */
  6100. disableTextureBindingOptimization: boolean;
  6101. /**
  6102. * Gets the audio engine
  6103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6104. * @ignoreNaming
  6105. */
  6106. static audioEngine: AudioEngine;
  6107. private _onFocus;
  6108. private _onBlur;
  6109. private _onCanvasPointerOut;
  6110. private _onCanvasBlur;
  6111. private _onCanvasFocus;
  6112. private _onFullscreenChange;
  6113. private _onPointerLockChange;
  6114. private _onVRDisplayPointerRestricted;
  6115. private _onVRDisplayPointerUnrestricted;
  6116. private _onVrDisplayConnect;
  6117. private _onVrDisplayDisconnect;
  6118. private _onVrDisplayPresentChange;
  6119. /**
  6120. * Observable signaled when VR display mode changes
  6121. */
  6122. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  6123. /**
  6124. * Observable signaled when VR request present is complete
  6125. */
  6126. onVRRequestPresentComplete: Observable<boolean>;
  6127. /**
  6128. * Observable signaled when VR request present starts
  6129. */
  6130. onVRRequestPresentStart: Observable<Engine>;
  6131. private _hardwareScalingLevel;
  6132. /** @ignore */
  6133. protected _caps: EngineCapabilities;
  6134. private _pointerLockRequested;
  6135. private _isStencilEnable;
  6136. private _colorWrite;
  6137. private _loadingScreen;
  6138. /** @ignore */
  6139. _drawCalls: PerfCounter;
  6140. /** @ignore */
  6141. _textureCollisions: PerfCounter;
  6142. private _glVersion;
  6143. private _glRenderer;
  6144. private _glVendor;
  6145. private _videoTextureSupported;
  6146. private _renderingQueueLaunched;
  6147. private _activeRenderLoops;
  6148. private _deterministicLockstep;
  6149. private _lockstepMaxSteps;
  6150. /**
  6151. * Observable signaled when a context lost event is raised
  6152. */
  6153. onContextLostObservable: Observable<Engine>;
  6154. /**
  6155. * Observable signaled when a context restored event is raised
  6156. */
  6157. onContextRestoredObservable: Observable<Engine>;
  6158. private _onContextLost;
  6159. private _onContextRestored;
  6160. private _contextWasLost;
  6161. private _doNotHandleContextLost;
  6162. private _performanceMonitor;
  6163. private _fps;
  6164. private _deltaTime;
  6165. /**
  6166. * Turn this value on if you want to pause FPS computation when in background
  6167. */
  6168. disablePerformanceMonitorInBackground: boolean;
  6169. /**
  6170. * Gets the performance monitor attached to this engine
  6171. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  6172. */
  6173. readonly performanceMonitor: PerformanceMonitor;
  6174. /** @ignore */
  6175. protected _depthCullingState: _DepthCullingState;
  6176. /** @ignore */
  6177. protected _stencilState: _StencilState;
  6178. /** @ignore */
  6179. protected _alphaState: _AlphaState;
  6180. /** @ignore */
  6181. protected _alphaMode: number;
  6182. private _internalTexturesCache;
  6183. /** @ignore */
  6184. protected _activeChannel: number;
  6185. private _currentTextureChannel;
  6186. /** @ignore */
  6187. protected _boundTexturesCache: {
  6188. [key: string]: Nullable<InternalTexture>;
  6189. };
  6190. /** @ignore */
  6191. protected _currentEffect: Nullable<Effect>;
  6192. /** @ignore */
  6193. protected _currentProgram: Nullable<WebGLProgram>;
  6194. private _compiledEffects;
  6195. private _vertexAttribArraysEnabled;
  6196. /** @ignore */
  6197. protected _cachedViewport: Nullable<Viewport>;
  6198. private _cachedVertexArrayObject;
  6199. /** @ignore */
  6200. protected _cachedVertexBuffers: any;
  6201. /** @ignore */
  6202. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  6203. /** @ignore */
  6204. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  6205. /** @ignore */
  6206. protected _currentRenderTarget: Nullable<InternalTexture>;
  6207. private _uintIndicesCurrentlySet;
  6208. private _currentBoundBuffer;
  6209. /** @ignore */
  6210. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  6211. private _currentBufferPointers;
  6212. private _currentInstanceLocations;
  6213. private _currentInstanceBuffers;
  6214. private _textureUnits;
  6215. private _firstBoundInternalTextureTracker;
  6216. private _lastBoundInternalTextureTracker;
  6217. private _workingCanvas;
  6218. private _workingContext;
  6219. private _rescalePostProcess;
  6220. private _dummyFramebuffer;
  6221. private _externalData;
  6222. private _bindedRenderFunction;
  6223. private _vaoRecordInProgress;
  6224. private _mustWipeVertexAttributes;
  6225. private _emptyTexture;
  6226. private _emptyCubeTexture;
  6227. private _emptyTexture3D;
  6228. private _frameHandler;
  6229. private _nextFreeTextureSlots;
  6230. private _maxSimultaneousTextures;
  6231. private _activeRequests;
  6232. private _texturesSupported;
  6233. private _textureFormatInUse;
  6234. /**
  6235. * Gets the list of texture formats supported
  6236. */
  6237. readonly texturesSupported: Array<string>;
  6238. /**
  6239. * Gets the list of texture formats in use
  6240. */
  6241. readonly textureFormatInUse: Nullable<string>;
  6242. /**
  6243. * Gets the current viewport
  6244. */
  6245. readonly currentViewport: Nullable<Viewport>;
  6246. /**
  6247. * Gets the default empty texture
  6248. */
  6249. readonly emptyTexture: InternalTexture;
  6250. /**
  6251. * Gets the default empty 3D texture
  6252. */
  6253. readonly emptyTexture3D: InternalTexture;
  6254. /**
  6255. * Gets the default empty cube texture
  6256. */
  6257. readonly emptyCubeTexture: InternalTexture;
  6258. /**
  6259. * Creates a new engine
  6260. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  6261. * @param antialias defines enable antialiasing (default: false)
  6262. * @param options defines further options to be sent to the getContext() function
  6263. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  6264. */
  6265. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  6266. private _rebuildInternalTextures();
  6267. private _rebuildEffects();
  6268. private _rebuildBuffers();
  6269. private _initGLContext();
  6270. /**
  6271. * Gets version of the current webGL context
  6272. */
  6273. readonly webGLVersion: number;
  6274. /**
  6275. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  6276. */
  6277. readonly isStencilEnable: boolean;
  6278. private _prepareWorkingCanvas();
  6279. /**
  6280. * Reset the texture cache to empty state
  6281. */
  6282. resetTextureCache(): void;
  6283. /**
  6284. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  6285. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6286. * @returns true if engine is in deterministic lock step mode
  6287. */
  6288. isDeterministicLockStep(): boolean;
  6289. /**
  6290. * Gets the max steps when engine is running in deterministic lock step
  6291. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6292. * @returns the max steps
  6293. */
  6294. getLockstepMaxSteps(): number;
  6295. /**
  6296. * Gets an object containing information about the current webGL context
  6297. * @returns an object containing the vender, the renderer and the version of the current webGL context
  6298. */
  6299. getGlInfo(): {
  6300. vendor: string;
  6301. renderer: string;
  6302. version: string;
  6303. };
  6304. /**
  6305. * Gets current aspect ratio
  6306. * @param camera defines the camera to use to get the aspect ratio
  6307. * @param useScreen defines if screen size must be used (or the current render target if any)
  6308. * @returns a number defining the aspect ratio
  6309. */
  6310. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  6311. /**
  6312. * Gets the current render width
  6313. * @param useScreen defines if screen size must be used (or the current render target if any)
  6314. * @returns a number defining the current render width
  6315. */
  6316. getRenderWidth(useScreen?: boolean): number;
  6317. /**
  6318. * Gets the current render height
  6319. * @param useScreen defines if screen size must be used (or the current render target if any)
  6320. * @returns a number defining the current render height
  6321. */
  6322. getRenderHeight(useScreen?: boolean): number;
  6323. /**
  6324. * Gets the HTML canvas attached with the current webGL context
  6325. * @returns a HTML canvas
  6326. */
  6327. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  6328. /**
  6329. * Gets the client rect of the HTML canvas attached with the current webGL context
  6330. * @returns a client rectanglee
  6331. */
  6332. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  6333. /**
  6334. * Defines the hardware scaling level.
  6335. * By default the hardware scaling level is computed from the window device ratio.
  6336. * 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.
  6337. * @param level defines the level to use
  6338. */
  6339. setHardwareScalingLevel(level: number): void;
  6340. /**
  6341. * Gets the current hardware scaling level.
  6342. * By default the hardware scaling level is computed from the window device ratio.
  6343. * 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.
  6344. * @returns a number indicating the current hardware scaling level
  6345. */
  6346. getHardwareScalingLevel(): number;
  6347. /**
  6348. * Gets the list of loaded textures
  6349. * @returns an array containing all loaded textures
  6350. */
  6351. getLoadedTexturesCache(): InternalTexture[];
  6352. /**
  6353. * Gets the object containing all engine capabilities
  6354. * @returns the EngineCapabilities object
  6355. */
  6356. getCaps(): EngineCapabilities;
  6357. /** @ignore */
  6358. readonly drawCalls: number;
  6359. /** @ignore */
  6360. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  6361. /**
  6362. * Gets the current depth function
  6363. * @returns a number defining the depth function
  6364. */
  6365. getDepthFunction(): Nullable<number>;
  6366. /**
  6367. * Sets the current depth function
  6368. * @param depthFunc defines the function to use
  6369. */
  6370. setDepthFunction(depthFunc: number): void;
  6371. /**
  6372. * Sets the current depth function to GREATER
  6373. */
  6374. setDepthFunctionToGreater(): void;
  6375. /**
  6376. * Sets the current depth function to GEQUAL
  6377. */
  6378. setDepthFunctionToGreaterOrEqual(): void;
  6379. /**
  6380. * Sets the current depth function to LESS
  6381. */
  6382. setDepthFunctionToLess(): void;
  6383. /**
  6384. * Sets the current depth function to LEQUAL
  6385. */
  6386. setDepthFunctionToLessOrEqual(): void;
  6387. /**
  6388. * Gets a boolean indicating if stencil buffer is enabled
  6389. * @returns the current stencil buffer state
  6390. */
  6391. getStencilBuffer(): boolean;
  6392. /**
  6393. * Enable or disable the stencil buffer
  6394. * @param enable defines if the stencil buffer must be enabled or disabled
  6395. */
  6396. setStencilBuffer(enable: boolean): void;
  6397. /**
  6398. * Gets the current stencil mask
  6399. * @returns a number defining the new stencil mask to use
  6400. */
  6401. getStencilMask(): number;
  6402. /**
  6403. * Sets the current stencil mask
  6404. * @param mask defines the new stencil mask to use
  6405. */
  6406. setStencilMask(mask: number): void;
  6407. /**
  6408. * Gets the current stencil function
  6409. * @returns a number defining the stencil function to use
  6410. */
  6411. getStencilFunction(): number;
  6412. /**
  6413. * Gets the current stencil reference value
  6414. * @returns a number defining the stencil reference value to use
  6415. */
  6416. getStencilFunctionReference(): number;
  6417. /**
  6418. * Gets the current stencil mask
  6419. * @returns a number defining the stencil mask to use
  6420. */
  6421. getStencilFunctionMask(): number;
  6422. /**
  6423. * Sets the current stencil function
  6424. * @param stencilFunc defines the new stencil function to use
  6425. */
  6426. setStencilFunction(stencilFunc: number): void;
  6427. /**
  6428. * Sets the current stencil reference
  6429. * @param reference defines the new stencil reference to use
  6430. */
  6431. setStencilFunctionReference(reference: number): void;
  6432. /**
  6433. * Sets the current stencil mask
  6434. * @param mask defines the new stencil mask to use
  6435. */
  6436. setStencilFunctionMask(mask: number): void;
  6437. /**
  6438. * Gets the current stencil operation when stencil fails
  6439. * @returns a number defining stencil operation to use when stencil fails
  6440. */
  6441. getStencilOperationFail(): number;
  6442. /**
  6443. * Gets the current stencil operation when depth fails
  6444. * @returns a number defining stencil operation to use when depth fails
  6445. */
  6446. getStencilOperationDepthFail(): number;
  6447. /**
  6448. * Gets the current stencil operation when stencil passes
  6449. * @returns a number defining stencil operation to use when stencil passes
  6450. */
  6451. getStencilOperationPass(): number;
  6452. /**
  6453. * Sets the stencil operation to use when stencil fails
  6454. * @param operation defines the stencil operation to use when stencil fails
  6455. */
  6456. setStencilOperationFail(operation: number): void;
  6457. /**
  6458. * Sets the stencil operation to use when depth fails
  6459. * @param operation defines the stencil operation to use when depth fails
  6460. */
  6461. setStencilOperationDepthFail(operation: number): void;
  6462. /**
  6463. * Sets the stencil operation to use when stencil passes
  6464. * @param operation defines the stencil operation to use when stencil passes
  6465. */
  6466. setStencilOperationPass(operation: number): void;
  6467. /**
  6468. * Sets a boolean indicating if the dithering state is enabled or disabled
  6469. * @param value defines the dithering state
  6470. */
  6471. setDitheringState(value: boolean): void;
  6472. /**
  6473. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  6474. * @param value defines the rasterizer state
  6475. */
  6476. setRasterizerState(value: boolean): void;
  6477. /**
  6478. * stop executing a render loop function and remove it from the execution array
  6479. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  6480. */
  6481. stopRenderLoop(renderFunction?: () => void): void;
  6482. /** @ignore */
  6483. _renderLoop(): void;
  6484. /**
  6485. * Register and execute a render loop. The engine can have more than one render function
  6486. * @param renderFunction defines the function to continuously execute
  6487. */
  6488. runRenderLoop(renderFunction: () => void): void;
  6489. /**
  6490. * Toggle full screen mode
  6491. * @param requestPointerLock defines if a pointer lock should be requested from the user
  6492. * @param options defines an option object to be sent to the requestFullscreen function
  6493. */
  6494. switchFullscreen(requestPointerLock: boolean): void;
  6495. /**
  6496. * Clear the current render buffer or the current render target (if any is set up)
  6497. * @param color defines the color to use
  6498. * @param backBuffer defines if the back buffer must be cleared
  6499. * @param depth defines if the depth buffer must be cleared
  6500. * @param stencil defines if the stencil buffer must be cleared
  6501. */
  6502. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  6503. /**
  6504. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  6505. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  6506. * @param y defines the y-coordinate of the corner of the clear rectangle
  6507. * @param width defines the width of the clear rectangle
  6508. * @param height defines the height of the clear rectangle
  6509. * @param clearColor defines the clear color
  6510. */
  6511. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  6512. /**
  6513. * Set the WebGL's viewport
  6514. * @param viewport defines the viewport element to be used
  6515. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  6516. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  6517. */
  6518. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  6519. /**
  6520. * Directly set the WebGL Viewport
  6521. * @param x defines the x coordinate of the viewport (in screen space)
  6522. * @param y defines the y coordinate of the viewport (in screen space)
  6523. * @param width defines the width of the viewport (in screen space)
  6524. * @param height defines the height of the viewport (in screen space)
  6525. * @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
  6526. */
  6527. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  6528. /**
  6529. * Begin a new frame
  6530. */
  6531. beginFrame(): void;
  6532. /**
  6533. * Enf the current frame
  6534. */
  6535. endFrame(): void;
  6536. /**
  6537. * Resize the view according to the canvas' size
  6538. */
  6539. resize(): void;
  6540. /**
  6541. * Force a specific size of the canvas
  6542. * @param width defines the new canvas' width
  6543. * @param height defines the new canvas' height
  6544. */
  6545. setSize(width: number, height: number): void;
  6546. /**
  6547. * Gets a boolean indicating if a webVR device was detected
  6548. * @returns true if a webVR device was detected
  6549. */
  6550. isVRDevicePresent(): boolean;
  6551. /**
  6552. * Gets the current webVR device
  6553. * @returns the current webVR device (or null)
  6554. */
  6555. getVRDevice(): any;
  6556. /**
  6557. * Initializes a webVR display and starts listening to display change events
  6558. * The onVRDisplayChangedObservable will be notified upon these changes
  6559. * @returns The onVRDisplayChangedObservable
  6560. */
  6561. initWebVR(): Observable<IDisplayChangedEventArgs>;
  6562. /**
  6563. * Initializes a webVR display and starts listening to display change events
  6564. * The onVRDisplayChangedObservable will be notified upon these changes
  6565. * @returns A promise containing a VRDisplay and if vr is supported
  6566. */
  6567. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  6568. /**
  6569. * Call this function to switch to webVR mode
  6570. * Will do nothing if webVR is not supported or if there is no webVR device
  6571. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6572. */
  6573. enableVR(): void;
  6574. /**
  6575. * Call this function to leave webVR mode
  6576. * Will do nothing if webVR is not supported or if there is no webVR device
  6577. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6578. */
  6579. disableVR(): void;
  6580. private _onVRFullScreenTriggered;
  6581. private _getVRDisplaysAsync();
  6582. /**
  6583. * Binds the frame buffer to the specified texture.
  6584. * @param texture The texture to render to or null for the default canvas
  6585. * @param faceIndex The face of the texture to render to in case of cube texture
  6586. * @param requiredWidth The width of the target to render to
  6587. * @param requiredHeight The height of the target to render to
  6588. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  6589. * @param depthStencilTexture The depth stencil texture to use to render
  6590. */
  6591. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  6592. private bindUnboundFramebuffer(framebuffer);
  6593. /**
  6594. * Unbind the current render target texture from the webGL context
  6595. * @param texture defines the render target texture to unbind
  6596. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  6597. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  6598. */
  6599. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  6600. /**
  6601. * Unbind a list of render target textures from the webGL context
  6602. * This is used only when drawBuffer extension or webGL2 are active
  6603. * @param textures defines the render target textures to unbind
  6604. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  6605. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  6606. */
  6607. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  6608. /**
  6609. * Force the mipmap generation for the given render target texture
  6610. * @param texture defines the render target texture to use
  6611. */
  6612. generateMipMapsForCubemap(texture: InternalTexture): void;
  6613. /**
  6614. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  6615. */
  6616. flushFramebuffer(): void;
  6617. /**
  6618. * Unbind the current render target and bind the default framebuffer
  6619. */
  6620. restoreDefaultFramebuffer(): void;
  6621. /**
  6622. * Create an uniform buffer
  6623. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6624. * @param elements defines the content of the uniform buffer
  6625. * @returns the webGL uniform buffer
  6626. */
  6627. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  6628. /**
  6629. * Create a dynamic uniform buffer
  6630. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6631. * @param elements defines the content of the uniform buffer
  6632. * @returns the webGL uniform buffer
  6633. */
  6634. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  6635. /**
  6636. * Update an existing uniform buffer
  6637. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6638. * @param uniformBuffer defines the target uniform buffer
  6639. * @param elements defines the content to update
  6640. * @param offset defines the offset in the uniform buffer where update should start
  6641. * @param count defines the size of the data to update
  6642. */
  6643. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  6644. private _resetVertexBufferBinding();
  6645. /**
  6646. * Creates a vertex buffer
  6647. * @param data the data for the vertex buffer
  6648. * @returns the new WebGL static buffer
  6649. */
  6650. createVertexBuffer(data: DataArray): WebGLBuffer;
  6651. /**
  6652. * Creates a dynamic vertex buffer
  6653. * @param data the data for the dynamic vertex buffer
  6654. * @returns the new WebGL dynamic buffer
  6655. */
  6656. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  6657. /**
  6658. * Update a dynamic index buffer
  6659. * @param indexBuffer defines the target index buffer
  6660. * @param indices defines the data to update
  6661. * @param offset defines the offset in the target index buffer where update should start
  6662. */
  6663. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  6664. /**
  6665. * Updates a dynamic vertex buffer.
  6666. * @param vertexBuffer the vertex buffer to update
  6667. * @param data the data used to update the vertex buffer
  6668. * @param byteOffset the byte offset of the data
  6669. * @param byteLength the byte length of the data
  6670. */
  6671. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  6672. private _resetIndexBufferBinding();
  6673. /**
  6674. * Creates a new index buffer
  6675. * @param indices defines the content of the index buffer
  6676. * @param updatable defines if the index buffer must be updatable
  6677. * @returns a new webGL buffer
  6678. */
  6679. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  6680. /**
  6681. * Bind a webGL buffer to the webGL context
  6682. * @param buffer defines the buffer to bind
  6683. */
  6684. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  6685. /**
  6686. * Bind an uniform buffer to the current webGL context
  6687. * @param buffer defines the buffer to bind
  6688. */
  6689. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  6690. /**
  6691. * Bind a buffer to the current webGL context at a given location
  6692. * @param buffer defines the buffer to bind
  6693. * @param location defines the index where to bind the buffer
  6694. */
  6695. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  6696. /**
  6697. * Bind a specific block at a given index in a specific shader program
  6698. * @param shaderProgram defines the shader program
  6699. * @param blockName defines the block name
  6700. * @param index defines the index where to bind the block
  6701. */
  6702. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  6703. private bindIndexBuffer(buffer);
  6704. private bindBuffer(buffer, target);
  6705. /**
  6706. * update the bound buffer with the given data
  6707. * @param data defines the data to update
  6708. */
  6709. updateArrayBuffer(data: Float32Array): void;
  6710. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  6711. private _bindIndexBufferWithCache(indexBuffer);
  6712. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  6713. /**
  6714. * Records a vertex array object
  6715. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  6716. * @param vertexBuffers defines the list of vertex buffers to store
  6717. * @param indexBuffer defines the index buffer to store
  6718. * @param effect defines the effect to store
  6719. * @returns the new vertex array object
  6720. */
  6721. recordVertexArrayObject(vertexBuffers: {
  6722. [key: string]: VertexBuffer;
  6723. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  6724. /**
  6725. * Bind a specific vertex array object
  6726. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  6727. * @param vertexArrayObject defines the vertex array object to bind
  6728. * @param indexBuffer defines the index buffer to bind
  6729. */
  6730. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  6731. /**
  6732. * Bind webGl buffers directly to the webGL context
  6733. * @param vertexBuffer defines the vertex buffer to bind
  6734. * @param indexBuffer defines the index buffer to bind
  6735. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  6736. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  6737. * @param effect defines the effect associated with the vertex buffer
  6738. */
  6739. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  6740. private _unbindVertexArrayObject();
  6741. /**
  6742. * Bind a list of vertex buffers to the webGL context
  6743. * @param vertexBuffers defines the list of vertex buffers to bind
  6744. * @param indexBuffer defines the index buffer to bind
  6745. * @param effect defines the effect associated with the vertex buffers
  6746. */
  6747. bindBuffers(vertexBuffers: {
  6748. [key: string]: Nullable<VertexBuffer>;
  6749. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  6750. /**
  6751. * Unbind all instance attributes
  6752. */
  6753. unbindInstanceAttributes(): void;
  6754. /**
  6755. * Release and free the memory of a vertex array object
  6756. * @param vao defines the vertex array object to delete
  6757. */
  6758. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  6759. /** @ignore */
  6760. _releaseBuffer(buffer: WebGLBuffer): boolean;
  6761. /**
  6762. * Creates a webGL buffer to use with instanciation
  6763. * @param capacity defines the size of the buffer
  6764. * @returns the webGL buffer
  6765. */
  6766. createInstancesBuffer(capacity: number): WebGLBuffer;
  6767. /**
  6768. * Delete a webGL buffer used with instanciation
  6769. * @param buffer defines the webGL buffer to delete
  6770. */
  6771. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  6772. /**
  6773. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  6774. * @param instancesBuffer defines the webGL buffer to update and bind
  6775. * @param data defines the data to store in the buffer
  6776. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  6777. */
  6778. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  6779. /**
  6780. * Apply all cached states (depth, culling, stencil and alpha)
  6781. */
  6782. applyStates(): void;
  6783. /**
  6784. * Send a draw order
  6785. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  6786. * @param indexStart defines the starting index
  6787. * @param indexCount defines the number of index to draw
  6788. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  6789. */
  6790. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  6791. /**
  6792. * Draw a list of points
  6793. * @param verticesStart defines the index of first vertex to draw
  6794. * @param verticesCount defines the count of vertices to draw
  6795. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  6796. */
  6797. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  6798. /**
  6799. * Draw a list of unindexed primitives
  6800. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  6801. * @param verticesStart defines the index of first vertex to draw
  6802. * @param verticesCount defines the count of vertices to draw
  6803. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  6804. */
  6805. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  6806. /**
  6807. * Draw a list of indexed primitives
  6808. * @param fillMode defines the primitive to use
  6809. * @param indexStart defines the starting index
  6810. * @param indexCount defines the number of index to draw
  6811. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  6812. */
  6813. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  6814. /**
  6815. * Draw a list of unindexed primitives
  6816. * @param fillMode defines the primitive to use
  6817. * @param verticesStart defines the index of first vertex to draw
  6818. * @param verticesCount defines the count of vertices to draw
  6819. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  6820. */
  6821. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  6822. private _drawMode(fillMode);
  6823. /** @ignore */
  6824. _releaseEffect(effect: Effect): void;
  6825. /** @ignore */
  6826. _deleteProgram(program: WebGLProgram): void;
  6827. /**
  6828. * Create a new effect (used to store vertex/fragment shaders)
  6829. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  6830. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  6831. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  6832. * @param samplers defines an array of string used to represent textures
  6833. * @param defines defines the string containing the defines to use to compile the shaders
  6834. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  6835. * @param onCompiled defines a function to call when the effect creation is successful
  6836. * @param onError defines a function to call when the effect creation has failed
  6837. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  6838. * @returns the new Effect
  6839. */
  6840. 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;
  6841. /**
  6842. * Create an effect to use with particle systems
  6843. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  6844. * @param uniformsNames defines a list of attribute names
  6845. * @param samplers defines an array of string used to represent textures
  6846. * @param defines defines the string containing the defines to use to compile the shaders
  6847. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  6848. * @param onCompiled defines a function to call when the effect creation is successful
  6849. * @param onError defines a function to call when the effect creation has failed
  6850. * @returns the new Effect
  6851. */
  6852. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  6853. /**
  6854. * Directly creates a webGL program
  6855. * @param vertexCode defines the vertex shader code to use
  6856. * @param fragmentCode defines the fragment shader code to use
  6857. * @param context defines the webGL context to use (if not set, the current one will be used)
  6858. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  6859. * @returns the new webGL program
  6860. */
  6861. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  6862. /**
  6863. * Creates a webGL program
  6864. * @param vertexCode defines the vertex shader code to use
  6865. * @param fragmentCode defines the fragment shader code to use
  6866. * @param defines defines the string containing the defines to use to compile the shaders
  6867. * @param context defines the webGL context to use (if not set, the current one will be used)
  6868. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  6869. * @returns the new webGL program
  6870. */
  6871. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  6872. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  6873. /**
  6874. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  6875. * @param shaderProgram defines the webGL program to use
  6876. * @param uniformsNames defines the list of uniform names
  6877. * @returns an array of webGL uniform locations
  6878. */
  6879. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  6880. /**
  6881. * Gets the lsit of active attributes for a given webGL program
  6882. * @param shaderProgram defines the webGL program to use
  6883. * @param attributesNames defines the list of attribute names to get
  6884. * @returns an array of indices indicating the offset of each attribute
  6885. */
  6886. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  6887. /**
  6888. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  6889. * @param effect defines the effect to activate
  6890. */
  6891. enableEffect(effect: Nullable<Effect>): void;
  6892. /**
  6893. * Set the value of an uniform to an array of int32
  6894. * @param uniform defines the webGL uniform location where to store the value
  6895. * @param array defines the array of int32 to store
  6896. */
  6897. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  6898. /**
  6899. * Set the value of an uniform to an array of int32 (stored as vec2)
  6900. * @param uniform defines the webGL uniform location where to store the value
  6901. * @param array defines the array of int32 to store
  6902. */
  6903. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  6904. /**
  6905. * Set the value of an uniform to an array of int32 (stored as vec3)
  6906. * @param uniform defines the webGL uniform location where to store the value
  6907. * @param array defines the array of int32 to store
  6908. */
  6909. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  6910. /**
  6911. * Set the value of an uniform to an array of int32 (stored as vec4)
  6912. * @param uniform defines the webGL uniform location where to store the value
  6913. * @param array defines the array of int32 to store
  6914. */
  6915. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  6916. /**
  6917. * Set the value of an uniform to an array of float32
  6918. * @param uniform defines the webGL uniform location where to store the value
  6919. * @param array defines the array of float32 to store
  6920. */
  6921. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  6922. /**
  6923. * Set the value of an uniform to an array of float32 (stored as vec2)
  6924. * @param uniform defines the webGL uniform location where to store the value
  6925. * @param array defines the array of float32 to store
  6926. */
  6927. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  6928. /**
  6929. * Set the value of an uniform to an array of float32 (stored as vec3)
  6930. * @param uniform defines the webGL uniform location where to store the value
  6931. * @param array defines the array of float32 to store
  6932. */
  6933. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  6934. /**
  6935. * Set the value of an uniform to an array of float32 (stored as vec4)
  6936. * @param uniform defines the webGL uniform location where to store the value
  6937. * @param array defines the array of float32 to store
  6938. */
  6939. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  6940. /**
  6941. * Set the value of an uniform to an array of number
  6942. * @param uniform defines the webGL uniform location where to store the value
  6943. * @param array defines the array of number to store
  6944. */
  6945. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  6946. /**
  6947. * Set the value of an uniform to an array of number (stored as vec2)
  6948. * @param uniform defines the webGL uniform location where to store the value
  6949. * @param array defines the array of number to store
  6950. */
  6951. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  6952. /**
  6953. * Set the value of an uniform to an array of number (stored as vec3)
  6954. * @param uniform defines the webGL uniform location where to store the value
  6955. * @param array defines the array of number to store
  6956. */
  6957. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  6958. /**
  6959. * Set the value of an uniform to an array of number (stored as vec4)
  6960. * @param uniform defines the webGL uniform location where to store the value
  6961. * @param array defines the array of number to store
  6962. */
  6963. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  6964. /**
  6965. * Set the value of an uniform to an array of float32 (stored as matrices)
  6966. * @param uniform defines the webGL uniform location where to store the value
  6967. * @param matrices defines the array of float32 to store
  6968. */
  6969. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  6970. /**
  6971. * Set the value of an uniform to a matrix
  6972. * @param uniform defines the webGL uniform location where to store the value
  6973. * @param matrix defines the matrix to store
  6974. */
  6975. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  6976. /**
  6977. * Set the value of an uniform to a matrix (3x3)
  6978. * @param uniform defines the webGL uniform location where to store the value
  6979. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  6980. */
  6981. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  6982. /**
  6983. * Set the value of an uniform to a matrix (2x2)
  6984. * @param uniform defines the webGL uniform location where to store the value
  6985. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  6986. */
  6987. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  6988. /**
  6989. * Set the value of an uniform to a number (int)
  6990. * @param uniform defines the webGL uniform location where to store the value
  6991. * @param value defines the int number to store
  6992. */
  6993. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  6994. /**
  6995. * Set the value of an uniform to a number (float)
  6996. * @param uniform defines the webGL uniform location where to store the value
  6997. * @param value defines the float number to store
  6998. */
  6999. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7000. /**
  7001. * Set the value of an uniform to a vec2
  7002. * @param uniform defines the webGL uniform location where to store the value
  7003. * @param x defines the 1st component of the value
  7004. * @param y defines the 2nd component of the value
  7005. */
  7006. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  7007. /**
  7008. * Set the value of an uniform to a vec3
  7009. * @param uniform defines the webGL uniform location where to store the value
  7010. * @param x defines the 1st component of the value
  7011. * @param y defines the 2nd component of the value
  7012. * @param z defines the 3rd component of the value
  7013. */
  7014. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  7015. /**
  7016. * Set the value of an uniform to a boolean
  7017. * @param uniform defines the webGL uniform location where to store the value
  7018. * @param bool defines the boolean to store
  7019. */
  7020. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  7021. /**
  7022. * Set the value of an uniform to a vec4
  7023. * @param uniform defines the webGL uniform location where to store the value
  7024. * @param x defines the 1st component of the value
  7025. * @param y defines the 2nd component of the value
  7026. * @param z defines the 3rd component of the value
  7027. * @param w defines the 4th component of the value
  7028. */
  7029. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  7030. /**
  7031. * Set the value of an uniform to a Color3
  7032. * @param uniform defines the webGL uniform location where to store the value
  7033. * @param color3 defines the color to store
  7034. */
  7035. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  7036. /**
  7037. * Set the value of an uniform to a Color3 and an alpha value
  7038. * @param uniform defines the webGL uniform location where to store the value
  7039. * @param color3 defines the color to store
  7040. * @param alpha defines the alpha component to store
  7041. */
  7042. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  7043. /**
  7044. * Sets a Color4 on a uniform variable
  7045. * @param uniform defines the uniform location
  7046. * @param color4 defines the value to be set
  7047. */
  7048. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  7049. /**
  7050. * Set various states to the webGL context
  7051. * @param culling defines backface culling state
  7052. * @param zOffset defines the value to apply to zOffset (0 by default)
  7053. * @param force defines if states must be applied even if cache is up to date
  7054. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  7055. */
  7056. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  7057. /**
  7058. * Set the z offset to apply to current rendering
  7059. * @param value defines the offset to apply
  7060. */
  7061. setZOffset(value: number): void;
  7062. /**
  7063. * Gets the current value of the zOffset
  7064. * @returns the current zOffset state
  7065. */
  7066. getZOffset(): number;
  7067. /**
  7068. * Enable or disable depth buffering
  7069. * @param enable defines the state to set
  7070. */
  7071. setDepthBuffer(enable: boolean): void;
  7072. /**
  7073. * Gets a boolean indicating if depth writing is enabled
  7074. * @returns the current depth writing state
  7075. */
  7076. getDepthWrite(): boolean;
  7077. /**
  7078. * Enable or disable depth writing
  7079. * @param enable defines the state to set
  7080. */
  7081. setDepthWrite(enable: boolean): void;
  7082. /**
  7083. * Enable or disable color writing
  7084. * @param enable defines the state to set
  7085. */
  7086. setColorWrite(enable: boolean): void;
  7087. /**
  7088. * Gets a boolean indicating if color writing is enabled
  7089. * @returns the current color writing state
  7090. */
  7091. getColorWrite(): boolean;
  7092. /**
  7093. * Sets alpha constants used by some alpha blending modes
  7094. * @param r defines the red component
  7095. * @param g defines the green component
  7096. * @param b defines the blue component
  7097. * @param a defines the alpha component
  7098. */
  7099. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  7100. /**
  7101. * Sets the current alpha mode
  7102. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  7103. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  7104. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  7105. */
  7106. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  7107. /**
  7108. * Gets the current alpha mode
  7109. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  7110. * @returns the current alpha mode
  7111. */
  7112. getAlphaMode(): number;
  7113. /**
  7114. * Force the entire cache to be cleared
  7115. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  7116. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  7117. */
  7118. wipeCaches(bruteForce?: boolean): void;
  7119. /**
  7120. * Set the compressed texture format to use, based on the formats you have, and the formats
  7121. * supported by the hardware / browser.
  7122. *
  7123. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  7124. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  7125. * to API arguments needed to compressed textures. This puts the burden on the container
  7126. * generator to house the arcane code for determining these for current & future formats.
  7127. *
  7128. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  7129. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  7130. *
  7131. * Note: The result of this call is not taken into account when a texture is base64.
  7132. *
  7133. * @param formatsAvailable defines the list of those format families you have created
  7134. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  7135. *
  7136. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  7137. * @returns The extension selected.
  7138. */
  7139. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  7140. /** @ignore */
  7141. _createTexture(): WebGLTexture;
  7142. /**
  7143. * Usually called from BABYLON.Texture.ts.
  7144. * Passed information to create a WebGLTexture
  7145. * @param urlArg defines a value which contains one of the following:
  7146. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  7147. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  7148. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  7149. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  7150. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  7151. * @param scene needed for loading to the correct scene
  7152. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  7153. * @param onLoad optional callback to be called upon successful completion
  7154. * @param onError optional callback to be called upon failure
  7155. * @param buffer a source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
  7156. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  7157. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  7158. * @returns a InternalTexture for assignment back into BABYLON.Texture
  7159. */
  7160. 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<ArrayBuffer | HTMLImageElement>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  7161. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  7162. /**
  7163. * Update a raw texture
  7164. * @param texture defines the texture to update
  7165. * @param data defines the data to store in the texture
  7166. * @param format defines the format of the data
  7167. * @param invertY defines if data must be stored with Y axis inverted
  7168. * @param compression defines the compression used (null by default)
  7169. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7170. */
  7171. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  7172. /**
  7173. * Creates a raw texture
  7174. * @param data defines the data to store in the texture
  7175. * @param width defines the width of the texture
  7176. * @param height defines the height of the texture
  7177. * @param format defines the format of the data
  7178. * @param generateMipMaps defines if the engine should generate the mip levels
  7179. * @param invertY defines if data must be stored with Y axis inverted
  7180. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  7181. * @param compression defines the compression used (null by default)
  7182. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7183. * @returns the raw texture inside an InternalTexture
  7184. */
  7185. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  7186. /**
  7187. * Creates a dynamic texture
  7188. * @param width defines the width of the texture
  7189. * @param height defines the height of the texture
  7190. * @param generateMipMaps defines if the engine should generate the mip levels
  7191. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  7192. * @returns the dynamic texture inside an InternalTexture
  7193. */
  7194. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  7195. /**
  7196. * Update the sampling mode of a given texture
  7197. * @param samplingMode defines the required sampling mode
  7198. * @param texture defines the texture to update
  7199. */
  7200. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  7201. /**
  7202. * Update the content of a dynamic texture
  7203. * @param texture defines the texture to update
  7204. * @param canvas defines the canvas containing the source
  7205. * @param invertY defines if data must be stored with Y axis inverted
  7206. * @param premulAlpha defines if alpha is stored as premultiplied
  7207. * @param format defines the format of the data
  7208. */
  7209. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  7210. /**
  7211. * Update a video texture
  7212. * @param texture defines the texture to update
  7213. * @param video defines the video element to use
  7214. * @param invertY defines if data must be stored with Y axis inverted
  7215. */
  7216. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  7217. /**
  7218. * Updates a depth texture Comparison Mode and Function.
  7219. * If the comparison Function is equal to 0, the mode will be set to none.
  7220. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  7221. * @param texture The texture to set the comparison function for
  7222. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  7223. */
  7224. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  7225. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  7226. /**
  7227. * Creates a depth stencil texture.
  7228. * This is only available in WebGL 2 or with the depth texture extension available.
  7229. * @param size The size of face edge in the texture.
  7230. * @param options The options defining the texture.
  7231. * @returns The texture
  7232. */
  7233. createDepthStencilTexture(size: number | {
  7234. width: number;
  7235. height: number;
  7236. }, options: DepthTextureCreationOptions): InternalTexture;
  7237. /**
  7238. * Creates a depth stencil texture.
  7239. * This is only available in WebGL 2 or with the depth texture extension available.
  7240. * @param size The size of face edge in the texture.
  7241. * @param options The options defining the texture.
  7242. * @returns The texture
  7243. */
  7244. private _createDepthStencilTexture(size, options);
  7245. /**
  7246. * Creates a depth stencil cube texture.
  7247. * This is only available in WebGL 2.
  7248. * @param size The size of face edge in the cube texture.
  7249. * @param options The options defining the cube texture.
  7250. * @returns The cube texture
  7251. */
  7252. private _createDepthStencilCubeTexture(size, options);
  7253. /**
  7254. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  7255. * @param renderTarget The render target to set the frame buffer for
  7256. */
  7257. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  7258. /**
  7259. * Creates a new render target texture
  7260. * @param size defines the size of the texture
  7261. * @param options defines the options used to create the texture
  7262. * @returns a new render target texture stored in an InternalTexture
  7263. */
  7264. createRenderTargetTexture(size: number | {
  7265. width: number;
  7266. height: number;
  7267. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  7268. /**
  7269. * Create a multi render target texture
  7270. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  7271. * @param size defines the size of the texture
  7272. * @param options defines the creation options
  7273. * @returns the cube texture as an InternalTexture
  7274. */
  7275. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  7276. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  7277. /**
  7278. * Updates the sample count of a render target texture
  7279. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  7280. * @param texture defines the texture to update
  7281. * @param samples defines the sample count to set
  7282. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  7283. */
  7284. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  7285. /**
  7286. * Update the sample count for a given multiple render target texture
  7287. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  7288. * @param textures defines the textures to update
  7289. * @param samples defines the sample count to set
  7290. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  7291. */
  7292. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  7293. /** @ignore */
  7294. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  7295. /** @ignore */
  7296. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  7297. /**
  7298. * Creates a new render target cube texture
  7299. * @param size defines the size of the texture
  7300. * @param options defines the options used to create the texture
  7301. * @returns a new render target cube texture stored in an InternalTexture
  7302. */
  7303. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  7304. /**
  7305. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  7306. * @param rootUrl defines the url where the file to load is located
  7307. * @param scene defines the current scene
  7308. * @param scale defines scale to apply to the mip map selection
  7309. * @param offset defines offset to apply to the mip map selection
  7310. * @param onLoad defines an optional callback raised when the texture is loaded
  7311. * @param onError defines an optional callback raised if there is an issue to load the texture
  7312. * @param format defines the format of the data
  7313. * @param forcedExtension defines the extension to use to pick the right loader
  7314. * @returns the cube texture as an InternalTexture
  7315. */
  7316. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, scale: number, offset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any): InternalTexture;
  7317. /**
  7318. * Creates a cube texture
  7319. * @param rootUrl defines the url where the files to load is located
  7320. * @param scene defines the current scene
  7321. * @param files defines the list of files to load (1 per face)
  7322. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7323. * @param onLoad defines an optional callback raised when the texture is loaded
  7324. * @param onError defines an optional callback raised if there is an issue to load the texture
  7325. * @param format defines the format of the data
  7326. * @param forcedExtension defines the extension to use to pick the right loader
  7327. * @returns the cube texture as an InternalTexture
  7328. */
  7329. 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): InternalTexture;
  7330. private setCubeMapTextureParams(gl, loadMipmap);
  7331. /**
  7332. * Update a raw cube texture
  7333. * @param texture defines the texture to udpdate
  7334. * @param data defines the data to store
  7335. * @param format defines the data format
  7336. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7337. * @param invertY defines if data must be stored with Y axis inverted
  7338. * @param compression defines the compression used (null by default)
  7339. * @param level defines which level of the texture to update
  7340. */
  7341. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  7342. /**
  7343. * Creates a new raw cube texture
  7344. * @param data defines the array of data to use to create each face
  7345. * @param size defines the size of the textures
  7346. * @param format defines the format of the data
  7347. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  7348. * @param generateMipMaps defines if the engine should generate the mip levels
  7349. * @param invertY defines if data must be stored with Y axis inverted
  7350. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7351. * @param compression defines the compression used (null by default)
  7352. * @returns the cube texture as an InternalTexture
  7353. */
  7354. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  7355. /**
  7356. * Creates a new raw cube texture from a specified url
  7357. * @param url defines the url where the data is located
  7358. * @param scene defines the current scene
  7359. * @param size defines the size of the textures
  7360. * @param format defines the format of the data
  7361. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  7362. * @param noMipmap defines if the engine should avoid generating the mip levels
  7363. * @param callback defines a callback used to extract texture data from loaded data
  7364. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  7365. * @param onLoad defines a callback called when texture is loaded
  7366. * @param onError defines a callback called if there is an error
  7367. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7368. * @param invertY defines if data must be stored with Y axis inverted
  7369. * @returns the cube texture as an InternalTexture
  7370. */
  7371. 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;
  7372. /**
  7373. * Update a raw 3D texture
  7374. * @param texture defines the texture to update
  7375. * @param data defines the data to store
  7376. * @param format defines the data format
  7377. * @param invertY defines if data must be stored with Y axis inverted
  7378. * @param compression defines the used compression (can be null)
  7379. */
  7380. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  7381. /**
  7382. * Creates a new raw 3D texture
  7383. * @param data defines the data used to create the texture
  7384. * @param width defines the width of the texture
  7385. * @param height defines the height of the texture
  7386. * @param depth defines the depth of the texture
  7387. * @param format defines the format of the texture
  7388. * @param generateMipMaps defines if the engine must generate mip levels
  7389. * @param invertY defines if data must be stored with Y axis inverted
  7390. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7391. * @param compression defines the compressed used (can be null)
  7392. * @returns a new raw 3D texture (stored in an InternalTexture)
  7393. */
  7394. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  7395. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  7396. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  7397. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  7398. /** @ignore */
  7399. _releaseFramebufferObjects(texture: InternalTexture): void;
  7400. /** @ignore */
  7401. _releaseTexture(texture: InternalTexture): void;
  7402. private setProgram(program);
  7403. private _boundUniforms;
  7404. /**
  7405. * Binds an effect to the webGL context
  7406. * @param effect defines the effect to bind
  7407. */
  7408. bindSamplers(effect: Effect): void;
  7409. private _moveBoundTextureOnTop(internalTexture);
  7410. private _getCorrectTextureChannel(channel, internalTexture);
  7411. private _linkTrackers(previous, next);
  7412. private _removeDesignatedSlot(internalTexture);
  7413. private _activateCurrentTexture();
  7414. /** @ignore */
  7415. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean): void;
  7416. /** @ignore */
  7417. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  7418. /**
  7419. * Sets a texture to the webGL context from a postprocess
  7420. * @param channel defines the channel to use
  7421. * @param postProcess defines the source postprocess
  7422. */
  7423. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  7424. /**
  7425. * Binds the output of the passed in post process to the texture channel specified
  7426. * @param channel The channel the texture should be bound to
  7427. * @param postProcess The post process which's output should be bound
  7428. */
  7429. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  7430. /**
  7431. * Unbind all textures from the webGL context
  7432. */
  7433. unbindAllTextures(): void;
  7434. /**
  7435. * Sets a texture to the according uniform.
  7436. * @param channel The texture channel
  7437. * @param uniform The uniform to set
  7438. * @param texture The texture to apply
  7439. */
  7440. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  7441. /**
  7442. * Sets a depth stencil texture from a render target to the according uniform.
  7443. * @param channel The texture channel
  7444. * @param uniform The uniform to set
  7445. * @param texture The render target texture containing the depth stencil texture to apply
  7446. */
  7447. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  7448. private _bindSamplerUniformToChannel(sourceSlot, destination);
  7449. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  7450. /**
  7451. * Sets an array of texture to the webGL context
  7452. * @param channel defines the channel where the texture array must be set
  7453. * @param uniform defines the associated uniform location
  7454. * @param textures defines the array of textures to bind
  7455. */
  7456. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  7457. /** @ignore */
  7458. _setAnisotropicLevel(key: number, texture: BaseTexture): void;
  7459. /**
  7460. * Reads pixels from the current frame buffer. Please note that this function can be slow
  7461. * @param x defines the x coordinate of the rectangle where pixels must be read
  7462. * @param y defines the y coordinate of the rectangle where pixels must be read
  7463. * @param width defines the width of the rectangle where pixels must be read
  7464. * @param height defines the height of the rectangle where pixels must be read
  7465. * @returns a Uint8Array containing RGBA colors
  7466. */
  7467. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  7468. /**
  7469. * Add an externaly attached data from its key.
  7470. * This method call will fail and return false, if such key already exists.
  7471. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  7472. * @param key the unique key that identifies the data
  7473. * @param data the data object to associate to the key for this Engine instance
  7474. * @return true if no such key were already present and the data was added successfully, false otherwise
  7475. */
  7476. addExternalData<T>(key: string, data: T): boolean;
  7477. /**
  7478. * Get an externaly attached data from its key
  7479. * @param key the unique key that identifies the data
  7480. * @return the associated data, if present (can be null), or undefined if not present
  7481. */
  7482. getExternalData<T>(key: string): T;
  7483. /**
  7484. * Get an externaly attached data from its key, create it using a factory if it's not already present
  7485. * @param key the unique key that identifies the data
  7486. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  7487. * @return the associated data, can be null if the factory returned null.
  7488. */
  7489. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  7490. /**
  7491. * Remove an externaly attached data from the Engine instance
  7492. * @param key the unique key that identifies the data
  7493. * @return true if the data was successfully removed, false if it doesn't exist
  7494. */
  7495. removeExternalData(key: string): boolean;
  7496. /**
  7497. * Unbind all vertex attributes from the webGL context
  7498. */
  7499. unbindAllAttributes(): void;
  7500. /**
  7501. * 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
  7502. */
  7503. releaseEffects(): void;
  7504. /**
  7505. * Dispose and release all associated resources
  7506. */
  7507. dispose(): void;
  7508. /**
  7509. * Display the loading screen
  7510. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7511. */
  7512. displayLoadingUI(): void;
  7513. /**
  7514. * Hide the loading screen
  7515. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7516. */
  7517. hideLoadingUI(): void;
  7518. /**
  7519. * Gets the current loading screen object
  7520. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7521. */
  7522. /**
  7523. * Sets the current loading screen object
  7524. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7525. */
  7526. loadingScreen: ILoadingScreen;
  7527. /**
  7528. * Sets the current loading screen text
  7529. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7530. */
  7531. loadingUIText: string;
  7532. /**
  7533. * Sets the current loading screen background color
  7534. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7535. */
  7536. loadingUIBackgroundColor: string;
  7537. /**
  7538. * Attach a new callback raised when context lost event is fired
  7539. * @param callback defines the callback to call
  7540. */
  7541. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  7542. /**
  7543. * Attach a new callback raised when context restored event is fired
  7544. * @param callback defines the callback to call
  7545. */
  7546. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  7547. /**
  7548. * Gets the source code of the vertex shader associated with a specific webGL program
  7549. * @param program defines the program to use
  7550. * @returns a string containing the source code of the vertex shader associated with the program
  7551. */
  7552. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  7553. /**
  7554. * Gets the source code of the fragment shader associated with a specific webGL program
  7555. * @param program defines the program to use
  7556. * @returns a string containing the source code of the fragment shader associated with the program
  7557. */
  7558. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  7559. /**
  7560. * Get the current error code of the webGL context
  7561. * @returns the error code
  7562. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  7563. */
  7564. getError(): number;
  7565. /**
  7566. * Gets the current framerate
  7567. * @returns a number representing the framerate
  7568. */
  7569. getFps(): number;
  7570. /**
  7571. * Gets the time spent between current and previous frame
  7572. * @returns a number representing the delta time in ms
  7573. */
  7574. getDeltaTime(): number;
  7575. private _measureFps();
  7576. /** @ignore */
  7577. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  7578. private _canRenderToFloatFramebuffer();
  7579. private _canRenderToHalfFloatFramebuffer();
  7580. private _canRenderToFramebuffer(type);
  7581. /** @ignore */
  7582. _getWebGLTextureType(type: number): number;
  7583. private _getInternalFormat(format);
  7584. /** @ignore */
  7585. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  7586. /** @ignore */
  7587. _getRGBAMultiSampleBufferFormat(type: number): number;
  7588. /**
  7589. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  7590. * @return the new query
  7591. */
  7592. createQuery(): WebGLQuery;
  7593. /**
  7594. * Delete and release a webGL query
  7595. * @param query defines the query to delete
  7596. * @return the current engine
  7597. */
  7598. deleteQuery(query: WebGLQuery): Engine;
  7599. /**
  7600. * Check if a given query has resolved and got its value
  7601. * @param query defines the query to check
  7602. * @returns true if the query got its value
  7603. */
  7604. isQueryResultAvailable(query: WebGLQuery): boolean;
  7605. /**
  7606. * Gets the value of a given query
  7607. * @param query defines the query to check
  7608. * @returns the value of the query
  7609. */
  7610. getQueryResult(query: WebGLQuery): number;
  7611. /**
  7612. * Initiates an occlusion query
  7613. * @param algorithmType defines the algorithm to use
  7614. * @param query defines the query to use
  7615. * @returns the current engine
  7616. * @see http://doc.babylonjs.com/features/occlusionquery
  7617. */
  7618. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  7619. /**
  7620. * Ends an occlusion query
  7621. * @see http://doc.babylonjs.com/features/occlusionquery
  7622. * @param algorithmType defines the algorithm to use
  7623. * @returns the current engine
  7624. */
  7625. endOcclusionQuery(algorithmType: number): Engine;
  7626. private _createTimeQuery();
  7627. private _deleteTimeQuery(query);
  7628. private _getTimeQueryResult(query);
  7629. private _getTimeQueryAvailability(query);
  7630. private _currentNonTimestampToken;
  7631. /**
  7632. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  7633. * Please note that only one query can be issued at a time
  7634. * @returns a time token used to track the time span
  7635. */
  7636. startTimeQuery(): Nullable<_TimeToken>;
  7637. /**
  7638. * Ends a time query
  7639. * @param token defines the token used to measure the time span
  7640. * @returns the time spent (in ns)
  7641. */
  7642. endTimeQuery(token: _TimeToken): int;
  7643. private getGlAlgorithmType(algorithmType);
  7644. /**
  7645. * Creates a webGL transform feedback object
  7646. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  7647. * @returns the webGL transform feedback object
  7648. */
  7649. createTransformFeedback(): WebGLTransformFeedback;
  7650. /**
  7651. * Delete a webGL transform feedback object
  7652. * @param value defines the webGL transform feedback object to delete
  7653. */
  7654. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  7655. /**
  7656. * Bind a webGL transform feedback object to the webgl context
  7657. * @param value defines the webGL transform feedback object to bind
  7658. */
  7659. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  7660. /**
  7661. * Begins a transform feedback operation
  7662. * @param usePoints defines if points or triangles must be used
  7663. */
  7664. beginTransformFeedback(usePoints?: boolean): void;
  7665. /**
  7666. * Ends a transform feedback operation
  7667. */
  7668. endTransformFeedback(): void;
  7669. /**
  7670. * Specify the varyings to use with transform feedback
  7671. * @param program defines the associated webGL program
  7672. * @param value defines the list of strings representing the varying names
  7673. */
  7674. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  7675. /**
  7676. * Bind a webGL buffer for a transform feedback operation
  7677. * @param value defines the webGL buffer to bind
  7678. */
  7679. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  7680. /** @ignore */
  7681. _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;
  7682. /** @ignore */
  7683. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  7684. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  7685. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  7686. /**
  7687. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  7688. * @returns true if the engine can be created
  7689. * @ignoreNaming
  7690. */
  7691. static isSupported(): boolean;
  7692. }
  7693. }
  7694. declare module BABYLON {
  7695. class NullEngineOptions {
  7696. renderWidth: number;
  7697. renderHeight: number;
  7698. textureSize: number;
  7699. deterministicLockstep: boolean;
  7700. lockstepMaxSteps: number;
  7701. }
  7702. /**
  7703. * The null engine class provides support for headless version of babylon.js.
  7704. * This can be used in server side scenario or for testing purposes
  7705. */
  7706. class NullEngine extends Engine {
  7707. private _options;
  7708. isDeterministicLockStep(): boolean;
  7709. getLockstepMaxSteps(): number;
  7710. getHardwareScalingLevel(): number;
  7711. constructor(options?: NullEngineOptions);
  7712. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  7713. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  7714. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7715. getRenderWidth(useScreen?: boolean): number;
  7716. getRenderHeight(useScreen?: boolean): number;
  7717. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7718. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  7719. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  7720. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  7721. bindSamplers(effect: Effect): void;
  7722. enableEffect(effect: Effect): void;
  7723. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  7724. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  7725. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  7726. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  7727. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  7728. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  7729. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  7730. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  7731. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  7732. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  7733. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  7734. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  7735. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  7736. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  7737. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  7738. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  7739. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  7740. setFloat(uniform: WebGLUniformLocation, value: number): void;
  7741. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  7742. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  7743. setBool(uniform: WebGLUniformLocation, bool: number): void;
  7744. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  7745. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  7746. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  7747. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  7748. bindBuffers(vertexBuffers: {
  7749. [key: string]: VertexBuffer;
  7750. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  7751. wipeCaches(bruteForce?: boolean): void;
  7752. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7753. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  7754. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7755. _createTexture(): WebGLTexture;
  7756. _releaseTexture(texture: InternalTexture): void;
  7757. 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;
  7758. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  7759. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  7760. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  7761. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7762. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  7763. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7764. /**
  7765. * Updates a dynamic vertex buffer.
  7766. * @param vertexBuffer the vertex buffer to update
  7767. * @param data the data used to update the vertex buffer
  7768. * @param byteOffset the byte offset of the data (optional)
  7769. * @param byteLength the byte length of the data (optional)
  7770. */
  7771. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  7772. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  7773. _bindTexture(channel: number, texture: InternalTexture): void;
  7774. _releaseBuffer(buffer: WebGLBuffer): boolean;
  7775. }
  7776. }
  7777. interface WebGLRenderingContext {
  7778. readonly RASTERIZER_DISCARD: number;
  7779. readonly DEPTH_COMPONENT24: number;
  7780. readonly TEXTURE_3D: number;
  7781. readonly TEXTURE_2D_ARRAY: number;
  7782. readonly TEXTURE_COMPARE_FUNC: number;
  7783. readonly TEXTURE_COMPARE_MODE: number;
  7784. readonly COMPARE_REF_TO_TEXTURE: number;
  7785. readonly TEXTURE_WRAP_R: number;
  7786. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  7787. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  7788. 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;
  7789. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  7790. readonly TRANSFORM_FEEDBACK: number;
  7791. readonly INTERLEAVED_ATTRIBS: number;
  7792. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  7793. createTransformFeedback(): WebGLTransformFeedback;
  7794. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  7795. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  7796. beginTransformFeedback(primitiveMode: number): void;
  7797. endTransformFeedback(): void;
  7798. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  7799. }
  7800. interface ImageBitmap {
  7801. readonly width: number;
  7802. readonly height: number;
  7803. close(): void;
  7804. }
  7805. interface WebGLQuery extends WebGLObject {
  7806. }
  7807. declare var WebGLQuery: {
  7808. prototype: WebGLQuery;
  7809. new (): WebGLQuery;
  7810. };
  7811. interface WebGLSampler extends WebGLObject {
  7812. }
  7813. declare var WebGLSampler: {
  7814. prototype: WebGLSampler;
  7815. new (): WebGLSampler;
  7816. };
  7817. interface WebGLSync extends WebGLObject {
  7818. }
  7819. declare var WebGLSync: {
  7820. prototype: WebGLSync;
  7821. new (): WebGLSync;
  7822. };
  7823. interface WebGLTransformFeedback extends WebGLObject {
  7824. }
  7825. declare var WebGLTransformFeedback: {
  7826. prototype: WebGLTransformFeedback;
  7827. new (): WebGLTransformFeedback;
  7828. };
  7829. interface WebGLVertexArrayObject extends WebGLObject {
  7830. }
  7831. declare var WebGLVertexArrayObject: {
  7832. prototype: WebGLVertexArrayObject;
  7833. new (): WebGLVertexArrayObject;
  7834. };
  7835. declare module BABYLON {
  7836. class KeyboardEventTypes {
  7837. static _KEYDOWN: number;
  7838. static _KEYUP: number;
  7839. static readonly KEYDOWN: number;
  7840. static readonly KEYUP: number;
  7841. }
  7842. class KeyboardInfo {
  7843. type: number;
  7844. event: KeyboardEvent;
  7845. constructor(type: number, event: KeyboardEvent);
  7846. }
  7847. /**
  7848. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  7849. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  7850. */
  7851. class KeyboardInfoPre extends KeyboardInfo {
  7852. constructor(type: number, event: KeyboardEvent);
  7853. skipOnPointerObservable: boolean;
  7854. }
  7855. }
  7856. declare module BABYLON {
  7857. class PointerEventTypes {
  7858. static _POINTERDOWN: number;
  7859. static _POINTERUP: number;
  7860. static _POINTERMOVE: number;
  7861. static _POINTERWHEEL: number;
  7862. static _POINTERPICK: number;
  7863. static _POINTERTAP: number;
  7864. static _POINTERDOUBLETAP: number;
  7865. static readonly POINTERDOWN: number;
  7866. static readonly POINTERUP: number;
  7867. static readonly POINTERMOVE: number;
  7868. static readonly POINTERWHEEL: number;
  7869. static readonly POINTERPICK: number;
  7870. static readonly POINTERTAP: number;
  7871. static readonly POINTERDOUBLETAP: number;
  7872. }
  7873. class PointerInfoBase {
  7874. type: number;
  7875. event: PointerEvent | MouseWheelEvent;
  7876. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  7877. }
  7878. /**
  7879. * This class is used to store pointer related info for the onPrePointerObservable event.
  7880. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  7881. */
  7882. class PointerInfoPre extends PointerInfoBase {
  7883. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  7884. localPosition: Vector2;
  7885. skipOnPointerObservable: boolean;
  7886. }
  7887. /**
  7888. * This type contains all the data related to a pointer event in Babylon.js.
  7889. * 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.
  7890. */
  7891. class PointerInfo extends PointerInfoBase {
  7892. pickInfo: Nullable<PickingInfo>;
  7893. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  7894. }
  7895. }
  7896. declare module BABYLON {
  7897. class StickValues {
  7898. x: number;
  7899. y: number;
  7900. constructor(x: number, y: number);
  7901. }
  7902. interface GamepadButtonChanges {
  7903. changed: boolean;
  7904. pressChanged: boolean;
  7905. touchChanged: boolean;
  7906. valueChanged: boolean;
  7907. }
  7908. class Gamepad {
  7909. id: string;
  7910. index: number;
  7911. browserGamepad: any;
  7912. type: number;
  7913. private _leftStick;
  7914. private _rightStick;
  7915. _isConnected: boolean;
  7916. private _leftStickAxisX;
  7917. private _leftStickAxisY;
  7918. private _rightStickAxisX;
  7919. private _rightStickAxisY;
  7920. private _onleftstickchanged;
  7921. private _onrightstickchanged;
  7922. static GAMEPAD: number;
  7923. static GENERIC: number;
  7924. static XBOX: number;
  7925. static POSE_ENABLED: number;
  7926. protected _invertLeftStickY: boolean;
  7927. readonly isConnected: boolean;
  7928. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  7929. onleftstickchanged(callback: (values: StickValues) => void): void;
  7930. onrightstickchanged(callback: (values: StickValues) => void): void;
  7931. leftStick: StickValues;
  7932. rightStick: StickValues;
  7933. update(): void;
  7934. dispose(): void;
  7935. }
  7936. class GenericPad extends Gamepad {
  7937. private _buttons;
  7938. private _onbuttondown;
  7939. private _onbuttonup;
  7940. onButtonDownObservable: Observable<number>;
  7941. onButtonUpObservable: Observable<number>;
  7942. onbuttondown(callback: (buttonPressed: number) => void): void;
  7943. onbuttonup(callback: (buttonReleased: number) => void): void;
  7944. constructor(id: string, index: number, browserGamepad: any);
  7945. private _setButtonValue(newValue, currentValue, buttonIndex);
  7946. update(): void;
  7947. dispose(): void;
  7948. }
  7949. }
  7950. declare module BABYLON {
  7951. class GamepadManager {
  7952. private _scene;
  7953. private _babylonGamepads;
  7954. private _oneGamepadConnected;
  7955. _isMonitoring: boolean;
  7956. private _gamepadEventSupported;
  7957. private _gamepadSupport;
  7958. onGamepadConnectedObservable: Observable<Gamepad>;
  7959. onGamepadDisconnectedObservable: Observable<Gamepad>;
  7960. private _onGamepadConnectedEvent;
  7961. private _onGamepadDisconnectedEvent;
  7962. constructor(_scene?: Scene | undefined);
  7963. readonly gamepads: Gamepad[];
  7964. getGamepadByType(type?: number): Nullable<Gamepad>;
  7965. dispose(): void;
  7966. private _addNewGamepad(gamepad);
  7967. private _startMonitoringGamepads();
  7968. private _stopMonitoringGamepads();
  7969. _checkGamepadsStatus(): void;
  7970. private _updateGamepadObjects();
  7971. }
  7972. }
  7973. declare module BABYLON {
  7974. enum Xbox360Button {
  7975. A = 0,
  7976. B = 1,
  7977. X = 2,
  7978. Y = 3,
  7979. Start = 4,
  7980. Back = 5,
  7981. LB = 6,
  7982. RB = 7,
  7983. LeftStick = 8,
  7984. RightStick = 9,
  7985. }
  7986. enum Xbox360Dpad {
  7987. Up = 0,
  7988. Down = 1,
  7989. Left = 2,
  7990. Right = 3,
  7991. }
  7992. class Xbox360Pad extends Gamepad {
  7993. private _leftTrigger;
  7994. private _rightTrigger;
  7995. private _onlefttriggerchanged;
  7996. private _onrighttriggerchanged;
  7997. private _onbuttondown;
  7998. private _onbuttonup;
  7999. private _ondpaddown;
  8000. private _ondpadup;
  8001. onButtonDownObservable: Observable<Xbox360Button>;
  8002. onButtonUpObservable: Observable<Xbox360Button>;
  8003. onPadDownObservable: Observable<Xbox360Dpad>;
  8004. onPadUpObservable: Observable<Xbox360Dpad>;
  8005. private _buttonA;
  8006. private _buttonB;
  8007. private _buttonX;
  8008. private _buttonY;
  8009. private _buttonBack;
  8010. private _buttonStart;
  8011. private _buttonLB;
  8012. private _buttonRB;
  8013. private _buttonLeftStick;
  8014. private _buttonRightStick;
  8015. private _dPadUp;
  8016. private _dPadDown;
  8017. private _dPadLeft;
  8018. private _dPadRight;
  8019. private _isXboxOnePad;
  8020. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  8021. onlefttriggerchanged(callback: (value: number) => void): void;
  8022. onrighttriggerchanged(callback: (value: number) => void): void;
  8023. leftTrigger: number;
  8024. rightTrigger: number;
  8025. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  8026. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  8027. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  8028. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  8029. private _setButtonValue(newValue, currentValue, buttonType);
  8030. private _setDPadValue(newValue, currentValue, buttonType);
  8031. buttonA: number;
  8032. buttonB: number;
  8033. buttonX: number;
  8034. buttonY: number;
  8035. buttonStart: number;
  8036. buttonBack: number;
  8037. buttonLB: number;
  8038. buttonRB: number;
  8039. buttonLeftStick: number;
  8040. buttonRightStick: number;
  8041. dPadUp: number;
  8042. dPadDown: number;
  8043. dPadLeft: number;
  8044. dPadRight: number;
  8045. update(): void;
  8046. dispose(): void;
  8047. }
  8048. }
  8049. declare module BABYLON {
  8050. /**
  8051. * Represents the different options available during the creation of
  8052. * a Environment helper.
  8053. *
  8054. * This can control the default ground, skybox and image processing setup of your scene.
  8055. */
  8056. interface IEnvironmentHelperOptions {
  8057. /**
  8058. * Specifies wether or not to create a ground.
  8059. * True by default.
  8060. */
  8061. createGround: boolean;
  8062. /**
  8063. * Specifies the ground size.
  8064. * 15 by default.
  8065. */
  8066. groundSize: number;
  8067. /**
  8068. * The texture used on the ground for the main color.
  8069. * Comes from the BabylonJS CDN by default.
  8070. *
  8071. * Remarks: Can be either a texture or a url.
  8072. */
  8073. groundTexture: string | BaseTexture;
  8074. /**
  8075. * The color mixed in the ground texture by default.
  8076. * BabylonJS clearColor by default.
  8077. */
  8078. groundColor: Color3;
  8079. /**
  8080. * Specifies the ground opacity.
  8081. * 1 by default.
  8082. */
  8083. groundOpacity: number;
  8084. /**
  8085. * Enables the ground to receive shadows.
  8086. * True by default.
  8087. */
  8088. enableGroundShadow: boolean;
  8089. /**
  8090. * Helps preventing the shadow to be fully black on the ground.
  8091. * 0.5 by default.
  8092. */
  8093. groundShadowLevel: number;
  8094. /**
  8095. * Creates a mirror texture attach to the ground.
  8096. * false by default.
  8097. */
  8098. enableGroundMirror: boolean;
  8099. /**
  8100. * Specifies the ground mirror size ratio.
  8101. * 0.3 by default as the default kernel is 64.
  8102. */
  8103. groundMirrorSizeRatio: number;
  8104. /**
  8105. * Specifies the ground mirror blur kernel size.
  8106. * 64 by default.
  8107. */
  8108. groundMirrorBlurKernel: number;
  8109. /**
  8110. * Specifies the ground mirror visibility amount.
  8111. * 1 by default
  8112. */
  8113. groundMirrorAmount: number;
  8114. /**
  8115. * Specifies the ground mirror reflectance weight.
  8116. * This uses the standard weight of the background material to setup the fresnel effect
  8117. * of the mirror.
  8118. * 1 by default.
  8119. */
  8120. groundMirrorFresnelWeight: number;
  8121. /**
  8122. * Specifies the ground mirror Falloff distance.
  8123. * This can helps reducing the size of the reflection.
  8124. * 0 by Default.
  8125. */
  8126. groundMirrorFallOffDistance: number;
  8127. /**
  8128. * Specifies the ground mirror texture type.
  8129. * Unsigned Int by Default.
  8130. */
  8131. groundMirrorTextureType: number;
  8132. /**
  8133. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  8134. * the shown objects.
  8135. */
  8136. groundYBias: number;
  8137. /**
  8138. * Specifies wether or not to create a skybox.
  8139. * True by default.
  8140. */
  8141. createSkybox: boolean;
  8142. /**
  8143. * Specifies the skybox size.
  8144. * 20 by default.
  8145. */
  8146. skyboxSize: number;
  8147. /**
  8148. * The texture used on the skybox for the main color.
  8149. * Comes from the BabylonJS CDN by default.
  8150. *
  8151. * Remarks: Can be either a texture or a url.
  8152. */
  8153. skyboxTexture: string | BaseTexture;
  8154. /**
  8155. * The color mixed in the skybox texture by default.
  8156. * BabylonJS clearColor by default.
  8157. */
  8158. skyboxColor: Color3;
  8159. /**
  8160. * The background rotation around the Y axis of the scene.
  8161. * This helps aligning the key lights of your scene with the background.
  8162. * 0 by default.
  8163. */
  8164. backgroundYRotation: number;
  8165. /**
  8166. * Compute automatically the size of the elements to best fit with the scene.
  8167. */
  8168. sizeAuto: boolean;
  8169. /**
  8170. * Default position of the rootMesh if autoSize is not true.
  8171. */
  8172. rootPosition: Vector3;
  8173. /**
  8174. * Sets up the image processing in the scene.
  8175. * true by default.
  8176. */
  8177. setupImageProcessing: boolean;
  8178. /**
  8179. * The texture used as your environment texture in the scene.
  8180. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  8181. *
  8182. * Remarks: Can be either a texture or a url.
  8183. */
  8184. environmentTexture: string | BaseTexture;
  8185. /**
  8186. * The value of the exposure to apply to the scene.
  8187. * 0.6 by default if setupImageProcessing is true.
  8188. */
  8189. cameraExposure: number;
  8190. /**
  8191. * The value of the contrast to apply to the scene.
  8192. * 1.6 by default if setupImageProcessing is true.
  8193. */
  8194. cameraContrast: number;
  8195. /**
  8196. * Specifies wether or not tonemapping should be enabled in the scene.
  8197. * true by default if setupImageProcessing is true.
  8198. */
  8199. toneMappingEnabled: boolean;
  8200. }
  8201. /**
  8202. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  8203. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  8204. * It also helps with the default setup of your imageProcessing configuration.
  8205. */
  8206. class EnvironmentHelper {
  8207. /**
  8208. * Default ground texture URL.
  8209. */
  8210. private static _groundTextureCDNUrl;
  8211. /**
  8212. * Default skybox texture URL.
  8213. */
  8214. private static _skyboxTextureCDNUrl;
  8215. /**
  8216. * Default environment texture URL.
  8217. */
  8218. private static _environmentTextureCDNUrl;
  8219. /**
  8220. * Creates the default options for the helper.
  8221. */
  8222. private static _getDefaultOptions();
  8223. private _rootMesh;
  8224. /**
  8225. * Gets the root mesh created by the helper.
  8226. */
  8227. readonly rootMesh: Mesh;
  8228. private _skybox;
  8229. /**
  8230. * Gets the skybox created by the helper.
  8231. */
  8232. readonly skybox: Nullable<Mesh>;
  8233. private _skyboxTexture;
  8234. /**
  8235. * Gets the skybox texture created by the helper.
  8236. */
  8237. readonly skyboxTexture: Nullable<BaseTexture>;
  8238. private _skyboxMaterial;
  8239. /**
  8240. * Gets the skybox material created by the helper.
  8241. */
  8242. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  8243. private _ground;
  8244. /**
  8245. * Gets the ground mesh created by the helper.
  8246. */
  8247. readonly ground: Nullable<Mesh>;
  8248. private _groundTexture;
  8249. /**
  8250. * Gets the ground texture created by the helper.
  8251. */
  8252. readonly groundTexture: Nullable<BaseTexture>;
  8253. private _groundMirror;
  8254. /**
  8255. * Gets the ground mirror created by the helper.
  8256. */
  8257. readonly groundMirror: Nullable<MirrorTexture>;
  8258. /**
  8259. * Gets the ground mirror render list to helps pushing the meshes
  8260. * you wish in the ground reflection.
  8261. */
  8262. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  8263. private _groundMaterial;
  8264. /**
  8265. * Gets the ground material created by the helper.
  8266. */
  8267. readonly groundMaterial: Nullable<BackgroundMaterial>;
  8268. /**
  8269. * Stores the creation options.
  8270. */
  8271. private readonly _scene;
  8272. private _options;
  8273. /**
  8274. * This observable will be notified with any error during the creation of the environment,
  8275. * mainly texture creation errors.
  8276. */
  8277. onErrorObservable: Observable<{
  8278. message?: string;
  8279. exception?: any;
  8280. }>;
  8281. /**
  8282. * constructor
  8283. * @param options
  8284. * @param scene The scene to add the material to
  8285. */
  8286. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  8287. /**
  8288. * Updates the background according to the new options
  8289. * @param options
  8290. */
  8291. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  8292. /**
  8293. * Sets the primary color of all the available elements.
  8294. * @param color
  8295. */
  8296. setMainColor(color: Color3): void;
  8297. /**
  8298. * Setup the image processing according to the specified options.
  8299. */
  8300. private _setupImageProcessing();
  8301. /**
  8302. * Setup the environment texture according to the specified options.
  8303. */
  8304. private _setupEnvironmentTexture();
  8305. /**
  8306. * Setup the background according to the specified options.
  8307. */
  8308. private _setupBackground();
  8309. /**
  8310. * Get the scene sizes according to the setup.
  8311. */
  8312. private _getSceneSize();
  8313. /**
  8314. * Setup the ground according to the specified options.
  8315. */
  8316. private _setupGround(sceneSize);
  8317. /**
  8318. * Setup the ground material according to the specified options.
  8319. */
  8320. private _setupGroundMaterial();
  8321. /**
  8322. * Setup the ground diffuse texture according to the specified options.
  8323. */
  8324. private _setupGroundDiffuseTexture();
  8325. /**
  8326. * Setup the ground mirror texture according to the specified options.
  8327. */
  8328. private _setupGroundMirrorTexture(sceneSize);
  8329. /**
  8330. * Setup the ground to receive the mirror texture.
  8331. */
  8332. private _setupMirrorInGroundMaterial();
  8333. /**
  8334. * Setup the skybox according to the specified options.
  8335. */
  8336. private _setupSkybox(sceneSize);
  8337. /**
  8338. * Setup the skybox material according to the specified options.
  8339. */
  8340. private _setupSkyboxMaterial();
  8341. /**
  8342. * Setup the skybox reflection texture according to the specified options.
  8343. */
  8344. private _setupSkyboxReflectionTexture();
  8345. private _errorHandler;
  8346. /**
  8347. * Dispose all the elements created by the Helper.
  8348. */
  8349. dispose(): void;
  8350. }
  8351. }
  8352. declare module BABYLON {
  8353. /**
  8354. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  8355. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  8356. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  8357. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  8358. */
  8359. class VideoDome extends Node {
  8360. /**
  8361. * The video texture being displayed on the sphere
  8362. */
  8363. protected _videoTexture: VideoTexture;
  8364. /**
  8365. * The skybox material
  8366. */
  8367. protected _material: BackgroundMaterial;
  8368. /**
  8369. * The surface used for the skybox
  8370. */
  8371. protected _mesh: Mesh;
  8372. /**
  8373. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  8374. * Also see the options.resolution property.
  8375. */
  8376. fovMultiplier: number;
  8377. /**
  8378. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  8379. * @param name Element's name, child elements will append suffixes for their own names.
  8380. * @param urlsOrVideo
  8381. * @param options An object containing optional or exposed sub element properties:
  8382. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  8383. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  8384. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  8385. * @param options **loop=true** Automatically loop video on end.
  8386. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  8387. */
  8388. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  8389. resolution?: number;
  8390. clickToPlay?: boolean;
  8391. autoPlay?: boolean;
  8392. loop?: boolean;
  8393. size?: number;
  8394. }, scene: Scene);
  8395. /**
  8396. * Releases resources associated with this node.
  8397. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8398. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8399. */
  8400. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8401. }
  8402. }
  8403. declare module BABYLON {
  8404. /**
  8405. * Effect layer options. This helps customizing the behaviour
  8406. * of the effect layer.
  8407. */
  8408. interface IEffectLayerOptions {
  8409. /**
  8410. * Multiplication factor apply to the canvas size to compute the render target size
  8411. * used to generated the objects (the smaller the faster).
  8412. */
  8413. mainTextureRatio: number;
  8414. /**
  8415. * Enforces a fixed size texture to ensure effect stability across devices.
  8416. */
  8417. mainTextureFixedSize?: number;
  8418. /**
  8419. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  8420. */
  8421. alphaBlendingMode: number;
  8422. /**
  8423. * The camera attached to the layer.
  8424. */
  8425. camera: Nullable<Camera>;
  8426. }
  8427. /**
  8428. * The effect layer Helps adding post process effect blended with the main pass.
  8429. *
  8430. * This can be for instance use to generate glow or higlight effects on the scene.
  8431. *
  8432. * The effect layer class can not be used directly and is intented to inherited from to be
  8433. * customized per effects.
  8434. */
  8435. abstract class EffectLayer {
  8436. private _vertexBuffers;
  8437. private _indexBuffer;
  8438. private _cachedDefines;
  8439. private _effectLayerMapGenerationEffect;
  8440. private _effectLayerOptions;
  8441. private _mergeEffect;
  8442. protected _scene: Scene;
  8443. protected _engine: Engine;
  8444. protected _maxSize: number;
  8445. protected _mainTextureDesiredSize: ISize;
  8446. protected _mainTexture: RenderTargetTexture;
  8447. protected _shouldRender: boolean;
  8448. protected _postProcesses: PostProcess[];
  8449. protected _textures: BaseTexture[];
  8450. protected _emissiveTextureAndColor: {
  8451. texture: Nullable<BaseTexture>;
  8452. color: Color4;
  8453. };
  8454. /**
  8455. * The name of the layer
  8456. */
  8457. name: string;
  8458. /**
  8459. * The clear color of the texture used to generate the glow map.
  8460. */
  8461. neutralColor: Color4;
  8462. /**
  8463. * Specifies wether the highlight layer is enabled or not.
  8464. */
  8465. isEnabled: boolean;
  8466. /**
  8467. * Gets the camera attached to the layer.
  8468. */
  8469. readonly camera: Nullable<Camera>;
  8470. /**
  8471. * An event triggered when the effect layer has been disposed.
  8472. */
  8473. onDisposeObservable: Observable<EffectLayer>;
  8474. /**
  8475. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  8476. */
  8477. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  8478. /**
  8479. * An event triggered when the generated texture is being merged in the scene.
  8480. */
  8481. onBeforeComposeObservable: Observable<EffectLayer>;
  8482. /**
  8483. * An event triggered when the generated texture has been merged in the scene.
  8484. */
  8485. onAfterComposeObservable: Observable<EffectLayer>;
  8486. /**
  8487. * An event triggered when the efffect layer changes its size.
  8488. */
  8489. onSizeChangedObservable: Observable<EffectLayer>;
  8490. /**
  8491. * Instantiates a new effect Layer and references it in the scene.
  8492. * @param name The name of the layer
  8493. * @param scene The scene to use the layer in
  8494. */
  8495. constructor(
  8496. /** The Friendly of the effect in the scene */
  8497. name: string, scene: Scene);
  8498. /**
  8499. * Get the effect name of the layer.
  8500. * @return The effect name
  8501. */
  8502. abstract getEffectName(): string;
  8503. /**
  8504. * Checks for the readiness of the element composing the layer.
  8505. * @param subMesh the mesh to check for
  8506. * @param useInstances specify wether or not to use instances to render the mesh
  8507. * @return true if ready otherwise, false
  8508. */
  8509. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  8510. /**
  8511. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  8512. * @returns true if the effect requires stencil during the main canvas render pass.
  8513. */
  8514. abstract needStencil(): boolean;
  8515. /**
  8516. * Create the merge effect. This is the shader use to blit the information back
  8517. * to the main canvas at the end of the scene rendering.
  8518. * @returns The effect containing the shader used to merge the effect on the main canvas
  8519. */
  8520. protected abstract _createMergeEffect(): Effect;
  8521. /**
  8522. * Creates the render target textures and post processes used in the effect layer.
  8523. */
  8524. protected abstract _createTextureAndPostProcesses(): void;
  8525. /**
  8526. * Implementation specific of rendering the generating effect on the main canvas.
  8527. * @param effect The effect used to render through
  8528. */
  8529. protected abstract _internalRender(effect: Effect): void;
  8530. /**
  8531. * Sets the required values for both the emissive texture and and the main color.
  8532. */
  8533. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  8534. /**
  8535. * Free any resources and references associated to a mesh.
  8536. * Internal use
  8537. * @param mesh The mesh to free.
  8538. */
  8539. abstract _disposeMesh(mesh: Mesh): void;
  8540. /**
  8541. * Initializes the effect layer with the required options.
  8542. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  8543. */
  8544. protected _init(options: Partial<IEffectLayerOptions>): void;
  8545. /**
  8546. * Generates the index buffer of the full screen quad blending to the main canvas.
  8547. */
  8548. private _generateIndexBuffer();
  8549. /**
  8550. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  8551. */
  8552. private _genrateVertexBuffer();
  8553. /**
  8554. * Sets the main texture desired size which is the closest power of two
  8555. * of the engine canvas size.
  8556. */
  8557. private _setMainTextureSize();
  8558. /**
  8559. * Creates the main texture for the effect layer.
  8560. */
  8561. protected _createMainTexture(): void;
  8562. /**
  8563. * Checks for the readiness of the element composing the layer.
  8564. * @param subMesh the mesh to check for
  8565. * @param useInstances specify wether or not to use instances to render the mesh
  8566. * @param emissiveTexture the associated emissive texture used to generate the glow
  8567. * @return true if ready otherwise, false
  8568. */
  8569. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  8570. /**
  8571. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  8572. */
  8573. render(): void;
  8574. /**
  8575. * Determine if a given mesh will be used in the current effect.
  8576. * @param mesh mesh to test
  8577. * @returns true if the mesh will be used
  8578. */
  8579. hasMesh(mesh: AbstractMesh): boolean;
  8580. /**
  8581. * Returns true if the layer contains information to display, otherwise false.
  8582. * @returns true if the glow layer should be rendered
  8583. */
  8584. shouldRender(): boolean;
  8585. /**
  8586. * Returns true if the mesh should render, otherwise false.
  8587. * @param mesh The mesh to render
  8588. * @returns true if it should render otherwise false
  8589. */
  8590. protected _shouldRenderMesh(mesh: Mesh): boolean;
  8591. /**
  8592. * Returns true if the mesh should render, otherwise false.
  8593. * @param mesh The mesh to render
  8594. * @returns true if it should render otherwise false
  8595. */
  8596. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  8597. /**
  8598. * Renders the submesh passed in parameter to the generation map.
  8599. */
  8600. protected _renderSubMesh(subMesh: SubMesh): void;
  8601. /**
  8602. * Rebuild the required buffers.
  8603. * @ignore Internal use only.
  8604. */
  8605. _rebuild(): void;
  8606. /**
  8607. * Dispose only the render target textures and post process.
  8608. */
  8609. private _disposeTextureAndPostProcesses();
  8610. /**
  8611. * Dispose the highlight layer and free resources.
  8612. */
  8613. dispose(): void;
  8614. /**
  8615. * Gets the class name of the effect layer
  8616. * @returns the string with the class name of the effect layer
  8617. */
  8618. getClassName(): string;
  8619. }
  8620. }
  8621. declare module BABYLON {
  8622. /**
  8623. * Glow layer options. This helps customizing the behaviour
  8624. * of the glow layer.
  8625. */
  8626. interface IGlowLayerOptions {
  8627. /**
  8628. * Multiplication factor apply to the canvas size to compute the render target size
  8629. * used to generated the glowing objects (the smaller the faster).
  8630. */
  8631. mainTextureRatio: number;
  8632. /**
  8633. * Enforces a fixed size texture to ensure resize independant blur.
  8634. */
  8635. mainTextureFixedSize?: number;
  8636. /**
  8637. * How big is the kernel of the blur texture.
  8638. */
  8639. blurKernelSize: number;
  8640. /**
  8641. * The camera attached to the layer.
  8642. */
  8643. camera: Nullable<Camera>;
  8644. /**
  8645. * Enable MSAA by chosing the number of samples.
  8646. */
  8647. mainTextureSamples?: number;
  8648. }
  8649. /**
  8650. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  8651. *
  8652. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  8653. * glowy meshes to your scene.
  8654. *
  8655. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  8656. */
  8657. class GlowLayer extends EffectLayer {
  8658. /**
  8659. * Effect Name of the layer.
  8660. */
  8661. static readonly EffectName: string;
  8662. /**
  8663. * The default blur kernel size used for the glow.
  8664. */
  8665. static DefaultBlurKernelSize: number;
  8666. /**
  8667. * The default texture size ratio used for the glow.
  8668. */
  8669. static DefaultTextureRatio: number;
  8670. /**
  8671. * Gets the kernel size of the blur.
  8672. */
  8673. /**
  8674. * Sets the kernel size of the blur.
  8675. */
  8676. blurKernelSize: number;
  8677. /**
  8678. * Gets the glow intensity.
  8679. */
  8680. /**
  8681. * Sets the glow intensity.
  8682. */
  8683. intensity: number;
  8684. private _options;
  8685. private _intensity;
  8686. private _horizontalBlurPostprocess1;
  8687. private _verticalBlurPostprocess1;
  8688. private _horizontalBlurPostprocess2;
  8689. private _verticalBlurPostprocess2;
  8690. private _blurTexture1;
  8691. private _blurTexture2;
  8692. private _postProcesses1;
  8693. private _postProcesses2;
  8694. private _includedOnlyMeshes;
  8695. private _excludedMeshes;
  8696. /**
  8697. * Callback used to let the user override the color selection on a per mesh basis
  8698. */
  8699. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  8700. /**
  8701. * Callback used to let the user override the texture selection on a per mesh basis
  8702. */
  8703. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  8704. /**
  8705. * Instantiates a new glow Layer and references it to the scene.
  8706. * @param name The name of the layer
  8707. * @param scene The scene to use the layer in
  8708. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  8709. */
  8710. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  8711. /**
  8712. * Get the effect name of the layer.
  8713. * @return The effect name
  8714. */
  8715. getEffectName(): string;
  8716. /**
  8717. * Create the merge effect. This is the shader use to blit the information back
  8718. * to the main canvas at the end of the scene rendering.
  8719. */
  8720. protected _createMergeEffect(): Effect;
  8721. /**
  8722. * Creates the render target textures and post processes used in the glow layer.
  8723. */
  8724. protected _createTextureAndPostProcesses(): void;
  8725. /**
  8726. * Checks for the readiness of the element composing the layer.
  8727. * @param subMesh the mesh to check for
  8728. * @param useInstances specify wether or not to use instances to render the mesh
  8729. * @param emissiveTexture the associated emissive texture used to generate the glow
  8730. * @return true if ready otherwise, false
  8731. */
  8732. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  8733. /**
  8734. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  8735. */
  8736. needStencil(): boolean;
  8737. /**
  8738. * Implementation specific of rendering the generating effect on the main canvas.
  8739. * @param effect The effect used to render through
  8740. */
  8741. protected _internalRender(effect: Effect): void;
  8742. /**
  8743. * Sets the required values for both the emissive texture and and the main color.
  8744. */
  8745. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  8746. /**
  8747. * Returns true if the mesh should render, otherwise false.
  8748. * @param mesh The mesh to render
  8749. * @returns true if it should render otherwise false
  8750. */
  8751. protected _shouldRenderMesh(mesh: Mesh): boolean;
  8752. /**
  8753. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  8754. * @param mesh The mesh to exclude from the glow layer
  8755. */
  8756. addExcludedMesh(mesh: Mesh): void;
  8757. /**
  8758. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  8759. * @param mesh The mesh to remove
  8760. */
  8761. removeExcludedMesh(mesh: Mesh): void;
  8762. /**
  8763. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  8764. * @param mesh The mesh to include in the glow layer
  8765. */
  8766. addIncludedOnlyMesh(mesh: Mesh): void;
  8767. /**
  8768. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  8769. * @param mesh The mesh to remove
  8770. */
  8771. removeIncludedOnlyMesh(mesh: Mesh): void;
  8772. /**
  8773. * Determine if a given mesh will be used in the glow layer
  8774. * @param mesh The mesh to test
  8775. * @returns true if the mesh will be highlighted by the current glow layer
  8776. */
  8777. hasMesh(mesh: AbstractMesh): boolean;
  8778. /**
  8779. * Free any resources and references associated to a mesh.
  8780. * Internal use
  8781. * @param mesh The mesh to free.
  8782. */
  8783. _disposeMesh(mesh: Mesh): void;
  8784. /**
  8785. * Gets the class name of the effect layer
  8786. * @returns the string with the class name of the effect layer
  8787. */
  8788. getClassName(): string;
  8789. /**
  8790. * Serializes this glow layer
  8791. * @returns a serialized glow layer object
  8792. */
  8793. serialize(): any;
  8794. /**
  8795. * Creates a Glow Layer from parsed glow layer data
  8796. * @param parsedGlowLayer defines glow layer data
  8797. * @param scene defines the current scene
  8798. * @param rootUrl defines the root URL containing the glow layer information
  8799. * @returns a parsed Glow Layer
  8800. */
  8801. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  8802. }
  8803. }
  8804. declare module BABYLON {
  8805. /**
  8806. * Highlight layer options. This helps customizing the behaviour
  8807. * of the highlight layer.
  8808. */
  8809. interface IHighlightLayerOptions {
  8810. /**
  8811. * Multiplication factor apply to the canvas size to compute the render target size
  8812. * used to generated the glowing objects (the smaller the faster).
  8813. */
  8814. mainTextureRatio: number;
  8815. /**
  8816. * Enforces a fixed size texture to ensure resize independant blur.
  8817. */
  8818. mainTextureFixedSize?: number;
  8819. /**
  8820. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  8821. * of the picture to blur (the smaller the faster).
  8822. */
  8823. blurTextureSizeRatio: number;
  8824. /**
  8825. * How big in texel of the blur texture is the vertical blur.
  8826. */
  8827. blurVerticalSize: number;
  8828. /**
  8829. * How big in texel of the blur texture is the horizontal blur.
  8830. */
  8831. blurHorizontalSize: number;
  8832. /**
  8833. * Alpha blending mode used to apply the blur. Default is combine.
  8834. */
  8835. alphaBlendingMode: number;
  8836. /**
  8837. * The camera attached to the layer.
  8838. */
  8839. camera: Nullable<Camera>;
  8840. /**
  8841. * Should we display highlight as a solid stroke?
  8842. */
  8843. isStroke?: boolean;
  8844. }
  8845. /**
  8846. * The highlight layer Helps adding a glow effect around a mesh.
  8847. *
  8848. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  8849. * glowy meshes to your scene.
  8850. *
  8851. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  8852. */
  8853. class HighlightLayer extends EffectLayer {
  8854. name: string;
  8855. /**
  8856. * Effect Name of the highlight layer.
  8857. */
  8858. static readonly EffectName: string;
  8859. /**
  8860. * The neutral color used during the preparation of the glow effect.
  8861. * This is black by default as the blend operation is a blend operation.
  8862. */
  8863. static NeutralColor: Color4;
  8864. /**
  8865. * Stencil value used for glowing meshes.
  8866. */
  8867. static GlowingMeshStencilReference: number;
  8868. /**
  8869. * Stencil value used for the other meshes in the scene.
  8870. */
  8871. static NormalMeshStencilReference: number;
  8872. /**
  8873. * Specifies whether or not the inner glow is ACTIVE in the layer.
  8874. */
  8875. innerGlow: boolean;
  8876. /**
  8877. * Specifies whether or not the outer glow is ACTIVE in the layer.
  8878. */
  8879. outerGlow: boolean;
  8880. /**
  8881. * Gets the horizontal size of the blur.
  8882. */
  8883. /**
  8884. * Specifies the horizontal size of the blur.
  8885. */
  8886. blurHorizontalSize: number;
  8887. /**
  8888. * Gets the vertical size of the blur.
  8889. */
  8890. /**
  8891. * Specifies the vertical size of the blur.
  8892. */
  8893. blurVerticalSize: number;
  8894. /**
  8895. * An event triggered when the highlight layer is being blurred.
  8896. */
  8897. onBeforeBlurObservable: Observable<HighlightLayer>;
  8898. /**
  8899. * An event triggered when the highlight layer has been blurred.
  8900. */
  8901. onAfterBlurObservable: Observable<HighlightLayer>;
  8902. private _instanceGlowingMeshStencilReference;
  8903. private _options;
  8904. private _downSamplePostprocess;
  8905. private _horizontalBlurPostprocess;
  8906. private _verticalBlurPostprocess;
  8907. private _blurTexture;
  8908. private _meshes;
  8909. private _excludedMeshes;
  8910. /**
  8911. * Instantiates a new highlight Layer and references it to the scene..
  8912. * @param name The name of the layer
  8913. * @param scene The scene to use the layer in
  8914. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  8915. */
  8916. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  8917. /**
  8918. * Get the effect name of the layer.
  8919. * @return The effect name
  8920. */
  8921. getEffectName(): string;
  8922. /**
  8923. * Create the merge effect. This is the shader use to blit the information back
  8924. * to the main canvas at the end of the scene rendering.
  8925. */
  8926. protected _createMergeEffect(): Effect;
  8927. /**
  8928. * Creates the render target textures and post processes used in the highlight layer.
  8929. */
  8930. protected _createTextureAndPostProcesses(): void;
  8931. /**
  8932. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  8933. */
  8934. needStencil(): boolean;
  8935. /**
  8936. * Checks for the readiness of the element composing the layer.
  8937. * @param subMesh the mesh to check for
  8938. * @param useInstances specify wether or not to use instances to render the mesh
  8939. * @param emissiveTexture the associated emissive texture used to generate the glow
  8940. * @return true if ready otherwise, false
  8941. */
  8942. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  8943. /**
  8944. * Implementation specific of rendering the generating effect on the main canvas.
  8945. * @param effect The effect used to render through
  8946. */
  8947. protected _internalRender(effect: Effect): void;
  8948. /**
  8949. * Returns true if the layer contains information to display, otherwise false.
  8950. */
  8951. shouldRender(): boolean;
  8952. /**
  8953. * Returns true if the mesh should render, otherwise false.
  8954. * @param mesh The mesh to render
  8955. * @returns true if it should render otherwise false
  8956. */
  8957. protected _shouldRenderMesh(mesh: Mesh): boolean;
  8958. /**
  8959. * Sets the required values for both the emissive texture and and the main color.
  8960. */
  8961. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  8962. /**
  8963. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  8964. * @param mesh The mesh to exclude from the highlight layer
  8965. */
  8966. addExcludedMesh(mesh: Mesh): void;
  8967. /**
  8968. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  8969. * @param mesh The mesh to highlight
  8970. */
  8971. removeExcludedMesh(mesh: Mesh): void;
  8972. /**
  8973. * Determine if a given mesh will be highlighted by the current HighlightLayer
  8974. * @param mesh mesh to test
  8975. * @returns true if the mesh will be highlighted by the current HighlightLayer
  8976. */
  8977. hasMesh(mesh: AbstractMesh): boolean;
  8978. /**
  8979. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  8980. * @param mesh The mesh to highlight
  8981. * @param color The color of the highlight
  8982. * @param glowEmissiveOnly Extract the glow from the emissive texture
  8983. */
  8984. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  8985. /**
  8986. * Remove a mesh from the highlight layer in order to make it stop glowing.
  8987. * @param mesh The mesh to highlight
  8988. */
  8989. removeMesh(mesh: Mesh): void;
  8990. /**
  8991. * Force the stencil to the normal expected value for none glowing parts
  8992. */
  8993. private _defaultStencilReference(mesh);
  8994. /**
  8995. * Free any resources and references associated to a mesh.
  8996. * Internal use
  8997. * @param mesh The mesh to free.
  8998. */
  8999. _disposeMesh(mesh: Mesh): void;
  9000. /**
  9001. * Dispose the highlight layer and free resources.
  9002. */
  9003. dispose(): void;
  9004. }
  9005. }
  9006. declare module BABYLON {
  9007. class Layer {
  9008. name: string;
  9009. texture: Nullable<Texture>;
  9010. isBackground: boolean;
  9011. color: Color4;
  9012. scale: Vector2;
  9013. offset: Vector2;
  9014. alphaBlendingMode: number;
  9015. alphaTest: boolean;
  9016. layerMask: number;
  9017. private _scene;
  9018. private _vertexBuffers;
  9019. private _indexBuffer;
  9020. private _effect;
  9021. private _alphaTestEffect;
  9022. /**
  9023. * An event triggered when the layer is disposed.
  9024. */
  9025. onDisposeObservable: Observable<Layer>;
  9026. private _onDisposeObserver;
  9027. onDispose: () => void;
  9028. /**
  9029. * An event triggered before rendering the scene
  9030. */
  9031. onBeforeRenderObservable: Observable<Layer>;
  9032. private _onBeforeRenderObserver;
  9033. onBeforeRender: () => void;
  9034. /**
  9035. * An event triggered after rendering the scene
  9036. */
  9037. onAfterRenderObservable: Observable<Layer>;
  9038. private _onAfterRenderObserver;
  9039. onAfterRender: () => void;
  9040. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  9041. private _createIndexBuffer();
  9042. _rebuild(): void;
  9043. render(): void;
  9044. dispose(): void;
  9045. }
  9046. }
  9047. declare module BABYLON {
  9048. /**
  9049. * This class can be used to get instrumentation data from a Babylon engine
  9050. */
  9051. class EngineInstrumentation implements IDisposable {
  9052. engine: Engine;
  9053. private _captureGPUFrameTime;
  9054. private _gpuFrameTimeToken;
  9055. private _gpuFrameTime;
  9056. private _captureShaderCompilationTime;
  9057. private _shaderCompilationTime;
  9058. private _onBeginFrameObserver;
  9059. private _onEndFrameObserver;
  9060. private _onBeforeShaderCompilationObserver;
  9061. private _onAfterShaderCompilationObserver;
  9062. /**
  9063. * Gets the perf counter used for GPU frame time
  9064. */
  9065. readonly gpuFrameTimeCounter: PerfCounter;
  9066. /**
  9067. * Gets the GPU frame time capture status
  9068. */
  9069. /**
  9070. * Enable or disable the GPU frame time capture
  9071. */
  9072. captureGPUFrameTime: boolean;
  9073. /**
  9074. * Gets the perf counter used for shader compilation time
  9075. */
  9076. readonly shaderCompilationTimeCounter: PerfCounter;
  9077. /**
  9078. * Gets the shader compilation time capture status
  9079. */
  9080. /**
  9081. * Enable or disable the shader compilation time capture
  9082. */
  9083. captureShaderCompilationTime: boolean;
  9084. constructor(engine: Engine);
  9085. dispose(): void;
  9086. }
  9087. }
  9088. declare module BABYLON {
  9089. /**
  9090. * This class can be used to get instrumentation data from a Babylon engine
  9091. */
  9092. class SceneInstrumentation implements IDisposable {
  9093. scene: Scene;
  9094. private _captureActiveMeshesEvaluationTime;
  9095. private _activeMeshesEvaluationTime;
  9096. private _captureRenderTargetsRenderTime;
  9097. private _renderTargetsRenderTime;
  9098. private _captureFrameTime;
  9099. private _frameTime;
  9100. private _captureRenderTime;
  9101. private _renderTime;
  9102. private _captureInterFrameTime;
  9103. private _interFrameTime;
  9104. private _captureParticlesRenderTime;
  9105. private _particlesRenderTime;
  9106. private _captureSpritesRenderTime;
  9107. private _spritesRenderTime;
  9108. private _capturePhysicsTime;
  9109. private _physicsTime;
  9110. private _captureAnimationsTime;
  9111. private _animationsTime;
  9112. private _onBeforeActiveMeshesEvaluationObserver;
  9113. private _onAfterActiveMeshesEvaluationObserver;
  9114. private _onBeforeRenderTargetsRenderObserver;
  9115. private _onAfterRenderTargetsRenderObserver;
  9116. private _onAfterRenderObserver;
  9117. private _onBeforeDrawPhaseObserver;
  9118. private _onAfterDrawPhaseObserver;
  9119. private _onBeforeAnimationsObserver;
  9120. private _onBeforeParticlesRenderingObserver;
  9121. private _onAfterParticlesRenderingObserver;
  9122. private _onBeforeSpritesRenderingObserver;
  9123. private _onAfterSpritesRenderingObserver;
  9124. private _onBeforePhysicsObserver;
  9125. private _onAfterPhysicsObserver;
  9126. private _onAfterAnimationsObserver;
  9127. /**
  9128. * Gets the perf counter used for active meshes evaluation time
  9129. */
  9130. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  9131. /**
  9132. * Gets the active meshes evaluation time capture status
  9133. */
  9134. /**
  9135. * Enable or disable the active meshes evaluation time capture
  9136. */
  9137. captureActiveMeshesEvaluationTime: boolean;
  9138. /**
  9139. * Gets the perf counter used for render targets render time
  9140. */
  9141. readonly renderTargetsRenderTimeCounter: PerfCounter;
  9142. /**
  9143. * Gets the render targets render time capture status
  9144. */
  9145. /**
  9146. * Enable or disable the render targets render time capture
  9147. */
  9148. captureRenderTargetsRenderTime: boolean;
  9149. /**
  9150. * Gets the perf counter used for particles render time
  9151. */
  9152. readonly particlesRenderTimeCounter: PerfCounter;
  9153. /**
  9154. * Gets the particles render time capture status
  9155. */
  9156. /**
  9157. * Enable or disable the particles render time capture
  9158. */
  9159. captureParticlesRenderTime: boolean;
  9160. /**
  9161. * Gets the perf counter used for sprites render time
  9162. */
  9163. readonly spritesRenderTimeCounter: PerfCounter;
  9164. /**
  9165. * Gets the sprites render time capture status
  9166. */
  9167. /**
  9168. * Enable or disable the sprites render time capture
  9169. */
  9170. captureSpritesRenderTime: boolean;
  9171. /**
  9172. * Gets the perf counter used for physics time
  9173. */
  9174. readonly physicsTimeCounter: PerfCounter;
  9175. /**
  9176. * Gets the physics time capture status
  9177. */
  9178. /**
  9179. * Enable or disable the physics time capture
  9180. */
  9181. capturePhysicsTime: boolean;
  9182. /**
  9183. * Gets the perf counter used for animations time
  9184. */
  9185. readonly animationsTimeCounter: PerfCounter;
  9186. /**
  9187. * Gets the animations time capture status
  9188. */
  9189. /**
  9190. * Enable or disable the animations time capture
  9191. */
  9192. captureAnimationsTime: boolean;
  9193. /**
  9194. * Gets the perf counter used for frame time capture
  9195. */
  9196. readonly frameTimeCounter: PerfCounter;
  9197. /**
  9198. * Gets the frame time capture status
  9199. */
  9200. /**
  9201. * Enable or disable the frame time capture
  9202. */
  9203. captureFrameTime: boolean;
  9204. /**
  9205. * Gets the perf counter used for inter-frames time capture
  9206. */
  9207. readonly interFrameTimeCounter: PerfCounter;
  9208. /**
  9209. * Gets the inter-frames time capture status
  9210. */
  9211. /**
  9212. * Enable or disable the inter-frames time capture
  9213. */
  9214. captureInterFrameTime: boolean;
  9215. /**
  9216. * Gets the perf counter used for render time capture
  9217. */
  9218. readonly renderTimeCounter: PerfCounter;
  9219. /**
  9220. * Gets the render time capture status
  9221. */
  9222. /**
  9223. * Enable or disable the render time capture
  9224. */
  9225. captureRenderTime: boolean;
  9226. /**
  9227. * Gets the perf counter used for draw calls
  9228. */
  9229. readonly drawCallsCounter: PerfCounter;
  9230. /**
  9231. * Gets the perf counter used for texture collisions
  9232. */
  9233. readonly textureCollisionsCounter: PerfCounter;
  9234. constructor(scene: Scene);
  9235. dispose(): void;
  9236. }
  9237. }
  9238. declare module BABYLON {
  9239. class _TimeToken {
  9240. _startTimeQuery: Nullable<WebGLQuery>;
  9241. _endTimeQuery: Nullable<WebGLQuery>;
  9242. _timeElapsedQuery: Nullable<WebGLQuery>;
  9243. _timeElapsedQueryEnded: boolean;
  9244. }
  9245. }
  9246. declare module BABYLON {
  9247. class LensFlare {
  9248. size: number;
  9249. position: number;
  9250. color: Color3;
  9251. texture: Nullable<Texture>;
  9252. alphaMode: number;
  9253. private _system;
  9254. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  9255. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  9256. dispose(): void;
  9257. }
  9258. }
  9259. declare module BABYLON {
  9260. class LensFlareSystem {
  9261. name: string;
  9262. lensFlares: LensFlare[];
  9263. borderLimit: number;
  9264. viewportBorder: number;
  9265. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  9266. layerMask: number;
  9267. id: string;
  9268. private _scene;
  9269. private _emitter;
  9270. private _vertexBuffers;
  9271. private _indexBuffer;
  9272. private _effect;
  9273. private _positionX;
  9274. private _positionY;
  9275. private _isEnabled;
  9276. constructor(name: string, emitter: any, scene: Scene);
  9277. isEnabled: boolean;
  9278. getScene(): Scene;
  9279. getEmitter(): any;
  9280. setEmitter(newEmitter: any): void;
  9281. getEmitterPosition(): Vector3;
  9282. computeEffectivePosition(globalViewport: Viewport): boolean;
  9283. _isVisible(): boolean;
  9284. render(): boolean;
  9285. dispose(): void;
  9286. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  9287. serialize(): any;
  9288. }
  9289. }
  9290. declare module BABYLON {
  9291. interface ILoadingScreen {
  9292. displayLoadingUI: () => void;
  9293. hideLoadingUI: () => void;
  9294. loadingUIBackgroundColor: string;
  9295. loadingUIText: string;
  9296. }
  9297. class DefaultLoadingScreen implements ILoadingScreen {
  9298. private _renderingCanvas;
  9299. private _loadingText;
  9300. private _loadingDivBackgroundColor;
  9301. private _loadingDiv;
  9302. private _loadingTextDiv;
  9303. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  9304. displayLoadingUI(): void;
  9305. hideLoadingUI(): void;
  9306. loadingUIText: string;
  9307. loadingUIBackgroundColor: string;
  9308. private _resizeLoadingUI;
  9309. }
  9310. }
  9311. declare module BABYLON {
  9312. class SceneLoaderProgressEvent {
  9313. readonly lengthComputable: boolean;
  9314. readonly loaded: number;
  9315. readonly total: number;
  9316. constructor(lengthComputable: boolean, loaded: number, total: number);
  9317. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  9318. }
  9319. interface ISceneLoaderPluginExtensions {
  9320. [extension: string]: {
  9321. isBinary: boolean;
  9322. };
  9323. }
  9324. interface ISceneLoaderPluginFactory {
  9325. name: string;
  9326. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  9327. canDirectLoad?: (data: string) => boolean;
  9328. }
  9329. interface ISceneLoaderPlugin {
  9330. /**
  9331. * The friendly name of this plugin.
  9332. */
  9333. name: string;
  9334. /**
  9335. * The file extensions supported by this plugin.
  9336. */
  9337. extensions: string | ISceneLoaderPluginExtensions;
  9338. /**
  9339. * Import meshes into a scene.
  9340. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  9341. * @param scene The scene to import into
  9342. * @param data The data to import
  9343. * @param rootUrl The root url for scene and resources
  9344. * @param meshes The meshes array to import into
  9345. * @param particleSystems The particle systems array to import into
  9346. * @param skeletons The skeletons array to import into
  9347. * @param onError The callback when import fails
  9348. * @returns True if successful or false otherwise
  9349. */
  9350. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  9351. /**
  9352. * Load into a scene.
  9353. * @param scene The scene to load into
  9354. * @param data The data to import
  9355. * @param rootUrl The root url for scene and resources
  9356. * @param onError The callback when import fails
  9357. * @returns true if successful or false otherwise
  9358. */
  9359. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  9360. /**
  9361. * The callback that returns true if the data can be directly loaded.
  9362. */
  9363. canDirectLoad?: (data: string) => boolean;
  9364. /**
  9365. * The callback that allows custom handling of the root url based on the response url.
  9366. */
  9367. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  9368. /**
  9369. * Load into an asset container.
  9370. * @param scene The scene to load into
  9371. * @param data The data to import
  9372. * @param rootUrl The root url for scene and resources
  9373. * @param onError The callback when import fails
  9374. * @returns The loaded asset container
  9375. */
  9376. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  9377. }
  9378. interface ISceneLoaderPluginAsync {
  9379. /**
  9380. * The friendly name of this plugin.
  9381. */
  9382. name: string;
  9383. /**
  9384. * The file extensions supported by this plugin.
  9385. */
  9386. extensions: string | ISceneLoaderPluginExtensions;
  9387. /**
  9388. * Import meshes into a scene.
  9389. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  9390. * @param scene The scene to import into
  9391. * @param data The data to import
  9392. * @param rootUrl The root url for scene and resources
  9393. * @param onProgress The callback when the load progresses
  9394. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  9395. */
  9396. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  9397. meshes: AbstractMesh[];
  9398. particleSystems: ParticleSystem[];
  9399. skeletons: Skeleton[];
  9400. animationGroups: AnimationGroup[];
  9401. }>;
  9402. /**
  9403. * Load into a scene.
  9404. * @param scene The scene to load into
  9405. * @param data The data to import
  9406. * @param rootUrl The root url for scene and resources
  9407. * @param onProgress The callback when the load progresses
  9408. * @returns Nothing
  9409. */
  9410. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  9411. /**
  9412. * The callback that returns true if the data can be directly loaded.
  9413. */
  9414. canDirectLoad?: (data: string) => boolean;
  9415. /**
  9416. * The callback that allows custom handling of the root url based on the response url.
  9417. */
  9418. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  9419. /**
  9420. * Load into an asset container.
  9421. * @param scene The scene to load into
  9422. * @param data The data to import
  9423. * @param rootUrl The root url for scene and resources
  9424. * @param onProgress The callback when the load progresses
  9425. * @returns The loaded asset container
  9426. */
  9427. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  9428. }
  9429. class SceneLoader {
  9430. private static _ForceFullSceneLoadingForIncremental;
  9431. private static _ShowLoadingScreen;
  9432. private static _CleanBoneMatrixWeights;
  9433. static readonly NO_LOGGING: number;
  9434. static readonly MINIMAL_LOGGING: number;
  9435. static readonly SUMMARY_LOGGING: number;
  9436. static readonly DETAILED_LOGGING: number;
  9437. private static _loggingLevel;
  9438. static ForceFullSceneLoadingForIncremental: boolean;
  9439. static ShowLoadingScreen: boolean;
  9440. static loggingLevel: number;
  9441. static CleanBoneMatrixWeights: boolean;
  9442. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  9443. private static _registeredPlugins;
  9444. private static _getDefaultPlugin();
  9445. private static _getPluginForExtension(extension);
  9446. private static _getPluginForDirectLoad(data);
  9447. private static _getPluginForFilename(sceneFilename);
  9448. private static _getDirectLoad(sceneFilename);
  9449. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  9450. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  9451. static IsPluginForExtensionAvailable(extension: string): boolean;
  9452. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  9453. /**
  9454. * Import meshes into a scene
  9455. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  9456. * @param rootUrl a string that defines the root url for scene and resources
  9457. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  9458. * @param scene the instance of BABYLON.Scene to append to
  9459. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  9460. * @param onProgress a callback with a progress event for each file being loaded
  9461. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  9462. * @param pluginExtension the extension used to determine the plugin
  9463. * @returns The loaded plugin
  9464. */
  9465. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename: string, scene: 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>;
  9466. /**
  9467. * Import meshes into a scene
  9468. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  9469. * @param rootUrl a string that defines the root url for scene and resources
  9470. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  9471. * @param scene the instance of BABYLON.Scene to append to
  9472. * @param onProgress a callback with a progress event for each file being loaded
  9473. * @param pluginExtension the extension used to determine the plugin
  9474. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  9475. */
  9476. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  9477. meshes: AbstractMesh[];
  9478. particleSystems: ParticleSystem[];
  9479. skeletons: Skeleton[];
  9480. animationGroups: AnimationGroup[];
  9481. }>;
  9482. /**
  9483. * Load a scene
  9484. * @param rootUrl a string that defines the root url for scene and resources
  9485. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  9486. * @param engine is the instance of BABYLON.Engine to use to create the scene
  9487. * @param onSuccess a callback with the scene when import succeeds
  9488. * @param onProgress a callback with a progress event for each file being loaded
  9489. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  9490. * @param pluginExtension the extension used to determine the plugin
  9491. * @returns The loaded plugin
  9492. */
  9493. 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>;
  9494. /**
  9495. * Load a scene
  9496. * @param rootUrl a string that defines the root url for scene and resources
  9497. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  9498. * @param engine is the instance of BABYLON.Engine to use to create the scene
  9499. * @param onProgress a callback with a progress event for each file being loaded
  9500. * @param pluginExtension the extension used to determine the plugin
  9501. * @returns The loaded scene
  9502. */
  9503. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  9504. /**
  9505. * Append a scene
  9506. * @param rootUrl a string that defines the root url for scene and resources
  9507. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  9508. * @param scene is the instance of BABYLON.Scene to append to
  9509. * @param onSuccess a callback with the scene when import succeeds
  9510. * @param onProgress a callback with a progress event for each file being loaded
  9511. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  9512. * @param pluginExtension the extension used to determine the plugin
  9513. * @returns The loaded plugin
  9514. */
  9515. static Append(rootUrl: string, sceneFilename: any, scene: 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>;
  9516. /**
  9517. * Append a scene
  9518. * @param rootUrl a string that defines the root url for scene and resources
  9519. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  9520. * @param scene is the instance of BABYLON.Scene to append to
  9521. * @param onProgress a callback with a progress event for each file being loaded
  9522. * @param pluginExtension the extension used to determine the plugin
  9523. * @returns The given scene
  9524. */
  9525. static AppendAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  9526. /**
  9527. * Load a scene into an asset container
  9528. * @param rootUrl a string that defines the root url for scene and resources
  9529. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  9530. * @param scene is the instance of BABYLON.Scene to append to
  9531. * @param onSuccess a callback with the scene when import succeeds
  9532. * @param onProgress a callback with a progress event for each file being loaded
  9533. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  9534. * @param pluginExtension the extension used to determine the plugin
  9535. * @returns The loaded plugin
  9536. */
  9537. static LoadAssetContainer(rootUrl: string, sceneFilename: any, scene: 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>;
  9538. /**
  9539. * Load a scene into an asset container
  9540. * @param rootUrl a string that defines the root url for scene and resources
  9541. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  9542. * @param scene is the instance of BABYLON.Scene to append to
  9543. * @param onProgress a callback with a progress event for each file being loaded
  9544. * @param pluginExtension the extension used to determine the plugin
  9545. * @returns The loaded asset container
  9546. */
  9547. static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  9548. }
  9549. }
  9550. declare module BABYLON {
  9551. /**
  9552. * A directional light is defined by a direction (what a surprise!).
  9553. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  9554. * 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.
  9555. * Documentation: https://doc.babylonjs.com/babylon101/lights
  9556. */
  9557. class DirectionalLight extends ShadowLight {
  9558. private _shadowFrustumSize;
  9559. /**
  9560. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  9561. */
  9562. /**
  9563. * Specifies a fix frustum size for the shadow generation.
  9564. */
  9565. shadowFrustumSize: number;
  9566. private _shadowOrthoScale;
  9567. /**
  9568. * Gets the shadow projection scale against the optimal computed one.
  9569. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  9570. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  9571. */
  9572. /**
  9573. * Sets the shadow projection scale against the optimal computed one.
  9574. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  9575. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  9576. */
  9577. shadowOrthoScale: number;
  9578. /**
  9579. * Automatically compute the projection matrix to best fit (including all the casters)
  9580. * on each frame.
  9581. */
  9582. autoUpdateExtends: boolean;
  9583. private _orthoLeft;
  9584. private _orthoRight;
  9585. private _orthoTop;
  9586. private _orthoBottom;
  9587. /**
  9588. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  9589. * The directional light is emitted from everywhere in the given direction.
  9590. * It can cast shawdows.
  9591. * Documentation : http://doc.babylonjs.com/tutorials/lights
  9592. * @param name The friendly name of the light
  9593. * @param direction The direction of the light
  9594. * @param scene The scene the light belongs to
  9595. */
  9596. constructor(name: string, direction: Vector3, scene: Scene);
  9597. /**
  9598. * Returns the string "DirectionalLight".
  9599. * @return The class name
  9600. */
  9601. getClassName(): string;
  9602. /**
  9603. * Returns the integer 1.
  9604. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9605. */
  9606. getTypeID(): number;
  9607. /**
  9608. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  9609. * Returns the DirectionalLight Shadow projection matrix.
  9610. */
  9611. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9612. /**
  9613. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  9614. * Returns the DirectionalLight Shadow projection matrix.
  9615. */
  9616. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  9617. /**
  9618. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  9619. * Returns the DirectionalLight Shadow projection matrix.
  9620. */
  9621. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9622. protected _buildUniformLayout(): void;
  9623. /**
  9624. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  9625. * @param effect The effect to update
  9626. * @param lightIndex The index of the light in the effect to update
  9627. * @returns The directional light
  9628. */
  9629. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  9630. /**
  9631. * Gets the minZ used for shadow according to both the scene and the light.
  9632. *
  9633. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  9634. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  9635. * @param activeCamera The camera we are returning the min for
  9636. * @returns the depth min z
  9637. */
  9638. getDepthMinZ(activeCamera: Camera): number;
  9639. /**
  9640. * Gets the maxZ used for shadow according to both the scene and the light.
  9641. *
  9642. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  9643. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  9644. * @param activeCamera The camera we are returning the max for
  9645. * @returns the depth max z
  9646. */
  9647. getDepthMaxZ(activeCamera: Camera): number;
  9648. }
  9649. }
  9650. declare module BABYLON {
  9651. /**
  9652. * The HemisphericLight simulates the ambient environment light,
  9653. * so the passed direction is the light reflection direction, not the incoming direction.
  9654. */
  9655. class HemisphericLight extends Light {
  9656. /**
  9657. * The groundColor is the light in the opposite direction to the one specified during creation.
  9658. * 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.
  9659. */
  9660. groundColor: Color3;
  9661. /**
  9662. * The light reflection direction, not the incoming direction.
  9663. */
  9664. direction: Vector3;
  9665. private _worldMatrix;
  9666. /**
  9667. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  9668. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  9669. * The HemisphericLight can't cast shadows.
  9670. * Documentation : http://doc.babylonjs.com/tutorials/lights
  9671. * @param name The friendly name of the light
  9672. * @param direction The direction of the light reflection
  9673. * @param scene The scene the light belongs to
  9674. */
  9675. constructor(name: string, direction: Vector3, scene: Scene);
  9676. protected _buildUniformLayout(): void;
  9677. /**
  9678. * Returns the string "HemisphericLight".
  9679. * @return The class name
  9680. */
  9681. getClassName(): string;
  9682. /**
  9683. * Sets the HemisphericLight direction towards the passed target (Vector3).
  9684. * Returns the updated direction.
  9685. * @param target The target the direction should point to
  9686. * @return The computed direction
  9687. */
  9688. setDirectionToTarget(target: Vector3): Vector3;
  9689. /**
  9690. * Returns the shadow generator associated to the light.
  9691. * @returns Always null for hemispheric lights because it does not support shadows.
  9692. */
  9693. getShadowGenerator(): Nullable<ShadowGenerator>;
  9694. /**
  9695. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  9696. * @param effect The effect to update
  9697. * @param lightIndex The index of the light in the effect to update
  9698. * @returns The hemispheric light
  9699. */
  9700. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  9701. /**
  9702. * @ignore internal use only.
  9703. */
  9704. _getWorldMatrix(): Matrix;
  9705. /**
  9706. * Returns the integer 3.
  9707. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9708. */
  9709. getTypeID(): number;
  9710. }
  9711. }
  9712. declare module BABYLON {
  9713. /**
  9714. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9715. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9716. * 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.
  9717. */
  9718. abstract class Light extends Node {
  9719. private static _LIGHTMAP_DEFAULT;
  9720. private static _LIGHTMAP_SPECULAR;
  9721. private static _LIGHTMAP_SHADOWSONLY;
  9722. /**
  9723. * If every light affecting the material is in this lightmapMode,
  9724. * material.lightmapTexture adds or multiplies
  9725. * (depends on material.useLightmapAsShadowmap)
  9726. * after every other light calculations.
  9727. */
  9728. static readonly LIGHTMAP_DEFAULT: number;
  9729. /**
  9730. * material.lightmapTexture as only diffuse lighting from this light
  9731. * adds only specular lighting from this light
  9732. * adds dynamic shadows
  9733. */
  9734. static readonly LIGHTMAP_SPECULAR: number;
  9735. /**
  9736. * material.lightmapTexture as only lighting
  9737. * no light calculation from this light
  9738. * only adds dynamic shadows from this light
  9739. */
  9740. static readonly LIGHTMAP_SHADOWSONLY: number;
  9741. private static _INTENSITYMODE_AUTOMATIC;
  9742. private static _INTENSITYMODE_LUMINOUSPOWER;
  9743. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  9744. private static _INTENSITYMODE_ILLUMINANCE;
  9745. private static _INTENSITYMODE_LUMINANCE;
  9746. /**
  9747. * Each light type uses the default quantity according to its type:
  9748. * point/spot lights use luminous intensity
  9749. * directional lights use illuminance
  9750. */
  9751. static readonly INTENSITYMODE_AUTOMATIC: number;
  9752. /**
  9753. * lumen (lm)
  9754. */
  9755. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9756. /**
  9757. * candela (lm/sr)
  9758. */
  9759. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9760. /**
  9761. * lux (lm/m^2)
  9762. */
  9763. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9764. /**
  9765. * nit (cd/m^2)
  9766. */
  9767. static readonly INTENSITYMODE_LUMINANCE: number;
  9768. private static _LIGHTTYPEID_POINTLIGHT;
  9769. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  9770. private static _LIGHTTYPEID_SPOTLIGHT;
  9771. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  9772. /**
  9773. * Light type const id of the point light.
  9774. */
  9775. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9776. /**
  9777. * Light type const id of the directional light.
  9778. */
  9779. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9780. /**
  9781. * Light type const id of the spot light.
  9782. */
  9783. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9784. /**
  9785. * Light type const id of the hemispheric light.
  9786. */
  9787. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9788. /**
  9789. * Diffuse gives the basic color to an object.
  9790. */
  9791. diffuse: Color3;
  9792. /**
  9793. * Specular produces a highlight color on an object.
  9794. * Note: This is note affecting PBR materials.
  9795. */
  9796. specular: Color3;
  9797. /**
  9798. * Strength of the light.
  9799. * Note: By default it is define in the framework own unit.
  9800. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9801. */
  9802. intensity: number;
  9803. /**
  9804. * Defines how far from the source the light is impacting in scene units.
  9805. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9806. */
  9807. range: number;
  9808. /**
  9809. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9810. * of light.
  9811. */
  9812. private _photometricScale;
  9813. private _intensityMode;
  9814. /**
  9815. * Gets the photometric scale used to interpret the intensity.
  9816. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9817. */
  9818. /**
  9819. * Sets the photometric scale used to interpret the intensity.
  9820. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9821. */
  9822. intensityMode: number;
  9823. private _radius;
  9824. /**
  9825. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9826. */
  9827. /**
  9828. * sets the light radius used by PBR Materials to simulate soft area lights.
  9829. */
  9830. radius: number;
  9831. private _renderPriority;
  9832. /**
  9833. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9834. * exceeding the number allowed of the materials.
  9835. */
  9836. renderPriority: number;
  9837. /**
  9838. * Defines wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9839. * the current shadow generator.
  9840. */
  9841. shadowEnabled: boolean;
  9842. private _includedOnlyMeshes;
  9843. /**
  9844. * Gets the only meshes impacted by this light.
  9845. */
  9846. /**
  9847. * Sets the only meshes impacted by this light.
  9848. */
  9849. includedOnlyMeshes: AbstractMesh[];
  9850. private _excludedMeshes;
  9851. /**
  9852. * Gets the meshes not impacted by this light.
  9853. */
  9854. /**
  9855. * Sets the meshes not impacted by this light.
  9856. */
  9857. excludedMeshes: AbstractMesh[];
  9858. private _excludeWithLayerMask;
  9859. /**
  9860. * Gets the layer id use to find what meshes are not impacted by the light.
  9861. * Inactive if 0
  9862. */
  9863. /**
  9864. * Sets the layer id use to find what meshes are not impacted by the light.
  9865. * Inactive if 0
  9866. */
  9867. excludeWithLayerMask: number;
  9868. private _includeOnlyWithLayerMask;
  9869. /**
  9870. * Gets the layer id use to find what meshes are impacted by the light.
  9871. * Inactive if 0
  9872. */
  9873. /**
  9874. * Sets the layer id use to find what meshes are impacted by the light.
  9875. * Inactive if 0
  9876. */
  9877. includeOnlyWithLayerMask: number;
  9878. private _lightmapMode;
  9879. /**
  9880. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9881. */
  9882. /**
  9883. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9884. */
  9885. lightmapMode: number;
  9886. private _parentedWorldMatrix;
  9887. /**
  9888. * Shadow generator associted to the light.
  9889. * Internal use only.
  9890. */
  9891. _shadowGenerator: Nullable<IShadowGenerator>;
  9892. /**
  9893. * @ignore Internal use only.
  9894. */
  9895. _excludedMeshesIds: string[];
  9896. /**
  9897. * @ignore Internal use only.
  9898. */
  9899. _includedOnlyMeshesIds: string[];
  9900. /**
  9901. * The current light unifom buffer.
  9902. * @ignore Internal use only.
  9903. */
  9904. _uniformBuffer: UniformBuffer;
  9905. /**
  9906. * Creates a Light object in the scene.
  9907. * Documentation : http://doc.babylonjs.com/tutorials/lights
  9908. * @param name The firendly name of the light
  9909. * @param scene The scene the light belongs too
  9910. */
  9911. constructor(name: string, scene: Scene);
  9912. protected abstract _buildUniformLayout(): void;
  9913. /**
  9914. * Sets the passed Effect "effect" with the Light information.
  9915. * @param effect The effect to update
  9916. * @param lightIndex The index of the light in the effect to update
  9917. * @returns The light
  9918. */
  9919. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9920. /**
  9921. * @ignore internal use only.
  9922. */
  9923. abstract _getWorldMatrix(): Matrix;
  9924. /**
  9925. * Returns the string "Light".
  9926. * @returns the class name
  9927. */
  9928. getClassName(): string;
  9929. /**
  9930. * Converts the light information to a readable string for debug purpose.
  9931. * @param fullDetails Supports for multiple levels of logging within scene loading
  9932. * @returns the human readable light info
  9933. */
  9934. toString(fullDetails?: boolean): string;
  9935. /**
  9936. * Set the enabled state of this node.
  9937. * @param value - the new enabled state
  9938. */
  9939. setEnabled(value: boolean): void;
  9940. /**
  9941. * Returns the Light associated shadow generator if any.
  9942. * @return the associated shadow generator.
  9943. */
  9944. getShadowGenerator(): Nullable<IShadowGenerator>;
  9945. /**
  9946. * Returns a Vector3, the absolute light position in the World.
  9947. * @returns the world space position of the light
  9948. */
  9949. getAbsolutePosition(): Vector3;
  9950. /**
  9951. * Specifies if the light will affect the passed mesh.
  9952. * @param mesh The mesh to test against the light
  9953. * @return true the mesh is affected otherwise, false.
  9954. */
  9955. canAffectMesh(mesh: AbstractMesh): boolean;
  9956. /**
  9957. * Computes and Returns the light World matrix.
  9958. * @returns the world matrix
  9959. */
  9960. getWorldMatrix(): Matrix;
  9961. /**
  9962. * Sort function to order lights for rendering.
  9963. * @param a First Light object to compare to second.
  9964. * @param b Second Light object to compare first.
  9965. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9966. */
  9967. static CompareLightsPriority(a: Light, b: Light): number;
  9968. /**
  9969. * Releases resources associated with this node.
  9970. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9971. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9972. */
  9973. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9974. /**
  9975. * Returns the light type ID (integer).
  9976. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9977. */
  9978. getTypeID(): number;
  9979. /**
  9980. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9981. * @returns the scaled intensity in intensity mode unit
  9982. */
  9983. getScaledIntensity(): number;
  9984. /**
  9985. * Returns a new Light object, named "name", from the current one.
  9986. * @param name The name of the cloned light
  9987. * @returns the new created light
  9988. */
  9989. clone(name: string): Nullable<Light>;
  9990. /**
  9991. * Serializes the current light into a Serialization object.
  9992. * @returns the serialized object.
  9993. */
  9994. serialize(): any;
  9995. /**
  9996. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9997. * This new light is named "name" and added to the passed scene.
  9998. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9999. * @param name The friendly name of the light
  10000. * @param scene The scene the new light will belong to
  10001. * @returns the constructor function
  10002. */
  10003. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10004. /**
  10005. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10006. * @param parsedLight The JSON representation of the light
  10007. * @param scene The scene to create the parsed light in
  10008. * @returns the created light after parsing
  10009. */
  10010. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10011. private _hookArrayForExcluded(array);
  10012. private _hookArrayForIncludedOnly(array);
  10013. private _resyncMeshes();
  10014. /**
  10015. * Forces the meshes to update their light related information in their rendering used effects
  10016. * @ignore Internal Use Only
  10017. */
  10018. _markMeshesAsLightDirty(): void;
  10019. /**
  10020. * Recomputes the cached photometric scale if needed.
  10021. */
  10022. private _computePhotometricScale();
  10023. /**
  10024. * Returns the Photometric Scale according to the light type and intensity mode.
  10025. */
  10026. private _getPhotometricScale();
  10027. /**
  10028. * Reorder the light in the scene according to their defined priority.
  10029. * @ignore Internal Use Only
  10030. */
  10031. _reorderLightsInScene(): void;
  10032. }
  10033. }
  10034. declare module BABYLON {
  10035. /**
  10036. * A point light is a light defined by an unique point in world space.
  10037. * The light is emitted in every direction from this point.
  10038. * A good example of a point light is a standard light bulb.
  10039. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10040. */
  10041. class PointLight extends ShadowLight {
  10042. private _shadowAngle;
  10043. /**
  10044. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10045. * This specifies what angle the shadow will use to be created.
  10046. *
  10047. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  10048. */
  10049. /**
  10050. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10051. * This specifies what angle the shadow will use to be created.
  10052. *
  10053. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  10054. */
  10055. shadowAngle: number;
  10056. /**
  10057. * Gets the direction if it has been set.
  10058. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10059. */
  10060. /**
  10061. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10062. */
  10063. direction: Vector3;
  10064. /**
  10065. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  10066. * A PointLight emits the light in every direction.
  10067. * It can cast shadows.
  10068. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  10069. * ```javascript
  10070. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  10071. * ```
  10072. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10073. * @param name The light friendly name
  10074. * @param position The position of the point light in the scene
  10075. * @param scene The scene the lights belongs to
  10076. */
  10077. constructor(name: string, position: Vector3, scene: Scene);
  10078. /**
  10079. * Returns the string "PointLight"
  10080. * @returns the class name
  10081. */
  10082. getClassName(): string;
  10083. /**
  10084. * Returns the integer 0.
  10085. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10086. */
  10087. getTypeID(): number;
  10088. /**
  10089. * Specifies wether or not the shadowmap should be a cube texture.
  10090. * @returns true if the shadowmap needs to be a cube texture.
  10091. */
  10092. needCube(): boolean;
  10093. /**
  10094. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  10095. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10096. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10097. */
  10098. getShadowDirection(faceIndex?: number): Vector3;
  10099. /**
  10100. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  10101. * - fov = PI / 2
  10102. * - aspect ratio : 1.0
  10103. * - z-near and far equal to the active camera minZ and maxZ.
  10104. * Returns the PointLight.
  10105. */
  10106. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10107. protected _buildUniformLayout(): void;
  10108. /**
  10109. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  10110. * @param effect The effect to update
  10111. * @param lightIndex The index of the light in the effect to update
  10112. * @returns The point light
  10113. */
  10114. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  10115. }
  10116. }
  10117. declare module BABYLON {
  10118. /**
  10119. * Interface describing all the common properties and methods a shadow light needs to implement.
  10120. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10121. * as well as binding the different shadow properties to the effects.
  10122. */
  10123. interface IShadowLight extends Light {
  10124. /**
  10125. * The light id in the scene (used in scene.findLighById for instance)
  10126. */
  10127. id: string;
  10128. /**
  10129. * The position the shdow will be casted from.
  10130. */
  10131. position: Vector3;
  10132. /**
  10133. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10134. */
  10135. direction: Vector3;
  10136. /**
  10137. * The transformed position. Position of the light in world space taking parenting in account.
  10138. */
  10139. transformedPosition: Vector3;
  10140. /**
  10141. * The transformed direction. Direction of the light in world space taking parenting in account.
  10142. */
  10143. transformedDirection: Vector3;
  10144. /**
  10145. * The friendly name of the light in the scene.
  10146. */
  10147. name: string;
  10148. /**
  10149. * Defines the shadow projection clipping minimum z value.
  10150. */
  10151. shadowMinZ: number;
  10152. /**
  10153. * Defines the shadow projection clipping maximum z value.
  10154. */
  10155. shadowMaxZ: number;
  10156. /**
  10157. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10158. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10159. */
  10160. computeTransformedInformation(): boolean;
  10161. /**
  10162. * Gets the scene the light belongs to.
  10163. * @returns The scene
  10164. */
  10165. getScene(): Scene;
  10166. /**
  10167. * Callback defining a custom Projection Matrix Builder.
  10168. * This can be used to override the default projection matrix computation.
  10169. */
  10170. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10171. /**
  10172. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10173. * @param matrix The materix to updated with the projection information
  10174. * @param viewMatrix The transform matrix of the light
  10175. * @param renderList The list of mesh to render in the map
  10176. * @returns The current light
  10177. */
  10178. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10179. /**
  10180. * Gets the current depth scale used in ESM.
  10181. * @returns The scale
  10182. */
  10183. getDepthScale(): number;
  10184. /**
  10185. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10186. * @returns true if a cube texture needs to be use
  10187. */
  10188. needCube(): boolean;
  10189. /**
  10190. * Detects if the projection matrix requires to be recomputed this frame.
  10191. * @returns true if it requires to be recomputed otherwise, false.
  10192. */
  10193. needProjectionMatrixCompute(): boolean;
  10194. /**
  10195. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10196. */
  10197. forceProjectionMatrixCompute(): void;
  10198. /**
  10199. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10200. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10201. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10202. */
  10203. getShadowDirection(faceIndex?: number): Vector3;
  10204. /**
  10205. * Gets the minZ used for shadow according to both the scene and the light.
  10206. * @param activeCamera The camera we are returning the min for
  10207. * @returns the depth min z
  10208. */
  10209. getDepthMinZ(activeCamera: Camera): number;
  10210. /**
  10211. * Gets the maxZ used for shadow according to both the scene and the light.
  10212. * @param activeCamera The camera we are returning the max for
  10213. * @returns the depth max z
  10214. */
  10215. getDepthMaxZ(activeCamera: Camera): number;
  10216. }
  10217. /**
  10218. * Base implementation IShadowLight
  10219. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10220. */
  10221. abstract class ShadowLight extends Light implements IShadowLight {
  10222. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10223. protected _position: Vector3;
  10224. protected _setPosition(value: Vector3): void;
  10225. /**
  10226. * Sets the position the shadow will be casted from. Also use as the light position for both
  10227. * point and spot lights.
  10228. */
  10229. /**
  10230. * Sets the position the shadow will be casted from. Also use as the light position for both
  10231. * point and spot lights.
  10232. */
  10233. position: Vector3;
  10234. protected _direction: Vector3;
  10235. protected _setDirection(value: Vector3): void;
  10236. /**
  10237. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10238. * Also use as the light direction on spot and directional lights.
  10239. */
  10240. /**
  10241. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10242. * Also use as the light direction on spot and directional lights.
  10243. */
  10244. direction: Vector3;
  10245. private _shadowMinZ;
  10246. /**
  10247. * Gets the shadow projection clipping minimum z value.
  10248. */
  10249. /**
  10250. * Sets the shadow projection clipping minimum z value.
  10251. */
  10252. shadowMinZ: number;
  10253. private _shadowMaxZ;
  10254. /**
  10255. * Sets the shadow projection clipping maximum z value.
  10256. */
  10257. /**
  10258. * Gets the shadow projection clipping maximum z value.
  10259. */
  10260. shadowMaxZ: number;
  10261. /**
  10262. * Callback defining a custom Projection Matrix Builder.
  10263. * This can be used to override the default projection matrix computation.
  10264. */
  10265. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10266. /**
  10267. * The transformed position. Position of the light in world space taking parenting in account.
  10268. */
  10269. transformedPosition: Vector3;
  10270. /**
  10271. * The transformed direction. Direction of the light in world space taking parenting in account.
  10272. */
  10273. transformedDirection: Vector3;
  10274. private _worldMatrix;
  10275. private _needProjectionMatrixCompute;
  10276. /**
  10277. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10278. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10279. */
  10280. computeTransformedInformation(): boolean;
  10281. /**
  10282. * Return the depth scale used for the shadow map.
  10283. * @returns the depth scale.
  10284. */
  10285. getDepthScale(): number;
  10286. /**
  10287. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10288. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10289. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10290. */
  10291. getShadowDirection(faceIndex?: number): Vector3;
  10292. /**
  10293. * Returns the ShadowLight absolute position in the World.
  10294. * @returns the position vector in world space
  10295. */
  10296. getAbsolutePosition(): Vector3;
  10297. /**
  10298. * Sets the ShadowLight direction toward the passed target.
  10299. * @param target The point tot target in local space
  10300. * @returns the updated ShadowLight direction
  10301. */
  10302. setDirectionToTarget(target: Vector3): Vector3;
  10303. /**
  10304. * Returns the light rotation in euler definition.
  10305. * @returns the x y z rotation in local space.
  10306. */
  10307. getRotation(): Vector3;
  10308. /**
  10309. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10310. * @returns true if a cube texture needs to be use
  10311. */
  10312. needCube(): boolean;
  10313. /**
  10314. * Detects if the projection matrix requires to be recomputed this frame.
  10315. * @returns true if it requires to be recomputed otherwise, false.
  10316. */
  10317. needProjectionMatrixCompute(): boolean;
  10318. /**
  10319. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10320. */
  10321. forceProjectionMatrixCompute(): void;
  10322. /**
  10323. * Get the world matrix of the sahdow lights.
  10324. * @ignore Internal Use Only
  10325. */
  10326. _getWorldMatrix(): Matrix;
  10327. /**
  10328. * Gets the minZ used for shadow according to both the scene and the light.
  10329. * @param activeCamera The camera we are returning the min for
  10330. * @returns the depth min z
  10331. */
  10332. getDepthMinZ(activeCamera: Camera): number;
  10333. /**
  10334. * Gets the maxZ used for shadow according to both the scene and the light.
  10335. * @param activeCamera The camera we are returning the max for
  10336. * @returns the depth max z
  10337. */
  10338. getDepthMaxZ(activeCamera: Camera): number;
  10339. /**
  10340. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10341. * @param matrix The materix to updated with the projection information
  10342. * @param viewMatrix The transform matrix of the light
  10343. * @param renderList The list of mesh to render in the map
  10344. * @returns The current light
  10345. */
  10346. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10347. }
  10348. }
  10349. declare module BABYLON {
  10350. /**
  10351. * A spot light is defined by a position, a direction, an angle, and an exponent.
  10352. * These values define a cone of light starting from the position, emitting toward the direction.
  10353. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  10354. * and the exponent defines the speed of the decay of the light with distance (reach).
  10355. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10356. */
  10357. class SpotLight extends ShadowLight {
  10358. private _angle;
  10359. /**
  10360. * Gets the cone angle of the spot light in Radians.
  10361. */
  10362. /**
  10363. * Sets the cone angle of the spot light in Radians.
  10364. */
  10365. angle: number;
  10366. private _shadowAngleScale;
  10367. /**
  10368. * Allows scaling the angle of the light for shadow generation only.
  10369. */
  10370. /**
  10371. * Allows scaling the angle of the light for shadow generation only.
  10372. */
  10373. shadowAngleScale: number;
  10374. /**
  10375. * The light decay speed with the distance from the emission spot.
  10376. */
  10377. exponent: number;
  10378. private _projectionTextureMatrix;
  10379. /**
  10380. * Allows reading the projecton texture
  10381. */
  10382. readonly projectionTextureMatrix: Matrix;
  10383. protected _projectionTextureLightNear: number;
  10384. /**
  10385. * Gets the near clip of the Spotlight for texture projection.
  10386. */
  10387. /**
  10388. * Sets the near clip of the Spotlight for texture projection.
  10389. */
  10390. projectionTextureLightNear: number;
  10391. protected _projectionTextureLightFar: number;
  10392. /**
  10393. * Gets the far clip of the Spotlight for texture projection.
  10394. */
  10395. /**
  10396. * Sets the far clip of the Spotlight for texture projection.
  10397. */
  10398. projectionTextureLightFar: number;
  10399. protected _projectionTextureUpDirection: Vector3;
  10400. /**
  10401. * Gets the Up vector of the Spotlight for texture projection.
  10402. */
  10403. /**
  10404. * Sets the Up vector of the Spotlight for texture projection.
  10405. */
  10406. projectionTextureUpDirection: Vector3;
  10407. private _projectionTexture;
  10408. /**
  10409. * Gets the projection texture of the light.
  10410. */
  10411. /**
  10412. * Sets the projection texture of the light.
  10413. */
  10414. projectionTexture: Nullable<BaseTexture>;
  10415. private _projectionTextureViewLightDirty;
  10416. private _projectionTextureProjectionLightDirty;
  10417. private _projectionTextureDirty;
  10418. private _projectionTextureViewTargetVector;
  10419. private _projectionTextureViewLightMatrix;
  10420. private _projectionTextureProjectionLightMatrix;
  10421. private _projectionTextureScalingMatrix;
  10422. /**
  10423. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  10424. * It can cast shadows.
  10425. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10426. * @param name The light friendly name
  10427. * @param position The position of the spot light in the scene
  10428. * @param direction The direction of the light in the scene
  10429. * @param angle The cone angle of the light in Radians
  10430. * @param exponent The light decay speed with the distance from the emission spot
  10431. * @param scene The scene the lights belongs to
  10432. */
  10433. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  10434. /**
  10435. * Returns the string "SpotLight".
  10436. * @returns the class name
  10437. */
  10438. getClassName(): string;
  10439. /**
  10440. * Returns the integer 2.
  10441. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10442. */
  10443. getTypeID(): number;
  10444. /**
  10445. * Overrides the direction setter to recompute the projection texture view light Matrix.
  10446. */
  10447. protected _setDirection(value: Vector3): void;
  10448. /**
  10449. * Overrides the position setter to recompute the projection texture view light Matrix.
  10450. */
  10451. protected _setPosition(value: Vector3): void;
  10452. /**
  10453. * 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.
  10454. * Returns the SpotLight.
  10455. */
  10456. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10457. protected _computeProjectionTextureViewLightMatrix(): void;
  10458. protected _computeProjectionTextureProjectionLightMatrix(): void;
  10459. /**
  10460. * Main function for light texture projection matrix computing.
  10461. */
  10462. protected _computeProjectionTextureMatrix(): void;
  10463. protected _buildUniformLayout(): void;
  10464. /**
  10465. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  10466. * @param effect The effect to update
  10467. * @param lightIndex The index of the light in the effect to update
  10468. * @returns The spot light
  10469. */
  10470. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  10471. /**
  10472. * Disposes the light and the associated resources.
  10473. */
  10474. dispose(): void;
  10475. }
  10476. }
  10477. declare module BABYLON {
  10478. /**
  10479. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  10480. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  10481. * 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;
  10482. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  10483. */
  10484. class ColorCurves {
  10485. private _dirty;
  10486. private _tempColor;
  10487. private _globalCurve;
  10488. private _highlightsCurve;
  10489. private _midtonesCurve;
  10490. private _shadowsCurve;
  10491. private _positiveCurve;
  10492. private _negativeCurve;
  10493. private _globalHue;
  10494. private _globalDensity;
  10495. private _globalSaturation;
  10496. private _globalExposure;
  10497. /**
  10498. * Gets the global Hue value.
  10499. * 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).
  10500. */
  10501. /**
  10502. * Sets the global Hue value.
  10503. * 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).
  10504. */
  10505. globalHue: number;
  10506. /**
  10507. * Gets the global Density value.
  10508. * 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.
  10509. * Values less than zero provide a filter of opposite hue.
  10510. */
  10511. /**
  10512. * Sets the global Density value.
  10513. * 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.
  10514. * Values less than zero provide a filter of opposite hue.
  10515. */
  10516. globalDensity: number;
  10517. /**
  10518. * Gets the global Saturation value.
  10519. * 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.
  10520. */
  10521. /**
  10522. * Sets the global Saturation value.
  10523. * 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.
  10524. */
  10525. globalSaturation: number;
  10526. private _highlightsHue;
  10527. private _highlightsDensity;
  10528. private _highlightsSaturation;
  10529. private _highlightsExposure;
  10530. /**
  10531. * Gets the highlights Hue value.
  10532. * 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).
  10533. */
  10534. /**
  10535. * Sets the highlights Hue value.
  10536. * 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).
  10537. */
  10538. highlightsHue: number;
  10539. /**
  10540. * Gets the highlights Density value.
  10541. * 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.
  10542. * Values less than zero provide a filter of opposite hue.
  10543. */
  10544. /**
  10545. * Sets the highlights Density value.
  10546. * 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.
  10547. * Values less than zero provide a filter of opposite hue.
  10548. */
  10549. highlightsDensity: number;
  10550. /**
  10551. * Gets the highlights Saturation value.
  10552. * 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.
  10553. */
  10554. /**
  10555. * Sets the highlights Saturation value.
  10556. * 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.
  10557. */
  10558. highlightsSaturation: number;
  10559. /**
  10560. * Gets the highlights Exposure value.
  10561. * 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.
  10562. */
  10563. /**
  10564. * Sets the highlights Exposure value.
  10565. * 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.
  10566. */
  10567. highlightsExposure: number;
  10568. private _midtonesHue;
  10569. private _midtonesDensity;
  10570. private _midtonesSaturation;
  10571. private _midtonesExposure;
  10572. /**
  10573. * Gets the midtones Hue value.
  10574. * 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).
  10575. */
  10576. /**
  10577. * Sets the midtones Hue value.
  10578. * 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).
  10579. */
  10580. midtonesHue: number;
  10581. /**
  10582. * Gets the midtones Density value.
  10583. * 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.
  10584. * Values less than zero provide a filter of opposite hue.
  10585. */
  10586. /**
  10587. * Sets the midtones Density value.
  10588. * 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.
  10589. * Values less than zero provide a filter of opposite hue.
  10590. */
  10591. midtonesDensity: number;
  10592. /**
  10593. * Gets the midtones Saturation value.
  10594. * 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.
  10595. */
  10596. /**
  10597. * Sets the midtones Saturation value.
  10598. * 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.
  10599. */
  10600. midtonesSaturation: number;
  10601. /**
  10602. * Gets the midtones Exposure value.
  10603. * 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.
  10604. */
  10605. /**
  10606. * Sets the midtones Exposure value.
  10607. * 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.
  10608. */
  10609. midtonesExposure: number;
  10610. private _shadowsHue;
  10611. private _shadowsDensity;
  10612. private _shadowsSaturation;
  10613. private _shadowsExposure;
  10614. /**
  10615. * Gets the shadows Hue value.
  10616. * 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).
  10617. */
  10618. /**
  10619. * Sets the shadows Hue value.
  10620. * 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).
  10621. */
  10622. shadowsHue: number;
  10623. /**
  10624. * Gets the shadows Density value.
  10625. * 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.
  10626. * Values less than zero provide a filter of opposite hue.
  10627. */
  10628. /**
  10629. * Sets the shadows Density value.
  10630. * 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.
  10631. * Values less than zero provide a filter of opposite hue.
  10632. */
  10633. shadowsDensity: number;
  10634. /**
  10635. * Gets the shadows Saturation value.
  10636. * 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.
  10637. */
  10638. /**
  10639. * Sets the shadows Saturation value.
  10640. * 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.
  10641. */
  10642. shadowsSaturation: number;
  10643. /**
  10644. * Gets the shadows Exposure value.
  10645. * 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.
  10646. */
  10647. /**
  10648. * Sets the shadows Exposure value.
  10649. * 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.
  10650. */
  10651. shadowsExposure: number;
  10652. getClassName(): string;
  10653. /**
  10654. * Binds the color curves to the shader.
  10655. * @param colorCurves The color curve to bind
  10656. * @param effect The effect to bind to
  10657. */
  10658. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  10659. /**
  10660. * Prepare the list of uniforms associated with the ColorCurves effects.
  10661. * @param uniformsList The list of uniforms used in the effect
  10662. */
  10663. static PrepareUniforms(uniformsList: string[]): void;
  10664. /**
  10665. * Returns color grading data based on a hue, density, saturation and exposure value.
  10666. * @param filterHue The hue of the color filter.
  10667. * @param filterDensity The density of the color filter.
  10668. * @param saturation The saturation.
  10669. * @param exposure The exposure.
  10670. * @param result The result data container.
  10671. */
  10672. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  10673. /**
  10674. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  10675. * @param value The input slider value in range [-100,100].
  10676. * @returns Adjusted value.
  10677. */
  10678. private static applyColorGradingSliderNonlinear(value);
  10679. /**
  10680. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  10681. * @param hue The hue (H) input.
  10682. * @param saturation The saturation (S) input.
  10683. * @param brightness The brightness (B) input.
  10684. * @result An RGBA color represented as Vector4.
  10685. */
  10686. private static fromHSBToRef(hue, saturation, brightness, result);
  10687. /**
  10688. * Returns a value clamped between min and max
  10689. * @param value The value to clamp
  10690. * @param min The minimum of value
  10691. * @param max The maximum of value
  10692. * @returns The clamped value.
  10693. */
  10694. private static clamp(value, min, max);
  10695. /**
  10696. * Clones the current color curve instance.
  10697. * @return The cloned curves
  10698. */
  10699. clone(): ColorCurves;
  10700. /**
  10701. * Serializes the current color curve instance to a json representation.
  10702. * @return a JSON representation
  10703. */
  10704. serialize(): any;
  10705. /**
  10706. * Parses the color curve from a json representation.
  10707. * @param source the JSON source to parse
  10708. * @return The parsed curves
  10709. */
  10710. static Parse(source: any): ColorCurves;
  10711. }
  10712. }
  10713. declare module BABYLON {
  10714. /**
  10715. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  10716. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  10717. */
  10718. class EffectFallbacks {
  10719. private _defines;
  10720. private _currentRank;
  10721. private _maxRank;
  10722. private _mesh;
  10723. /**
  10724. * Removes the fallback from the bound mesh.
  10725. */
  10726. unBindMesh(): void;
  10727. /**
  10728. * Adds a fallback on the specified property.
  10729. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  10730. * @param define The name of the define in the shader
  10731. */
  10732. addFallback(rank: number, define: string): void;
  10733. /**
  10734. * Sets the mesh to use CPU skinning when needing to fallback.
  10735. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  10736. * @param mesh The mesh to use the fallbacks.
  10737. */
  10738. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  10739. /**
  10740. * Checks to see if more fallbacks are still availible.
  10741. */
  10742. readonly isMoreFallbacks: boolean;
  10743. /**
  10744. * Removes the defines that shoould be removed when falling back.
  10745. * @param currentDefines defines the current define statements for the shader.
  10746. * @param effect defines the current effect we try to compile
  10747. * @returns The resulting defines with defines of the current rank removed.
  10748. */
  10749. reduce(currentDefines: string, effect: Effect): string;
  10750. }
  10751. /**
  10752. * Options to be used when creating an effect.
  10753. */
  10754. class EffectCreationOptions {
  10755. /**
  10756. * Atrributes that will be used in the shader.
  10757. */
  10758. attributes: string[];
  10759. /**
  10760. * Uniform varible names that will be set in the shader.
  10761. */
  10762. uniformsNames: string[];
  10763. /**
  10764. * Uniform buffer varible names that will be set in the shader.
  10765. */
  10766. uniformBuffersNames: string[];
  10767. /**
  10768. * Sampler texture variable names that will be set in the shader.
  10769. */
  10770. samplers: string[];
  10771. /**
  10772. * Define statements that will be set in the shader.
  10773. */
  10774. defines: any;
  10775. /**
  10776. * Possible fallbacks for this effect to improve performance when needed.
  10777. */
  10778. fallbacks: Nullable<EffectFallbacks>;
  10779. /**
  10780. * Callback that will be called when the shader is compiled.
  10781. */
  10782. onCompiled: Nullable<(effect: Effect) => void>;
  10783. /**
  10784. * Callback that will be called if an error occurs during shader compilation.
  10785. */
  10786. onError: Nullable<(effect: Effect, errors: string) => void>;
  10787. /**
  10788. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  10789. */
  10790. indexParameters: any;
  10791. /**
  10792. * Max number of lights that can be used in the shader.
  10793. */
  10794. maxSimultaneousLights: number;
  10795. /**
  10796. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  10797. */
  10798. transformFeedbackVaryings: Nullable<string[]>;
  10799. }
  10800. /**
  10801. * Effect containing vertex and fragment shader that can be executed on an object.
  10802. */
  10803. class Effect {
  10804. /**
  10805. * Name of the effect.
  10806. */
  10807. name: any;
  10808. /**
  10809. * String container all the define statements that should be set on the shader.
  10810. */
  10811. defines: string;
  10812. /**
  10813. * Callback that will be called when the shader is compiled.
  10814. */
  10815. onCompiled: Nullable<(effect: Effect) => void>;
  10816. /**
  10817. * Callback that will be called if an error occurs during shader compilation.
  10818. */
  10819. onError: Nullable<(effect: Effect, errors: string) => void>;
  10820. /**
  10821. * Callback that will be called when effect is bound.
  10822. */
  10823. onBind: Nullable<(effect: Effect) => void>;
  10824. /**
  10825. * Unique ID of the effect.
  10826. */
  10827. uniqueId: number;
  10828. /**
  10829. * Observable that will be called when the shader is compiled.
  10830. */
  10831. onCompileObservable: Observable<Effect>;
  10832. /**
  10833. * Observable that will be called if an error occurs during shader compilation.
  10834. */
  10835. onErrorObservable: Observable<Effect>;
  10836. /**
  10837. * Observable that will be called when effect is bound.
  10838. */
  10839. onBindObservable: Observable<Effect>;
  10840. private static _uniqueIdSeed;
  10841. private _engine;
  10842. private _uniformBuffersNames;
  10843. private _uniformsNames;
  10844. private _samplers;
  10845. private _isReady;
  10846. private _compilationError;
  10847. private _attributesNames;
  10848. private _attributes;
  10849. private _uniforms;
  10850. /**
  10851. * Key for the effect.
  10852. */
  10853. _key: string;
  10854. private _indexParameters;
  10855. private _fallbacks;
  10856. private _vertexSourceCode;
  10857. private _fragmentSourceCode;
  10858. private _vertexSourceCodeOverride;
  10859. private _fragmentSourceCodeOverride;
  10860. private _transformFeedbackVaryings;
  10861. /**
  10862. * Compiled shader to webGL program.
  10863. */
  10864. _program: WebGLProgram;
  10865. private _valueCache;
  10866. private static _baseCache;
  10867. /**
  10868. * Instantiates an effect.
  10869. * An effect can be used to create/manage/execute vertex and fragment shaders.
  10870. * @param baseName Name of the effect.
  10871. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  10872. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  10873. * @param samplers List of sampler variables that will be passed to the shader.
  10874. * @param engine Engine to be used to render the effect
  10875. * @param defines Define statements to be added to the shader.
  10876. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  10877. * @param onCompiled Callback that will be called when the shader is compiled.
  10878. * @param onError Callback that will be called if an error occurs during shader compilation.
  10879. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  10880. */
  10881. 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);
  10882. /**
  10883. * Unique key for this effect
  10884. */
  10885. readonly key: string;
  10886. /**
  10887. * If the effect has been compiled and prepared.
  10888. * @returns if the effect is compiled and prepared.
  10889. */
  10890. isReady(): boolean;
  10891. /**
  10892. * The engine the effect was initialized with.
  10893. * @returns the engine.
  10894. */
  10895. getEngine(): Engine;
  10896. /**
  10897. * The compiled webGL program for the effect
  10898. * @returns the webGL program.
  10899. */
  10900. getProgram(): WebGLProgram;
  10901. /**
  10902. * The set of names of attribute variables for the shader.
  10903. * @returns An array of attribute names.
  10904. */
  10905. getAttributesNames(): string[];
  10906. /**
  10907. * Returns the attribute at the given index.
  10908. * @param index The index of the attribute.
  10909. * @returns The location of the attribute.
  10910. */
  10911. getAttributeLocation(index: number): number;
  10912. /**
  10913. * Returns the attribute based on the name of the variable.
  10914. * @param name of the attribute to look up.
  10915. * @returns the attribute location.
  10916. */
  10917. getAttributeLocationByName(name: string): number;
  10918. /**
  10919. * The number of attributes.
  10920. * @returns the numnber of attributes.
  10921. */
  10922. getAttributesCount(): number;
  10923. /**
  10924. * Gets the index of a uniform variable.
  10925. * @param uniformName of the uniform to look up.
  10926. * @returns the index.
  10927. */
  10928. getUniformIndex(uniformName: string): number;
  10929. /**
  10930. * Returns the attribute based on the name of the variable.
  10931. * @param uniformName of the uniform to look up.
  10932. * @returns the location of the uniform.
  10933. */
  10934. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  10935. /**
  10936. * Returns an array of sampler variable names
  10937. * @returns The array of sampler variable neames.
  10938. */
  10939. getSamplers(): string[];
  10940. /**
  10941. * The error from the last compilation.
  10942. * @returns the error string.
  10943. */
  10944. getCompilationError(): string;
  10945. /**
  10946. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  10947. * @param func The callback to be used.
  10948. */
  10949. executeWhenCompiled(func: (effect: Effect) => void): void;
  10950. /** @ignore */
  10951. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  10952. /** @ignore */
  10953. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  10954. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  10955. private _processShaderConversion(sourceCode, isFragment, callback);
  10956. private _processIncludes(sourceCode, callback);
  10957. private _processPrecision(source);
  10958. /**
  10959. * Recompiles the webGL program
  10960. * @param vertexSourceCode The source code for the vertex shader.
  10961. * @param fragmentSourceCode The source code for the fragment shader.
  10962. * @param onCompiled Callback called when completed.
  10963. * @param onError Callback called on error.
  10964. */
  10965. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  10966. /**
  10967. * Gets the uniform locations of the the specified variable names
  10968. * @param names THe names of the variables to lookup.
  10969. * @returns Array of locations in the same order as variable names.
  10970. */
  10971. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  10972. /**
  10973. * Prepares the effect
  10974. */
  10975. _prepareEffect(): void;
  10976. /**
  10977. * Checks if the effect is supported. (Must be called after compilation)
  10978. */
  10979. readonly isSupported: boolean;
  10980. /**
  10981. * Binds a texture to the engine to be used as output of the shader.
  10982. * @param channel Name of the output variable.
  10983. * @param texture Texture to bind.
  10984. */
  10985. _bindTexture(channel: string, texture: InternalTexture): void;
  10986. /**
  10987. * Sets a texture on the engine to be used in the shader.
  10988. * @param channel Name of the sampler variable.
  10989. * @param texture Texture to set.
  10990. */
  10991. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  10992. /**
  10993. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  10994. * @param channel Name of the sampler variable.
  10995. * @param texture Texture to set.
  10996. */
  10997. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  10998. /**
  10999. * Sets an array of textures on the engine to be used in the shader.
  11000. * @param channel Name of the variable.
  11001. * @param textures Textures to set.
  11002. */
  11003. setTextureArray(channel: string, textures: BaseTexture[]): void;
  11004. /**
  11005. * 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)
  11006. * @param channel Name of the sampler variable.
  11007. * @param postProcess Post process to get the input texture from.
  11008. */
  11009. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  11010. /**
  11011. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  11012. * 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)
  11013. * @param channel Name of the sampler variable.
  11014. * @param postProcess Post process to get the output texture from.
  11015. */
  11016. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  11017. /** @ignore */
  11018. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  11019. /** @ignore */
  11020. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  11021. /** @ignore */
  11022. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  11023. /** @ignore */
  11024. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  11025. /**
  11026. * Binds a buffer to a uniform.
  11027. * @param buffer Buffer to bind.
  11028. * @param name Name of the uniform variable to bind to.
  11029. */
  11030. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  11031. /**
  11032. * Binds block to a uniform.
  11033. * @param blockName Name of the block to bind.
  11034. * @param index Index to bind.
  11035. */
  11036. bindUniformBlock(blockName: string, index: number): void;
  11037. /**
  11038. * Sets an interger value on a uniform variable.
  11039. * @param uniformName Name of the variable.
  11040. * @param value Value to be set.
  11041. * @returns this effect.
  11042. */
  11043. setInt(uniformName: string, value: number): Effect;
  11044. /**
  11045. * Sets an int array on a uniform variable.
  11046. * @param uniformName Name of the variable.
  11047. * @param array array to be set.
  11048. * @returns this effect.
  11049. */
  11050. setIntArray(uniformName: string, array: Int32Array): Effect;
  11051. /**
  11052. * 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)
  11053. * @param uniformName Name of the variable.
  11054. * @param array array to be set.
  11055. * @returns this effect.
  11056. */
  11057. setIntArray2(uniformName: string, array: Int32Array): Effect;
  11058. /**
  11059. * 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)
  11060. * @param uniformName Name of the variable.
  11061. * @param array array to be set.
  11062. * @returns this effect.
  11063. */
  11064. setIntArray3(uniformName: string, array: Int32Array): Effect;
  11065. /**
  11066. * 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)
  11067. * @param uniformName Name of the variable.
  11068. * @param array array to be set.
  11069. * @returns this effect.
  11070. */
  11071. setIntArray4(uniformName: string, array: Int32Array): Effect;
  11072. /**
  11073. * Sets an float array on a uniform variable.
  11074. * @param uniformName Name of the variable.
  11075. * @param array array to be set.
  11076. * @returns this effect.
  11077. */
  11078. setFloatArray(uniformName: string, array: Float32Array): Effect;
  11079. /**
  11080. * 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)
  11081. * @param uniformName Name of the variable.
  11082. * @param array array to be set.
  11083. * @returns this effect.
  11084. */
  11085. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  11086. /**
  11087. * 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)
  11088. * @param uniformName Name of the variable.
  11089. * @param array array to be set.
  11090. * @returns this effect.
  11091. */
  11092. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  11093. /**
  11094. * 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)
  11095. * @param uniformName Name of the variable.
  11096. * @param array array to be set.
  11097. * @returns this effect.
  11098. */
  11099. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  11100. /**
  11101. * Sets an array on a uniform variable.
  11102. * @param uniformName Name of the variable.
  11103. * @param array array to be set.
  11104. * @returns this effect.
  11105. */
  11106. setArray(uniformName: string, array: number[]): Effect;
  11107. /**
  11108. * 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)
  11109. * @param uniformName Name of the variable.
  11110. * @param array array to be set.
  11111. * @returns this effect.
  11112. */
  11113. setArray2(uniformName: string, array: number[]): Effect;
  11114. /**
  11115. * 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)
  11116. * @param uniformName Name of the variable.
  11117. * @param array array to be set.
  11118. * @returns this effect.
  11119. */
  11120. setArray3(uniformName: string, array: number[]): Effect;
  11121. /**
  11122. * 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)
  11123. * @param uniformName Name of the variable.
  11124. * @param array array to be set.
  11125. * @returns this effect.
  11126. */
  11127. setArray4(uniformName: string, array: number[]): Effect;
  11128. /**
  11129. * Sets matrices on a uniform variable.
  11130. * @param uniformName Name of the variable.
  11131. * @param matrices matrices to be set.
  11132. * @returns this effect.
  11133. */
  11134. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  11135. /**
  11136. * Sets matrix on a uniform variable.
  11137. * @param uniformName Name of the variable.
  11138. * @param matrix matrix to be set.
  11139. * @returns this effect.
  11140. */
  11141. setMatrix(uniformName: string, matrix: Matrix): Effect;
  11142. /**
  11143. * 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)
  11144. * @param uniformName Name of the variable.
  11145. * @param matrix matrix to be set.
  11146. * @returns this effect.
  11147. */
  11148. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  11149. /**
  11150. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  11151. * @param uniformName Name of the variable.
  11152. * @param matrix matrix to be set.
  11153. * @returns this effect.
  11154. */
  11155. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  11156. /**
  11157. * Sets a float on a uniform variable.
  11158. * @param uniformName Name of the variable.
  11159. * @param value value to be set.
  11160. * @returns this effect.
  11161. */
  11162. setFloat(uniformName: string, value: number): Effect;
  11163. /**
  11164. * Sets a boolean on a uniform variable.
  11165. * @param uniformName Name of the variable.
  11166. * @param bool value to be set.
  11167. * @returns this effect.
  11168. */
  11169. setBool(uniformName: string, bool: boolean): Effect;
  11170. /**
  11171. * Sets a Vector2 on a uniform variable.
  11172. * @param uniformName Name of the variable.
  11173. * @param vector2 vector2 to be set.
  11174. * @returns this effect.
  11175. */
  11176. setVector2(uniformName: string, vector2: Vector2): Effect;
  11177. /**
  11178. * Sets a float2 on a uniform variable.
  11179. * @param uniformName Name of the variable.
  11180. * @param x First float in float2.
  11181. * @param y Second float in float2.
  11182. * @returns this effect.
  11183. */
  11184. setFloat2(uniformName: string, x: number, y: number): Effect;
  11185. /**
  11186. * Sets a Vector3 on a uniform variable.
  11187. * @param uniformName Name of the variable.
  11188. * @param vector3 Value to be set.
  11189. * @returns this effect.
  11190. */
  11191. setVector3(uniformName: string, vector3: Vector3): Effect;
  11192. /**
  11193. * Sets a float3 on a uniform variable.
  11194. * @param uniformName Name of the variable.
  11195. * @param x First float in float3.
  11196. * @param y Second float in float3.
  11197. * @param z Third float in float3.
  11198. * @returns this effect.
  11199. */
  11200. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  11201. /**
  11202. * Sets a Vector4 on a uniform variable.
  11203. * @param uniformName Name of the variable.
  11204. * @param vector4 Value to be set.
  11205. * @returns this effect.
  11206. */
  11207. setVector4(uniformName: string, vector4: Vector4): Effect;
  11208. /**
  11209. * Sets a float4 on a uniform variable.
  11210. * @param uniformName Name of the variable.
  11211. * @param x First float in float4.
  11212. * @param y Second float in float4.
  11213. * @param z Third float in float4.
  11214. * @param w Fourth float in float4.
  11215. * @returns this effect.
  11216. */
  11217. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  11218. /**
  11219. * Sets a Color3 on a uniform variable.
  11220. * @param uniformName Name of the variable.
  11221. * @param color3 Value to be set.
  11222. * @returns this effect.
  11223. */
  11224. setColor3(uniformName: string, color3: Color3): Effect;
  11225. /**
  11226. * Sets a Color4 on a uniform variable.
  11227. * @param uniformName Name of the variable.
  11228. * @param color3 Value to be set.
  11229. * @param alpha Alpha value to be set.
  11230. * @returns this effect.
  11231. */
  11232. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  11233. /**
  11234. * Sets a Color4 on a uniform variable
  11235. * @param uniformName defines the name of the variable
  11236. * @param color4 defines the value to be set
  11237. * @returns this effect.
  11238. */
  11239. setDirectColor4(uniformName: string, color4: Color4): Effect;
  11240. /**
  11241. * Store of each shader (The can be looked up using effect.key)
  11242. */
  11243. static ShadersStore: {
  11244. [key: string]: string;
  11245. };
  11246. /**
  11247. * Store of each included file for a shader (The can be looked up using effect.key)
  11248. */
  11249. static IncludesShadersStore: {
  11250. [key: string]: string;
  11251. };
  11252. /**
  11253. * Resets the cache of effects.
  11254. */
  11255. static ResetCache(): void;
  11256. }
  11257. }
  11258. declare module BABYLON {
  11259. class FresnelParameters {
  11260. private _isEnabled;
  11261. isEnabled: boolean;
  11262. leftColor: Color3;
  11263. rightColor: Color3;
  11264. bias: number;
  11265. power: number;
  11266. clone(): FresnelParameters;
  11267. serialize(): any;
  11268. static Parse(parsedFresnelParameters: any): FresnelParameters;
  11269. }
  11270. }
  11271. declare module BABYLON {
  11272. /**
  11273. * Interface to follow in your material defines to integrate easily the
  11274. * Image proccessing functions.
  11275. * @ignore
  11276. */
  11277. interface IImageProcessingConfigurationDefines {
  11278. IMAGEPROCESSING: boolean;
  11279. VIGNETTE: boolean;
  11280. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11281. VIGNETTEBLENDMODEOPAQUE: boolean;
  11282. TONEMAPPING: boolean;
  11283. CONTRAST: boolean;
  11284. EXPOSURE: boolean;
  11285. COLORCURVES: boolean;
  11286. COLORGRADING: boolean;
  11287. COLORGRADING3D: boolean;
  11288. SAMPLER3DGREENDEPTH: boolean;
  11289. SAMPLER3DBGRMAP: boolean;
  11290. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11291. }
  11292. /**
  11293. * This groups together the common properties used for image processing either in direct forward pass
  11294. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11295. * or not.
  11296. */
  11297. class ImageProcessingConfiguration {
  11298. /**
  11299. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11300. */
  11301. colorCurves: Nullable<ColorCurves>;
  11302. private _colorCurvesEnabled;
  11303. /**
  11304. * Gets wether the color curves effect is enabled.
  11305. */
  11306. /**
  11307. * Sets wether the color curves effect is enabled.
  11308. */
  11309. colorCurvesEnabled: boolean;
  11310. /**
  11311. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11312. */
  11313. colorGradingTexture: Nullable<BaseTexture>;
  11314. private _colorGradingEnabled;
  11315. /**
  11316. * Gets wether the color grading effect is enabled.
  11317. */
  11318. /**
  11319. * Sets wether the color grading effect is enabled.
  11320. */
  11321. colorGradingEnabled: boolean;
  11322. private _colorGradingWithGreenDepth;
  11323. /**
  11324. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11325. */
  11326. /**
  11327. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11328. */
  11329. colorGradingWithGreenDepth: boolean;
  11330. private _colorGradingBGR;
  11331. /**
  11332. * Gets wether the color grading texture contains BGR values.
  11333. */
  11334. /**
  11335. * Sets wether the color grading texture contains BGR values.
  11336. */
  11337. colorGradingBGR: boolean;
  11338. _exposure: number;
  11339. /**
  11340. * Gets the Exposure used in the effect.
  11341. */
  11342. /**
  11343. * Sets the Exposure used in the effect.
  11344. */
  11345. exposure: number;
  11346. private _toneMappingEnabled;
  11347. /**
  11348. * Gets wether the tone mapping effect is enabled.
  11349. */
  11350. /**
  11351. * Sets wether the tone mapping effect is enabled.
  11352. */
  11353. toneMappingEnabled: boolean;
  11354. protected _contrast: number;
  11355. /**
  11356. * Gets the contrast used in the effect.
  11357. */
  11358. /**
  11359. * Sets the contrast used in the effect.
  11360. */
  11361. contrast: number;
  11362. /**
  11363. * Vignette stretch size.
  11364. */
  11365. vignetteStretch: number;
  11366. /**
  11367. * Vignette centre X Offset.
  11368. */
  11369. vignetteCentreX: number;
  11370. /**
  11371. * Vignette centre Y Offset.
  11372. */
  11373. vignetteCentreY: number;
  11374. /**
  11375. * Vignette weight or intensity of the vignette effect.
  11376. */
  11377. vignetteWeight: number;
  11378. /**
  11379. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11380. * if vignetteEnabled is set to true.
  11381. */
  11382. vignetteColor: Color4;
  11383. /**
  11384. * Camera field of view used by the Vignette effect.
  11385. */
  11386. vignetteCameraFov: number;
  11387. private _vignetteBlendMode;
  11388. /**
  11389. * Gets the vignette blend mode allowing different kind of effect.
  11390. */
  11391. /**
  11392. * Sets the vignette blend mode allowing different kind of effect.
  11393. */
  11394. vignetteBlendMode: number;
  11395. private _vignetteEnabled;
  11396. /**
  11397. * Gets wether the vignette effect is enabled.
  11398. */
  11399. /**
  11400. * Sets wether the vignette effect is enabled.
  11401. */
  11402. vignetteEnabled: boolean;
  11403. private _applyByPostProcess;
  11404. /**
  11405. * Gets wether the image processing is applied through a post process or not.
  11406. */
  11407. /**
  11408. * Sets wether the image processing is applied through a post process or not.
  11409. */
  11410. applyByPostProcess: boolean;
  11411. private _isEnabled;
  11412. /**
  11413. * Gets wether the image processing is enabled or not.
  11414. */
  11415. /**
  11416. * Sets wether the image processing is enabled or not.
  11417. */
  11418. isEnabled: boolean;
  11419. /**
  11420. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11421. */
  11422. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11423. /**
  11424. * Method called each time the image processing information changes requires to recompile the effect.
  11425. */
  11426. protected _updateParameters(): void;
  11427. getClassName(): string;
  11428. /**
  11429. * Prepare the list of uniforms associated with the Image Processing effects.
  11430. * @param uniformsList The list of uniforms used in the effect
  11431. * @param defines the list of defines currently in use
  11432. */
  11433. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11434. /**
  11435. * Prepare the list of samplers associated with the Image Processing effects.
  11436. * @param uniformsList The list of uniforms used in the effect
  11437. * @param defines the list of defines currently in use
  11438. */
  11439. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11440. /**
  11441. * Prepare the list of defines associated to the shader.
  11442. * @param defines the list of defines to complete
  11443. */
  11444. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11445. /**
  11446. * Returns true if all the image processing information are ready.
  11447. */
  11448. isReady(): boolean;
  11449. /**
  11450. * Binds the image processing to the shader.
  11451. * @param effect The effect to bind to
  11452. */
  11453. bind(effect: Effect, aspectRatio?: number): void;
  11454. /**
  11455. * Clones the current image processing instance.
  11456. * @return The cloned image processing
  11457. */
  11458. clone(): ImageProcessingConfiguration;
  11459. /**
  11460. * Serializes the current image processing instance to a json representation.
  11461. * @return a JSON representation
  11462. */
  11463. serialize(): any;
  11464. /**
  11465. * Parses the image processing from a json representation.
  11466. * @param source the JSON source to parse
  11467. * @return The parsed image processing
  11468. */
  11469. static Parse(source: any): ImageProcessingConfiguration;
  11470. private static _VIGNETTEMODE_MULTIPLY;
  11471. private static _VIGNETTEMODE_OPAQUE;
  11472. /**
  11473. * Used to apply the vignette as a mix with the pixel color.
  11474. */
  11475. static readonly VIGNETTEMODE_MULTIPLY: number;
  11476. /**
  11477. * Used to apply the vignette as a replacement of the pixel color.
  11478. */
  11479. static readonly VIGNETTEMODE_OPAQUE: number;
  11480. }
  11481. }
  11482. declare module BABYLON {
  11483. /**
  11484. * Manages the defines for the Material
  11485. */
  11486. class MaterialDefines {
  11487. private _keys;
  11488. private _isDirty;
  11489. _renderId: number;
  11490. _areLightsDirty: boolean;
  11491. _areAttributesDirty: boolean;
  11492. _areTexturesDirty: boolean;
  11493. _areFresnelDirty: boolean;
  11494. _areMiscDirty: boolean;
  11495. _areImageProcessingDirty: boolean;
  11496. _normals: boolean;
  11497. _uvs: boolean;
  11498. _needNormals: boolean;
  11499. _needUVs: boolean;
  11500. /**
  11501. * Specifies if the material needs to be re-calculated
  11502. */
  11503. readonly isDirty: boolean;
  11504. /**
  11505. * Marks the material to indicate that it has been re-calculated
  11506. */
  11507. markAsProcessed(): void;
  11508. /**
  11509. * Marks the material to indicate that it needs to be re-calculated
  11510. */
  11511. markAsUnprocessed(): void;
  11512. /**
  11513. * Marks the material to indicate all of its defines need to be re-calculated
  11514. */
  11515. markAllAsDirty(): void;
  11516. /**
  11517. * Marks the material to indicate that image processing needs to be re-calculated
  11518. */
  11519. markAsImageProcessingDirty(): void;
  11520. /**
  11521. * Marks the material to indicate the lights need to be re-calculated
  11522. */
  11523. markAsLightDirty(): void;
  11524. /**
  11525. * Marks the attribute state as changed
  11526. */
  11527. markAsAttributesDirty(): void;
  11528. /**
  11529. * Marks the texture state as changed
  11530. */
  11531. markAsTexturesDirty(): void;
  11532. /**
  11533. * Marks the fresnel state as changed
  11534. */
  11535. markAsFresnelDirty(): void;
  11536. /**
  11537. * Marks the misc state as changed
  11538. */
  11539. markAsMiscDirty(): void;
  11540. /**
  11541. * Rebuilds the material defines
  11542. */
  11543. rebuild(): void;
  11544. /**
  11545. * Specifies if two material defines are equal
  11546. * @param other - A material define instance to compare to
  11547. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  11548. */
  11549. isEqual(other: MaterialDefines): boolean;
  11550. /**
  11551. * Clones this instance's defines to another instance
  11552. * @param other - material defines to clone values to
  11553. */
  11554. cloneTo(other: MaterialDefines): void;
  11555. /**
  11556. * Resets the material define values
  11557. */
  11558. reset(): void;
  11559. /**
  11560. * Converts the material define values to a string
  11561. * @returns - String of material define information
  11562. */
  11563. toString(): string;
  11564. }
  11565. /**
  11566. * Base class for the main features of a material in Babylon.js
  11567. */
  11568. class Material implements IAnimatable {
  11569. private static _TriangleFillMode;
  11570. private static _WireFrameFillMode;
  11571. private static _PointFillMode;
  11572. private static _PointListDrawMode;
  11573. private static _LineListDrawMode;
  11574. private static _LineLoopDrawMode;
  11575. private static _LineStripDrawMode;
  11576. private static _TriangleStripDrawMode;
  11577. private static _TriangleFanDrawMode;
  11578. /**
  11579. * Returns the triangle fill mode
  11580. */
  11581. static readonly TriangleFillMode: number;
  11582. /**
  11583. * Returns the wireframe mode
  11584. */
  11585. static readonly WireFrameFillMode: number;
  11586. /**
  11587. * Returns the point fill mode
  11588. */
  11589. static readonly PointFillMode: number;
  11590. /**
  11591. * Returns the point list draw mode
  11592. */
  11593. static readonly PointListDrawMode: number;
  11594. /**
  11595. * Returns the line list draw mode
  11596. */
  11597. static readonly LineListDrawMode: number;
  11598. /**
  11599. * Returns the line loop draw mode
  11600. */
  11601. static readonly LineLoopDrawMode: number;
  11602. /**
  11603. * Returns the line strip draw mode
  11604. */
  11605. static readonly LineStripDrawMode: number;
  11606. /**
  11607. * Returns the triangle strip draw mode
  11608. */
  11609. static readonly TriangleStripDrawMode: number;
  11610. /**
  11611. * Returns the triangle fan draw mode
  11612. */
  11613. static readonly TriangleFanDrawMode: number;
  11614. /**
  11615. * Stores the clock-wise side orientation
  11616. */
  11617. private static _ClockWiseSideOrientation;
  11618. /**
  11619. * Stores the counter clock-wise side orientation
  11620. */
  11621. private static _CounterClockWiseSideOrientation;
  11622. /**
  11623. * Returns the clock-wise side orientation
  11624. */
  11625. static readonly ClockWiseSideOrientation: number;
  11626. /**
  11627. * Returns the counter clock-wise side orientation
  11628. */
  11629. static readonly CounterClockWiseSideOrientation: number;
  11630. /**
  11631. * The dirty texture flag value
  11632. */
  11633. private static _TextureDirtyFlag;
  11634. /**
  11635. * The dirty light flag value
  11636. */
  11637. private static _LightDirtyFlag;
  11638. /**
  11639. * The dirty fresnel flag value
  11640. */
  11641. private static _FresnelDirtyFlag;
  11642. /**
  11643. * The dirty attribute flag value
  11644. */
  11645. private static _AttributesDirtyFlag;
  11646. /**
  11647. * The dirty misc flag value
  11648. */
  11649. private static _MiscDirtyFlag;
  11650. /**
  11651. * Returns the dirty texture flag value
  11652. */
  11653. static readonly TextureDirtyFlag: number;
  11654. /**
  11655. * Returns the dirty light flag value
  11656. */
  11657. static readonly LightDirtyFlag: number;
  11658. /**
  11659. * Returns the dirty fresnel flag value
  11660. */
  11661. static readonly FresnelDirtyFlag: number;
  11662. /**
  11663. * Returns the dirty attributes flag value
  11664. */
  11665. static readonly AttributesDirtyFlag: number;
  11666. /**
  11667. * Returns the dirty misc flag value
  11668. */
  11669. static readonly MiscDirtyFlag: number;
  11670. /**
  11671. * The ID of the material
  11672. */
  11673. id: string;
  11674. /**
  11675. * The name of the material
  11676. */
  11677. name: string;
  11678. /**
  11679. * Specifies if the ready state should be checked on each call
  11680. */
  11681. checkReadyOnEveryCall: boolean;
  11682. /**
  11683. * Specifies if the ready state should be checked once
  11684. */
  11685. checkReadyOnlyOnce: boolean;
  11686. /**
  11687. * The state of the material
  11688. */
  11689. state: string;
  11690. /**
  11691. * The alpha value of the material
  11692. */
  11693. protected _alpha: number;
  11694. /**
  11695. * Gets the alpha value of the material
  11696. */
  11697. /**
  11698. * Sets the alpha value of the material
  11699. */
  11700. alpha: number;
  11701. /**
  11702. * Specifies if back face culling is enabled
  11703. */
  11704. protected _backFaceCulling: boolean;
  11705. /**
  11706. * Gets the back-face culling state
  11707. */
  11708. /**
  11709. * Sets the back-face culling state
  11710. */
  11711. backFaceCulling: boolean;
  11712. /**
  11713. * Stores the value for side orientation
  11714. */
  11715. sideOrientation: number;
  11716. /**
  11717. * Callback triggered when the material is compiled
  11718. */
  11719. onCompiled: (effect: Effect) => void;
  11720. /**
  11721. * Callback triggered when an error occurs
  11722. */
  11723. onError: (effect: Effect, errors: string) => void;
  11724. /**
  11725. * Callback triggered to get the render target textures
  11726. */
  11727. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  11728. /**
  11729. * Specifies if the material should be serialized
  11730. */
  11731. doNotSerialize: boolean;
  11732. /**
  11733. * Specifies if the effect should be stored on sub meshes
  11734. */
  11735. storeEffectOnSubMeshes: boolean;
  11736. /**
  11737. * Stores the animations for the material
  11738. */
  11739. animations: Array<Animation>;
  11740. /**
  11741. * An event triggered when the material is disposed
  11742. */
  11743. onDisposeObservable: Observable<Material>;
  11744. /**
  11745. * An observer which watches for dispose events
  11746. */
  11747. private _onDisposeObserver;
  11748. /**
  11749. * Called during a dispose event
  11750. */
  11751. onDispose: () => void;
  11752. /**
  11753. * An event triggered when the material is bound
  11754. */
  11755. onBindObservable: Observable<AbstractMesh>;
  11756. /**
  11757. * An observer which watches for bind events
  11758. */
  11759. private _onBindObserver;
  11760. /**
  11761. * Called during a bind event
  11762. */
  11763. onBind: (Mesh: AbstractMesh) => void;
  11764. /**
  11765. * An event triggered when the material is unbound
  11766. */
  11767. onUnBindObservable: Observable<Material>;
  11768. /**
  11769. * Stores the value of the alpha mode
  11770. */
  11771. private _alphaMode;
  11772. /**
  11773. * Gets the value of the alpha mode
  11774. */
  11775. /**
  11776. * Sets the value of the alpha mode.
  11777. *
  11778. * | Value | Type | Description |
  11779. * | --- | --- | --- |
  11780. * | 0 | ALPHA_DISABLE | |
  11781. * | 1 | ALPHA_ADD | |
  11782. * | 2 | ALPHA_COMBINE | |
  11783. * | 3 | ALPHA_SUBTRACT | |
  11784. * | 4 | ALPHA_MULTIPLY | |
  11785. * | 5 | ALPHA_MAXIMIZED | |
  11786. * | 6 | ALPHA_ONEONE | |
  11787. * | 7 | ALPHA_PREMULTIPLIED | |
  11788. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  11789. * | 9 | ALPHA_INTERPOLATE | |
  11790. * | 10 | ALPHA_SCREENMODE | |
  11791. *
  11792. */
  11793. alphaMode: number;
  11794. /**
  11795. * Stores the state of the need depth pre-pass value
  11796. */
  11797. private _needDepthPrePass;
  11798. /**
  11799. * Gets the depth pre-pass value
  11800. */
  11801. /**
  11802. * Sets the need depth pre-pass value
  11803. */
  11804. needDepthPrePass: boolean;
  11805. /**
  11806. * Specifies if depth writing should be disabled
  11807. */
  11808. disableDepthWrite: boolean;
  11809. /**
  11810. * Specifies if depth writing should be forced
  11811. */
  11812. forceDepthWrite: boolean;
  11813. /**
  11814. * Specifies if there should be a separate pass for culling
  11815. */
  11816. separateCullingPass: boolean;
  11817. /**
  11818. * Stores the state specifing if fog should be enabled
  11819. */
  11820. private _fogEnabled;
  11821. /**
  11822. * Gets the value of the fog enabled state
  11823. */
  11824. /**
  11825. * Sets the state for enabling fog
  11826. */
  11827. fogEnabled: boolean;
  11828. /**
  11829. * Stores the size of points
  11830. */
  11831. pointSize: number;
  11832. /**
  11833. * Stores the z offset value
  11834. */
  11835. zOffset: number;
  11836. /**
  11837. * Gets a value specifying if wireframe mode is enabled
  11838. */
  11839. /**
  11840. * Sets the state of wireframe mode
  11841. */
  11842. wireframe: boolean;
  11843. /**
  11844. * Gets the value specifying if point clouds are enabled
  11845. */
  11846. /**
  11847. * Sets the state of point cloud mode
  11848. */
  11849. pointsCloud: boolean;
  11850. /**
  11851. * Gets the material fill mode
  11852. */
  11853. /**
  11854. * Sets the material fill mode
  11855. */
  11856. fillMode: number;
  11857. /**
  11858. * Stores the effects for the material
  11859. */
  11860. _effect: Nullable<Effect>;
  11861. /**
  11862. * Specifies if the material was previously ready
  11863. */
  11864. _wasPreviouslyReady: boolean;
  11865. /**
  11866. * Specifies if uniform buffers should be used
  11867. */
  11868. private _useUBO;
  11869. /**
  11870. * Stores a reference to the scene
  11871. */
  11872. private _scene;
  11873. /**
  11874. * Stores the fill mode state
  11875. */
  11876. private _fillMode;
  11877. /**
  11878. * Specifies if the depth write state should be cached
  11879. */
  11880. private _cachedDepthWriteState;
  11881. /**
  11882. * Stores the uniform buffer
  11883. */
  11884. protected _uniformBuffer: UniformBuffer;
  11885. /**
  11886. * Creates a material instance
  11887. * @param name defines the name of the material
  11888. * @param scene defines the scene to reference
  11889. * @param doNotAdd specifies if the material should be added to the scene
  11890. */
  11891. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  11892. /**
  11893. * Returns a string representation of the current material
  11894. * @param fullDetails defines a boolean indicating which levels of logging is desired
  11895. * @returns a string with material information
  11896. */
  11897. toString(fullDetails?: boolean): string;
  11898. /**
  11899. * Gets the class name of the material
  11900. * @returns a string with the class name of the material
  11901. */
  11902. getClassName(): string;
  11903. /**
  11904. * Specifies if updates for the material been locked
  11905. */
  11906. readonly isFrozen: boolean;
  11907. /**
  11908. * Locks updates for the material
  11909. */
  11910. freeze(): void;
  11911. /**
  11912. * Unlocks updates for the material
  11913. */
  11914. unfreeze(): void;
  11915. /**
  11916. * Specifies if the material is ready to be used
  11917. * @param mesh defines the mesh to check
  11918. * @param useInstances specifies if instances should be used
  11919. * @returns a boolean indicating if the material is ready to be used
  11920. */
  11921. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  11922. /**
  11923. * Specifies that the submesh is ready to be used
  11924. * @param mesh defines the mesh to check
  11925. * @param subMesh defines which submesh to check
  11926. * @param useInstances specifies that instances should be used
  11927. * @returns a boolean indicating that the submesh is ready or not
  11928. */
  11929. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  11930. /**
  11931. * Returns the material effect
  11932. * @returns the effect associated with the material
  11933. */
  11934. getEffect(): Nullable<Effect>;
  11935. /**
  11936. * Returns the current scene
  11937. * @returns a Scene
  11938. */
  11939. getScene(): Scene;
  11940. /**
  11941. * Specifies if the material will require alpha blending
  11942. * @returns a boolean specifying if alpha blending is needed
  11943. */
  11944. needAlphaBlending(): boolean;
  11945. /**
  11946. * Specifies if the mesh will require alpha blending
  11947. * @param mesh defines the mesh to check
  11948. * @returns a boolean specifying if alpha blending is needed for the mesh
  11949. */
  11950. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  11951. /**
  11952. * Specifies if this material should be rendered in alpha test mode
  11953. * @returns a boolean specifying if an alpha test is needed.
  11954. */
  11955. needAlphaTesting(): boolean;
  11956. /**
  11957. * Gets the texture used for the alpha test
  11958. * @returns the texture to use for alpha testing
  11959. */
  11960. getAlphaTestTexture(): Nullable<BaseTexture>;
  11961. /**
  11962. * Marks the material to indicate that it needs to be re-calculated
  11963. */
  11964. markDirty(): void;
  11965. /** @ignore */
  11966. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  11967. /**
  11968. * Binds the material to the mesh
  11969. * @param world defines the world transformation matrix
  11970. * @param mesh defines the mesh to bind the material to
  11971. */
  11972. bind(world: Matrix, mesh?: Mesh): void;
  11973. /**
  11974. * Binds the submesh to the material
  11975. * @param world defines the world transformation matrix
  11976. * @param mesh defines the mesh containing the submesh
  11977. * @param subMesh defines the submesh to bind the material to
  11978. */
  11979. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  11980. /**
  11981. * Binds the world matrix to the material
  11982. * @param world defines the world transformation matrix
  11983. */
  11984. bindOnlyWorldMatrix(world: Matrix): void;
  11985. /**
  11986. * Binds the scene's uniform buffer to the effect.
  11987. * @param effect defines the effect to bind to the scene uniform buffer
  11988. * @param sceneUbo defines the uniform buffer storing scene data
  11989. */
  11990. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  11991. /**
  11992. * Binds the view matrix to the effect
  11993. * @param effect defines the effect to bind the view matrix to
  11994. */
  11995. bindView(effect: Effect): void;
  11996. /**
  11997. * Binds the view projection matrix to the effect
  11998. * @param effect defines the effect to bind the view projection matrix to
  11999. */
  12000. bindViewProjection(effect: Effect): void;
  12001. /**
  12002. * Specifies if material alpha testing should be turned on for the mesh
  12003. * @param mesh defines the mesh to check
  12004. */
  12005. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  12006. /**
  12007. * Processes to execute after binding the material to a mesh
  12008. * @param mesh defines the rendered mesh
  12009. */
  12010. protected _afterBind(mesh?: Mesh): void;
  12011. /**
  12012. * Unbinds the material from the mesh
  12013. */
  12014. unbind(): void;
  12015. /**
  12016. * Gets the active textures from the material
  12017. * @returns an array of textures
  12018. */
  12019. getActiveTextures(): BaseTexture[];
  12020. /**
  12021. * Specifies if the material uses a texture
  12022. * @param texture defines the texture to check against the material
  12023. * @returns a boolean specifying if the material uses the texture
  12024. */
  12025. hasTexture(texture: BaseTexture): boolean;
  12026. /**
  12027. * Makes a duplicate of the material, and gives it a new name
  12028. * @param name defines the new name for the duplicated material
  12029. * @returns the cloned material
  12030. */
  12031. clone(name: string): Nullable<Material>;
  12032. /**
  12033. * Gets the meshes bound to the material
  12034. * @returns an array of meshes bound to the material
  12035. */
  12036. getBindedMeshes(): AbstractMesh[];
  12037. /**
  12038. * Force shader compilation
  12039. * @param mesh defines the mesh associated with this material
  12040. * @param onCompiled defines a function to execute once the material is compiled
  12041. * @param options defines the options to configure the compilation
  12042. */
  12043. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  12044. clipPlane: boolean;
  12045. }>): void;
  12046. /**
  12047. * Force shader compilation
  12048. * @param mesh defines the mesh that will use this material
  12049. * @param options defines additional options for compiling the shaders
  12050. * @returns a promise that resolves when the compilation completes
  12051. */
  12052. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  12053. clipPlane: boolean;
  12054. }>): Promise<void>;
  12055. /**
  12056. * Marks a define in the material to indicate that it needs to be re-computed
  12057. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  12058. */
  12059. markAsDirty(flag: number): void;
  12060. /**
  12061. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  12062. * @param func defines a function which checks material defines against the submeshes
  12063. */
  12064. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  12065. /**
  12066. * Indicates that image processing needs to be re-calculated for all submeshes
  12067. */
  12068. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  12069. /**
  12070. * Indicates that textures need to be re-calculated for all submeshes
  12071. */
  12072. protected _markAllSubMeshesAsTexturesDirty(): void;
  12073. /**
  12074. * Indicates that fresnel needs to be re-calculated for all submeshes
  12075. */
  12076. protected _markAllSubMeshesAsFresnelDirty(): void;
  12077. /**
  12078. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  12079. */
  12080. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  12081. /**
  12082. * Indicates that lights need to be re-calculated for all submeshes
  12083. */
  12084. protected _markAllSubMeshesAsLightsDirty(): void;
  12085. /**
  12086. * Indicates that attributes need to be re-calculated for all submeshes
  12087. */
  12088. protected _markAllSubMeshesAsAttributesDirty(): void;
  12089. /**
  12090. * Indicates that misc needs to be re-calculated for all submeshes
  12091. */
  12092. protected _markAllSubMeshesAsMiscDirty(): void;
  12093. /**
  12094. * Indicates that textures and misc need to be re-calculated for all submeshes
  12095. */
  12096. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  12097. /**
  12098. * Disposes the material
  12099. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12100. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12101. */
  12102. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  12103. /**
  12104. * Serializes this material
  12105. * @returns the serialized material object
  12106. */
  12107. serialize(): any;
  12108. /**
  12109. * Creates a MultiMaterial from parsed MultiMaterial data.
  12110. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  12111. * @param scene defines the hosting scene
  12112. * @returns a new MultiMaterial
  12113. */
  12114. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  12115. /**
  12116. * Creates a material from parsed material data
  12117. * @param parsedMaterial defines parsed material data
  12118. * @param scene defines the hosting scene
  12119. * @param rootUrl defines the root URL to use to load textures
  12120. * @returns a new material
  12121. */
  12122. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  12123. }
  12124. }
  12125. declare module BABYLON {
  12126. /**
  12127. * "Static Class" containing the most commonly used helper while dealing with material for
  12128. * rendering purpose.
  12129. *
  12130. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  12131. *
  12132. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12133. */
  12134. class MaterialHelper {
  12135. /**
  12136. * Bind the current view position to an effect.
  12137. * @param effect The effect to be bound
  12138. * @param scene The scene the eyes position is used from
  12139. */
  12140. static BindEyePosition(effect: Effect, scene: Scene): void;
  12141. /**
  12142. * Helps preparing the defines values about the UVs in used in the effect.
  12143. * UVs are shared as much as we can accross chanels in the shaders.
  12144. * @param texture The texture we are preparing the UVs for
  12145. * @param defines The defines to update
  12146. * @param key The chanel key "diffuse", "specular"... used in the shader
  12147. */
  12148. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  12149. /**
  12150. * Binds a texture matrix value to its corrsponding uniform
  12151. * @param texture The texture to bind the matrix for
  12152. * @param uniformBuffer The uniform buffer receivin the data
  12153. * @param key The chanel key "diffuse", "specular"... used in the shader
  12154. */
  12155. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  12156. /**
  12157. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  12158. * @param mesh defines the current mesh
  12159. * @param scene defines the current scene
  12160. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  12161. * @param pointsCloud defines if point cloud rendering has to be turned on
  12162. * @param fogEnabled defines if fog has to be turned on
  12163. * @param alphaTest defines if alpha testing has to be turned on
  12164. * @param defines defines the current list of defines
  12165. */
  12166. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  12167. /**
  12168. * Helper used to prepare the list of defines associated with frame values for shader compilation
  12169. * @param scene defines the current scene
  12170. * @param engine defines the current engine
  12171. * @param defines specifies the list of active defines
  12172. * @param useInstances defines if instances have to be turned on
  12173. * @param useClipPlane defines if clip plane have to be turned on
  12174. */
  12175. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  12176. /**
  12177. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  12178. * @param mesh The mesh containing the geometry data we will draw
  12179. * @param defines The defines to update
  12180. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  12181. * @param useBones Precise whether bones should be used or not (override mesh info)
  12182. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  12183. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  12184. * @returns false if defines are considered not dirty and have not been checked
  12185. */
  12186. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  12187. /**
  12188. * Prepares the defines related to the light information passed in parameter
  12189. * @param scene The scene we are intending to draw
  12190. * @param mesh The mesh the effect is compiling for
  12191. * @param defines The defines to update
  12192. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  12193. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  12194. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  12195. * @returns true if normals will be required for the rest of the effect
  12196. */
  12197. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  12198. /**
  12199. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  12200. * that won t be acctive due to defines being turned off.
  12201. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  12202. * @param samplersList The samplers list
  12203. * @param defines The defines helping in the list generation
  12204. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  12205. */
  12206. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  12207. /**
  12208. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  12209. * @param defines The defines to update while falling back
  12210. * @param fallbacks The authorized effect fallbacks
  12211. * @param maxSimultaneousLights The maximum number of lights allowed
  12212. * @param rank the current rank of the Effect
  12213. * @returns The newly affected rank
  12214. */
  12215. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  12216. /**
  12217. * Prepares the list of attributes required for morph targets according to the effect defines.
  12218. * @param attribs The current list of supported attribs
  12219. * @param mesh The mesh to prepare the morph targets attributes for
  12220. * @param defines The current Defines of the effect
  12221. */
  12222. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  12223. /**
  12224. * Prepares the list of attributes required for bones according to the effect defines.
  12225. * @param attribs The current list of supported attribs
  12226. * @param mesh The mesh to prepare the bones attributes for
  12227. * @param defines The current Defines of the effect
  12228. * @param fallbacks The current efffect fallback strategy
  12229. */
  12230. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  12231. /**
  12232. * Prepares the list of attributes required for instances according to the effect defines.
  12233. * @param attribs The current list of supported attribs
  12234. * @param defines The current Defines of the effect
  12235. */
  12236. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  12237. /**
  12238. * Binds the light shadow information to the effect for the given mesh.
  12239. * @param light The light containing the generator
  12240. * @param scene The scene the lights belongs to
  12241. * @param mesh The mesh we are binding the information to render
  12242. * @param lightIndex The light index in the effect used to render the mesh
  12243. * @param effect The effect we are binding the data to
  12244. */
  12245. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  12246. /**
  12247. * Binds the light information to the effect.
  12248. * @param light The light containing the generator
  12249. * @param effect The effect we are binding the data to
  12250. * @param lightIndex The light index in the effect used to render
  12251. */
  12252. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  12253. /**
  12254. * Binds the lights information from the scene to the effect for the given mesh.
  12255. * @param scene The scene the lights belongs to
  12256. * @param mesh The mesh we are binding the information to render
  12257. * @param effect The effect we are binding the data to
  12258. * @param defines The generated defines for the effect
  12259. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  12260. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  12261. */
  12262. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  12263. /**
  12264. * Binds the fog information from the scene to the effect for the given mesh.
  12265. * @param scene The scene the lights belongs to
  12266. * @param mesh The mesh we are binding the information to render
  12267. * @param effect The effect we are binding the data to
  12268. */
  12269. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  12270. /**
  12271. * Binds the bones information from the mesh to the effect.
  12272. * @param mesh The mesh we are binding the information to render
  12273. * @param effect The effect we are binding the data to
  12274. */
  12275. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  12276. /**
  12277. * Binds the morph targets information from the mesh to the effect.
  12278. * @param abstractMesh The mesh we are binding the information to render
  12279. * @param effect The effect we are binding the data to
  12280. */
  12281. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  12282. /**
  12283. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  12284. * @param defines The generated defines used in the effect
  12285. * @param effect The effect we are binding the data to
  12286. * @param scene The scene we are willing to render with logarithmic scale for
  12287. */
  12288. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  12289. /**
  12290. * Binds the clip plane information from the scene to the effect.
  12291. * @param scene The scene the clip plane information are extracted from
  12292. * @param effect The effect we are binding the data to
  12293. */
  12294. static BindClipPlane(effect: Effect, scene: Scene): void;
  12295. }
  12296. }
  12297. declare module BABYLON {
  12298. class MultiMaterial extends Material {
  12299. private _subMaterials;
  12300. subMaterials: Nullable<Material>[];
  12301. constructor(name: string, scene: Scene);
  12302. private _hookArray(array);
  12303. getSubMaterial(index: number): Nullable<Material>;
  12304. getActiveTextures(): BaseTexture[];
  12305. getClassName(): string;
  12306. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12307. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  12308. serialize(): any;
  12309. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  12310. }
  12311. }
  12312. declare module BABYLON {
  12313. class PushMaterial extends Material {
  12314. protected _activeEffect: Effect;
  12315. protected _normalMatrix: Matrix;
  12316. constructor(name: string, scene: Scene);
  12317. getEffect(): Effect;
  12318. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12319. /**
  12320. * Binds the given world matrix to the active effect
  12321. *
  12322. * @param world the matrix to bind
  12323. */
  12324. bindOnlyWorldMatrix(world: Matrix): void;
  12325. /**
  12326. * Binds the given normal matrix to the active effect
  12327. *
  12328. * @param normalMatrix the matrix to bind
  12329. */
  12330. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  12331. bind(world: Matrix, mesh?: Mesh): void;
  12332. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  12333. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  12334. }
  12335. }
  12336. declare module BABYLON {
  12337. class ShaderMaterial extends Material {
  12338. private _shaderPath;
  12339. private _options;
  12340. private _textures;
  12341. private _textureArrays;
  12342. private _floats;
  12343. private _ints;
  12344. private _floatsArrays;
  12345. private _colors3;
  12346. private _colors3Arrays;
  12347. private _colors4;
  12348. private _vectors2;
  12349. private _vectors3;
  12350. private _vectors4;
  12351. private _matrices;
  12352. private _matrices3x3;
  12353. private _matrices2x2;
  12354. private _vectors2Arrays;
  12355. private _vectors3Arrays;
  12356. private _cachedWorldViewMatrix;
  12357. private _renderId;
  12358. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  12359. getClassName(): string;
  12360. needAlphaBlending(): boolean;
  12361. needAlphaTesting(): boolean;
  12362. private _checkUniform(uniformName);
  12363. setTexture(name: string, texture: Texture): ShaderMaterial;
  12364. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12365. setFloat(name: string, value: number): ShaderMaterial;
  12366. setInt(name: string, value: number): ShaderMaterial;
  12367. setFloats(name: string, value: number[]): ShaderMaterial;
  12368. setColor3(name: string, value: Color3): ShaderMaterial;
  12369. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12370. setColor4(name: string, value: Color4): ShaderMaterial;
  12371. setVector2(name: string, value: Vector2): ShaderMaterial;
  12372. setVector3(name: string, value: Vector3): ShaderMaterial;
  12373. setVector4(name: string, value: Vector4): ShaderMaterial;
  12374. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12375. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12376. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12377. setArray2(name: string, value: number[]): ShaderMaterial;
  12378. setArray3(name: string, value: number[]): ShaderMaterial;
  12379. private _checkCache(scene, mesh?, useInstances?);
  12380. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12381. bindOnlyWorldMatrix(world: Matrix): void;
  12382. bind(world: Matrix, mesh?: Mesh): void;
  12383. getActiveTextures(): BaseTexture[];
  12384. hasTexture(texture: BaseTexture): boolean;
  12385. clone(name: string): ShaderMaterial;
  12386. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  12387. serialize(): any;
  12388. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12389. }
  12390. }
  12391. declare module BABYLON {
  12392. /** @ignore */
  12393. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  12394. MAINUV1: boolean;
  12395. MAINUV2: boolean;
  12396. DIFFUSE: boolean;
  12397. DIFFUSEDIRECTUV: number;
  12398. AMBIENT: boolean;
  12399. AMBIENTDIRECTUV: number;
  12400. OPACITY: boolean;
  12401. OPACITYDIRECTUV: number;
  12402. OPACITYRGB: boolean;
  12403. REFLECTION: boolean;
  12404. EMISSIVE: boolean;
  12405. EMISSIVEDIRECTUV: number;
  12406. SPECULAR: boolean;
  12407. SPECULARDIRECTUV: number;
  12408. BUMP: boolean;
  12409. BUMPDIRECTUV: number;
  12410. PARALLAX: boolean;
  12411. PARALLAXOCCLUSION: boolean;
  12412. SPECULAROVERALPHA: boolean;
  12413. CLIPPLANE: boolean;
  12414. ALPHATEST: boolean;
  12415. DEPTHPREPASS: boolean;
  12416. ALPHAFROMDIFFUSE: boolean;
  12417. POINTSIZE: boolean;
  12418. FOG: boolean;
  12419. SPECULARTERM: boolean;
  12420. DIFFUSEFRESNEL: boolean;
  12421. OPACITYFRESNEL: boolean;
  12422. REFLECTIONFRESNEL: boolean;
  12423. REFRACTIONFRESNEL: boolean;
  12424. EMISSIVEFRESNEL: boolean;
  12425. FRESNEL: boolean;
  12426. NORMAL: boolean;
  12427. UV1: boolean;
  12428. UV2: boolean;
  12429. VERTEXCOLOR: boolean;
  12430. VERTEXALPHA: boolean;
  12431. NUM_BONE_INFLUENCERS: number;
  12432. BonesPerMesh: number;
  12433. INSTANCES: boolean;
  12434. GLOSSINESS: boolean;
  12435. ROUGHNESS: boolean;
  12436. EMISSIVEASILLUMINATION: boolean;
  12437. LINKEMISSIVEWITHDIFFUSE: boolean;
  12438. REFLECTIONFRESNELFROMSPECULAR: boolean;
  12439. LIGHTMAP: boolean;
  12440. LIGHTMAPDIRECTUV: number;
  12441. OBJECTSPACE_NORMALMAP: boolean;
  12442. USELIGHTMAPASSHADOWMAP: boolean;
  12443. REFLECTIONMAP_3D: boolean;
  12444. REFLECTIONMAP_SPHERICAL: boolean;
  12445. REFLECTIONMAP_PLANAR: boolean;
  12446. REFLECTIONMAP_CUBIC: boolean;
  12447. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  12448. REFLECTIONMAP_PROJECTION: boolean;
  12449. REFLECTIONMAP_SKYBOX: boolean;
  12450. REFLECTIONMAP_EXPLICIT: boolean;
  12451. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  12452. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  12453. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  12454. INVERTCUBICMAP: boolean;
  12455. LOGARITHMICDEPTH: boolean;
  12456. REFRACTION: boolean;
  12457. REFRACTIONMAP_3D: boolean;
  12458. REFLECTIONOVERALPHA: boolean;
  12459. TWOSIDEDLIGHTING: boolean;
  12460. SHADOWFLOAT: boolean;
  12461. MORPHTARGETS: boolean;
  12462. MORPHTARGETS_NORMAL: boolean;
  12463. MORPHTARGETS_TANGENT: boolean;
  12464. NUM_MORPH_INFLUENCERS: number;
  12465. NONUNIFORMSCALING: boolean;
  12466. PREMULTIPLYALPHA: boolean;
  12467. IMAGEPROCESSING: boolean;
  12468. VIGNETTE: boolean;
  12469. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12470. VIGNETTEBLENDMODEOPAQUE: boolean;
  12471. TONEMAPPING: boolean;
  12472. CONTRAST: boolean;
  12473. COLORCURVES: boolean;
  12474. COLORGRADING: boolean;
  12475. COLORGRADING3D: boolean;
  12476. SAMPLER3DGREENDEPTH: boolean;
  12477. SAMPLER3DBGRMAP: boolean;
  12478. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12479. EXPOSURE: boolean;
  12480. constructor();
  12481. setReflectionMode(modeToEnable: string): void;
  12482. }
  12483. class StandardMaterial extends PushMaterial {
  12484. private _diffuseTexture;
  12485. diffuseTexture: Nullable<BaseTexture>;
  12486. private _ambientTexture;
  12487. ambientTexture: Nullable<BaseTexture>;
  12488. private _opacityTexture;
  12489. opacityTexture: Nullable<BaseTexture>;
  12490. private _reflectionTexture;
  12491. reflectionTexture: Nullable<BaseTexture>;
  12492. private _emissiveTexture;
  12493. emissiveTexture: Nullable<BaseTexture>;
  12494. private _specularTexture;
  12495. specularTexture: Nullable<BaseTexture>;
  12496. private _bumpTexture;
  12497. bumpTexture: Nullable<BaseTexture>;
  12498. private _lightmapTexture;
  12499. lightmapTexture: Nullable<BaseTexture>;
  12500. private _refractionTexture;
  12501. refractionTexture: Nullable<BaseTexture>;
  12502. ambientColor: Color3;
  12503. diffuseColor: Color3;
  12504. specularColor: Color3;
  12505. emissiveColor: Color3;
  12506. specularPower: number;
  12507. private _useAlphaFromDiffuseTexture;
  12508. useAlphaFromDiffuseTexture: boolean;
  12509. private _useEmissiveAsIllumination;
  12510. useEmissiveAsIllumination: boolean;
  12511. private _linkEmissiveWithDiffuse;
  12512. linkEmissiveWithDiffuse: boolean;
  12513. private _useSpecularOverAlpha;
  12514. useSpecularOverAlpha: boolean;
  12515. private _useReflectionOverAlpha;
  12516. useReflectionOverAlpha: boolean;
  12517. private _disableLighting;
  12518. disableLighting: boolean;
  12519. private _useObjectSpaceNormalMap;
  12520. /**
  12521. * Allows using an object space normal map (instead of tangent space).
  12522. */
  12523. useObjectSpaceNormalMap: boolean;
  12524. private _useParallax;
  12525. useParallax: boolean;
  12526. private _useParallaxOcclusion;
  12527. useParallaxOcclusion: boolean;
  12528. parallaxScaleBias: number;
  12529. private _roughness;
  12530. roughness: number;
  12531. indexOfRefraction: number;
  12532. invertRefractionY: boolean;
  12533. private _useLightmapAsShadowmap;
  12534. useLightmapAsShadowmap: boolean;
  12535. private _diffuseFresnelParameters;
  12536. diffuseFresnelParameters: FresnelParameters;
  12537. private _opacityFresnelParameters;
  12538. opacityFresnelParameters: FresnelParameters;
  12539. private _reflectionFresnelParameters;
  12540. reflectionFresnelParameters: FresnelParameters;
  12541. private _refractionFresnelParameters;
  12542. refractionFresnelParameters: FresnelParameters;
  12543. private _emissiveFresnelParameters;
  12544. emissiveFresnelParameters: FresnelParameters;
  12545. private _useReflectionFresnelFromSpecular;
  12546. useReflectionFresnelFromSpecular: boolean;
  12547. private _useGlossinessFromSpecularMapAlpha;
  12548. useGlossinessFromSpecularMapAlpha: boolean;
  12549. private _maxSimultaneousLights;
  12550. maxSimultaneousLights: number;
  12551. /**
  12552. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  12553. */
  12554. private _invertNormalMapX;
  12555. invertNormalMapX: boolean;
  12556. /**
  12557. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  12558. */
  12559. private _invertNormalMapY;
  12560. invertNormalMapY: boolean;
  12561. /**
  12562. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  12563. */
  12564. private _twoSidedLighting;
  12565. twoSidedLighting: boolean;
  12566. /**
  12567. * Default configuration related to image processing available in the standard Material.
  12568. */
  12569. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12570. /**
  12571. * Gets the image processing configuration used either in this material.
  12572. */
  12573. /**
  12574. * Sets the Default image processing configuration used either in the this material.
  12575. *
  12576. * If sets to null, the scene one is in use.
  12577. */
  12578. imageProcessingConfiguration: ImageProcessingConfiguration;
  12579. /**
  12580. * Keep track of the image processing observer to allow dispose and replace.
  12581. */
  12582. private _imageProcessingObserver;
  12583. /**
  12584. * Attaches a new image processing configuration to the Standard Material.
  12585. * @param configuration
  12586. */
  12587. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12588. /**
  12589. * Gets wether the color curves effect is enabled.
  12590. */
  12591. /**
  12592. * Sets wether the color curves effect is enabled.
  12593. */
  12594. cameraColorCurvesEnabled: boolean;
  12595. /**
  12596. * Gets wether the color grading effect is enabled.
  12597. */
  12598. /**
  12599. * Gets wether the color grading effect is enabled.
  12600. */
  12601. cameraColorGradingEnabled: boolean;
  12602. /**
  12603. * Gets wether tonemapping is enabled or not.
  12604. */
  12605. /**
  12606. * Sets wether tonemapping is enabled or not
  12607. */
  12608. cameraToneMappingEnabled: boolean;
  12609. /**
  12610. * The camera exposure used on this material.
  12611. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  12612. * This corresponds to a photographic exposure.
  12613. */
  12614. /**
  12615. * The camera exposure used on this material.
  12616. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  12617. * This corresponds to a photographic exposure.
  12618. */
  12619. cameraExposure: number;
  12620. /**
  12621. * Gets The camera contrast used on this material.
  12622. */
  12623. /**
  12624. * Sets The camera contrast used on this material.
  12625. */
  12626. cameraContrast: number;
  12627. /**
  12628. * Gets the Color Grading 2D Lookup Texture.
  12629. */
  12630. /**
  12631. * Sets the Color Grading 2D Lookup Texture.
  12632. */
  12633. cameraColorGradingTexture: Nullable<BaseTexture>;
  12634. /**
  12635. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  12636. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  12637. * 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;
  12638. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  12639. */
  12640. /**
  12641. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  12642. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  12643. * 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;
  12644. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  12645. */
  12646. cameraColorCurves: Nullable<ColorCurves>;
  12647. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  12648. protected _renderTargets: SmartArray<RenderTargetTexture>;
  12649. protected _worldViewProjectionMatrix: Matrix;
  12650. protected _globalAmbientColor: Color3;
  12651. protected _useLogarithmicDepth: boolean;
  12652. constructor(name: string, scene: Scene);
  12653. getClassName(): string;
  12654. useLogarithmicDepth: boolean;
  12655. needAlphaBlending(): boolean;
  12656. needAlphaTesting(): boolean;
  12657. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  12658. getAlphaTestTexture(): Nullable<BaseTexture>;
  12659. /**
  12660. * Child classes can use it to update shaders
  12661. */
  12662. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  12663. buildUniformLayout(): void;
  12664. unbind(): void;
  12665. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  12666. getAnimatables(): IAnimatable[];
  12667. getActiveTextures(): BaseTexture[];
  12668. hasTexture(texture: BaseTexture): boolean;
  12669. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  12670. clone(name: string): StandardMaterial;
  12671. serialize(): any;
  12672. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  12673. static _DiffuseTextureEnabled: boolean;
  12674. static DiffuseTextureEnabled: boolean;
  12675. static _AmbientTextureEnabled: boolean;
  12676. static AmbientTextureEnabled: boolean;
  12677. static _OpacityTextureEnabled: boolean;
  12678. static OpacityTextureEnabled: boolean;
  12679. static _ReflectionTextureEnabled: boolean;
  12680. static ReflectionTextureEnabled: boolean;
  12681. static _EmissiveTextureEnabled: boolean;
  12682. static EmissiveTextureEnabled: boolean;
  12683. static _SpecularTextureEnabled: boolean;
  12684. static SpecularTextureEnabled: boolean;
  12685. static _BumpTextureEnabled: boolean;
  12686. static BumpTextureEnabled: boolean;
  12687. static _LightmapTextureEnabled: boolean;
  12688. static LightmapTextureEnabled: boolean;
  12689. static _RefractionTextureEnabled: boolean;
  12690. static RefractionTextureEnabled: boolean;
  12691. static _ColorGradingTextureEnabled: boolean;
  12692. static ColorGradingTextureEnabled: boolean;
  12693. static _FresnelEnabled: boolean;
  12694. static FresnelEnabled: boolean;
  12695. }
  12696. }
  12697. declare module BABYLON {
  12698. class UniformBuffer {
  12699. private _engine;
  12700. private _buffer;
  12701. private _data;
  12702. private _bufferData;
  12703. private _dynamic?;
  12704. private _uniformLocations;
  12705. private _uniformSizes;
  12706. private _uniformLocationPointer;
  12707. private _needSync;
  12708. private _noUBO;
  12709. private _currentEffect;
  12710. private static _MAX_UNIFORM_SIZE;
  12711. private static _tempBuffer;
  12712. /**
  12713. * Wrapper for updateUniform.
  12714. * @method updateMatrix3x3
  12715. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12716. * @param {Float32Array} matrix
  12717. */
  12718. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  12719. /**
  12720. * Wrapper for updateUniform.
  12721. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12722. * @param {Float32Array} matrix
  12723. */
  12724. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  12725. /**
  12726. * Wrapper for updateUniform.
  12727. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12728. * @param {number} x
  12729. */
  12730. updateFloat: (name: string, x: number) => void;
  12731. /**
  12732. * Wrapper for updateUniform.
  12733. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12734. * @param {number} x
  12735. * @param {number} y
  12736. * @param {string} [suffix] Suffix to add to the uniform name.
  12737. */
  12738. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  12739. /**
  12740. * Wrapper for updateUniform.
  12741. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12742. * @param {number} x
  12743. * @param {number} y
  12744. * @param {number} z
  12745. * @param {string} [suffix] Suffix to add to the uniform name.
  12746. */
  12747. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  12748. /**
  12749. * Wrapper for updateUniform.
  12750. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12751. * @param {number} x
  12752. * @param {number} y
  12753. * @param {number} z
  12754. * @param {number} w
  12755. * @param {string} [suffix] Suffix to add to the uniform name.
  12756. */
  12757. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  12758. /**
  12759. * Wrapper for updateUniform.
  12760. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12761. * @param {Matrix} A 4x4 matrix.
  12762. */
  12763. updateMatrix: (name: string, mat: Matrix) => void;
  12764. /**
  12765. * Wrapper for updateUniform.
  12766. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12767. * @param {Vector3} vector
  12768. */
  12769. updateVector3: (name: string, vector: Vector3) => void;
  12770. /**
  12771. * Wrapper for updateUniform.
  12772. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12773. * @param {Vector4} vector
  12774. */
  12775. updateVector4: (name: string, vector: Vector4) => void;
  12776. /**
  12777. * Wrapper for updateUniform.
  12778. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12779. * @param {Color3} color
  12780. * @param {string} [suffix] Suffix to add to the uniform name.
  12781. */
  12782. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  12783. /**
  12784. * Wrapper for updateUniform.
  12785. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12786. * @param {Color3} color
  12787. * @param {number} alpha
  12788. * @param {string} [suffix] Suffix to add to the uniform name.
  12789. */
  12790. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  12791. /**
  12792. * Uniform buffer objects.
  12793. *
  12794. * Handles blocks of uniform on the GPU.
  12795. *
  12796. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  12797. *
  12798. * For more information, please refer to :
  12799. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  12800. */
  12801. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  12802. /**
  12803. * Indicates if the buffer is using the WebGL2 UBO implementation,
  12804. * or just falling back on setUniformXXX calls.
  12805. */
  12806. readonly useUbo: boolean;
  12807. /**
  12808. * Indicates if the WebGL underlying uniform buffer is in sync
  12809. * with the javascript cache data.
  12810. */
  12811. readonly isSync: boolean;
  12812. /**
  12813. * Indicates if the WebGL underlying uniform buffer is dynamic.
  12814. * Also, a dynamic UniformBuffer will disable cache verification and always
  12815. * update the underlying WebGL uniform buffer to the GPU.
  12816. */
  12817. isDynamic(): boolean;
  12818. /**
  12819. * The data cache on JS side.
  12820. */
  12821. getData(): Float32Array;
  12822. /**
  12823. * The underlying WebGL Uniform buffer.
  12824. */
  12825. getBuffer(): Nullable<WebGLBuffer>;
  12826. /**
  12827. * std140 layout specifies how to align data within an UBO structure.
  12828. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  12829. * for specs.
  12830. */
  12831. private _fillAlignment(size);
  12832. /**
  12833. * Adds an uniform in the buffer.
  12834. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  12835. * for the layout to be correct !
  12836. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12837. * @param {number|number[]} size Data size, or data directly.
  12838. */
  12839. addUniform(name: string, size: number | number[]): void;
  12840. /**
  12841. * Wrapper for addUniform.
  12842. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12843. * @param {Matrix} mat A 4x4 matrix.
  12844. */
  12845. addMatrix(name: string, mat: Matrix): void;
  12846. /**
  12847. * Wrapper for addUniform.
  12848. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12849. * @param {number} x
  12850. * @param {number} y
  12851. */
  12852. addFloat2(name: string, x: number, y: number): void;
  12853. /**
  12854. * Wrapper for addUniform.
  12855. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12856. * @param {number} x
  12857. * @param {number} y
  12858. * @param {number} z
  12859. */
  12860. addFloat3(name: string, x: number, y: number, z: number): void;
  12861. /**
  12862. * Wrapper for addUniform.
  12863. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12864. * @param {Color3} color
  12865. */
  12866. addColor3(name: string, color: Color3): void;
  12867. /**
  12868. * Wrapper for addUniform.
  12869. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12870. * @param {Color3} color
  12871. * @param {number} alpha
  12872. */
  12873. addColor4(name: string, color: Color3, alpha: number): void;
  12874. /**
  12875. * Wrapper for addUniform.
  12876. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12877. * @param {Vector3} vector
  12878. */
  12879. addVector3(name: string, vector: Vector3): void;
  12880. /**
  12881. * Wrapper for addUniform.
  12882. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12883. */
  12884. addMatrix3x3(name: string): void;
  12885. /**
  12886. * Wrapper for addUniform.
  12887. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12888. */
  12889. addMatrix2x2(name: string): void;
  12890. /**
  12891. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  12892. */
  12893. create(): void;
  12894. _rebuild(): void;
  12895. /**
  12896. * Updates the WebGL Uniform Buffer on the GPU.
  12897. * If the `dynamic` flag is set to true, no cache comparison is done.
  12898. * Otherwise, the buffer will be updated only if the cache differs.
  12899. */
  12900. update(): void;
  12901. /**
  12902. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  12903. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  12904. * @param {number[]|Float32Array} data Flattened data
  12905. * @param {number} size Size of the data.
  12906. */
  12907. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  12908. private _updateMatrix3x3ForUniform(name, matrix);
  12909. private _updateMatrix3x3ForEffect(name, matrix);
  12910. private _updateMatrix2x2ForEffect(name, matrix);
  12911. private _updateMatrix2x2ForUniform(name, matrix);
  12912. private _updateFloatForEffect(name, x);
  12913. private _updateFloatForUniform(name, x);
  12914. private _updateFloat2ForEffect(name, x, y, suffix?);
  12915. private _updateFloat2ForUniform(name, x, y, suffix?);
  12916. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  12917. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  12918. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  12919. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  12920. private _updateMatrixForEffect(name, mat);
  12921. private _updateMatrixForUniform(name, mat);
  12922. private _updateVector3ForEffect(name, vector);
  12923. private _updateVector3ForUniform(name, vector);
  12924. private _updateVector4ForEffect(name, vector);
  12925. private _updateVector4ForUniform(name, vector);
  12926. private _updateColor3ForEffect(name, color, suffix?);
  12927. private _updateColor3ForUniform(name, color, suffix?);
  12928. private _updateColor4ForEffect(name, color, alpha, suffix?);
  12929. private _updateColor4ForUniform(name, color, alpha, suffix?);
  12930. /**
  12931. * Sets a sampler uniform on the effect.
  12932. * @param {string} name Name of the sampler.
  12933. * @param {Texture} texture
  12934. */
  12935. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  12936. /**
  12937. * Directly updates the value of the uniform in the cache AND on the GPU.
  12938. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  12939. * @param {number[]|Float32Array} data Flattened data
  12940. */
  12941. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  12942. /**
  12943. * Binds this uniform buffer to an effect.
  12944. * @param {Effect} effect
  12945. * @param {string} name Name of the uniform block in the shader.
  12946. */
  12947. bindToEffect(effect: Effect, name: string): void;
  12948. /**
  12949. * Disposes the uniform buffer.
  12950. */
  12951. dispose(): void;
  12952. }
  12953. }
  12954. declare module BABYLON {
  12955. class Scalar {
  12956. /**
  12957. * Two pi constants convenient for computation.
  12958. */
  12959. static TwoPi: number;
  12960. /**
  12961. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  12962. */
  12963. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  12964. /**
  12965. * Returns a string : the upper case translation of the number i to hexadecimal.
  12966. */
  12967. static ToHex(i: number): string;
  12968. /**
  12969. * Returns -1 if value is negative and +1 is value is positive.
  12970. * Returns the value itself if it's equal to zero.
  12971. */
  12972. static Sign(value: number): number;
  12973. /**
  12974. * Returns the value itself if it's between min and max.
  12975. * Returns min if the value is lower than min.
  12976. * Returns max if the value is greater than max.
  12977. */
  12978. static Clamp(value: number, min?: number, max?: number): number;
  12979. /**
  12980. * Returns the log2 of value.
  12981. */
  12982. static Log2(value: number): number;
  12983. /**
  12984. * Loops the value, so that it is never larger than length and never smaller than 0.
  12985. *
  12986. * This is similar to the modulo operator but it works with floating point numbers.
  12987. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  12988. * With t = 5 and length = 2.5, the result would be 0.0.
  12989. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  12990. */
  12991. static Repeat(value: number, length: number): number;
  12992. /**
  12993. * Normalize the value between 0.0 and 1.0 using min and max values
  12994. */
  12995. static Normalize(value: number, min: number, max: number): number;
  12996. /**
  12997. * Denormalize the value from 0.0 and 1.0 using min and max values
  12998. */
  12999. static Denormalize(normalized: number, min: number, max: number): number;
  13000. /**
  13001. * Calculates the shortest difference between two given angles given in degrees.
  13002. */
  13003. static DeltaAngle(current: number, target: number): number;
  13004. /**
  13005. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  13006. *
  13007. * The returned value will move back and forth between 0 and length
  13008. */
  13009. static PingPong(tx: number, length: number): number;
  13010. /**
  13011. * Interpolates between min and max with smoothing at the limits.
  13012. *
  13013. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  13014. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  13015. */
  13016. static SmoothStep(from: number, to: number, tx: number): number;
  13017. /**
  13018. * Moves a value current towards target.
  13019. *
  13020. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  13021. * Negative values of maxDelta pushes the value away from target.
  13022. */
  13023. static MoveTowards(current: number, target: number, maxDelta: number): number;
  13024. /**
  13025. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  13026. *
  13027. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  13028. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  13029. */
  13030. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  13031. /**
  13032. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  13033. */
  13034. static Lerp(start: number, end: number, amount: number): number;
  13035. /**
  13036. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  13037. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  13038. */
  13039. static LerpAngle(start: number, end: number, amount: number): number;
  13040. /**
  13041. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  13042. */
  13043. static InverseLerp(a: number, b: number, value: number): number;
  13044. /**
  13045. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  13046. */
  13047. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  13048. /**
  13049. * Returns a random float number between and min and max values
  13050. */
  13051. static RandomRange(min: number, max: number): number;
  13052. /**
  13053. * This function returns percentage of a number in a given range.
  13054. *
  13055. * RangeToPercent(40,20,60) will return 0.5 (50%)
  13056. * RangeToPercent(34,0,100) will return 0.34 (34%)
  13057. */
  13058. static RangeToPercent(number: number, min: number, max: number): number;
  13059. /**
  13060. * This function returns number that corresponds to the percentage in a given range.
  13061. *
  13062. * PercentToRange(0.34,0,100) will return 34.
  13063. */
  13064. static PercentToRange(percent: number, min: number, max: number): number;
  13065. /**
  13066. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  13067. * @param angle The angle to normalize in radian.
  13068. * @return The converted angle.
  13069. */
  13070. static NormalizeRadians(angle: number): number;
  13071. }
  13072. }
  13073. declare module BABYLON {
  13074. const ToGammaSpace: number;
  13075. const ToLinearSpace = 2.2;
  13076. const Epsilon = 0.001;
  13077. /**
  13078. * Class used to hold a RBG color
  13079. */
  13080. class Color3 {
  13081. /**
  13082. * Defines the red component (between 0 and 1, default is 0)
  13083. */
  13084. r: number;
  13085. /**
  13086. * Defines the green component (between 0 and 1, default is 0)
  13087. */
  13088. g: number;
  13089. /**
  13090. * Defines the blue component (between 0 and 1, default is 0)
  13091. */
  13092. b: number;
  13093. /**
  13094. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  13095. * @param r defines the red component (between 0 and 1, default is 0)
  13096. * @param g defines the green component (between 0 and 1, default is 0)
  13097. * @param b defines the blue component (between 0 and 1, default is 0)
  13098. */
  13099. constructor(
  13100. /**
  13101. * Defines the red component (between 0 and 1, default is 0)
  13102. */
  13103. r?: number,
  13104. /**
  13105. * Defines the green component (between 0 and 1, default is 0)
  13106. */
  13107. g?: number,
  13108. /**
  13109. * Defines the blue component (between 0 and 1, default is 0)
  13110. */
  13111. b?: number);
  13112. /**
  13113. * Creates a string with the Color3 current values
  13114. * @returns the string representation of the Color3 object
  13115. */
  13116. toString(): string;
  13117. /**
  13118. * Returns the string "Color3"
  13119. * @returns "Color3"
  13120. */
  13121. getClassName(): string;
  13122. /**
  13123. * Compute the Color3 hash code
  13124. * @returns an unique number that can be used to hash Color3 objects
  13125. */
  13126. getHashCode(): number;
  13127. /**
  13128. * Stores in the passed array from the passed starting index the red, green, blue values as successive elements
  13129. * @param array defines the array where to store the r,g,b components
  13130. * @param index defines an optional index in the target array to define where to start storing values
  13131. * @returns the current Color3 object
  13132. */
  13133. toArray(array: FloatArray, index?: number): Color3;
  13134. /**
  13135. * Returns a new {BABYLON.Color4} object from the current Color3 and the passed alpha
  13136. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  13137. * @returns a new {BABYLON.Color4} object
  13138. */
  13139. toColor4(alpha?: number): Color4;
  13140. /**
  13141. * Returns a new array populated with 3 numeric elements : red, green and blue values
  13142. * @returns the new array
  13143. */
  13144. asArray(): number[];
  13145. /**
  13146. * Returns the luminance value
  13147. * @returns a float value
  13148. */
  13149. toLuminance(): number;
  13150. /**
  13151. * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object
  13152. * @param otherColor defines the second operand
  13153. * @returns the new Color3 object
  13154. */
  13155. multiply(otherColor: Color3): Color3;
  13156. /**
  13157. * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result"
  13158. * @param otherColor defines the second operand
  13159. * @param result defines the Color3 object where to store the result
  13160. * @returns the current Color3
  13161. */
  13162. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  13163. /**
  13164. * Determines equality between Color3 objects
  13165. * @param otherColor defines the second operand
  13166. * @returns true if the rgb values are equal to the passed ones
  13167. */
  13168. equals(otherColor: Color3): boolean;
  13169. /**
  13170. * Determines equality between the current Color3 object and a set of r,b,g values
  13171. * @param r defines the red component to check
  13172. * @param g defines the green component to check
  13173. * @param b defines the blue component to check
  13174. * @returns true if the rgb values are equal to the passed ones
  13175. */
  13176. equalsFloats(r: number, g: number, b: number): boolean;
  13177. /**
  13178. * Multiplies in place each rgb value by scale
  13179. * @param scale defines the scaling factor
  13180. * @returns the updated Color3
  13181. */
  13182. scale(scale: number): Color3;
  13183. /**
  13184. * Multiplies the rgb values by scale and stores the result into "result"
  13185. * @param scale defines the scaling factor
  13186. * @param result defines the Color3 object where to store the result
  13187. * @returns the unmodified current Color3
  13188. */
  13189. scaleToRef(scale: number, result: Color3): Color3;
  13190. /**
  13191. * Scale the current Color3 values by a factor and add the result to a given Color3
  13192. * @param scale defines the scale factor
  13193. * @param result defines color to store the result into
  13194. * @returns the unmodified current Color3
  13195. */
  13196. scaleAndAddToRef(scale: number, result: Color3): Color3;
  13197. /**
  13198. * Clamps the rgb values by the min and max values and stores the result into "result"
  13199. * @param min defines minimum clamping value (default is 0)
  13200. * @param max defines maximum clamping value (default is 1)
  13201. * @param result defines color to store the result into
  13202. * @returns the original Color3
  13203. */
  13204. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  13205. /**
  13206. * Creates a new Color3 set with the added values of the current Color3 and of the passed one
  13207. * @param otherColor defines the second operand
  13208. * @returns the new Color3
  13209. */
  13210. add(otherColor: Color3): Color3;
  13211. /**
  13212. * Stores the result of the addition of the current Color3 and passed one rgb values into "result"
  13213. * @param otherColor defines the second operand
  13214. * @param result defines Color3 object to store the result into
  13215. * @returns the unmodified current Color3
  13216. */
  13217. addToRef(otherColor: Color3, result: Color3): Color3;
  13218. /**
  13219. * Returns a new Color3 set with the subtracted values of the passed one from the current Color3
  13220. * @param otherColor defines the second operand
  13221. * @returns the new Color3
  13222. */
  13223. subtract(otherColor: Color3): Color3;
  13224. /**
  13225. * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result"
  13226. * @param otherColor defines the second operand
  13227. * @param result defines Color3 object to store the result into
  13228. * @returns the unmodified current Color3
  13229. */
  13230. subtractToRef(otherColor: Color3, result: Color3): Color3;
  13231. /**
  13232. * Copy the current object
  13233. * @returns a new Color3 copied the current one
  13234. */
  13235. clone(): Color3;
  13236. /**
  13237. * Copies the rgb values from the source in the current Color3
  13238. * @param source defines the source Color3 object
  13239. * @returns the updated Color3 object
  13240. */
  13241. copyFrom(source: Color3): Color3;
  13242. /**
  13243. * Updates the Color3 rgb values from the passed floats
  13244. * @param r defines the red component to read from
  13245. * @param g defines the green component to read from
  13246. * @param b defines the blue component to read from
  13247. * @returns the current Color3 object
  13248. */
  13249. copyFromFloats(r: number, g: number, b: number): Color3;
  13250. /**
  13251. * Updates the Color3 rgb values from the passed floats
  13252. * @param r defines the red component to read from
  13253. * @param g defines the green component to read from
  13254. * @param b defines the blue component to read from
  13255. * @returns the current Color3 object
  13256. */
  13257. set(r: number, g: number, b: number): Color3;
  13258. /**
  13259. * Compute the Color3 hexadecimal code as a string
  13260. * @returns a string containing the hexadecimal representation of the Color3 object
  13261. */
  13262. toHexString(): string;
  13263. /**
  13264. * Computes a new Color3 converted from the current one to linear space
  13265. * @returns a new Color3 object
  13266. */
  13267. toLinearSpace(): Color3;
  13268. /**
  13269. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  13270. * @param convertedColor defines the Color3 object where to store the linear space version
  13271. * @returns the unmodified Color3
  13272. */
  13273. toLinearSpaceToRef(convertedColor: Color3): Color3;
  13274. /**
  13275. * Computes a new Color3 converted from the current one to gamma space
  13276. * @returns a new Color3 object
  13277. */
  13278. toGammaSpace(): Color3;
  13279. /**
  13280. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  13281. * @param convertedColor defines the Color3 object where to store the gamma space version
  13282. * @returns the unmodified Color3
  13283. */
  13284. toGammaSpaceToRef(convertedColor: Color3): Color3;
  13285. /**
  13286. * Creates a new Color3 from the string containing valid hexadecimal values
  13287. * @param hex defines a string containing valid hexadecimal values
  13288. * @returns a new Color3 object
  13289. */
  13290. static FromHexString(hex: string): Color3;
  13291. /**
  13292. * Creates a new Vector3 from the starting index of the passed array
  13293. * @param array defines the source array
  13294. * @param offset defines an offset in the source array
  13295. * @returns a new Color3 object
  13296. */
  13297. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  13298. /**
  13299. * Creates a new Color3 from integer values (< 256)
  13300. * @param r defines the red component to read from (value between 0 and 255)
  13301. * @param g defines the green component to read from (value between 0 and 255)
  13302. * @param b defines the blue component to read from (value between 0 and 255)
  13303. * @returns a new Color3 object
  13304. */
  13305. static FromInts(r: number, g: number, b: number): Color3;
  13306. /**
  13307. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  13308. * @param start defines the start Color3 value
  13309. * @param end defines the end Color3 value
  13310. * @param amount defines the gradient value between start and end
  13311. * @returns a new Color3 object
  13312. */
  13313. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  13314. /**
  13315. * Returns a Color3 value containing a red color
  13316. * @returns a new Color3 object
  13317. */
  13318. static Red(): Color3;
  13319. /**
  13320. * Returns a Color3 value containing a green color
  13321. * @returns a new Color3 object
  13322. */
  13323. static Green(): Color3;
  13324. /**
  13325. * Returns a Color3 value containing a blue color
  13326. * @returns a new Color3 object
  13327. */
  13328. static Blue(): Color3;
  13329. /**
  13330. * Returns a Color3 value containing a black color
  13331. * @returns a new Color3 object
  13332. */
  13333. static Black(): Color3;
  13334. /**
  13335. * Returns a Color3 value containing a white color
  13336. * @returns a new Color3 object
  13337. */
  13338. static White(): Color3;
  13339. /**
  13340. * Returns a Color3 value containing a purple color
  13341. * @returns a new Color3 object
  13342. */
  13343. static Purple(): Color3;
  13344. /**
  13345. * Returns a Color3 value containing a magenta color
  13346. * @returns a new Color3 object
  13347. */
  13348. static Magenta(): Color3;
  13349. /**
  13350. * Returns a Color3 value containing a yellow color
  13351. * @returns a new Color3 object
  13352. */
  13353. static Yellow(): Color3;
  13354. /**
  13355. * Returns a Color3 value containing a gray color
  13356. * @returns a new Color3 object
  13357. */
  13358. static Gray(): Color3;
  13359. /**
  13360. * Returns a Color3 value containing a teal color
  13361. * @returns a new Color3 object
  13362. */
  13363. static Teal(): Color3;
  13364. /**
  13365. * Returns a Color3 value containing a random color
  13366. * @returns a new Color3 object
  13367. */
  13368. static Random(): Color3;
  13369. }
  13370. /**
  13371. * Class used to hold a RBGA color
  13372. */
  13373. class Color4 {
  13374. /**
  13375. * Defines the red component (between 0 and 1, default is 0)
  13376. */
  13377. r: number;
  13378. /**
  13379. * Defines the green component (between 0 and 1, default is 0)
  13380. */
  13381. g: number;
  13382. /**
  13383. * Defines the blue component (between 0 and 1, default is 0)
  13384. */
  13385. b: number;
  13386. /**
  13387. * Defines the alpha component (between 0 and 1, default is 1)
  13388. */
  13389. a: number;
  13390. /**
  13391. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  13392. * @param r defines the red component (between 0 and 1, default is 0)
  13393. * @param g defines the green component (between 0 and 1, default is 0)
  13394. * @param b defines the blue component (between 0 and 1, default is 0)
  13395. * @param a defines the alpha component (between 0 and 1, default is 1)
  13396. */
  13397. constructor(
  13398. /**
  13399. * Defines the red component (between 0 and 1, default is 0)
  13400. */
  13401. r?: number,
  13402. /**
  13403. * Defines the green component (between 0 and 1, default is 0)
  13404. */
  13405. g?: number,
  13406. /**
  13407. * Defines the blue component (between 0 and 1, default is 0)
  13408. */
  13409. b?: number,
  13410. /**
  13411. * Defines the alpha component (between 0 and 1, default is 1)
  13412. */
  13413. a?: number);
  13414. /**
  13415. * Adds in place the passed Color4 values to the current Color4 object
  13416. * @param right defines the second operand
  13417. * @returns the current updated Color4 object
  13418. */
  13419. addInPlace(right: Color4): Color4;
  13420. /**
  13421. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  13422. * @returns the new array
  13423. */
  13424. asArray(): number[];
  13425. /**
  13426. * Stores from the starting index in the passed array the Color4 successive values
  13427. * @param array defines the array where to store the r,g,b components
  13428. * @param index defines an optional index in the target array to define where to start storing values
  13429. * @returns the current Color4 object
  13430. */
  13431. toArray(array: number[], index?: number): Color4;
  13432. /**
  13433. * Creates a new Color4 set with the added values of the current Color4 and of the passed one
  13434. * @param right defines the second operand
  13435. * @returns a new Color4 object
  13436. */
  13437. add(right: Color4): Color4;
  13438. /**
  13439. * Creates a new Color4 set with the subtracted values of the passed one from the current Color4
  13440. * @param right defines the second operand
  13441. * @returns a new Color4 object
  13442. */
  13443. subtract(right: Color4): Color4;
  13444. /**
  13445. * Subtracts the passed ones from the current Color4 values and stores the results in "result"
  13446. * @param right defines the second operand
  13447. * @param result defines the Color4 object where to store the result
  13448. * @returns the current Color4 object
  13449. */
  13450. subtractToRef(right: Color4, result: Color4): Color4;
  13451. /**
  13452. * Creates a new Color4 with the current Color4 values multiplied by scale
  13453. * @param scale defines the scaling factor to apply
  13454. * @returns a new Color4 object
  13455. */
  13456. scale(scale: number): Color4;
  13457. /**
  13458. * Multiplies the current Color4 values by scale and stores the result in "result"
  13459. * @param scale defines the scaling factor to apply
  13460. * @param result defines the Color4 object where to store the result
  13461. * @returns the current unmodified Color4
  13462. */
  13463. scaleToRef(scale: number, result: Color4): Color4;
  13464. /**
  13465. * Scale the current Color4 values by a factor and add the result to a given Color4
  13466. * @param scale defines the scale factor
  13467. * @param result defines the Color4 object where to store the result
  13468. * @returns the unmodified current Color4
  13469. */
  13470. scaleAndAddToRef(scale: number, result: Color4): Color4;
  13471. /**
  13472. * Clamps the rgb values by the min and max values and stores the result into "result"
  13473. * @param min defines minimum clamping value (default is 0)
  13474. * @param max defines maximum clamping value (default is 1)
  13475. * @param result defines color to store the result into.
  13476. * @returns the cuurent Color4
  13477. */
  13478. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  13479. /**
  13480. * Multipy an Color4 value by another and return a new Color4 object
  13481. * @param color defines the Color4 value to multiply by
  13482. * @returns a new Color4 object
  13483. */
  13484. multiply(color: Color4): Color4;
  13485. /**
  13486. * Multipy a Color4 value by another and push the result in a reference value
  13487. * @param color defines the Color4 value to multiply by
  13488. * @param result defines the Color4 to fill the result in
  13489. * @returns the result Color4
  13490. */
  13491. multiplyToRef(color: Color4, result: Color4): Color4;
  13492. /**
  13493. * Creates a string with the Color4 current values
  13494. * @returns the string representation of the Color4 object
  13495. */
  13496. toString(): string;
  13497. /**
  13498. * Returns the string "Color4"
  13499. * @returns "Color4"
  13500. */
  13501. getClassName(): string;
  13502. /**
  13503. * Compute the Color4 hash code
  13504. * @returns an unique number that can be used to hash Color4 objects
  13505. */
  13506. getHashCode(): number;
  13507. /**
  13508. * Creates a new Color4 copied from the current one
  13509. * @returns a new Color4 object
  13510. */
  13511. clone(): Color4;
  13512. /**
  13513. * Copies the passed Color4 values into the current one
  13514. * @param source defines the source Color4 object
  13515. * @returns the current updated Color4 object
  13516. */
  13517. copyFrom(source: Color4): Color4;
  13518. /**
  13519. * Copies the passed float values into the current one
  13520. * @param r defines the red component to read from
  13521. * @param g defines the green component to read from
  13522. * @param b defines the blue component to read from
  13523. * @param a defines the alpha component to read from
  13524. * @returns the current updated Color4 object
  13525. */
  13526. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  13527. /**
  13528. * Copies the passed float values into the current one
  13529. * @param r defines the red component to read from
  13530. * @param g defines the green component to read from
  13531. * @param b defines the blue component to read from
  13532. * @param a defines the alpha component to read from
  13533. * @returns the current updated Color4 object
  13534. */
  13535. set(r: number, g: number, b: number, a: number): Color4;
  13536. /**
  13537. * Compute the Color4 hexadecimal code as a string
  13538. * @returns a string containing the hexadecimal representation of the Color4 object
  13539. */
  13540. toHexString(): string;
  13541. /**
  13542. * Computes a new Color4 converted from the current one to linear space
  13543. * @returns a new Color4 object
  13544. */
  13545. toLinearSpace(): Color4;
  13546. /**
  13547. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  13548. * @param convertedColor defines the Color4 object where to store the linear space version
  13549. * @returns the unmodified Color4
  13550. */
  13551. toLinearSpaceToRef(convertedColor: Color4): Color4;
  13552. /**
  13553. * Computes a new Color4 converted from the current one to gamma space
  13554. * @returns a new Color4 object
  13555. */
  13556. toGammaSpace(): Color4;
  13557. /**
  13558. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  13559. * @param convertedColor defines the Color4 object where to store the gamma space version
  13560. * @returns the unmodified Color4
  13561. */
  13562. toGammaSpaceToRef(convertedColor: Color4): Color4;
  13563. /**
  13564. * Creates a new Color4 from the string containing valid hexadecimal values
  13565. * @param hex defines a string containing valid hexadecimal values
  13566. * @returns a new Color4 object
  13567. */
  13568. static FromHexString(hex: string): Color4;
  13569. /**
  13570. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  13571. * @param left defines the start value
  13572. * @param right defines the end value
  13573. * @param amount defines the gradient factor
  13574. * @returns a new Color4 object
  13575. */
  13576. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  13577. /**
  13578. * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  13579. * @param left defines the start value
  13580. * @param right defines the end value
  13581. * @param amount defines the gradient factor
  13582. * @param result defines the Color4 object where to store data
  13583. */
  13584. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  13585. /**
  13586. * Creates a new Color4 from the starting index element of the passed array
  13587. * @param array defines the source array to read from
  13588. * @param offset defines the offset in the source array
  13589. * @returns a new Color4 object
  13590. */
  13591. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  13592. /**
  13593. * Creates a new Color3 from integer values (< 256)
  13594. * @param r defines the red component to read from (value between 0 and 255)
  13595. * @param g defines the green component to read from (value between 0 and 255)
  13596. * @param b defines the blue component to read from (value between 0 and 255)
  13597. * @param a defines the alpha component to read from (value between 0 and 255)
  13598. * @returns a new Color3 object
  13599. */
  13600. static FromInts(r: number, g: number, b: number, a: number): Color4;
  13601. /**
  13602. * Check the content of a given array and convert it to an array containing RGBA data
  13603. * If the original array was already containing count * 4 values then it is returned directly
  13604. * @param colors defines the array to check
  13605. * @param count defines the number of RGBA data to expect
  13606. * @returns an array containing count * 4 values (RGBA)
  13607. */
  13608. static CheckColors4(colors: number[], count: number): number[];
  13609. }
  13610. class Vector2 {
  13611. x: number;
  13612. y: number;
  13613. /**
  13614. * Creates a new Vector2 from the passed x and y coordinates.
  13615. */
  13616. constructor(x: number, y: number);
  13617. /**
  13618. * Returns a string with the Vector2 coordinates.
  13619. */
  13620. toString(): string;
  13621. /**
  13622. * Returns the string "Vector2"
  13623. */
  13624. getClassName(): string;
  13625. /**
  13626. * Returns the Vector2 hash code as a number.
  13627. */
  13628. getHashCode(): number;
  13629. /**
  13630. * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index.
  13631. * Returns the Vector2.
  13632. */
  13633. toArray(array: FloatArray, index?: number): Vector2;
  13634. /**
  13635. * Returns a new array with 2 elements : the Vector2 coordinates.
  13636. */
  13637. asArray(): number[];
  13638. /**
  13639. * Sets the Vector2 coordinates with the passed Vector2 coordinates.
  13640. * Returns the updated Vector2.
  13641. */
  13642. copyFrom(source: Vector2): Vector2;
  13643. /**
  13644. * Sets the Vector2 coordinates with the passed floats.
  13645. * Returns the updated Vector2.
  13646. */
  13647. copyFromFloats(x: number, y: number): Vector2;
  13648. /**
  13649. * Sets the Vector2 coordinates with the passed floats.
  13650. * Returns the updated Vector2.
  13651. */
  13652. set(x: number, y: number): Vector2;
  13653. /**
  13654. * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates.
  13655. */
  13656. add(otherVector: Vector2): Vector2;
  13657. /**
  13658. * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates.
  13659. * Returns the Vector2.
  13660. */
  13661. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  13662. /**
  13663. * Set the Vector2 coordinates by adding the passed Vector2 coordinates.
  13664. * Returns the updated Vector2.
  13665. */
  13666. addInPlace(otherVector: Vector2): Vector2;
  13667. /**
  13668. * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates.
  13669. */
  13670. addVector3(otherVector: Vector3): Vector2;
  13671. /**
  13672. * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2.
  13673. */
  13674. subtract(otherVector: Vector2): Vector2;
  13675. /**
  13676. * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates.
  13677. * Returns the Vector2.
  13678. */
  13679. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  13680. /**
  13681. * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates.
  13682. * Returns the updated Vector2.
  13683. */
  13684. subtractInPlace(otherVector: Vector2): Vector2;
  13685. /**
  13686. * Multiplies in place the current Vector2 coordinates by the passed ones.
  13687. * Returns the updated Vector2.
  13688. */
  13689. multiplyInPlace(otherVector: Vector2): Vector2;
  13690. /**
  13691. * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates.
  13692. */
  13693. multiply(otherVector: Vector2): Vector2;
  13694. /**
  13695. * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates.
  13696. * Returns the Vector2.
  13697. */
  13698. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  13699. /**
  13700. * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats.
  13701. */
  13702. multiplyByFloats(x: number, y: number): Vector2;
  13703. /**
  13704. * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates.
  13705. */
  13706. divide(otherVector: Vector2): Vector2;
  13707. /**
  13708. * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates.
  13709. * Returns the Vector2.
  13710. */
  13711. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  13712. /**
  13713. * Divides the current Vector3 coordinates by the passed ones.
  13714. * Returns the updated Vector3.
  13715. */
  13716. divideInPlace(otherVector: Vector2): Vector2;
  13717. /**
  13718. * Returns a new Vector2 with current Vector2 negated coordinates.
  13719. */
  13720. negate(): Vector2;
  13721. /**
  13722. * Multiply the Vector2 coordinates by scale.
  13723. * Returns the updated Vector2.
  13724. */
  13725. scaleInPlace(scale: number): Vector2;
  13726. /**
  13727. * Returns a new Vector2 scaled by "scale" from the current Vector2.
  13728. */
  13729. scale(scale: number): Vector2;
  13730. /**
  13731. * Scale the current Vector2 values by a factor to a given Vector2
  13732. * @param scale defines the scale factor
  13733. * @param result defines the Vector2 object where to store the result
  13734. * @returns the unmodified current Vector2
  13735. */
  13736. scaleToRef(scale: number, result: Vector2): Vector2;
  13737. /**
  13738. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  13739. * @param scale defines the scale factor
  13740. * @param result defines the Vector2 object where to store the result
  13741. * @returns the unmodified current Vector2
  13742. */
  13743. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  13744. /**
  13745. * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones.
  13746. */
  13747. equals(otherVector: Vector2): boolean;
  13748. /**
  13749. * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon.
  13750. */
  13751. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  13752. /**
  13753. * Returns the vector length (float).
  13754. */
  13755. length(): number;
  13756. /**
  13757. * Returns the vector squared length (float);
  13758. */
  13759. lengthSquared(): number;
  13760. /**
  13761. * Normalize the vector.
  13762. * Returns the updated Vector2.
  13763. */
  13764. normalize(): Vector2;
  13765. /**
  13766. * Returns a new Vector2 copied from the Vector2.
  13767. */
  13768. clone(): Vector2;
  13769. /**
  13770. * Returns a new Vector2(0, 0)
  13771. */
  13772. static Zero(): Vector2;
  13773. /**
  13774. * Returns a new Vector2(1, 1)
  13775. */
  13776. static One(): Vector2;
  13777. /**
  13778. * Returns a new Vector2 set from the passed index element of the passed array.
  13779. */
  13780. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  13781. /**
  13782. * Sets "result" from the passed index element of the passed array.
  13783. */
  13784. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  13785. /**
  13786. * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2.
  13787. */
  13788. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  13789. /**
  13790. * 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".
  13791. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  13792. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate.
  13793. */
  13794. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  13795. /**
  13796. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2".
  13797. */
  13798. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  13799. /**
  13800. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  13801. */
  13802. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  13803. /**
  13804. * Returns the dot product (float) of the vector "left" and the vector "right".
  13805. */
  13806. static Dot(left: Vector2, right: Vector2): number;
  13807. /**
  13808. * Returns a new Vector2 equal to the normalized passed vector.
  13809. */
  13810. static Normalize(vector: Vector2): Vector2;
  13811. /**
  13812. * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors.
  13813. */
  13814. static Minimize(left: Vector2, right: Vector2): Vector2;
  13815. /**
  13816. * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors.
  13817. */
  13818. static Maximize(left: Vector2, right: Vector2): Vector2;
  13819. /**
  13820. * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix.
  13821. */
  13822. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  13823. /**
  13824. * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates.
  13825. */
  13826. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  13827. /**
  13828. * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  13829. */
  13830. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  13831. /**
  13832. * Returns the distance (float) between the vectors "value1" and "value2".
  13833. */
  13834. static Distance(value1: Vector2, value2: Vector2): number;
  13835. /**
  13836. * Returns the squared distance (float) between the vectors "value1" and "value2".
  13837. */
  13838. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  13839. /**
  13840. * Returns a new Vecto2 located at the center of the vectors "value1" and "value2".
  13841. */
  13842. static Center(value1: Vector2, value2: Vector2): Vector2;
  13843. /**
  13844. * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  13845. */
  13846. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  13847. }
  13848. /**
  13849. * Classed used to store (x,y,z) vector representation
  13850. * A Vector3 is the main object used in 3D geometry
  13851. * It can represent etiher the coordinates of a point the space, either a direction
  13852. * Reminder: Babylon.js uses a left handed forward facing system
  13853. */
  13854. class Vector3 {
  13855. /**
  13856. * Defines the first coordinates (on X axis)
  13857. */
  13858. x: number;
  13859. /**
  13860. * Defines the second coordinates (on Y axis)
  13861. */
  13862. y: number;
  13863. /**
  13864. * Defines the third coordinates (on Z axis)
  13865. */
  13866. z: number;
  13867. /**
  13868. * Creates a new Vector3 object from the passed x, y, z (floats) coordinates.
  13869. * @param x defines the first coordinates (on X axis)
  13870. * @param y defines the second coordinates (on Y axis)
  13871. * @param z defines the third coordinates (on Z axis)
  13872. */
  13873. constructor(
  13874. /**
  13875. * Defines the first coordinates (on X axis)
  13876. */
  13877. x: number,
  13878. /**
  13879. * Defines the second coordinates (on Y axis)
  13880. */
  13881. y: number,
  13882. /**
  13883. * Defines the third coordinates (on Z axis)
  13884. */
  13885. z: number);
  13886. /**
  13887. * Creates a string representation of the Vector3
  13888. * @returns a string with the Vector3 coordinates.
  13889. */
  13890. toString(): string;
  13891. /**
  13892. * Gets the class name
  13893. * @returns the string "Vector3"
  13894. */
  13895. getClassName(): string;
  13896. /**
  13897. * Creates the Vector3 hash code
  13898. * @returns a number which tends to be unique between Vector3 instances
  13899. */
  13900. getHashCode(): number;
  13901. /**
  13902. * Creates an array containing three elements : the coordinates of the Vector3
  13903. * @returns a new array of numbers
  13904. */
  13905. asArray(): number[];
  13906. /**
  13907. * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3
  13908. * @param array defines the destination array
  13909. * @param index defines the offset in the destination array
  13910. * @returns the current Vector3
  13911. */
  13912. toArray(array: FloatArray, index?: number): Vector3;
  13913. /**
  13914. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  13915. * @returns a new Quaternion object, computed from the Vector3 coordinates
  13916. */
  13917. toQuaternion(): Quaternion;
  13918. /**
  13919. * Adds the passed vector to the current Vector3
  13920. * @param otherVector defines the second operand
  13921. * @returns the current updated Vector3
  13922. */
  13923. addInPlace(otherVector: Vector3): Vector3;
  13924. /**
  13925. * Gets a new Vector3, result of the addition the current Vector3 and the passed vector
  13926. * @param otherVector defines the second operand
  13927. * @returns the resulting Vector3
  13928. */
  13929. add(otherVector: Vector3): Vector3;
  13930. /**
  13931. * Adds the current Vector3 to the passed one and stores the result in the vector "result"
  13932. * @param otherVector defines the second operand
  13933. * @param result defines the Vector3 object where to store the result
  13934. * @returns the current Vector3
  13935. */
  13936. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  13937. /**
  13938. * Subtract the passed vector from the current Vector3
  13939. * @param otherVector defines the second operand
  13940. * @returns the current updated Vector3
  13941. */
  13942. subtractInPlace(otherVector: Vector3): Vector3;
  13943. /**
  13944. * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3
  13945. * @param otherVector defines the second operand
  13946. * @returns the resulting Vector3
  13947. */
  13948. subtract(otherVector: Vector3): Vector3;
  13949. /**
  13950. * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result".
  13951. * @param otherVector defines the second operand
  13952. * @param result defines the Vector3 object where to store the result
  13953. * @returns the current Vector3
  13954. */
  13955. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  13956. /**
  13957. * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates
  13958. * @param x defines the x coordinate of the operand
  13959. * @param y defines the y coordinate of the operand
  13960. * @param z defines the z coordinate of the operand
  13961. * @returns the resulting Vector3
  13962. */
  13963. subtractFromFloats(x: number, y: number, z: number): Vector3;
  13964. /**
  13965. * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result
  13966. * @param x defines the x coordinate of the operand
  13967. * @param y defines the y coordinate of the operand
  13968. * @param z defines the z coordinate of the operand
  13969. * @param result defines the Vector3 object where to store the result
  13970. * @returns the current Vector3
  13971. */
  13972. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  13973. /**
  13974. * Gets a new Vector3 set with the current Vector3 negated coordinates
  13975. * @returns a new Vector3
  13976. */
  13977. negate(): Vector3;
  13978. /**
  13979. * Multiplies the Vector3 coordinates by the float "scale"
  13980. * @param scale defines the multiplier factor
  13981. * @returns the current updated Vector3
  13982. */
  13983. scaleInPlace(scale: number): Vector3;
  13984. /**
  13985. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  13986. * @param scale defines the multiplier factor
  13987. * @returns a new Vector3
  13988. */
  13989. scale(scale: number): Vector3;
  13990. /**
  13991. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates
  13992. * @param scale defines the multiplier factor
  13993. * @param result defines the Vector3 object where to store the result
  13994. * @returns the current Vector3
  13995. */
  13996. scaleToRef(scale: number, result: Vector3): Vector3;
  13997. /**
  13998. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  13999. * @param scale defines the scale factor
  14000. * @param result defines the Vector3 object where to store the result
  14001. * @returns the unmodified current Vector3
  14002. */
  14003. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  14004. /**
  14005. * Returns true if the current Vector3 and the passed vector coordinates are strictly equal
  14006. * @param otherVector defines the second operand
  14007. * @returns true if both vectors are equals
  14008. */
  14009. equals(otherVector: Vector3): boolean;
  14010. /**
  14011. * Returns true if the current Vector3 and the passed vector coordinates are distant less than epsilon
  14012. * @param otherVector defines the second operand
  14013. * @param epsilon defines the minimal distance to define values as equals
  14014. * @returns true if both vectors are distant less than epsilon
  14015. */
  14016. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  14017. /**
  14018. * Returns true if the current Vector3 coordinates equals the passed floats
  14019. * @param x defines the x coordinate of the operand
  14020. * @param y defines the y coordinate of the operand
  14021. * @param z defines the z coordinate of the operand
  14022. * @returns true if both vectors are equals
  14023. */
  14024. equalsToFloats(x: number, y: number, z: number): boolean;
  14025. /**
  14026. * Multiplies the current Vector3 coordinates by the passed ones
  14027. * @param otherVector defines the second operand
  14028. * @returns the current updated Vector3
  14029. */
  14030. multiplyInPlace(otherVector: Vector3): Vector3;
  14031. /**
  14032. * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector
  14033. * @param otherVector defines the second operand
  14034. * @returns the new Vector3
  14035. */
  14036. multiply(otherVector: Vector3): Vector3;
  14037. /**
  14038. * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result"
  14039. * @param otherVector defines the second operand
  14040. * @param result defines the Vector3 object where to store the result
  14041. * @returns the current Vector3
  14042. */
  14043. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  14044. /**
  14045. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the passed floats
  14046. * @param x defines the x coordinate of the operand
  14047. * @param y defines the y coordinate of the operand
  14048. * @param z defines the z coordinate of the operand
  14049. * @returns the new Vector3
  14050. */
  14051. multiplyByFloats(x: number, y: number, z: number): Vector3;
  14052. /**
  14053. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the passed ones
  14054. * @param otherVector defines the second operand
  14055. * @returns the new Vector3
  14056. */
  14057. divide(otherVector: Vector3): Vector3;
  14058. /**
  14059. * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result"
  14060. * @param otherVector defines the second operand
  14061. * @param result defines the Vector3 object where to store the result
  14062. * @returns the current Vector3
  14063. */
  14064. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  14065. /**
  14066. * Divides the current Vector3 coordinates by the passed ones.
  14067. * @param otherVector defines the second operand
  14068. * @returns the current updated Vector3
  14069. */
  14070. divideInPlace(otherVector: Vector3): Vector3;
  14071. /**
  14072. * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones
  14073. * @param other defines the second operand
  14074. * @returns the current updated Vector3
  14075. */
  14076. minimizeInPlace(other: Vector3): Vector3;
  14077. /**
  14078. * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones.
  14079. * @param other defines the second operand
  14080. * @returns the current updated Vector3
  14081. */
  14082. maximizeInPlace(other: Vector3): Vector3;
  14083. /**
  14084. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  14085. */
  14086. readonly isNonUniform: boolean;
  14087. /**
  14088. * Gets the length of the Vector3
  14089. * @returns the length of the Vecto3
  14090. */
  14091. length(): number;
  14092. /**
  14093. * Gets the squared length of the Vector3
  14094. * @returns squared length of the Vector3
  14095. */
  14096. lengthSquared(): number;
  14097. /**
  14098. * Normalize the current Vector3.
  14099. * Please note that this is an in place operation.
  14100. * @returns the current updated Vector3
  14101. */
  14102. normalize(): Vector3;
  14103. /**
  14104. * Normalize the current Vector3 to a new vector
  14105. * @returns the new Vector3
  14106. */
  14107. normalizeToNew(): Vector3;
  14108. /**
  14109. * Normalize the current Vector3 to the reference
  14110. * @param reference define the Vector3 to update
  14111. * @returns the updated Vector3
  14112. */
  14113. normalizeToRef(reference: Vector3): Vector3;
  14114. /**
  14115. * Creates a new Vector3 copied from the current Vector3
  14116. * @returns the new Vector3
  14117. */
  14118. clone(): Vector3;
  14119. /**
  14120. * Copies the passed vector coordinates to the current Vector3 ones
  14121. * @param source defines the source Vector3
  14122. * @returns the current updated Vector3
  14123. */
  14124. copyFrom(source: Vector3): Vector3;
  14125. /**
  14126. * Copies the passed floats to the current Vector3 coordinates
  14127. * @param x defines the x coordinate of the operand
  14128. * @param y defines the y coordinate of the operand
  14129. * @param z defines the z coordinate of the operand
  14130. * @returns the current updated Vector3
  14131. */
  14132. copyFromFloats(x: number, y: number, z: number): Vector3;
  14133. /**
  14134. * Copies the passed floats to the current Vector3 coordinates
  14135. * @param x defines the x coordinate of the operand
  14136. * @param y defines the y coordinate of the operand
  14137. * @param z defines the z coordinate of the operand
  14138. * @returns the current updated Vector3
  14139. */
  14140. set(x: number, y: number, z: number): Vector3;
  14141. /**
  14142. * Get the clip factor between two vectors
  14143. * @param vector0 defines the first operand
  14144. * @param vector1 defines the second operand
  14145. * @param axis defines the axis to use
  14146. * @param size defines the size along the axis
  14147. * @returns the clip factor
  14148. */
  14149. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  14150. /**
  14151. * Get angle between two vectors
  14152. * @param vector0 angle between vector0 and vector1
  14153. * @param vector1 angle between vector0 and vector1
  14154. * @param normal direction of the normal
  14155. * @return the angle between vector0 and vector1
  14156. */
  14157. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  14158. /**
  14159. * Returns a new Vector3 set from the index "offset" of the passed array
  14160. * @param array defines the source array
  14161. * @param offset defines the offset in the source array
  14162. * @returns the new Vector3
  14163. */
  14164. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  14165. /**
  14166. * Returns a new Vector3 set from the index "offset" of the passed Float32Array
  14167. * This function is deprecated. Use FromArray instead
  14168. * @param array defines the source array
  14169. * @param offset defines the offset in the source array
  14170. * @returns the new Vector3
  14171. */
  14172. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  14173. /**
  14174. * Sets the passed vector "result" with the element values from the index "offset" of the passed array
  14175. * @param array defines the source array
  14176. * @param offset defines the offset in the source array
  14177. * @param result defines the Vector3 where to store the result
  14178. */
  14179. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  14180. /**
  14181. * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array
  14182. * This function is deprecated. Use FromArrayToRef instead.
  14183. * @param array defines the source array
  14184. * @param offset defines the offset in the source array
  14185. * @param result defines the Vector3 where to store the result
  14186. */
  14187. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  14188. /**
  14189. * Sets the passed vector "result" with the passed floats.
  14190. * @param x defines the x coordinate of the source
  14191. * @param y defines the y coordinate of the source
  14192. * @param z defines the z coordinate of the source
  14193. * @param result defines the Vector3 where to store the result
  14194. */
  14195. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  14196. /**
  14197. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  14198. * @returns a new empty Vector3
  14199. */
  14200. static Zero(): Vector3;
  14201. /**
  14202. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  14203. * @returns a new unit Vector3
  14204. */
  14205. static One(): Vector3;
  14206. /**
  14207. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  14208. * @returns a new up Vector3
  14209. */
  14210. static Up(): Vector3;
  14211. /**
  14212. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  14213. * @returns a new forward Vector3
  14214. */
  14215. static Forward(): Vector3;
  14216. /**
  14217. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  14218. * @returns a new right Vector3
  14219. */
  14220. static Right(): Vector3;
  14221. /**
  14222. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  14223. * @returns a new left Vector3
  14224. */
  14225. static Left(): Vector3;
  14226. /**
  14227. * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector.
  14228. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  14229. * @param vector defines the Vector3 to transform
  14230. * @param transformation defines the transformation matrix
  14231. * @returns the transformed Vector3
  14232. */
  14233. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  14234. /**
  14235. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector
  14236. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  14237. * @param vector defines the Vector3 to transform
  14238. * @param transformation defines the transformation matrix
  14239. * @param result defines the Vector3 where to store the result
  14240. */
  14241. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  14242. /**
  14243. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z)
  14244. * This method computes tranformed coordinates only, not transformed direction vectors
  14245. * @param x define the x coordinate of the source vector
  14246. * @param y define the y coordinate of the source vector
  14247. * @param z define the z coordinate of the source vector
  14248. * @param transformation defines the transformation matrix
  14249. * @param result defines the Vector3 where to store the result
  14250. */
  14251. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  14252. /**
  14253. * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector
  14254. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  14255. * @param vector defines the Vector3 to transform
  14256. * @param transformation defines the transformation matrix
  14257. * @returns the new Vector3
  14258. */
  14259. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  14260. /**
  14261. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector
  14262. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  14263. * @param vector defines the Vector3 to transform
  14264. * @param transformation defines the transformation matrix
  14265. * @param result defines the Vector3 where to store the result
  14266. */
  14267. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  14268. /**
  14269. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z)
  14270. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  14271. * @param x define the x coordinate of the source vector
  14272. * @param y define the y coordinate of the source vector
  14273. * @param z define the z coordinate of the source vector
  14274. * @param transformation defines the transformation matrix
  14275. * @param result defines the Vector3 where to store the result
  14276. */
  14277. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  14278. /**
  14279. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  14280. * @param value1 defines the first control point
  14281. * @param value2 defines the second control point
  14282. * @param value3 defines the third control point
  14283. * @param value4 defines the fourth control point
  14284. * @param amount defines the amount on the spline to use
  14285. * @returns the new Vector3
  14286. */
  14287. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  14288. /**
  14289. * 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"
  14290. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  14291. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  14292. * @param value defines the current value
  14293. * @param min defines the lower range value
  14294. * @param max defines the upper range value
  14295. * @returns the new Vector3
  14296. */
  14297. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  14298. /**
  14299. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  14300. * @param value1 defines the first control point
  14301. * @param tangent1 defines the first tangent vector
  14302. * @param value2 defines the second control point
  14303. * @param tangent2 defines the second tangent vector
  14304. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  14305. * @returns the new Vector3
  14306. */
  14307. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  14308. /**
  14309. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  14310. * @param start defines the start value
  14311. * @param end defines the end value
  14312. * @param amount max defines amount between both (between 0 and 1)
  14313. * @returns the new Vector3
  14314. */
  14315. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  14316. /**
  14317. * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  14318. * @param start defines the start value
  14319. * @param end defines the end value
  14320. * @param amount max defines amount between both (between 0 and 1)
  14321. * @param result defines the Vector3 where to store the result
  14322. */
  14323. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  14324. /**
  14325. * Returns the dot product (float) between the vectors "left" and "right"
  14326. * @param left defines the left operand
  14327. * @param right defines the right operand
  14328. * @returns the dot product
  14329. */
  14330. static Dot(left: Vector3, right: Vector3): number;
  14331. /**
  14332. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  14333. * The cross product is then orthogonal to both "left" and "right"
  14334. * @param left defines the left operand
  14335. * @param right defines the right operand
  14336. * @returns the cross product
  14337. */
  14338. static Cross(left: Vector3, right: Vector3): Vector3;
  14339. /**
  14340. * Sets the passed vector "result" with the cross product of "left" and "right"
  14341. * The cross product is then orthogonal to both "left" and "right"
  14342. * @param left defines the left operand
  14343. * @param right defines the right operand
  14344. * @param result defines the Vector3 where to store the result
  14345. */
  14346. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  14347. /**
  14348. * Returns a new Vector3 as the normalization of the passed vector
  14349. * @param vector defines the Vector3 to normalize
  14350. * @returns the new Vector3
  14351. */
  14352. static Normalize(vector: Vector3): Vector3;
  14353. /**
  14354. * Sets the passed vector "result" with the normalization of the passed first vector
  14355. * @param vector defines the Vector3 to normalize
  14356. * @param result defines the Vector3 where to store the result
  14357. */
  14358. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  14359. private static _viewportMatrixCache;
  14360. /**
  14361. * Project a Vector3 onto screen space
  14362. * @param vector defines the Vector3 to project
  14363. * @param world defines the world matrix to use
  14364. * @param transform defines the transform (view x projection) matrix to use
  14365. * @param viewport defines the screen viewport to use
  14366. * @returns the new Vector3
  14367. */
  14368. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  14369. /**
  14370. * Unproject from screen space to object space
  14371. * @param source defines the screen space Vector3 to use
  14372. * @param viewportWidth defines the current width of the viewport
  14373. * @param viewportHeight defines the current height of the viewport
  14374. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  14375. * @param transform defines the transform (view x projection) matrix to use
  14376. * @returns the new Vector3
  14377. */
  14378. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  14379. /**
  14380. * Unproject from screen space to object space
  14381. * @param source defines the screen space Vector3 to use
  14382. * @param viewportWidth defines the current width of the viewport
  14383. * @param viewportHeight defines the current height of the viewport
  14384. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  14385. * @param view defines the view matrix to use
  14386. * @param projection defines the projection matrix to use
  14387. * @returns the new Vector3
  14388. */
  14389. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  14390. /**
  14391. * Unproject from screen space to object space
  14392. * @param source defines the screen space Vector3 to use
  14393. * @param viewportWidth defines the current width of the viewport
  14394. * @param viewportHeight defines the current height of the viewport
  14395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  14396. * @param view defines the view matrix to use
  14397. * @param projection defines the projection matrix to use
  14398. * @param result defines the Vector3 where to store the result
  14399. */
  14400. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  14401. /**
  14402. * Unproject from screen space to object space
  14403. * @param sourceX defines the screen space x coordinate to use
  14404. * @param sourceY defines the screen space y coordinate to use
  14405. * @param sourceZ defines the screen space z coordinate to use
  14406. * @param viewportWidth defines the current width of the viewport
  14407. * @param viewportHeight defines the current height of the viewport
  14408. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  14409. * @param view defines the view matrix to use
  14410. * @param projection defines the projection matrix to use
  14411. * @param result defines the Vector3 where to store the result
  14412. */
  14413. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  14414. /**
  14415. * Gets the minimal coordinate values between two Vector3
  14416. * @param left defines the first operand
  14417. * @param right defines the second operand
  14418. * @returns the new Vector3
  14419. */
  14420. static Minimize(left: Vector3, right: Vector3): Vector3;
  14421. /**
  14422. * Gets the maximal coordinate values between two Vector3
  14423. * @param left defines the first operand
  14424. * @param right defines the second operand
  14425. * @returns the new Vector3
  14426. */
  14427. static Maximize(left: Vector3, right: Vector3): Vector3;
  14428. /**
  14429. * Returns the distance between the vectors "value1" and "value2"
  14430. * @param value1 defines the first operand
  14431. * @param value2 defines the second operand
  14432. * @returns the distance
  14433. */
  14434. static Distance(value1: Vector3, value2: Vector3): number;
  14435. /**
  14436. * Returns the squared distance between the vectors "value1" and "value2"
  14437. * @param value1 defines the first operand
  14438. * @param value2 defines the second operand
  14439. * @returns the squared distance
  14440. */
  14441. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  14442. /**
  14443. * Returns a new Vector3 located at the center between "value1" and "value2"
  14444. * @param value1 defines the first operand
  14445. * @param value2 defines the second operand
  14446. * @returns the new Vector3
  14447. */
  14448. static Center(value1: Vector3, value2: Vector3): Vector3;
  14449. /**
  14450. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  14451. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  14452. * to something in order to rotate it from its local system to the given target system
  14453. * Note: axis1, axis2 and axis3 are normalized during this operation
  14454. * @param axis1 defines the first axis
  14455. * @param axis2 defines the second axis
  14456. * @param axis3 defines the third axis
  14457. * @returns a new Vector3
  14458. */
  14459. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  14460. /**
  14461. * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3
  14462. * @param axis1 defines the first axis
  14463. * @param axis2 defines the second axis
  14464. * @param axis3 defines the third axis
  14465. * @param ref defines the Vector3 where to store the result
  14466. */
  14467. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  14468. }
  14469. class Vector4 {
  14470. x: number;
  14471. y: number;
  14472. z: number;
  14473. w: number;
  14474. /**
  14475. * Creates a Vector4 object from the passed floats.
  14476. */
  14477. constructor(x: number, y: number, z: number, w: number);
  14478. /**
  14479. * Returns the string with the Vector4 coordinates.
  14480. */
  14481. toString(): string;
  14482. /**
  14483. * Returns the string "Vector4".
  14484. */
  14485. getClassName(): string;
  14486. /**
  14487. * Returns the Vector4 hash code.
  14488. */
  14489. getHashCode(): number;
  14490. /**
  14491. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  14492. */
  14493. asArray(): number[];
  14494. /**
  14495. * Populates the passed array from the passed index with the Vector4 coordinates.
  14496. * Returns the Vector4.
  14497. */
  14498. toArray(array: FloatArray, index?: number): Vector4;
  14499. /**
  14500. * Adds the passed vector to the current Vector4.
  14501. * Returns the updated Vector4.
  14502. */
  14503. addInPlace(otherVector: Vector4): Vector4;
  14504. /**
  14505. * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one.
  14506. */
  14507. add(otherVector: Vector4): Vector4;
  14508. /**
  14509. * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one.
  14510. * Returns the current Vector4.
  14511. */
  14512. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  14513. /**
  14514. * Subtract in place the passed vector from the current Vector4.
  14515. * Returns the updated Vector4.
  14516. */
  14517. subtractInPlace(otherVector: Vector4): Vector4;
  14518. /**
  14519. * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4.
  14520. */
  14521. subtract(otherVector: Vector4): Vector4;
  14522. /**
  14523. * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4.
  14524. * Returns the current Vector4.
  14525. */
  14526. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  14527. /**
  14528. * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  14529. */
  14530. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  14531. /**
  14532. * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  14533. * Returns the current Vector4.
  14534. */
  14535. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  14536. /**
  14537. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  14538. */
  14539. negate(): Vector4;
  14540. /**
  14541. * Multiplies the current Vector4 coordinates by scale (float).
  14542. * Returns the updated Vector4.
  14543. */
  14544. scaleInPlace(scale: number): Vector4;
  14545. /**
  14546. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  14547. */
  14548. scale(scale: number): Vector4;
  14549. /**
  14550. * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float).
  14551. * Returns the current Vector4.
  14552. */
  14553. scaleToRef(scale: number, result: Vector4): Vector4;
  14554. /**
  14555. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  14556. * @param scale defines the scale factor
  14557. * @param result defines the Vector4 object where to store the result
  14558. * @returns the unmodified current Vector4
  14559. */
  14560. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  14561. /**
  14562. * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones.
  14563. */
  14564. equals(otherVector: Vector4): boolean;
  14565. /**
  14566. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones.
  14567. */
  14568. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  14569. /**
  14570. * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates.
  14571. */
  14572. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  14573. /**
  14574. * Multiplies in place the current Vector4 by the passed one.
  14575. * Returns the updated Vector4.
  14576. */
  14577. multiplyInPlace(otherVector: Vector4): Vector4;
  14578. /**
  14579. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one.
  14580. */
  14581. multiply(otherVector: Vector4): Vector4;
  14582. /**
  14583. * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one.
  14584. * Returns the current Vector4.
  14585. */
  14586. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  14587. /**
  14588. * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates.
  14589. */
  14590. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  14591. /**
  14592. * Returns a new Vector4 set with the division result of the current Vector4 by the passed one.
  14593. */
  14594. divide(otherVector: Vector4): Vector4;
  14595. /**
  14596. * Updates the passed vector "result" with the division result of the current Vector4 by the passed one.
  14597. * Returns the current Vector4.
  14598. */
  14599. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  14600. /**
  14601. * Divides the current Vector3 coordinates by the passed ones.
  14602. * @returns the updated Vector3.
  14603. */
  14604. divideInPlace(otherVector: Vector4): Vector4;
  14605. /**
  14606. * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones
  14607. * @param other defines the second operand
  14608. * @returns the current updated Vector4
  14609. */
  14610. minimizeInPlace(other: Vector4): Vector4;
  14611. /**
  14612. * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones
  14613. * @param other defines the second operand
  14614. * @returns the current updated Vector4
  14615. */
  14616. maximizeInPlace(other: Vector4): Vector4;
  14617. /**
  14618. * Returns the Vector4 length (float).
  14619. */
  14620. length(): number;
  14621. /**
  14622. * Returns the Vector4 squared length (float).
  14623. */
  14624. lengthSquared(): number;
  14625. /**
  14626. * Normalizes in place the Vector4.
  14627. * Returns the updated Vector4.
  14628. */
  14629. normalize(): Vector4;
  14630. /**
  14631. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  14632. */
  14633. toVector3(): Vector3;
  14634. /**
  14635. * Returns a new Vector4 copied from the current one.
  14636. */
  14637. clone(): Vector4;
  14638. /**
  14639. * Updates the current Vector4 with the passed one coordinates.
  14640. * Returns the updated Vector4.
  14641. */
  14642. copyFrom(source: Vector4): Vector4;
  14643. /**
  14644. * Updates the current Vector4 coordinates with the passed floats.
  14645. * Returns the updated Vector4.
  14646. */
  14647. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  14648. /**
  14649. * Updates the current Vector4 coordinates with the passed floats.
  14650. * Returns the updated Vector4.
  14651. */
  14652. set(x: number, y: number, z: number, w: number): Vector4;
  14653. /**
  14654. * Returns a new Vector4 set from the starting index of the passed array.
  14655. */
  14656. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  14657. /**
  14658. * Updates the passed vector "result" from the starting index of the passed array.
  14659. */
  14660. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  14661. /**
  14662. * Updates the passed vector "result" from the starting index of the passed Float32Array.
  14663. */
  14664. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  14665. /**
  14666. * Updates the passed vector "result" coordinates from the passed floats.
  14667. */
  14668. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  14669. /**
  14670. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  14671. */
  14672. static Zero(): Vector4;
  14673. /**
  14674. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  14675. */
  14676. static One(): Vector4;
  14677. /**
  14678. * Returns a new normalized Vector4 from the passed one.
  14679. */
  14680. static Normalize(vector: Vector4): Vector4;
  14681. /**
  14682. * Updates the passed vector "result" from the normalization of the passed one.
  14683. */
  14684. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  14685. static Minimize(left: Vector4, right: Vector4): Vector4;
  14686. static Maximize(left: Vector4, right: Vector4): Vector4;
  14687. /**
  14688. * Returns the distance (float) between the vectors "value1" and "value2".
  14689. */
  14690. static Distance(value1: Vector4, value2: Vector4): number;
  14691. /**
  14692. * Returns the squared distance (float) between the vectors "value1" and "value2".
  14693. */
  14694. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  14695. /**
  14696. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  14697. */
  14698. static Center(value1: Vector4, value2: Vector4): Vector4;
  14699. /**
  14700. * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector.
  14701. * This methods computes transformed normalized direction vectors only.
  14702. */
  14703. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  14704. /**
  14705. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector.
  14706. * This methods computes transformed normalized direction vectors only.
  14707. */
  14708. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  14709. /**
  14710. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w).
  14711. * This methods computes transformed normalized direction vectors only.
  14712. */
  14713. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  14714. }
  14715. interface ISize {
  14716. width: number;
  14717. height: number;
  14718. }
  14719. class Size implements ISize {
  14720. width: number;
  14721. height: number;
  14722. /**
  14723. * Creates a Size object from the passed width and height (floats).
  14724. */
  14725. constructor(width: number, height: number);
  14726. toString(): string;
  14727. /**
  14728. * Returns the string "Size"
  14729. */
  14730. getClassName(): string;
  14731. /**
  14732. * Returns the Size hash code.
  14733. */
  14734. getHashCode(): number;
  14735. /**
  14736. * Updates the current size from the passed one.
  14737. * Returns the updated Size.
  14738. */
  14739. copyFrom(src: Size): void;
  14740. /**
  14741. * Updates in place the current Size from the passed floats.
  14742. * Returns the updated Size.
  14743. */
  14744. copyFromFloats(width: number, height: number): Size;
  14745. /**
  14746. * Updates in place the current Size from the passed floats.
  14747. * Returns the updated Size.
  14748. */
  14749. set(width: number, height: number): Size;
  14750. /**
  14751. * Returns a new Size set with the multiplication result of the current Size and the passed floats.
  14752. */
  14753. multiplyByFloats(w: number, h: number): Size;
  14754. /**
  14755. * Returns a new Size copied from the passed one.
  14756. */
  14757. clone(): Size;
  14758. /**
  14759. * Boolean : True if the current Size and the passed one width and height are strictly equal.
  14760. */
  14761. equals(other: Size): boolean;
  14762. /**
  14763. * Returns the surface of the Size : width * height (float).
  14764. */
  14765. readonly surface: number;
  14766. /**
  14767. * Returns a new Size set to (0.0, 0.0)
  14768. */
  14769. static Zero(): Size;
  14770. /**
  14771. * Returns a new Size set as the addition result of the current Size and the passed one.
  14772. */
  14773. add(otherSize: Size): Size;
  14774. /**
  14775. * Returns a new Size set as the subtraction result of the passed one from the current Size.
  14776. */
  14777. subtract(otherSize: Size): Size;
  14778. /**
  14779. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  14780. */
  14781. static Lerp(start: Size, end: Size, amount: number): Size;
  14782. }
  14783. class Quaternion {
  14784. x: number;
  14785. y: number;
  14786. z: number;
  14787. w: number;
  14788. /**
  14789. * Creates a new Quaternion from the passed floats.
  14790. */
  14791. constructor(x?: number, y?: number, z?: number, w?: number);
  14792. /**
  14793. * Returns a string with the Quaternion coordinates.
  14794. */
  14795. toString(): string;
  14796. /**
  14797. * Returns the string "Quaternion".
  14798. */
  14799. getClassName(): string;
  14800. /**
  14801. * Returns the Quaternion hash code.
  14802. */
  14803. getHashCode(): number;
  14804. /**
  14805. * Returns a new array populated with 4 elements : the Quaternion coordinates.
  14806. */
  14807. asArray(): number[];
  14808. /**
  14809. * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal.
  14810. */
  14811. equals(otherQuaternion: Quaternion): boolean;
  14812. /**
  14813. * Returns a new Quaternion copied from the current one.
  14814. */
  14815. clone(): Quaternion;
  14816. /**
  14817. * Updates the current Quaternion from the passed one coordinates.
  14818. * Returns the updated Quaterion.
  14819. */
  14820. copyFrom(other: Quaternion): Quaternion;
  14821. /**
  14822. * Updates the current Quaternion from the passed float coordinates.
  14823. * Returns the updated Quaterion.
  14824. */
  14825. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  14826. /**
  14827. * Updates the current Quaternion from the passed float coordinates.
  14828. * Returns the updated Quaterion.
  14829. */
  14830. set(x: number, y: number, z: number, w: number): Quaternion;
  14831. /**
  14832. * Returns a new Quaternion as the addition result of the passed one and the current Quaternion.
  14833. */
  14834. add(other: Quaternion): Quaternion;
  14835. /**
  14836. * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion.
  14837. */
  14838. subtract(other: Quaternion): Quaternion;
  14839. /**
  14840. * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale".
  14841. */
  14842. scale(value: number): Quaternion;
  14843. /**
  14844. * Scale the current Quaternion values by a factor to a given Quaternion
  14845. * @param scale defines the scale factor
  14846. * @param result defines the Quaternion object where to store the result
  14847. * @returns the unmodified current Quaternion
  14848. */
  14849. scaleToRef(scale: number, result: Quaternion): Quaternion;
  14850. /**
  14851. * Scale the current Quaternion values by a factor and add the result to a given Quaternion
  14852. * @param scale defines the scale factor
  14853. * @param result defines the Quaternion object where to store the result
  14854. * @returns the unmodified current Quaternion
  14855. */
  14856. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  14857. /**
  14858. * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1".
  14859. */
  14860. multiply(q1: Quaternion): Quaternion;
  14861. /**
  14862. * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1".
  14863. * Returns the current Quaternion.
  14864. */
  14865. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  14866. /**
  14867. * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1".
  14868. * Returns the updated Quaternion.
  14869. */
  14870. multiplyInPlace(q1: Quaternion): Quaternion;
  14871. /**
  14872. * Sets the passed "ref" with the conjugation of the current Quaternion.
  14873. * Returns the current Quaternion.
  14874. */
  14875. conjugateToRef(ref: Quaternion): Quaternion;
  14876. /**
  14877. * Conjugates in place the current Quaternion.
  14878. * Returns the updated Quaternion.
  14879. */
  14880. conjugateInPlace(): Quaternion;
  14881. /**
  14882. * Returns a new Quaternion as the conjugate of the current Quaternion.
  14883. */
  14884. conjugate(): Quaternion;
  14885. /**
  14886. * Returns the Quaternion length (float).
  14887. */
  14888. length(): number;
  14889. /**
  14890. * Normalize in place the current Quaternion.
  14891. * Returns the updated Quaternion.
  14892. */
  14893. normalize(): Quaternion;
  14894. /**
  14895. * Returns a new Vector3 set with the Euler angles translated from the current Quaternion
  14896. * @param order is a reserved parameter and is ignore for now
  14897. * @returns the new Vector3
  14898. */
  14899. toEulerAngles(order?: string): Vector3;
  14900. /**
  14901. * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion
  14902. * @param result defines the vector which will be filled with the Euler angles
  14903. * @param order is a reserved parameter and is ignore for now
  14904. * @returns the current Quaternion
  14905. */
  14906. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  14907. /**
  14908. * Updates the passed rotation matrix with the current Quaternion values.
  14909. * Returns the current Quaternion.
  14910. */
  14911. toRotationMatrix(result: Matrix): Quaternion;
  14912. /**
  14913. * Updates the current Quaternion from the passed rotation matrix values.
  14914. * Returns the updated Quaternion.
  14915. */
  14916. fromRotationMatrix(matrix: Matrix): Quaternion;
  14917. /**
  14918. * Returns a new Quaternion set from the passed rotation matrix values.
  14919. */
  14920. static FromRotationMatrix(matrix: Matrix): Quaternion;
  14921. /**
  14922. * Updates the passed quaternion "result" with the passed rotation matrix values.
  14923. */
  14924. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  14925. /**
  14926. * Returns a new Quaternion set to (0.0, 0.0, 0.0).
  14927. */
  14928. static Zero(): Quaternion;
  14929. /**
  14930. * Returns a new Quaternion as the inverted current Quaternion.
  14931. */
  14932. static Inverse(q: Quaternion): Quaternion;
  14933. /**
  14934. * Returns the identity Quaternion.
  14935. */
  14936. static Identity(): Quaternion;
  14937. static IsIdentity(quaternion: Quaternion): boolean;
  14938. /**
  14939. * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float).
  14940. */
  14941. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  14942. /**
  14943. * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float).
  14944. */
  14945. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  14946. /**
  14947. * Retuns a new Quaternion set from the starting index of the passed array.
  14948. */
  14949. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  14950. /**
  14951. * Returns a new Quaternion set from the passed Euler float angles (y, x, z).
  14952. */
  14953. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  14954. /**
  14955. * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z).
  14956. */
  14957. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  14958. /**
  14959. * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation
  14960. */
  14961. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  14962. /**
  14963. * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation
  14964. */
  14965. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  14966. /**
  14967. * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  14968. * cf to Vector3.RotationFromAxis() documentation.
  14969. * Note : axis1, axis2 and axis3 are normalized during this operation.
  14970. */
  14971. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion;
  14972. /**
  14973. * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  14974. * cf to Vector3.RotationFromAxis() documentation.
  14975. * Note : axis1, axis2 and axis3 are normalized during this operation.
  14976. */
  14977. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  14978. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  14979. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  14980. /**
  14981. * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2".
  14982. */
  14983. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  14984. }
  14985. class Matrix {
  14986. private static _tempQuaternion;
  14987. private static _xAxis;
  14988. private static _yAxis;
  14989. private static _zAxis;
  14990. private static _updateFlagSeed;
  14991. private static _identityReadOnly;
  14992. private _isIdentity;
  14993. private _isIdentityDirty;
  14994. updateFlag: number;
  14995. m: Float32Array;
  14996. _markAsUpdated(): void;
  14997. constructor();
  14998. /**
  14999. * Boolean : True is the matrix is the identity matrix
  15000. */
  15001. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  15002. /**
  15003. * Returns the matrix determinant (float).
  15004. */
  15005. determinant(): number;
  15006. /**
  15007. * Returns the matrix underlying array.
  15008. */
  15009. toArray(): Float32Array;
  15010. /**
  15011. * Returns the matrix underlying array.
  15012. */
  15013. asArray(): Float32Array;
  15014. /**
  15015. * Inverts in place the Matrix.
  15016. * Returns the Matrix inverted.
  15017. */
  15018. invert(): Matrix;
  15019. /**
  15020. * Sets all the matrix elements to zero.
  15021. * Returns the Matrix.
  15022. */
  15023. reset(): Matrix;
  15024. /**
  15025. * Returns a new Matrix as the addition result of the current Matrix and the passed one.
  15026. */
  15027. add(other: Matrix): Matrix;
  15028. /**
  15029. * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one.
  15030. * Returns the Matrix.
  15031. */
  15032. addToRef(other: Matrix, result: Matrix): Matrix;
  15033. /**
  15034. * Adds in place the passed matrix to the current Matrix.
  15035. * Returns the updated Matrix.
  15036. */
  15037. addToSelf(other: Matrix): Matrix;
  15038. /**
  15039. * Sets the passed matrix with the current inverted Matrix.
  15040. * Returns the unmodified current Matrix.
  15041. */
  15042. invertToRef(other: Matrix): Matrix;
  15043. /**
  15044. * Inserts the translation vector (using 3 x floats) in the current Matrix.
  15045. * Returns the updated Matrix.
  15046. */
  15047. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  15048. /**
  15049. * Inserts the translation vector in the current Matrix.
  15050. * Returns the updated Matrix.
  15051. */
  15052. setTranslation(vector3: Vector3): Matrix;
  15053. /**
  15054. * Returns a new Vector3 as the extracted translation from the Matrix.
  15055. */
  15056. getTranslation(): Vector3;
  15057. /**
  15058. * Fill a Vector3 with the extracted translation from the Matrix.
  15059. */
  15060. getTranslationToRef(result: Vector3): Matrix;
  15061. /**
  15062. * Remove rotation and scaling part from the Matrix.
  15063. * Returns the updated Matrix.
  15064. */
  15065. removeRotationAndScaling(): Matrix;
  15066. /**
  15067. * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one.
  15068. */
  15069. multiply(other: Matrix): Matrix;
  15070. /**
  15071. * Updates the current Matrix from the passed one values.
  15072. * Returns the updated Matrix.
  15073. */
  15074. copyFrom(other: Matrix): Matrix;
  15075. /**
  15076. * Populates the passed array from the starting index with the Matrix values.
  15077. * Returns the Matrix.
  15078. */
  15079. copyToArray(array: Float32Array, offset?: number): Matrix;
  15080. /**
  15081. * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one.
  15082. */
  15083. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  15084. /**
  15085. * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one.
  15086. */
  15087. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  15088. /**
  15089. * Boolean : True is the current Matrix and the passed one values are strictly equal.
  15090. */
  15091. equals(value: Matrix): boolean;
  15092. /**
  15093. * Returns a new Matrix from the current Matrix.
  15094. */
  15095. clone(): Matrix;
  15096. /**
  15097. * Returns the string "Matrix"
  15098. */
  15099. getClassName(): string;
  15100. /**
  15101. * Returns the Matrix hash code.
  15102. */
  15103. getHashCode(): number;
  15104. /**
  15105. * Decomposes the current Matrix into :
  15106. * - a scale vector3 passed as a reference to update,
  15107. * - a rotation quaternion passed as a reference to update,
  15108. * - a translation vector3 passed as a reference to update.
  15109. * Returns the true if operation was successful.
  15110. */
  15111. decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean;
  15112. /**
  15113. * Returns the index-th row of the current matrix as a new Vector4.
  15114. */
  15115. getRow(index: number): Nullable<Vector4>;
  15116. /**
  15117. * Sets the index-th row of the current matrix with the passed Vector4 values.
  15118. * Returns the updated Matrix.
  15119. */
  15120. setRow(index: number, row: Vector4): Matrix;
  15121. /**
  15122. * Compute the transpose of the matrix.
  15123. * Returns a new Matrix.
  15124. */
  15125. transpose(): Matrix;
  15126. /**
  15127. * Compute the transpose of the matrix.
  15128. * Returns the current matrix.
  15129. */
  15130. transposeToRef(result: Matrix): Matrix;
  15131. /**
  15132. * Sets the index-th row of the current matrix with the passed 4 x float values.
  15133. * Returns the updated Matrix.
  15134. */
  15135. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  15136. /**
  15137. * Compute a new Matrix set with the current Matrix values multiplied by scale (float)
  15138. * @param scale defines the scale factor
  15139. * @returns a new Matrix
  15140. */
  15141. scale(scale: number): Matrix;
  15142. /**
  15143. * Scale the current Matrix values by a factor to a given result Matrix
  15144. * @param scale defines the scale factor
  15145. * @param result defines the Matrix to store the result
  15146. * @returns the current Matrix
  15147. */
  15148. scaleToRef(scale: number, result: Matrix): Matrix;
  15149. /**
  15150. * Scale the current Matrix values by a factor and add the result to a given Matrix
  15151. * @param scale defines the scale factor
  15152. * @param result defines the Matrix to store the result
  15153. * @returns the current Matrix
  15154. */
  15155. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  15156. /**
  15157. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  15158. * @param ref matrix to store the result
  15159. */
  15160. toNormalMatrix(ref: Matrix): void;
  15161. /**
  15162. * Returns a new Matrix as the extracted rotation matrix from the current one.
  15163. */
  15164. getRotationMatrix(): Matrix;
  15165. /**
  15166. * Extracts the rotation matrix from the current one and sets it as the passed "result".
  15167. * Returns the current Matrix.
  15168. */
  15169. getRotationMatrixToRef(result: Matrix): Matrix;
  15170. /**
  15171. * Returns a new Matrix set from the starting index of the passed array.
  15172. */
  15173. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  15174. /**
  15175. * Sets the passed "result" matrix from the starting index of the passed array.
  15176. */
  15177. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  15178. /**
  15179. * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale".
  15180. */
  15181. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  15182. /**
  15183. * Sets the passed matrix "result" with the 16 passed floats.
  15184. */
  15185. 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;
  15186. /**
  15187. * Static identity matrix to be used as readonly matrix
  15188. * Must not be updated.
  15189. */
  15190. static readonly IdentityReadOnly: Matrix;
  15191. /**
  15192. * Returns a new Matrix set from the 16 passed floats.
  15193. */
  15194. 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;
  15195. /**
  15196. * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  15197. */
  15198. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  15199. /**
  15200. * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  15201. */
  15202. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  15203. /**
  15204. * Returns a new indentity Matrix.
  15205. */
  15206. static Identity(): Matrix;
  15207. /**
  15208. * Sets the passed "result" as an identity matrix.
  15209. */
  15210. static IdentityToRef(result: Matrix): void;
  15211. /**
  15212. * Returns a new zero Matrix.
  15213. */
  15214. static Zero(): Matrix;
  15215. /**
  15216. * Returns a new rotation matrix for "angle" radians around the X axis.
  15217. */
  15218. static RotationX(angle: number): Matrix;
  15219. /**
  15220. * Returns a new Matrix as the passed inverted one.
  15221. */
  15222. static Invert(source: Matrix): Matrix;
  15223. /**
  15224. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis.
  15225. */
  15226. static RotationXToRef(angle: number, result: Matrix): void;
  15227. /**
  15228. * Returns a new rotation matrix for "angle" radians around the Y axis.
  15229. */
  15230. static RotationY(angle: number): Matrix;
  15231. /**
  15232. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis.
  15233. */
  15234. static RotationYToRef(angle: number, result: Matrix): void;
  15235. /**
  15236. * Returns a new rotation matrix for "angle" radians around the Z axis.
  15237. */
  15238. static RotationZ(angle: number): Matrix;
  15239. /**
  15240. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis.
  15241. */
  15242. static RotationZToRef(angle: number, result: Matrix): void;
  15243. /**
  15244. * Returns a new rotation matrix for "angle" radians around the passed axis.
  15245. */
  15246. static RotationAxis(axis: Vector3, angle: number): Matrix;
  15247. /**
  15248. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis.
  15249. */
  15250. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  15251. /**
  15252. * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z).
  15253. */
  15254. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  15255. /**
  15256. * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z).
  15257. */
  15258. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  15259. /**
  15260. * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z).
  15261. */
  15262. static Scaling(x: number, y: number, z: number): Matrix;
  15263. /**
  15264. * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z).
  15265. */
  15266. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  15267. /**
  15268. * Returns a new Matrix as a translation matrix from the passed floats (x, y, z).
  15269. */
  15270. static Translation(x: number, y: number, z: number): Matrix;
  15271. /**
  15272. * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z).
  15273. */
  15274. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  15275. /**
  15276. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  15277. * @param startValue defines the start value
  15278. * @param endValue defines the end value
  15279. * @param gradient defines the gradient factor
  15280. * @returns the new matrix
  15281. */
  15282. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  15283. /**
  15284. * Set the passed matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  15285. * @param startValue defines the start value
  15286. * @param endValue defines the end value
  15287. * @param gradient defines the gradient factor
  15288. * @param result defines the Matrix object where to store data
  15289. */
  15290. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  15291. /**
  15292. * Returns a new Matrix whose values are computed by :
  15293. * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices,
  15294. * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end,
  15295. * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices.
  15296. */
  15297. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  15298. /**
  15299. * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  15300. * This methods works for a Left-Handed system.
  15301. */
  15302. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  15303. /**
  15304. * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  15305. * This methods works for a Left-Handed system.
  15306. */
  15307. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  15308. /**
  15309. * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  15310. * This methods works for a Right-Handed system.
  15311. */
  15312. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  15313. /**
  15314. * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  15315. * This methods works for a Left-Handed system.
  15316. */
  15317. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  15318. /**
  15319. * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  15320. */
  15321. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  15322. /**
  15323. * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  15324. */
  15325. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  15326. /**
  15327. * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  15328. */
  15329. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  15330. /**
  15331. * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  15332. */
  15333. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  15334. /**
  15335. * Returns a new Matrix as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  15336. */
  15337. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  15338. /**
  15339. * Sets the passed matrix "result" as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  15340. */
  15341. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  15342. /**
  15343. * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  15344. */
  15345. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  15346. /**
  15347. * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  15348. */
  15349. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  15350. /**
  15351. * Sets the passed matrix "result" as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  15352. */
  15353. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  15354. /**
  15355. * Returns a new Matrix as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  15356. */
  15357. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  15358. /**
  15359. * Sets the passed matrix "result" as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  15360. */
  15361. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  15362. /**
  15363. * Sets the passed matrix "result" as a left-handed perspective projection matrix for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  15364. */
  15365. static PerspectiveFovWebVRToRef(fov: {
  15366. upDegrees: number;
  15367. downDegrees: number;
  15368. leftDegrees: number;
  15369. rightDegrees: number;
  15370. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  15371. /**
  15372. * Returns the final transformation matrix : world * view * projection * viewport
  15373. */
  15374. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  15375. /**
  15376. * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix.
  15377. */
  15378. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  15379. /**
  15380. * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix.
  15381. */
  15382. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  15383. /**
  15384. * Compute the transpose of the passed Matrix.
  15385. * Returns a new Matrix.
  15386. */
  15387. static Transpose(matrix: Matrix): Matrix;
  15388. /**
  15389. * Compute the transpose of the passed Matrix and store it in the result matrix.
  15390. */
  15391. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  15392. /**
  15393. * Returns a new Matrix as the reflection matrix across the passed plane.
  15394. */
  15395. static Reflection(plane: Plane): Matrix;
  15396. /**
  15397. * Sets the passed matrix "result" as the reflection matrix across the passed plane.
  15398. */
  15399. static ReflectionToRef(plane: Plane, result: Matrix): void;
  15400. /**
  15401. * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis.
  15402. */
  15403. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  15404. /**
  15405. * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion.
  15406. */
  15407. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  15408. }
  15409. class Plane {
  15410. normal: Vector3;
  15411. d: number;
  15412. /**
  15413. * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  15414. */
  15415. constructor(a: number, b: number, c: number, d: number);
  15416. /**
  15417. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  15418. */
  15419. asArray(): number[];
  15420. /**
  15421. * Returns a new plane copied from the current Plane.
  15422. */
  15423. clone(): Plane;
  15424. /**
  15425. * Returns the string "Plane".
  15426. */
  15427. getClassName(): string;
  15428. /**
  15429. * Returns the Plane hash code.
  15430. */
  15431. getHashCode(): number;
  15432. /**
  15433. * Normalize the current Plane in place.
  15434. * Returns the updated Plane.
  15435. */
  15436. normalize(): Plane;
  15437. /**
  15438. * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix.
  15439. */
  15440. transform(transformation: Matrix): Plane;
  15441. /**
  15442. * Returns the dot product (float) of the point coordinates and the plane normal.
  15443. */
  15444. dotCoordinate(point: Vector3): number;
  15445. /**
  15446. * Updates the current Plane from the plane defined by the three passed points.
  15447. * Returns the updated Plane.
  15448. */
  15449. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  15450. /**
  15451. * Boolean : True is the vector "direction" is the same side than the plane normal.
  15452. */
  15453. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  15454. /**
  15455. * Returns the signed distance (float) from the passed point to the Plane.
  15456. */
  15457. signedDistanceTo(point: Vector3): number;
  15458. /**
  15459. * Returns a new Plane from the passed array.
  15460. */
  15461. static FromArray(array: ArrayLike<number>): Plane;
  15462. /**
  15463. * Returns a new Plane defined by the three passed points.
  15464. */
  15465. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  15466. /**
  15467. * Returns a new Plane the normal vector to this plane at the passed origin point.
  15468. * Note : the vector "normal" is updated because normalized.
  15469. */
  15470. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  15471. /**
  15472. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point.
  15473. */
  15474. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  15475. }
  15476. class Viewport {
  15477. x: number;
  15478. y: number;
  15479. width: number;
  15480. height: number;
  15481. /**
  15482. * Creates a Viewport object located at (x, y) and sized (width, height).
  15483. */
  15484. constructor(x: number, y: number, width: number, height: number);
  15485. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  15486. /**
  15487. * Returns a new Viewport copied from the current one.
  15488. */
  15489. clone(): Viewport;
  15490. }
  15491. class Frustum {
  15492. /**
  15493. * Returns a new array of 6 Frustum planes computed by the passed transformation matrix.
  15494. */
  15495. static GetPlanes(transform: Matrix): Plane[];
  15496. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15497. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15498. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15499. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15500. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15501. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15502. /**
  15503. * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix.
  15504. */
  15505. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  15506. }
  15507. enum Space {
  15508. LOCAL = 0,
  15509. WORLD = 1,
  15510. BONE = 2,
  15511. }
  15512. class Axis {
  15513. static X: Vector3;
  15514. static Y: Vector3;
  15515. static Z: Vector3;
  15516. }
  15517. class BezierCurve {
  15518. /**
  15519. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats.
  15520. */
  15521. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  15522. }
  15523. enum Orientation {
  15524. CW = 0,
  15525. CCW = 1,
  15526. }
  15527. class Angle {
  15528. private _radians;
  15529. /**
  15530. * Creates an Angle object of "radians" radians (float).
  15531. */
  15532. constructor(radians: number);
  15533. /**
  15534. * Returns the Angle value in degrees (float).
  15535. */
  15536. degrees: () => number;
  15537. /**
  15538. * Returns the Angle value in radians (float).
  15539. */
  15540. radians: () => number;
  15541. /**
  15542. * Returns a new Angle object valued with the angle value in radians between the two passed vectors.
  15543. */
  15544. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  15545. /**
  15546. * Returns a new Angle object from the passed float in radians.
  15547. */
  15548. static FromRadians(radians: number): Angle;
  15549. /**
  15550. * Returns a new Angle object from the passed float in degrees.
  15551. */
  15552. static FromDegrees(degrees: number): Angle;
  15553. }
  15554. class Arc2 {
  15555. startPoint: Vector2;
  15556. midPoint: Vector2;
  15557. endPoint: Vector2;
  15558. centerPoint: Vector2;
  15559. radius: number;
  15560. angle: Angle;
  15561. startAngle: Angle;
  15562. orientation: Orientation;
  15563. /**
  15564. * Creates an Arc object from the three passed points : start, middle and end.
  15565. */
  15566. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  15567. }
  15568. class Path2 {
  15569. private _points;
  15570. private _length;
  15571. closed: boolean;
  15572. /**
  15573. * Creates a Path2 object from the starting 2D coordinates x and y.
  15574. */
  15575. constructor(x: number, y: number);
  15576. /**
  15577. * Adds a new segment until the passed coordinates (x, y) to the current Path2.
  15578. * Returns the updated Path2.
  15579. */
  15580. addLineTo(x: number, y: number): Path2;
  15581. /**
  15582. * 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.
  15583. * Returns the updated Path2.
  15584. */
  15585. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  15586. /**
  15587. * Closes the Path2.
  15588. * Returns the Path2.
  15589. */
  15590. close(): Path2;
  15591. /**
  15592. * Returns the Path2 total length (float).
  15593. */
  15594. length(): number;
  15595. /**
  15596. * Returns the Path2 internal array of points.
  15597. */
  15598. getPoints(): Vector2[];
  15599. /**
  15600. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  15601. */
  15602. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  15603. /**
  15604. * Returns a new Path2 starting at the coordinates (x, y).
  15605. */
  15606. static StartingAt(x: number, y: number): Path2;
  15607. }
  15608. class Path3D {
  15609. path: Vector3[];
  15610. private _curve;
  15611. private _distances;
  15612. private _tangents;
  15613. private _normals;
  15614. private _binormals;
  15615. private _raw;
  15616. /**
  15617. * new Path3D(path, normal, raw)
  15618. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  15619. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  15620. * path : an array of Vector3, the curve axis of the Path3D
  15621. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  15622. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  15623. */
  15624. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  15625. /**
  15626. * Returns the Path3D array of successive Vector3 designing its curve.
  15627. */
  15628. getCurve(): Vector3[];
  15629. /**
  15630. * Returns an array populated with tangent vectors on each Path3D curve point.
  15631. */
  15632. getTangents(): Vector3[];
  15633. /**
  15634. * Returns an array populated with normal vectors on each Path3D curve point.
  15635. */
  15636. getNormals(): Vector3[];
  15637. /**
  15638. * Returns an array populated with binormal vectors on each Path3D curve point.
  15639. */
  15640. getBinormals(): Vector3[];
  15641. /**
  15642. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  15643. */
  15644. getDistances(): number[];
  15645. /**
  15646. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  15647. * Returns the same object updated.
  15648. */
  15649. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  15650. private _compute(firstNormal);
  15651. private _getFirstNonNullVector(index);
  15652. private _getLastNonNullVector(index);
  15653. private _normalVector(v0, vt, va);
  15654. }
  15655. class Curve3 {
  15656. private _points;
  15657. private _length;
  15658. /**
  15659. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  15660. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  15661. * @param v1 (Vector3) the control point
  15662. * @param v2 (Vector3) the end point of the Quadratic Bezier
  15663. * @param nbPoints (integer) the wanted number of points in the curve
  15664. */
  15665. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  15666. /**
  15667. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  15668. * @param v0 (Vector3) the origin point of the Cubic Bezier
  15669. * @param v1 (Vector3) the first control point
  15670. * @param v2 (Vector3) the second control point
  15671. * @param v3 (Vector3) the end point of the Cubic Bezier
  15672. * @param nbPoints (integer) the wanted number of points in the curve
  15673. */
  15674. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  15675. /**
  15676. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  15677. * @param p1 (Vector3) the origin point of the Hermite Spline
  15678. * @param t1 (Vector3) the tangent vector at the origin point
  15679. * @param p2 (Vector3) the end point of the Hermite Spline
  15680. * @param t2 (Vector3) the tangent vector at the end point
  15681. * @param nbPoints (integer) the wanted number of points in the curve
  15682. */
  15683. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  15684. /**
  15685. * Returns a Curve3 object along a CatmullRom Spline curve :
  15686. * @param points (array of Vector3) the points the spline must pass through. At least, four points required.
  15687. * @param nbPoints (integer) the wanted number of points between each curve control points.
  15688. */
  15689. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3;
  15690. /**
  15691. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  15692. * A Curve3 is designed from a series of successive Vector3.
  15693. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  15694. */
  15695. constructor(points: Vector3[]);
  15696. /**
  15697. * Returns the Curve3 stored array of successive Vector3
  15698. */
  15699. getPoints(): Vector3[];
  15700. /**
  15701. * Returns the computed length (float) of the curve.
  15702. */
  15703. length(): number;
  15704. /**
  15705. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  15706. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  15707. * curveA and curveB keep unchanged.
  15708. */
  15709. continue(curve: Curve3): Curve3;
  15710. private _computeLength(path);
  15711. }
  15712. class PositionNormalVertex {
  15713. position: Vector3;
  15714. normal: Vector3;
  15715. constructor(position?: Vector3, normal?: Vector3);
  15716. clone(): PositionNormalVertex;
  15717. }
  15718. class PositionNormalTextureVertex {
  15719. position: Vector3;
  15720. normal: Vector3;
  15721. uv: Vector2;
  15722. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  15723. clone(): PositionNormalTextureVertex;
  15724. }
  15725. class Tmp {
  15726. static Color3: Color3[];
  15727. static Vector2: Vector2[];
  15728. static Vector3: Vector3[];
  15729. static Vector4: Vector4[];
  15730. static Quaternion: Quaternion[];
  15731. static Matrix: Matrix[];
  15732. }
  15733. }
  15734. declare module BABYLON {
  15735. class SphericalPolynomial {
  15736. x: Vector3;
  15737. y: Vector3;
  15738. z: Vector3;
  15739. xx: Vector3;
  15740. yy: Vector3;
  15741. zz: Vector3;
  15742. xy: Vector3;
  15743. yz: Vector3;
  15744. zx: Vector3;
  15745. addAmbient(color: Color3): void;
  15746. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  15747. scale(scale: number): void;
  15748. }
  15749. class SphericalHarmonics {
  15750. L00: Vector3;
  15751. L1_1: Vector3;
  15752. L10: Vector3;
  15753. L11: Vector3;
  15754. L2_2: Vector3;
  15755. L2_1: Vector3;
  15756. L20: Vector3;
  15757. L21: Vector3;
  15758. L22: Vector3;
  15759. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  15760. scale(scale: number): void;
  15761. convertIncidentRadianceToIrradiance(): void;
  15762. convertIrradianceToLambertianRadiance(): void;
  15763. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  15764. }
  15765. }
  15766. declare module BABYLON {
  15767. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  15768. static OCCLUSION_TYPE_NONE: number;
  15769. static OCCLUSION_TYPE_OPTIMISTIC: number;
  15770. static OCCLUSION_TYPE_STRICT: number;
  15771. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  15772. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  15773. static readonly BILLBOARDMODE_NONE: number;
  15774. static readonly BILLBOARDMODE_X: number;
  15775. static readonly BILLBOARDMODE_Y: number;
  15776. static readonly BILLBOARDMODE_Z: number;
  15777. static readonly BILLBOARDMODE_ALL: number;
  15778. private _facetPositions;
  15779. private _facetNormals;
  15780. private _facetPartitioning;
  15781. private _facetNb;
  15782. private _partitioningSubdivisions;
  15783. private _partitioningBBoxRatio;
  15784. private _facetDataEnabled;
  15785. private _facetParameters;
  15786. private _bbSize;
  15787. private _subDiv;
  15788. private _facetDepthSort;
  15789. private _facetDepthSortEnabled;
  15790. private _depthSortedIndices;
  15791. private _depthSortedFacets;
  15792. private _facetDepthSortFunction;
  15793. private _facetDepthSortFrom;
  15794. private _facetDepthSortOrigin;
  15795. private _invertedMatrix;
  15796. /**
  15797. * Read-only : the number of facets in the mesh
  15798. */
  15799. readonly facetNb: number;
  15800. /**
  15801. * The number (integer) of subdivisions per axis in the partioning space
  15802. */
  15803. partitioningSubdivisions: number;
  15804. /**
  15805. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  15806. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box.
  15807. */
  15808. partitioningBBoxRatio: number;
  15809. /**
  15810. * Boolean : must the facet be depth sorted on next call to `updateFacetData()` ?
  15811. * Works only for updatable meshes.
  15812. * Doesn't work with multi-materials.
  15813. */
  15814. mustDepthSortFacets: boolean;
  15815. /**
  15816. * The location (Vector3) where the facet depth sort must be computed from.
  15817. * By default, the active camera position.
  15818. * Used only when facet depth sort is enabled.
  15819. */
  15820. facetDepthSortFrom: Vector3;
  15821. /**
  15822. * Read-only boolean : is the feature facetData enabled ?
  15823. */
  15824. readonly isFacetDataEnabled: boolean;
  15825. _updateNonUniformScalingState(value: boolean): boolean;
  15826. /**
  15827. * An event triggered when this mesh collides with another one
  15828. */
  15829. onCollideObservable: Observable<AbstractMesh>;
  15830. private _onCollideObserver;
  15831. onCollide: () => void;
  15832. /**
  15833. * An event triggered when the collision's position changes
  15834. */
  15835. onCollisionPositionChangeObservable: Observable<Vector3>;
  15836. private _onCollisionPositionChangeObserver;
  15837. onCollisionPositionChange: () => void;
  15838. /**
  15839. * An event triggered when material is changed
  15840. */
  15841. onMaterialChangedObservable: Observable<AbstractMesh>;
  15842. definedFacingForward: boolean;
  15843. /**
  15844. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  15845. * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  15846. * or
  15847. * 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.
  15848. * for more info check WebGl documentations
  15849. */
  15850. occlusionQueryAlgorithmType: number;
  15851. /**
  15852. * 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:
  15853. * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  15854. * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  15855. * 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.
  15856. */
  15857. occlusionType: number;
  15858. /**
  15859. * 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.
  15860. * The default value is -1 which means don't break the query and wait till the result.
  15861. */
  15862. occlusionRetryCount: number;
  15863. private _occlusionInternalRetryCounter;
  15864. protected _isOccluded: boolean;
  15865. /**
  15866. * Property isOccluded : 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.
  15867. */
  15868. isOccluded: boolean;
  15869. private _isOcclusionQueryInProgress;
  15870. /**
  15871. * Flag to check the progress status of the query
  15872. */
  15873. readonly isOcclusionQueryInProgress: boolean;
  15874. private _occlusionQuery;
  15875. private _visibility;
  15876. /**
  15877. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  15878. */
  15879. /**
  15880. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  15881. */
  15882. visibility: number;
  15883. alphaIndex: number;
  15884. isVisible: boolean;
  15885. isPickable: boolean;
  15886. showBoundingBox: boolean;
  15887. showSubMeshesBoundingBox: boolean;
  15888. isBlocker: boolean;
  15889. enablePointerMoveEvents: boolean;
  15890. renderingGroupId: number;
  15891. private _material;
  15892. material: Nullable<Material>;
  15893. private _receiveShadows;
  15894. receiveShadows: boolean;
  15895. renderOutline: boolean;
  15896. outlineColor: Color3;
  15897. outlineWidth: number;
  15898. renderOverlay: boolean;
  15899. overlayColor: Color3;
  15900. overlayAlpha: number;
  15901. private _hasVertexAlpha;
  15902. hasVertexAlpha: boolean;
  15903. private _useVertexColors;
  15904. useVertexColors: boolean;
  15905. private _computeBonesUsingShaders;
  15906. computeBonesUsingShaders: boolean;
  15907. private _numBoneInfluencers;
  15908. numBoneInfluencers: number;
  15909. private _applyFog;
  15910. applyFog: boolean;
  15911. useOctreeForRenderingSelection: boolean;
  15912. useOctreeForPicking: boolean;
  15913. useOctreeForCollisions: boolean;
  15914. private _layerMask;
  15915. layerMask: number;
  15916. /**
  15917. * True if the mesh must be rendered in any case.
  15918. */
  15919. alwaysSelectAsActiveMesh: boolean;
  15920. /**
  15921. * This scene's action manager
  15922. */
  15923. actionManager: Nullable<ActionManager>;
  15924. physicsImpostor: Nullable<PhysicsImpostor>;
  15925. private _checkCollisions;
  15926. private _collisionMask;
  15927. private _collisionGroup;
  15928. ellipsoid: Vector3;
  15929. ellipsoidOffset: Vector3;
  15930. private _collider;
  15931. private _oldPositionForCollisions;
  15932. private _diffPositionForCollisions;
  15933. collisionMask: number;
  15934. collisionGroup: number;
  15935. edgesWidth: number;
  15936. edgesColor: Color4;
  15937. _edgesRenderer: Nullable<EdgesRenderer>;
  15938. private _collisionsTransformMatrix;
  15939. private _collisionsScalingMatrix;
  15940. _masterMesh: Nullable<AbstractMesh>;
  15941. _boundingInfo: Nullable<BoundingInfo>;
  15942. _renderId: number;
  15943. subMeshes: SubMesh[];
  15944. _submeshesOctree: Octree<SubMesh>;
  15945. _intersectionsInProgress: AbstractMesh[];
  15946. _unIndexed: boolean;
  15947. _lightSources: Light[];
  15948. readonly _positions: Nullable<Vector3[]>;
  15949. _waitingActions: any;
  15950. _waitingFreezeWorldMatrix: Nullable<boolean>;
  15951. private _skeleton;
  15952. _bonesTransformMatrices: Nullable<Float32Array>;
  15953. skeleton: Nullable<Skeleton>;
  15954. constructor(name: string, scene?: Nullable<Scene>);
  15955. /**
  15956. * Returns the string "AbstractMesh"
  15957. */
  15958. getClassName(): string;
  15959. /**
  15960. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  15961. */
  15962. toString(fullDetails?: boolean): string;
  15963. _rebuild(): void;
  15964. _resyncLightSources(): void;
  15965. _resyncLighSource(light: Light): void;
  15966. _removeLightSource(light: Light): void;
  15967. private _markSubMeshesAsDirty(func);
  15968. _markSubMeshesAsLightDirty(): void;
  15969. _markSubMeshesAsAttributesDirty(): void;
  15970. _markSubMeshesAsMiscDirty(): void;
  15971. /**
  15972. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  15973. * Default : (1.0, 1.0, 1.0)
  15974. */
  15975. /**
  15976. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  15977. * Default : (1.0, 1.0, 1.0)
  15978. */
  15979. scaling: Vector3;
  15980. /**
  15981. * Disables the mesh edger rendering mode.
  15982. * Returns the AbstractMesh.
  15983. */
  15984. disableEdgesRendering(): AbstractMesh;
  15985. /**
  15986. * Enables the edge rendering mode on the mesh.
  15987. * This mode makes the mesh edges visible.
  15988. * Returns the AbstractMesh.
  15989. */
  15990. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15991. /**
  15992. * Returns true if the mesh is blocked. Used by the class Mesh.
  15993. * Returns the boolean `false` by default.
  15994. */
  15995. readonly isBlocked: boolean;
  15996. /**
  15997. * Returns the mesh itself by default, used by the class Mesh.
  15998. * Returned type : AbstractMesh
  15999. */
  16000. getLOD(camera: Camera): AbstractMesh;
  16001. /**
  16002. * Returns 0 by default, used by the class Mesh.
  16003. * Returns an integer.
  16004. */
  16005. getTotalVertices(): number;
  16006. /**
  16007. * Returns null by default, used by the class Mesh.
  16008. * Returned type : integer array
  16009. */
  16010. getIndices(): Nullable<IndicesArray>;
  16011. /**
  16012. * Returns the array of the requested vertex data kind. Used by the class Mesh. Returns null here.
  16013. * Returned type : float array or Float32Array
  16014. */
  16015. getVerticesData(kind: string): Nullable<FloatArray>;
  16016. /**
  16017. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16018. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16019. * The `data` are either a numeric array either a Float32Array.
  16020. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16021. * 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).
  16022. * Note that a new underlying VertexBuffer object is created each call.
  16023. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16024. *
  16025. * Possible `kind` values :
  16026. * - BABYLON.VertexBuffer.PositionKind
  16027. * - BABYLON.VertexBuffer.UVKind
  16028. * - BABYLON.VertexBuffer.UV2Kind
  16029. * - BABYLON.VertexBuffer.UV3Kind
  16030. * - BABYLON.VertexBuffer.UV4Kind
  16031. * - BABYLON.VertexBuffer.UV5Kind
  16032. * - BABYLON.VertexBuffer.UV6Kind
  16033. * - BABYLON.VertexBuffer.ColorKind
  16034. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16035. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16036. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16037. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16038. *
  16039. * Returns the Mesh.
  16040. */
  16041. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16042. /**
  16043. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16044. * If the mesh has no geometry, it is simply returned as it is.
  16045. * The `data` are either a numeric array either a Float32Array.
  16046. * No new underlying VertexBuffer object is created.
  16047. * 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.
  16048. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16049. *
  16050. * Possible `kind` values :
  16051. * - BABYLON.VertexBuffer.PositionKind
  16052. * - BABYLON.VertexBuffer.UVKind
  16053. * - BABYLON.VertexBuffer.UV2Kind
  16054. * - BABYLON.VertexBuffer.UV3Kind
  16055. * - BABYLON.VertexBuffer.UV4Kind
  16056. * - BABYLON.VertexBuffer.UV5Kind
  16057. * - BABYLON.VertexBuffer.UV6Kind
  16058. * - BABYLON.VertexBuffer.ColorKind
  16059. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16060. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16061. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16062. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16063. *
  16064. * Returns the Mesh.
  16065. */
  16066. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  16067. /**
  16068. * Sets the mesh indices.
  16069. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16070. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16071. * This method creates a new index buffer each call.
  16072. * Returns the Mesh.
  16073. */
  16074. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  16075. /** Returns false by default, used by the class Mesh.
  16076. * Returns a boolean
  16077. */
  16078. isVerticesDataPresent(kind: string): boolean;
  16079. /**
  16080. * Returns the mesh BoundingInfo object or creates a new one and returns it if undefined.
  16081. * Returns a BoundingInfo
  16082. */
  16083. getBoundingInfo(): BoundingInfo;
  16084. /**
  16085. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units).
  16086. * @param includeDescendants Take the hierarchy's bounding box instead of the mesh's bounding box.
  16087. */
  16088. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  16089. /**
  16090. * Sets a mesh new object BoundingInfo.
  16091. * Returns the AbstractMesh.
  16092. */
  16093. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  16094. readonly useBones: boolean;
  16095. _preActivate(): void;
  16096. _preActivateForIntermediateRendering(renderId: number): void;
  16097. _activate(renderId: number): void;
  16098. /**
  16099. * Returns the latest update of the World matrix
  16100. * Returns a Matrix.
  16101. */
  16102. getWorldMatrix(): Matrix;
  16103. /**
  16104. * Returns the latest update of the World matrix determinant.
  16105. */
  16106. protected _getWorldMatrixDeterminant(): number;
  16107. /**
  16108. * Perform relative position change from the point of view of behind the front of the mesh.
  16109. * This is performed taking into account the meshes current rotation, so you do not have to care.
  16110. * Supports definition of mesh facing forward or backward.
  16111. * @param {number} amountRight
  16112. * @param {number} amountUp
  16113. * @param {number} amountForward
  16114. *
  16115. * Returns the AbstractMesh.
  16116. */
  16117. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  16118. /**
  16119. * Calculate relative position change from the point of view of behind the front of the mesh.
  16120. * This is performed taking into account the meshes current rotation, so you do not have to care.
  16121. * Supports definition of mesh facing forward or backward.
  16122. * @param {number} amountRight
  16123. * @param {number} amountUp
  16124. * @param {number} amountForward
  16125. *
  16126. * Returns a new Vector3.
  16127. */
  16128. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  16129. /**
  16130. * Perform relative rotation change from the point of view of behind the front of the mesh.
  16131. * Supports definition of mesh facing forward or backward.
  16132. * @param {number} flipBack
  16133. * @param {number} twirlClockwise
  16134. * @param {number} tiltRight
  16135. *
  16136. * Returns the AbstractMesh.
  16137. */
  16138. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  16139. /**
  16140. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  16141. * Supports definition of mesh facing forward or backward.
  16142. * @param {number} flipBack
  16143. * @param {number} twirlClockwise
  16144. * @param {number} tiltRight
  16145. *
  16146. * Returns a new Vector3.
  16147. */
  16148. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  16149. /**
  16150. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  16151. * @param includeDescendants Include bounding info from descendants as well (true by default).
  16152. */
  16153. getHierarchyBoundingVectors(includeDescendants?: boolean): {
  16154. min: Vector3;
  16155. max: Vector3;
  16156. };
  16157. /**
  16158. * Updates the mesh BoundingInfo object and all its children BoundingInfo objects also.
  16159. * Returns the AbstractMesh.
  16160. */
  16161. _updateBoundingInfo(): AbstractMesh;
  16162. /**
  16163. * Update a mesh's children BoundingInfo objects only.
  16164. * Returns the AbstractMesh.
  16165. */
  16166. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  16167. protected _afterComputeWorldMatrix(): void;
  16168. /**
  16169. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  16170. * A mesh is in the frustum if its bounding box intersects the frustum.
  16171. * Boolean returned.
  16172. */
  16173. isInFrustum(frustumPlanes: Plane[]): boolean;
  16174. /**
  16175. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  16176. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  16177. * Boolean returned.
  16178. */
  16179. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  16180. /**
  16181. * True if the mesh intersects another mesh or a SolidParticle object.
  16182. * 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)
  16183. * includeDescendants can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  16184. * Returns a boolean.
  16185. */
  16186. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  16187. /**
  16188. * Returns true if the passed point (Vector3) is inside the mesh bounding box.
  16189. * Returns a boolean.
  16190. */
  16191. intersectsPoint(point: Vector3): boolean;
  16192. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  16193. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  16194. /**
  16195. * Returns the distance from the mesh to the active camera.
  16196. * Returns a float.
  16197. */
  16198. getDistanceToCamera(camera?: Nullable<Camera>): number;
  16199. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  16200. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  16201. /**
  16202. * Property checkCollisions : Boolean, whether the camera should check the collisions against the mesh.
  16203. * Default `false`.
  16204. */
  16205. checkCollisions: boolean;
  16206. /**
  16207. * Gets Collider object used to compute collisions (not physics)
  16208. */
  16209. readonly collider: Collider;
  16210. moveWithCollisions(displacement: Vector3): AbstractMesh;
  16211. private _onCollisionPositionChange;
  16212. /**
  16213. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  16214. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree.
  16215. * Returns an Octree of submeshes.
  16216. */
  16217. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  16218. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  16219. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  16220. _checkCollision(collider: Collider): AbstractMesh;
  16221. _generatePointsArray(): boolean;
  16222. /**
  16223. * Checks if the passed Ray intersects with the mesh.
  16224. * Returns an object PickingInfo.
  16225. */
  16226. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  16227. /**
  16228. * Clones the mesh, used by the class Mesh.
  16229. * Just returns `null` for an AbstractMesh.
  16230. */
  16231. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  16232. /**
  16233. * Disposes all the mesh submeshes.
  16234. * Returns the AbstractMesh.
  16235. */
  16236. releaseSubMeshes(): AbstractMesh;
  16237. /**
  16238. * Releases resources associated with this abstract mesh.
  16239. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  16240. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  16241. */
  16242. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16243. /**
  16244. * Adds the passed mesh as a child to the current mesh.
  16245. * Returns the AbstractMesh.
  16246. */
  16247. addChild(mesh: AbstractMesh): AbstractMesh;
  16248. /**
  16249. * Removes the passed mesh from the current mesh children list.
  16250. * Returns the AbstractMesh.
  16251. */
  16252. removeChild(mesh: AbstractMesh): AbstractMesh;
  16253. /**
  16254. * Initialize the facet data arrays : facetNormals, facetPositions and facetPartitioning.
  16255. * Returns the AbstractMesh.
  16256. */
  16257. private _initFacetData();
  16258. /**
  16259. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  16260. * This method can be called within the render loop.
  16261. * 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.
  16262. * Returns the AbstractMesh.
  16263. */
  16264. updateFacetData(): AbstractMesh;
  16265. /**
  16266. * Returns the facetLocalNormals array.
  16267. * The normals are expressed in the mesh local space.
  16268. */
  16269. getFacetLocalNormals(): Vector3[];
  16270. /**
  16271. * Returns the facetLocalPositions array.
  16272. * The facet positions are expressed in the mesh local space.
  16273. */
  16274. getFacetLocalPositions(): Vector3[];
  16275. /**
  16276. * Returns the facetLocalPartioning array.
  16277. */
  16278. getFacetLocalPartitioning(): number[][];
  16279. /**
  16280. * Returns the i-th facet position in the world system.
  16281. * This method allocates a new Vector3 per call.
  16282. */
  16283. getFacetPosition(i: number): Vector3;
  16284. /**
  16285. * Sets the reference Vector3 with the i-th facet position in the world system.
  16286. * Returns the AbstractMesh.
  16287. */
  16288. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  16289. /**
  16290. * Returns the i-th facet normal in the world system.
  16291. * This method allocates a new Vector3 per call.
  16292. */
  16293. getFacetNormal(i: number): Vector3;
  16294. /**
  16295. * Sets the reference Vector3 with the i-th facet normal in the world system.
  16296. * Returns the AbstractMesh.
  16297. */
  16298. getFacetNormalToRef(i: number, ref: Vector3): this;
  16299. /**
  16300. * 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).
  16301. */
  16302. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  16303. /**
  16304. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found.
  16305. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) World projection on the facet.
  16306. * If checkFace is 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.
  16307. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  16308. * 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.
  16309. */
  16310. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  16311. /**
  16312. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found.
  16313. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) local projection on the facet.
  16314. * If checkFace is 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.
  16315. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  16316. * 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.
  16317. */
  16318. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  16319. /**
  16320. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  16321. */
  16322. getFacetDataParameters(): any;
  16323. /**
  16324. * Disables the feature FacetData and frees the related memory.
  16325. * Returns the AbstractMesh.
  16326. */
  16327. disableFacetData(): AbstractMesh;
  16328. /**
  16329. * Updates the AbstractMesh indices array. Actually, used by the Mesh object.
  16330. * Returns the mesh.
  16331. */
  16332. updateIndices(indices: IndicesArray): AbstractMesh;
  16333. /**
  16334. * The mesh Geometry. Actually used by the Mesh object.
  16335. * Returns a blank geometry object.
  16336. */
  16337. /**
  16338. * Creates new normals data for the mesh.
  16339. * @param updatable.
  16340. */
  16341. createNormals(updatable: boolean): void;
  16342. /**
  16343. * Align the mesh with a normal.
  16344. * Returns the mesh.
  16345. */
  16346. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  16347. protected checkOcclusionQuery(): void;
  16348. }
  16349. }
  16350. declare module BABYLON {
  16351. class Buffer {
  16352. private _engine;
  16353. private _buffer;
  16354. private _data;
  16355. private _updatable;
  16356. private _instanced;
  16357. /**
  16358. * Gets the byte stride.
  16359. */
  16360. readonly byteStride: number;
  16361. /**
  16362. * Constructor
  16363. * @param engine the engine
  16364. * @param data the data to use for this buffer
  16365. * @param updatable whether the data is updatable
  16366. * @param stride the stride (optional)
  16367. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  16368. * @param instanced whether the buffer is instanced (optional)
  16369. * @param useBytes set to true if the stride in in bytes (optional)
  16370. */
  16371. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  16372. /**
  16373. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  16374. * @param kind defines the vertex buffer kind (position, normal, etc.)
  16375. * @param offset defines offset in the buffer (0 by default)
  16376. * @param size defines the size in floats of attributes (position is 3 for instance)
  16377. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  16378. * @param instanced defines if the vertex buffer contains indexed data
  16379. * @param useBytes defines if the offset and stride are in bytes
  16380. * @returns the new vertex buffer
  16381. */
  16382. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  16383. isUpdatable(): boolean;
  16384. getData(): Nullable<DataArray>;
  16385. getBuffer(): Nullable<WebGLBuffer>;
  16386. /**
  16387. * Gets the stride in float32 units (i.e. byte stride / 4).
  16388. * May not be an integer if the byte stride is not divisible by 4.
  16389. * DEPRECATED. Use byteStride instead.
  16390. * @returns the stride in float32 units
  16391. */
  16392. getStrideSize(): number;
  16393. create(data?: Nullable<DataArray>): void;
  16394. _rebuild(): void;
  16395. update(data: DataArray): void;
  16396. /**
  16397. * Updates the data directly.
  16398. * @param data the new data
  16399. * @param offset the new offset
  16400. * @param vertexCount the vertex count (optional)
  16401. * @param useBytes set to true if the offset is in bytes
  16402. */
  16403. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  16404. dispose(): void;
  16405. }
  16406. }
  16407. declare module BABYLON {
  16408. class CSG {
  16409. private polygons;
  16410. matrix: Matrix;
  16411. position: Vector3;
  16412. rotation: Vector3;
  16413. rotationQuaternion: Nullable<Quaternion>;
  16414. scaling: Vector3;
  16415. static FromMesh(mesh: Mesh): CSG;
  16416. private static FromPolygons(polygons);
  16417. clone(): CSG;
  16418. union(csg: CSG): CSG;
  16419. unionInPlace(csg: CSG): void;
  16420. subtract(csg: CSG): CSG;
  16421. subtractInPlace(csg: CSG): void;
  16422. intersect(csg: CSG): CSG;
  16423. intersectInPlace(csg: CSG): void;
  16424. inverse(): CSG;
  16425. inverseInPlace(): void;
  16426. copyTransformAttributes(csg: CSG): CSG;
  16427. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  16428. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  16429. }
  16430. }
  16431. declare module BABYLON {
  16432. /**
  16433. * Class used to store geometry data (vertex buffers + index buffer)
  16434. */
  16435. class Geometry implements IGetSetVerticesData {
  16436. /**
  16437. * Gets or sets the unique ID of the geometry
  16438. */
  16439. id: string;
  16440. /**
  16441. * Gets the delay loading state of the geometry (none by default which means not delayed)
  16442. */
  16443. delayLoadState: number;
  16444. /**
  16445. * Gets the file containing the data to load when running in delay load state
  16446. */
  16447. delayLoadingFile: Nullable<string>;
  16448. /**
  16449. * Callback called when the geometry is updated
  16450. */
  16451. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  16452. private _scene;
  16453. private _engine;
  16454. private _meshes;
  16455. private _totalVertices;
  16456. private _indices;
  16457. private _vertexBuffers;
  16458. private _isDisposed;
  16459. private _extend;
  16460. private _boundingBias;
  16461. /** @ignore */
  16462. _delayInfo: Array<string>;
  16463. private _indexBuffer;
  16464. private _indexBufferIsUpdatable;
  16465. /** @ignore */
  16466. _boundingInfo: Nullable<BoundingInfo>;
  16467. /** @ignore */
  16468. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  16469. /** @ignore */
  16470. _softwareSkinningRenderId: number;
  16471. private _vertexArrayObjects;
  16472. private _updatable;
  16473. /** @ignore */
  16474. _positions: Nullable<Vector3[]>;
  16475. /**
  16476. * 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
  16477. */
  16478. /**
  16479. * 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
  16480. */
  16481. boundingBias: Vector2;
  16482. /**
  16483. * Static function used to attach a new empty geometry to a mesh
  16484. * @param mesh defines the mesh to attach the geometry to
  16485. * @returns the new {BABYLON.Geometry}
  16486. */
  16487. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  16488. /**
  16489. * Creates a new geometry
  16490. * @param id defines the unique ID
  16491. * @param scene defines the hosting scene
  16492. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  16493. * @param updatable defines if geometry must be updatable (false by default)
  16494. * @param mesh defines the mesh that will be associated with the geometry
  16495. */
  16496. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  16497. /**
  16498. * Gets the current extend of the geometry
  16499. */
  16500. readonly extend: {
  16501. minimum: Vector3;
  16502. maximum: Vector3;
  16503. };
  16504. /**
  16505. * Gets the hosting scene
  16506. * @returns the hosting {BABYLON.Scene}
  16507. */
  16508. getScene(): Scene;
  16509. /**
  16510. * Gets the hosting engine
  16511. * @returns the hosting {BABYLON.Engine}
  16512. */
  16513. getEngine(): Engine;
  16514. /**
  16515. * Defines if the geometry is ready to use
  16516. * @returns true if the geometry is ready to be used
  16517. */
  16518. isReady(): boolean;
  16519. /**
  16520. * Gets a value indicating that the geometry should not be serialized
  16521. */
  16522. readonly doNotSerialize: boolean;
  16523. /** @ignore */
  16524. _rebuild(): void;
  16525. /**
  16526. * Affects all gemetry data in one call
  16527. * @param vertexData defines the geometry data
  16528. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  16529. */
  16530. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  16531. /**
  16532. * Set specific vertex data
  16533. * @param kind defines the data kind (Position, normal, etc...)
  16534. * @param data defines the vertex data to use
  16535. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  16536. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  16537. */
  16538. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  16539. /**
  16540. * Removes a specific vertex data
  16541. * @param kind defines the data kind (Position, normal, etc...)
  16542. */
  16543. removeVerticesData(kind: string): void;
  16544. /**
  16545. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  16546. * @param buffer defines the vertex buffer to use
  16547. * @param totalVertices defines the total number of vertices for position kind (could be null)
  16548. */
  16549. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  16550. /**
  16551. * Update a specific vertex buffer
  16552. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  16553. * It will do nothing if the buffer is not updatable
  16554. * @param kind defines the data kind (Position, normal, etc...)
  16555. * @param data defines the data to use
  16556. * @param offset defines the offset in the target buffer where to store the data
  16557. */
  16558. updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void;
  16559. /**
  16560. * Update a specific vertex buffer
  16561. * This function will create a new buffer if the current one is not updatable
  16562. * @param kind defines the data kind (Position, normal, etc...)
  16563. * @param data defines the data to use
  16564. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  16565. */
  16566. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  16567. private _updateBoundingInfo(updateExtends, data);
  16568. /** @ignore */
  16569. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  16570. /**
  16571. * Gets total number of vertices
  16572. * @returns the total number of vertices
  16573. */
  16574. getTotalVertices(): number;
  16575. /**
  16576. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  16577. * @param kind defines the data kind (Position, normal, etc...)
  16578. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  16579. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  16580. * @returns a float array containing vertex data
  16581. */
  16582. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  16583. /**
  16584. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  16585. * @param kind defines the data kind (Position, normal, etc...)
  16586. * @returns true if the vertex buffer with the specified kind is updatable
  16587. */
  16588. isVertexBufferUpdatable(kind: string): boolean;
  16589. /**
  16590. * Gets a specific vertex buffer
  16591. * @param kind defines the data kind (Position, normal, etc...)
  16592. * @returns a {BABYLON.VertexBuffer}
  16593. */
  16594. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  16595. /**
  16596. * Returns all vertex buffers
  16597. * @return an object holding all vertex buffers indexed by kind
  16598. */
  16599. getVertexBuffers(): Nullable<{
  16600. [key: string]: VertexBuffer;
  16601. }>;
  16602. /**
  16603. * Gets a boolean indicating if specific vertex buffer is present
  16604. * @param kind defines the data kind (Position, normal, etc...)
  16605. * @returns true if data is present
  16606. */
  16607. isVerticesDataPresent(kind: string): boolean;
  16608. /**
  16609. * Gets a list of all attached data kinds (Position, normal, etc...)
  16610. * @returns a list of string containing all kinds
  16611. */
  16612. getVerticesDataKinds(): string[];
  16613. /**
  16614. * Update index buffer
  16615. * @param indices defines the indices to store in the index buffer
  16616. * @param offset defines the offset in the target buffer where to store the data
  16617. */
  16618. updateIndices(indices: IndicesArray, offset?: number): void;
  16619. /**
  16620. * Creates a new index buffer
  16621. * @param indices defines the indices to store in the index buffer
  16622. * @param totalVertices defines the total number of vertices (could be null)
  16623. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  16624. */
  16625. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  16626. /**
  16627. * Return the total number of indices
  16628. * @returns the total number of indices
  16629. */
  16630. getTotalIndices(): number;
  16631. /**
  16632. * Gets the index buffer array
  16633. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  16634. * @returns the index buffer array
  16635. */
  16636. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  16637. /**
  16638. * Gets the index buffer
  16639. * @return the index buffer
  16640. */
  16641. getIndexBuffer(): Nullable<WebGLBuffer>;
  16642. /** @ignore */
  16643. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  16644. /**
  16645. * Release the associated resources for a specific mesh
  16646. * @param mesh defines the source mesh
  16647. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  16648. */
  16649. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  16650. /**
  16651. * Apply current geometry to a given mesh
  16652. * @param mesh defines the mesh to apply geometry to
  16653. */
  16654. applyToMesh(mesh: Mesh): void;
  16655. private _updateExtend(data?);
  16656. private _applyToMesh(mesh);
  16657. private notifyUpdate(kind?);
  16658. /**
  16659. * Load the geometry if it was flagged as delay loaded
  16660. * @param scene defines the hosting scene
  16661. * @param onLoaded defines a callback called when the geometry is loaded
  16662. */
  16663. load(scene: Scene, onLoaded?: () => void): void;
  16664. private _queueLoad(scene, onLoaded?);
  16665. /**
  16666. * Invert the geometry to move from a right handed system to a left handed one.
  16667. */
  16668. toLeftHanded(): void;
  16669. /** @ignore */
  16670. _resetPointsArrayCache(): void;
  16671. /** @ignore */
  16672. _generatePointsArray(): boolean;
  16673. /**
  16674. * Gets a value indicating if the geometry is disposed
  16675. * @returns true if the geometry was disposed
  16676. */
  16677. isDisposed(): boolean;
  16678. private _disposeVertexArrayObjects();
  16679. /**
  16680. * Free all associated resources
  16681. */
  16682. dispose(): void;
  16683. /**
  16684. * Clone the current geometry into a new geometry
  16685. * @param id defines the unique ID of the new geometry
  16686. * @returns a new geometry object
  16687. */
  16688. copy(id: string): Geometry;
  16689. /**
  16690. * Serialize the current geometry info (and not the vertices data) into a JSON object
  16691. * @return a JSON representation of the current geometry data (without the vertices data)
  16692. */
  16693. serialize(): any;
  16694. private toNumberArray(origin);
  16695. /**
  16696. * Serialize all vertices data into a JSON oject
  16697. * @returns a JSON representation of the current geometry data
  16698. */
  16699. serializeVerticeData(): any;
  16700. /**
  16701. * Extracts a clone of a mesh geometry
  16702. * @param mesh defines the source mesh
  16703. * @param id defines the unique ID of the new geometry object
  16704. * @returns the new geometry object
  16705. */
  16706. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  16707. /**
  16708. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  16709. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  16710. * Be aware Math.random() could cause collisions, but:
  16711. * "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"
  16712. * @returns a string containing a new GUID
  16713. */
  16714. static RandomId(): string;
  16715. /** @ignore */
  16716. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  16717. private static _CleanMatricesWeights(parsedGeometry, mesh);
  16718. /**
  16719. * Create a new geometry from persisted data (Using .babylon file format)
  16720. * @param parsedVertexData defines the persisted data
  16721. * @param scene defines the hosting scene
  16722. * @param rootUrl defines the root url to use to load assets (like delayed data)
  16723. * @returns the new geometry object
  16724. */
  16725. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  16726. }
  16727. /**
  16728. * Abstract class used to provide common services for all typed geometries
  16729. */
  16730. class _PrimitiveGeometry extends Geometry {
  16731. private _canBeRegenerated;
  16732. private _beingRegenerated;
  16733. /**
  16734. * Creates a new typed geometry
  16735. * @param id defines the unique ID of the geometry
  16736. * @param scene defines the hosting scene
  16737. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16738. * @param mesh defines the hosting mesh (can be null)
  16739. */
  16740. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  16741. /**
  16742. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  16743. * @returns true if the geometry can be regenerated
  16744. */
  16745. canBeRegenerated(): boolean;
  16746. /**
  16747. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  16748. */
  16749. regenerate(): void;
  16750. /**
  16751. * Clone the geometry
  16752. * @param id defines the unique ID of the new geometry
  16753. * @returns the new geometry
  16754. */
  16755. asNewGeometry(id: string): Geometry;
  16756. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  16757. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  16758. /** @ignore */
  16759. _regenerateVertexData(): VertexData;
  16760. copy(id: string): Geometry;
  16761. serialize(): any;
  16762. }
  16763. /**
  16764. * Creates a ribbon geometry
  16765. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  16766. */
  16767. class RibbonGeometry extends _PrimitiveGeometry {
  16768. /**
  16769. * Defines the array of paths to use
  16770. */
  16771. pathArray: Vector3[][];
  16772. /**
  16773. * Defines if the last and first points of each path in your pathArray must be joined
  16774. */
  16775. closeArray: boolean;
  16776. /**
  16777. * Defines if the last and first points of each path in your pathArray must be joined
  16778. */
  16779. closePath: boolean;
  16780. /**
  16781. * Defines the offset between points
  16782. */
  16783. offset: number;
  16784. /**
  16785. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16786. */
  16787. side: number;
  16788. /**
  16789. * Creates a ribbon geometry
  16790. * @param id defines the unique ID of the geometry
  16791. * @param scene defines the hosting scene
  16792. * @param pathArray defines the array of paths to use
  16793. * @param closeArray defines if the last path and the first path must be joined
  16794. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  16795. * @param offset defines the offset between points
  16796. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16797. * @param mesh defines the hosting mesh (can be null)
  16798. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16799. */
  16800. constructor(id: string, scene: Scene,
  16801. /**
  16802. * Defines the array of paths to use
  16803. */
  16804. pathArray: Vector3[][],
  16805. /**
  16806. * Defines if the last and first points of each path in your pathArray must be joined
  16807. */
  16808. closeArray: boolean,
  16809. /**
  16810. * Defines if the last and first points of each path in your pathArray must be joined
  16811. */
  16812. closePath: boolean,
  16813. /**
  16814. * Defines the offset between points
  16815. */
  16816. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  16817. /**
  16818. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16819. */
  16820. side?: number);
  16821. /** @ignore */
  16822. _regenerateVertexData(): VertexData;
  16823. copy(id: string): Geometry;
  16824. }
  16825. /**
  16826. * Creates a box geometry
  16827. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  16828. */
  16829. class BoxGeometry extends _PrimitiveGeometry {
  16830. /**
  16831. * Defines the zise of the box (width, height and depth are the same)
  16832. */
  16833. size: number;
  16834. /**
  16835. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16836. */
  16837. side: number;
  16838. /**
  16839. * Creates a box geometry
  16840. * @param id defines the unique ID of the geometry
  16841. * @param scene defines the hosting scene
  16842. * @param size defines the zise of the box (width, height and depth are the same)
  16843. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16844. * @param mesh defines the hosting mesh (can be null)
  16845. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16846. */
  16847. constructor(id: string, scene: Scene,
  16848. /**
  16849. * Defines the zise of the box (width, height and depth are the same)
  16850. */
  16851. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  16852. /**
  16853. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16854. */
  16855. side?: number);
  16856. _regenerateVertexData(): VertexData;
  16857. copy(id: string): Geometry;
  16858. serialize(): any;
  16859. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  16860. }
  16861. /**
  16862. * Creates a sphere geometry
  16863. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  16864. */
  16865. class SphereGeometry extends _PrimitiveGeometry {
  16866. /**
  16867. * Defines the number of segments to use to create the sphere
  16868. */
  16869. segments: number;
  16870. /**
  16871. * Defines the diameter of the sphere
  16872. */
  16873. diameter: number;
  16874. /**
  16875. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16876. */
  16877. side: number;
  16878. /**
  16879. * Create a new sphere geometry
  16880. * @param id defines the unique ID of the geometry
  16881. * @param scene defines the hosting scene
  16882. * @param segments defines the number of segments to use to create the sphere
  16883. * @param diameter defines the diameter of the sphere
  16884. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16885. * @param mesh defines the hosting mesh (can be null)
  16886. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16887. */
  16888. constructor(id: string, scene: Scene,
  16889. /**
  16890. * Defines the number of segments to use to create the sphere
  16891. */
  16892. segments: number,
  16893. /**
  16894. * Defines the diameter of the sphere
  16895. */
  16896. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  16897. /**
  16898. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16899. */
  16900. side?: number);
  16901. _regenerateVertexData(): VertexData;
  16902. copy(id: string): Geometry;
  16903. serialize(): any;
  16904. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  16905. }
  16906. /**
  16907. * Creates a disc geometry
  16908. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  16909. */
  16910. class DiscGeometry extends _PrimitiveGeometry {
  16911. /**
  16912. * Defines the radius of the disc
  16913. */
  16914. radius: number;
  16915. /**
  16916. * Defines the tesselation factor to apply to the disc
  16917. */
  16918. tessellation: number;
  16919. /**
  16920. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16921. */
  16922. side: number;
  16923. /**
  16924. * Creates a new disc geometry
  16925. * @param id defines the unique ID of the geometry
  16926. * @param scene defines the hosting scene
  16927. * @param radius defines the radius of the disc
  16928. * @param tessellation defines the tesselation factor to apply to the disc
  16929. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16930. * @param mesh defines the hosting mesh (can be null)
  16931. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16932. */
  16933. constructor(id: string, scene: Scene,
  16934. /**
  16935. * Defines the radius of the disc
  16936. */
  16937. radius: number,
  16938. /**
  16939. * Defines the tesselation factor to apply to the disc
  16940. */
  16941. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  16942. /**
  16943. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16944. */
  16945. side?: number);
  16946. _regenerateVertexData(): VertexData;
  16947. copy(id: string): Geometry;
  16948. }
  16949. /**
  16950. * Creates a new cylinder geometry
  16951. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  16952. */
  16953. class CylinderGeometry extends _PrimitiveGeometry {
  16954. /**
  16955. * Defines the height of the cylinder
  16956. */
  16957. height: number;
  16958. /**
  16959. * Defines the diameter of the cylinder's top cap
  16960. */
  16961. diameterTop: number;
  16962. /**
  16963. * Defines the diameter of the cylinder's bottom cap
  16964. */
  16965. diameterBottom: number;
  16966. /**
  16967. * Defines the tessellation factor to apply to the cylinder
  16968. */
  16969. tessellation: number;
  16970. /**
  16971. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  16972. */
  16973. subdivisions: number;
  16974. /**
  16975. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16976. */
  16977. side: number;
  16978. /**
  16979. * Creates a new cylinder geometry
  16980. * @param id defines the unique ID of the geometry
  16981. * @param scene defines the hosting scene
  16982. * @param height defines the height of the cylinder
  16983. * @param diameterTop defines the diameter of the cylinder's top cap
  16984. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  16985. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  16986. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  16987. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16988. * @param mesh defines the hosting mesh (can be null)
  16989. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16990. */
  16991. constructor(id: string, scene: Scene,
  16992. /**
  16993. * Defines the height of the cylinder
  16994. */
  16995. height: number,
  16996. /**
  16997. * Defines the diameter of the cylinder's top cap
  16998. */
  16999. diameterTop: number,
  17000. /**
  17001. * Defines the diameter of the cylinder's bottom cap
  17002. */
  17003. diameterBottom: number,
  17004. /**
  17005. * Defines the tessellation factor to apply to the cylinder
  17006. */
  17007. tessellation: number,
  17008. /**
  17009. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  17010. */
  17011. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  17012. /**
  17013. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17014. */
  17015. side?: number);
  17016. _regenerateVertexData(): VertexData;
  17017. copy(id: string): Geometry;
  17018. serialize(): any;
  17019. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  17020. }
  17021. /**
  17022. * Creates a new torus geometry
  17023. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  17024. */
  17025. class TorusGeometry extends _PrimitiveGeometry {
  17026. /**
  17027. * Defines the diameter of the torus
  17028. */
  17029. diameter: number;
  17030. /**
  17031. * Defines the thickness of the torus (ie. internal diameter)
  17032. */
  17033. thickness: number;
  17034. /**
  17035. * Defines the tesselation factor to apply to the torus
  17036. */
  17037. tessellation: number;
  17038. /**
  17039. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17040. */
  17041. side: number;
  17042. /**
  17043. * Creates a new torus geometry
  17044. * @param id defines the unique ID of the geometry
  17045. * @param scene defines the hosting scene
  17046. * @param diameter defines the diameter of the torus
  17047. * @param thickness defines the thickness of the torus (ie. internal diameter)
  17048. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  17049. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  17050. * @param mesh defines the hosting mesh (can be null)
  17051. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17052. */
  17053. constructor(id: string, scene: Scene,
  17054. /**
  17055. * Defines the diameter of the torus
  17056. */
  17057. diameter: number,
  17058. /**
  17059. * Defines the thickness of the torus (ie. internal diameter)
  17060. */
  17061. thickness: number,
  17062. /**
  17063. * Defines the tesselation factor to apply to the torus
  17064. */
  17065. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  17066. /**
  17067. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17068. */
  17069. side?: number);
  17070. _regenerateVertexData(): VertexData;
  17071. copy(id: string): Geometry;
  17072. serialize(): any;
  17073. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  17074. }
  17075. /**
  17076. * Creates a new ground geometry
  17077. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  17078. */
  17079. class GroundGeometry extends _PrimitiveGeometry {
  17080. /**
  17081. * Defines the width of the ground
  17082. */
  17083. width: number;
  17084. /**
  17085. * Defines the height of the ground
  17086. */
  17087. height: number;
  17088. /**
  17089. * Defines the subdivisions to apply to the ground
  17090. */
  17091. subdivisions: number;
  17092. /**
  17093. * Creates a new ground geometry
  17094. * @param id defines the unique ID of the geometry
  17095. * @param scene defines the hosting scene
  17096. * @param width defines the width of the ground
  17097. * @param height defines the height of the ground
  17098. * @param subdivisions defines the subdivisions to apply to the ground
  17099. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  17100. * @param mesh defines the hosting mesh (can be null)
  17101. */
  17102. constructor(id: string, scene: Scene,
  17103. /**
  17104. * Defines the width of the ground
  17105. */
  17106. width: number,
  17107. /**
  17108. * Defines the height of the ground
  17109. */
  17110. height: number,
  17111. /**
  17112. * Defines the subdivisions to apply to the ground
  17113. */
  17114. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  17115. _regenerateVertexData(): VertexData;
  17116. copy(id: string): Geometry;
  17117. serialize(): any;
  17118. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  17119. }
  17120. /**
  17121. * Creates a tiled ground geometry
  17122. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  17123. */
  17124. class TiledGroundGeometry extends _PrimitiveGeometry {
  17125. /**
  17126. * Defines the minimum value on X axis
  17127. */
  17128. xmin: number;
  17129. /**
  17130. * Defines the minimum value on Z axis
  17131. */
  17132. zmin: number;
  17133. /**
  17134. * Defines the maximum value on X axis
  17135. */
  17136. xmax: number;
  17137. /**
  17138. * Defines the maximum value on Z axis
  17139. */
  17140. zmax: number;
  17141. /**
  17142. * Defines the subdivisions to apply to the ground
  17143. */
  17144. subdivisions: {
  17145. w: number;
  17146. h: number;
  17147. };
  17148. /**
  17149. * Defines the precision to use when computing the tiles
  17150. */
  17151. precision: {
  17152. w: number;
  17153. h: number;
  17154. };
  17155. /**
  17156. * Creates a tiled ground geometry
  17157. * @param id defines the unique ID of the geometry
  17158. * @param scene defines the hosting scene
  17159. * @param xmin defines the minimum value on X axis
  17160. * @param zmin defines the minimum value on Z axis
  17161. * @param xmax defines the maximum value on X axis
  17162. * @param zmax defines the maximum value on Z axis
  17163. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  17164. * @param precision defines the precision to use when computing the tiles
  17165. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  17166. * @param mesh defines the hosting mesh (can be null)
  17167. */
  17168. constructor(id: string, scene: Scene,
  17169. /**
  17170. * Defines the minimum value on X axis
  17171. */
  17172. xmin: number,
  17173. /**
  17174. * Defines the minimum value on Z axis
  17175. */
  17176. zmin: number,
  17177. /**
  17178. * Defines the maximum value on X axis
  17179. */
  17180. xmax: number,
  17181. /**
  17182. * Defines the maximum value on Z axis
  17183. */
  17184. zmax: number,
  17185. /**
  17186. * Defines the subdivisions to apply to the ground
  17187. */
  17188. subdivisions: {
  17189. w: number;
  17190. h: number;
  17191. },
  17192. /**
  17193. * Defines the precision to use when computing the tiles
  17194. */
  17195. precision: {
  17196. w: number;
  17197. h: number;
  17198. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  17199. _regenerateVertexData(): VertexData;
  17200. copy(id: string): Geometry;
  17201. }
  17202. /**
  17203. * Creates a plane geometry
  17204. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  17205. */
  17206. class PlaneGeometry extends _PrimitiveGeometry {
  17207. /**
  17208. * Defines the size of the plane (width === height)
  17209. */
  17210. size: number;
  17211. /**
  17212. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17213. */
  17214. side: number;
  17215. /**
  17216. * Creates a plane geometry
  17217. * @param id defines the unique ID of the geometry
  17218. * @param scene defines the hosting scene
  17219. * @param size defines the size of the plane (width === height)
  17220. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  17221. * @param mesh defines the hosting mesh (can be null)
  17222. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17223. */
  17224. constructor(id: string, scene: Scene,
  17225. /**
  17226. * Defines the size of the plane (width === height)
  17227. */
  17228. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  17229. /**
  17230. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17231. */
  17232. side?: number);
  17233. _regenerateVertexData(): VertexData;
  17234. copy(id: string): Geometry;
  17235. serialize(): any;
  17236. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  17237. }
  17238. /**
  17239. * Creates a torus knot geometry
  17240. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  17241. */
  17242. class TorusKnotGeometry extends _PrimitiveGeometry {
  17243. /**
  17244. * Defines the radius of the torus knot
  17245. */
  17246. radius: number;
  17247. /**
  17248. * Defines the thickness of the torus knot tube
  17249. */
  17250. tube: number;
  17251. /**
  17252. * Defines the number of radial segments
  17253. */
  17254. radialSegments: number;
  17255. /**
  17256. * Defines the number of tubular segments
  17257. */
  17258. tubularSegments: number;
  17259. /**
  17260. * Defines the first number of windings
  17261. */
  17262. p: number;
  17263. /**
  17264. * Defines the second number of windings
  17265. */
  17266. q: number;
  17267. /**
  17268. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17269. */
  17270. side: number;
  17271. /**
  17272. * Creates a torus knot geometry
  17273. * @param id defines the unique ID of the geometry
  17274. * @param scene defines the hosting scene
  17275. * @param radius defines the radius of the torus knot
  17276. * @param tube defines the thickness of the torus knot tube
  17277. * @param radialSegments defines the number of radial segments
  17278. * @param tubularSegments defines the number of tubular segments
  17279. * @param p defines the first number of windings
  17280. * @param q defines the second number of windings
  17281. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  17282. * @param mesh defines the hosting mesh (can be null)
  17283. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17284. */
  17285. constructor(id: string, scene: Scene,
  17286. /**
  17287. * Defines the radius of the torus knot
  17288. */
  17289. radius: number,
  17290. /**
  17291. * Defines the thickness of the torus knot tube
  17292. */
  17293. tube: number,
  17294. /**
  17295. * Defines the number of radial segments
  17296. */
  17297. radialSegments: number,
  17298. /**
  17299. * Defines the number of tubular segments
  17300. */
  17301. tubularSegments: number,
  17302. /**
  17303. * Defines the first number of windings
  17304. */
  17305. p: number,
  17306. /**
  17307. * Defines the second number of windings
  17308. */
  17309. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  17310. /**
  17311. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17312. */
  17313. side?: number);
  17314. _regenerateVertexData(): VertexData;
  17315. copy(id: string): Geometry;
  17316. serialize(): any;
  17317. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  17318. }
  17319. }
  17320. declare module BABYLON {
  17321. class GroundMesh extends Mesh {
  17322. generateOctree: boolean;
  17323. private _heightQuads;
  17324. _subdivisionsX: number;
  17325. _subdivisionsY: number;
  17326. _width: number;
  17327. _height: number;
  17328. _minX: number;
  17329. _maxX: number;
  17330. _minZ: number;
  17331. _maxZ: number;
  17332. constructor(name: string, scene: Scene);
  17333. getClassName(): string;
  17334. readonly subdivisions: number;
  17335. readonly subdivisionsX: number;
  17336. readonly subdivisionsY: number;
  17337. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  17338. /**
  17339. * Returns a height (y) value in the Worl system :
  17340. * the ground altitude at the coordinates (x, z) expressed in the World system.
  17341. * Returns the ground y position if (x, z) are outside the ground surface.
  17342. */
  17343. getHeightAtCoordinates(x: number, z: number): number;
  17344. /**
  17345. * Returns a normalized vector (Vector3) orthogonal to the ground
  17346. * at the ground coordinates (x, z) expressed in the World system.
  17347. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  17348. */
  17349. getNormalAtCoordinates(x: number, z: number): Vector3;
  17350. /**
  17351. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  17352. * at the ground coordinates (x, z) expressed in the World system.
  17353. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  17354. * Returns the GroundMesh.
  17355. */
  17356. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  17357. /**
  17358. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  17359. * if the ground has been updated.
  17360. * This can be used in the render loop.
  17361. * Returns the GroundMesh.
  17362. */
  17363. updateCoordinateHeights(): GroundMesh;
  17364. private _getFacetAt(x, z);
  17365. private _initHeightQuads();
  17366. private _computeHeightQuads();
  17367. serialize(serializationObject: any): void;
  17368. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  17369. }
  17370. }
  17371. declare module BABYLON {
  17372. /**
  17373. * Creates an instance based on a source mesh.
  17374. */
  17375. class InstancedMesh extends AbstractMesh {
  17376. private _sourceMesh;
  17377. private _currentLOD;
  17378. constructor(name: string, source: Mesh);
  17379. /**
  17380. * Returns the string "InstancedMesh".
  17381. */
  17382. getClassName(): string;
  17383. readonly receiveShadows: boolean;
  17384. readonly material: Nullable<Material>;
  17385. readonly visibility: number;
  17386. readonly skeleton: Nullable<Skeleton>;
  17387. renderingGroupId: number;
  17388. /**
  17389. * Returns the total number of vertices (integer).
  17390. */
  17391. getTotalVertices(): number;
  17392. readonly sourceMesh: Mesh;
  17393. /**
  17394. * Is this node ready to be used/rendered
  17395. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17396. * @return {boolean} is it ready
  17397. */
  17398. isReady(completeCheck?: boolean): boolean;
  17399. /**
  17400. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17401. */
  17402. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17403. /**
  17404. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17405. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17406. * The `data` are either a numeric array either a Float32Array.
  17407. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17408. * 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).
  17409. * Note that a new underlying VertexBuffer object is created each call.
  17410. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17411. *
  17412. * Possible `kind` values :
  17413. * - BABYLON.VertexBuffer.PositionKind
  17414. * - BABYLON.VertexBuffer.UVKind
  17415. * - BABYLON.VertexBuffer.UV2Kind
  17416. * - BABYLON.VertexBuffer.UV3Kind
  17417. * - BABYLON.VertexBuffer.UV4Kind
  17418. * - BABYLON.VertexBuffer.UV5Kind
  17419. * - BABYLON.VertexBuffer.UV6Kind
  17420. * - BABYLON.VertexBuffer.ColorKind
  17421. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17422. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17423. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17424. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17425. *
  17426. * Returns the Mesh.
  17427. */
  17428. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17429. /**
  17430. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17431. * If the mesh has no geometry, it is simply returned as it is.
  17432. * The `data` are either a numeric array either a Float32Array.
  17433. * No new underlying VertexBuffer object is created.
  17434. * 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.
  17435. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17436. *
  17437. * Possible `kind` values :
  17438. * - BABYLON.VertexBuffer.PositionKind
  17439. * - BABYLON.VertexBuffer.UVKind
  17440. * - BABYLON.VertexBuffer.UV2Kind
  17441. * - BABYLON.VertexBuffer.UV3Kind
  17442. * - BABYLON.VertexBuffer.UV4Kind
  17443. * - BABYLON.VertexBuffer.UV5Kind
  17444. * - BABYLON.VertexBuffer.UV6Kind
  17445. * - BABYLON.VertexBuffer.ColorKind
  17446. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17447. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17448. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17449. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17450. *
  17451. * Returns the Mesh.
  17452. */
  17453. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17454. /**
  17455. * Sets the mesh indices.
  17456. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17457. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17458. * This method creates a new index buffer each call.
  17459. * Returns the Mesh.
  17460. */
  17461. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17462. /**
  17463. * Boolean : True if the mesh owns the requested kind of data.
  17464. */
  17465. isVerticesDataPresent(kind: string): boolean;
  17466. /**
  17467. * Returns an array of indices (IndicesArray).
  17468. */
  17469. getIndices(): Nullable<IndicesArray>;
  17470. readonly _positions: Nullable<Vector3[]>;
  17471. /**
  17472. * Sets a new updated BoundingInfo to the mesh.
  17473. * Returns the mesh.
  17474. */
  17475. refreshBoundingInfo(): InstancedMesh;
  17476. _preActivate(): InstancedMesh;
  17477. _activate(renderId: number): InstancedMesh;
  17478. /**
  17479. * Returns the current associated LOD AbstractMesh.
  17480. */
  17481. getLOD(camera: Camera): AbstractMesh;
  17482. _syncSubMeshes(): InstancedMesh;
  17483. _generatePointsArray(): boolean;
  17484. /**
  17485. * Creates a new InstancedMesh from the current mesh.
  17486. * - name (string) : the cloned mesh name
  17487. * - newParent (optional Node) : the optional Node to parent the clone to.
  17488. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17489. *
  17490. * Returns the clone.
  17491. */
  17492. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17493. /**
  17494. * Disposes the InstancedMesh.
  17495. * Returns nothing.
  17496. */
  17497. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17498. }
  17499. }
  17500. declare module BABYLON {
  17501. class LinesMesh extends Mesh {
  17502. useVertexColor: boolean | undefined;
  17503. useVertexAlpha: boolean | undefined;
  17504. color: Color3;
  17505. alpha: number;
  17506. /**
  17507. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17508. * This margin is expressed in world space coordinates, so its value may vary.
  17509. * Default value is 0.1
  17510. * @returns the intersection Threshold value.
  17511. */
  17512. /**
  17513. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17514. * This margin is expressed in world space coordinates, so its value may vary.
  17515. * @param value the new threshold to apply
  17516. */
  17517. intersectionThreshold: number;
  17518. private _intersectionThreshold;
  17519. private _colorShader;
  17520. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  17521. /**
  17522. * Returns the string "LineMesh"
  17523. */
  17524. getClassName(): string;
  17525. material: Material;
  17526. readonly checkCollisions: boolean;
  17527. createInstance(name: string): InstancedMesh;
  17528. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17529. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17530. dispose(doNotRecurse?: boolean): void;
  17531. /**
  17532. * Returns a new LineMesh object cloned from the current one.
  17533. */
  17534. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17535. }
  17536. }
  17537. declare module BABYLON {
  17538. class _InstancesBatch {
  17539. mustReturn: boolean;
  17540. visibleInstances: Nullable<InstancedMesh[]>[];
  17541. renderSelf: boolean[];
  17542. }
  17543. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  17544. static _FRONTSIDE: number;
  17545. static _BACKSIDE: number;
  17546. static _DOUBLESIDE: number;
  17547. static _DEFAULTSIDE: number;
  17548. static _NO_CAP: number;
  17549. static _CAP_START: number;
  17550. static _CAP_END: number;
  17551. static _CAP_ALL: number;
  17552. /**
  17553. * Mesh side orientation : usually the external or front surface
  17554. */
  17555. static readonly FRONTSIDE: number;
  17556. /**
  17557. * Mesh side orientation : usually the internal or back surface
  17558. */
  17559. static readonly BACKSIDE: number;
  17560. /**
  17561. * Mesh side orientation : both internal and external or front and back surfaces
  17562. */
  17563. static readonly DOUBLESIDE: number;
  17564. /**
  17565. * Mesh side orientation : by default, `FRONTSIDE`
  17566. */
  17567. static readonly DEFAULTSIDE: number;
  17568. /**
  17569. * Mesh cap setting : no cap
  17570. */
  17571. static readonly NO_CAP: number;
  17572. /**
  17573. * Mesh cap setting : one cap at the beginning of the mesh
  17574. */
  17575. static readonly CAP_START: number;
  17576. /**
  17577. * Mesh cap setting : one cap at the end of the mesh
  17578. */
  17579. static readonly CAP_END: number;
  17580. /**
  17581. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  17582. */
  17583. static readonly CAP_ALL: number;
  17584. /**
  17585. * An event triggered before rendering the mesh
  17586. */
  17587. onBeforeRenderObservable: Observable<Mesh>;
  17588. /**
  17589. * An event triggered after rendering the mesh
  17590. */
  17591. onAfterRenderObservable: Observable<Mesh>;
  17592. /**
  17593. * An event triggered before drawing the mesh
  17594. */
  17595. onBeforeDrawObservable: Observable<Mesh>;
  17596. private _onBeforeDrawObserver;
  17597. onBeforeDraw: () => void;
  17598. delayLoadState: number;
  17599. instances: InstancedMesh[];
  17600. delayLoadingFile: string;
  17601. _binaryInfo: any;
  17602. private _LODLevels;
  17603. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  17604. private _morphTargetManager;
  17605. morphTargetManager: Nullable<MorphTargetManager>;
  17606. _geometry: Nullable<Geometry>;
  17607. _delayInfo: Array<string>;
  17608. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  17609. _visibleInstances: any;
  17610. private _renderIdForInstances;
  17611. private _batchCache;
  17612. private _instancesBufferSize;
  17613. private _instancesBuffer;
  17614. private _instancesData;
  17615. private _overridenInstanceCount;
  17616. private _effectiveMaterial;
  17617. _shouldGenerateFlatShading: boolean;
  17618. private _preActivateId;
  17619. _originalBuilderSideOrientation: number;
  17620. overrideMaterialSideOrientation: Nullable<number>;
  17621. private _areNormalsFrozen;
  17622. private _sourcePositions;
  17623. private _sourceNormals;
  17624. private _source;
  17625. readonly source: Nullable<Mesh>;
  17626. isUnIndexed: boolean;
  17627. /**
  17628. * @constructor
  17629. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  17630. * @param {Scene} scene The scene to add this mesh to.
  17631. * @param {Node} parent The parent of this mesh, if it has one
  17632. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  17633. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17634. * When false, achieved by calling a clone(), also passing False.
  17635. * This will make creation of children, recursive.
  17636. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  17637. */
  17638. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  17639. /**
  17640. * Returns the string "Mesh".
  17641. */
  17642. getClassName(): string;
  17643. /**
  17644. * Returns a string.
  17645. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  17646. */
  17647. toString(fullDetails?: boolean): string;
  17648. /**
  17649. * True if the mesh has some Levels Of Details (LOD).
  17650. * Returns a boolean.
  17651. */
  17652. readonly hasLODLevels: boolean;
  17653. /**
  17654. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  17655. * @returns an array of {BABYLON.MeshLODLevel}
  17656. */
  17657. getLODLevels(): MeshLODLevel[];
  17658. private _sortLODLevels();
  17659. /**
  17660. * Add a mesh as LOD level triggered at the given distance.
  17661. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  17662. * @param {number} distance The distance from the center of the object to show this level
  17663. * @param {Mesh} mesh The mesh to be added as LOD level
  17664. * @return {Mesh} This mesh (for chaining)
  17665. */
  17666. addLODLevel(distance: number, mesh: Mesh): Mesh;
  17667. /**
  17668. * Returns the LOD level mesh at the passed distance or null if not found.
  17669. * It is related to the method `addLODLevel(distance, mesh)`.
  17670. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  17671. * Returns an object Mesh or `null`.
  17672. */
  17673. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  17674. /**
  17675. * Remove a mesh from the LOD array
  17676. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  17677. * @param {Mesh} mesh The mesh to be removed.
  17678. * @return {Mesh} This mesh (for chaining)
  17679. */
  17680. removeLODLevel(mesh: Mesh): Mesh;
  17681. /**
  17682. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  17683. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  17684. */
  17685. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  17686. /**
  17687. * Returns the mesh internal Geometry object.
  17688. */
  17689. readonly geometry: Nullable<Geometry>;
  17690. /**
  17691. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  17692. */
  17693. getTotalVertices(): number;
  17694. /**
  17695. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  17696. * 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.
  17697. * You can force the copy with forceCopy === true
  17698. * Returns null if the mesh has no geometry or no vertex buffer.
  17699. * Possible `kind` values :
  17700. * - BABYLON.VertexBuffer.PositionKind
  17701. * - BABYLON.VertexBuffer.UVKind
  17702. * - BABYLON.VertexBuffer.UV2Kind
  17703. * - BABYLON.VertexBuffer.UV3Kind
  17704. * - BABYLON.VertexBuffer.UV4Kind
  17705. * - BABYLON.VertexBuffer.UV5Kind
  17706. * - BABYLON.VertexBuffer.UV6Kind
  17707. * - BABYLON.VertexBuffer.ColorKind
  17708. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17709. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17710. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17711. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17712. */
  17713. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  17714. /**
  17715. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  17716. * Returns `null` if the mesh has no geometry.
  17717. * Possible `kind` values :
  17718. * - BABYLON.VertexBuffer.PositionKind
  17719. * - BABYLON.VertexBuffer.UVKind
  17720. * - BABYLON.VertexBuffer.UV2Kind
  17721. * - BABYLON.VertexBuffer.UV3Kind
  17722. * - BABYLON.VertexBuffer.UV4Kind
  17723. * - BABYLON.VertexBuffer.UV5Kind
  17724. * - BABYLON.VertexBuffer.UV6Kind
  17725. * - BABYLON.VertexBuffer.ColorKind
  17726. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17727. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17728. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17729. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17730. */
  17731. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  17732. /**
  17733. * Returns a boolean depending on the existence of the Vertex Data for the requested `kind`.
  17734. * Possible `kind` values :
  17735. * - BABYLON.VertexBuffer.PositionKind
  17736. * - BABYLON.VertexBuffer.UVKind
  17737. * - BABYLON.VertexBuffer.UV2Kind
  17738. * - BABYLON.VertexBuffer.UV3Kind
  17739. * - BABYLON.VertexBuffer.UV4Kind
  17740. * - BABYLON.VertexBuffer.UV5Kind
  17741. * - BABYLON.VertexBuffer.UV6Kind
  17742. * - BABYLON.VertexBuffer.ColorKind
  17743. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17744. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17745. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17746. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17747. */
  17748. isVerticesDataPresent(kind: string): boolean;
  17749. /**
  17750. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  17751. * Possible `kind` values :
  17752. * - BABYLON.VertexBuffer.PositionKind
  17753. * - BABYLON.VertexBuffer.UVKind
  17754. * - BABYLON.VertexBuffer.UV2Kind
  17755. * - BABYLON.VertexBuffer.UV3Kind
  17756. * - BABYLON.VertexBuffer.UV4Kind
  17757. * - BABYLON.VertexBuffer.UV5Kind
  17758. * - BABYLON.VertexBuffer.UV6Kind
  17759. * - BABYLON.VertexBuffer.ColorKind
  17760. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17761. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17762. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17763. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17764. */
  17765. isVertexBufferUpdatable(kind: string): boolean;
  17766. /**
  17767. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  17768. * Possible `kind` values :
  17769. * - BABYLON.VertexBuffer.PositionKind
  17770. * - BABYLON.VertexBuffer.UVKind
  17771. * - BABYLON.VertexBuffer.UV2Kind
  17772. * - BABYLON.VertexBuffer.UV3Kind
  17773. * - BABYLON.VertexBuffer.UV4Kind
  17774. * - BABYLON.VertexBuffer.UV5Kind
  17775. * - BABYLON.VertexBuffer.UV6Kind
  17776. * - BABYLON.VertexBuffer.ColorKind
  17777. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17778. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17779. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17780. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17781. */
  17782. getVerticesDataKinds(): string[];
  17783. /**
  17784. * Returns a positive integer : the total number of indices in this mesh geometry.
  17785. * Returns zero if the mesh has no geometry.
  17786. */
  17787. getTotalIndices(): number;
  17788. /**
  17789. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17790. * 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.
  17791. * Returns an empty array if the mesh has no geometry.
  17792. */
  17793. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  17794. readonly isBlocked: boolean;
  17795. /**
  17796. * Determine if the current mesh is ready to be rendered
  17797. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17798. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  17799. * @returns true if all associated assets are ready (material, textures, shaders)
  17800. */
  17801. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  17802. /**
  17803. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  17804. * This property is pertinent only for updatable parametric shapes.
  17805. */
  17806. readonly areNormalsFrozen: boolean;
  17807. /**
  17808. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  17809. * It has no effect at all on other shapes.
  17810. * It prevents the mesh normals from being recomputed on next `positions` array update.
  17811. * Returns the Mesh.
  17812. */
  17813. freezeNormals(): Mesh;
  17814. /**
  17815. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  17816. * It has no effect at all on other shapes.
  17817. * It reactivates the mesh normals computation if it was previously frozen.
  17818. * Returns the Mesh.
  17819. */
  17820. unfreezeNormals(): Mesh;
  17821. /**
  17822. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  17823. */
  17824. overridenInstanceCount: number;
  17825. _preActivate(): Mesh;
  17826. _preActivateForIntermediateRendering(renderId: number): Mesh;
  17827. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  17828. /**
  17829. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17830. * This means the mesh underlying bounding box and sphere are recomputed.
  17831. * Returns the Mesh.
  17832. */
  17833. refreshBoundingInfo(): Mesh;
  17834. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  17835. private _getPositionData(applySkeleton);
  17836. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  17837. subdivide(count: number): void;
  17838. /**
  17839. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17840. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17841. * The `data` are either a numeric array either a Float32Array.
  17842. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17843. * 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).
  17844. * Note that a new underlying VertexBuffer object is created each call.
  17845. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17846. *
  17847. * Possible `kind` values :
  17848. * - BABYLON.VertexBuffer.PositionKind
  17849. * - BABYLON.VertexBuffer.UVKind
  17850. * - BABYLON.VertexBuffer.UV2Kind
  17851. * - BABYLON.VertexBuffer.UV3Kind
  17852. * - BABYLON.VertexBuffer.UV4Kind
  17853. * - BABYLON.VertexBuffer.UV5Kind
  17854. * - BABYLON.VertexBuffer.UV6Kind
  17855. * - BABYLON.VertexBuffer.ColorKind
  17856. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17857. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17858. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17859. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17860. *
  17861. * Returns the Mesh.
  17862. */
  17863. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17864. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  17865. /**
  17866. * Sets the mesh VertexBuffer.
  17867. * Returns the Mesh.
  17868. */
  17869. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  17870. /**
  17871. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17872. * If the mesh has no geometry, it is simply returned as it is.
  17873. * The `data` are either a numeric array either a Float32Array.
  17874. * No new underlying VertexBuffer object is created.
  17875. * 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.
  17876. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17877. *
  17878. * Possible `kind` values :
  17879. * - BABYLON.VertexBuffer.PositionKind
  17880. * - BABYLON.VertexBuffer.UVKind
  17881. * - BABYLON.VertexBuffer.UV2Kind
  17882. * - BABYLON.VertexBuffer.UV3Kind
  17883. * - BABYLON.VertexBuffer.UV4Kind
  17884. * - BABYLON.VertexBuffer.UV5Kind
  17885. * - BABYLON.VertexBuffer.UV6Kind
  17886. * - BABYLON.VertexBuffer.ColorKind
  17887. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17888. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17889. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17890. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17891. *
  17892. * Returns the Mesh.
  17893. */
  17894. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17895. /**
  17896. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  17897. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  17898. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  17899. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  17900. * Returns the Mesh.
  17901. */
  17902. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  17903. /**
  17904. * Creates a un-shared specific occurence of the geometry for the mesh.
  17905. * Returns the Mesh.
  17906. */
  17907. makeGeometryUnique(): Mesh;
  17908. /**
  17909. * Sets the mesh indices.
  17910. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17911. * Type is Uint16Array by default unless the mesh has more than 65536 vertices.
  17912. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17913. * This method creates a new index buffer each call.
  17914. * Returns the Mesh.
  17915. */
  17916. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  17917. /**
  17918. * Update the current index buffer
  17919. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  17920. * Returns the Mesh.
  17921. */
  17922. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  17923. /**
  17924. * Invert the geometry to move from a right handed system to a left handed one.
  17925. * Returns the Mesh.
  17926. */
  17927. toLeftHanded(): Mesh;
  17928. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17929. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  17930. /**
  17931. * Registers for this mesh a javascript function called just before the rendering process.
  17932. * This function is passed the current mesh.
  17933. * Return the Mesh.
  17934. */
  17935. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  17936. /**
  17937. * Disposes a previously registered javascript function called before the rendering.
  17938. * This function is passed the current mesh.
  17939. * Returns the Mesh.
  17940. */
  17941. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  17942. /**
  17943. * Registers for this mesh a javascript function called just after the rendering is complete.
  17944. * This function is passed the current mesh.
  17945. * Returns the Mesh.
  17946. */
  17947. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  17948. /**
  17949. * Disposes a previously registered javascript function called after the rendering.
  17950. * This function is passed the current mesh.
  17951. * Return the Mesh.
  17952. */
  17953. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  17954. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  17955. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  17956. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  17957. /**
  17958. * Triggers the draw call for the mesh.
  17959. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  17960. * Returns the Mesh.
  17961. */
  17962. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  17963. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  17964. /**
  17965. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  17966. */
  17967. getEmittedParticleSystems(): IParticleSystem[];
  17968. /**
  17969. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  17970. */
  17971. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  17972. _checkDelayState(): Mesh;
  17973. private _queueLoad(scene);
  17974. /**
  17975. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  17976. */
  17977. isInFrustum(frustumPlanes: Plane[]): boolean;
  17978. /**
  17979. * Sets the mesh material by the material or multiMaterial `id` property.
  17980. * The material `id` is a string identifying the material or the multiMaterial.
  17981. * This method returns the Mesh.
  17982. */
  17983. setMaterialByID(id: string): Mesh;
  17984. /**
  17985. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  17986. */
  17987. getAnimatables(): IAnimatable[];
  17988. /**
  17989. * Modifies the mesh geometry according to the passed transformation matrix.
  17990. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  17991. * The mesh normals are modified accordingly the same transformation.
  17992. * tuto : http://doc.babylonjs.com/tutorials/How_Rotations_and_Translations_Work#baking-transform
  17993. * Note that, under the hood, this method sets a new VertexBuffer each call.
  17994. * Returns the Mesh.
  17995. */
  17996. bakeTransformIntoVertices(transform: Matrix): Mesh;
  17997. /**
  17998. * Modifies the mesh geometry according to its own current World Matrix.
  17999. * The mesh World Matrix is then reset.
  18000. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  18001. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  18002. * Note that, under the hood, this method sets a new VertexBuffer each call.
  18003. * Returns the Mesh.
  18004. */
  18005. bakeCurrentTransformIntoVertices(): Mesh;
  18006. readonly _positions: Nullable<Vector3[]>;
  18007. _resetPointsArrayCache(): Mesh;
  18008. _generatePointsArray(): boolean;
  18009. /**
  18010. * Returns a new Mesh object generated from the current mesh properties.
  18011. * This method must not get confused with createInstance().
  18012. * The parameter `name` is a string, the name given to the new mesh.
  18013. * The optional parameter `newParent` can be any Node object (default `null`).
  18014. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  18015. * 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.
  18016. */
  18017. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  18018. /**
  18019. * Releases resources associated with this mesh.
  18020. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18021. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18022. */
  18023. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18024. /**
  18025. * Modifies the mesh geometry according to a displacement map.
  18026. * 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.
  18027. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  18028. * This method returns nothing.
  18029. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  18030. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  18031. * 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.
  18032. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  18033. * The parameter `uvScale` is an optional vector2 used to scale UV.
  18034. *
  18035. * Returns the Mesh.
  18036. */
  18037. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  18038. /**
  18039. * Modifies the mesh geometry according to a displacementMap buffer.
  18040. * 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.
  18041. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  18042. * This method returns nothing.
  18043. * 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.
  18044. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  18045. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  18046. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  18047. * The parameter `uvScale` is an optional vector2 used to scale UV.
  18048. *
  18049. * Returns the Mesh.
  18050. */
  18051. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  18052. /**
  18053. * Modify the mesh to get a flat shading rendering.
  18054. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  18055. * This method returns the Mesh.
  18056. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  18057. */
  18058. convertToFlatShadedMesh(): Mesh;
  18059. /**
  18060. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  18061. * In other words, more vertices, no more indices and a single bigger VBO.
  18062. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  18063. * Returns the Mesh.
  18064. */
  18065. convertToUnIndexedMesh(): Mesh;
  18066. /**
  18067. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  18068. * This method returns the Mesh.
  18069. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  18070. */
  18071. flipFaces(flipNormals?: boolean): Mesh;
  18072. /**
  18073. * Creates a new InstancedMesh object from the mesh model.
  18074. * An instance shares the same properties and the same material than its model.
  18075. * Only these properties of each instance can then be set individually :
  18076. * - position
  18077. * - rotation
  18078. * - rotationQuaternion
  18079. * - setPivotMatrix
  18080. * - scaling
  18081. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  18082. * Warning : this method is not supported for Line mesh and LineSystem
  18083. */
  18084. createInstance(name: string): InstancedMesh;
  18085. /**
  18086. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  18087. * After this call, all the mesh instances have the same submeshes than the current mesh.
  18088. * This method returns the Mesh.
  18089. */
  18090. synchronizeInstances(): Mesh;
  18091. /**
  18092. * Simplify the mesh according to the given array of settings.
  18093. * Function will return immediately and will simplify async. It returns the Mesh.
  18094. * @param settings a collection of simplification settings.
  18095. * @param parallelProcessing should all levels calculate parallel or one after the other.
  18096. * @param type the type of simplification to run.
  18097. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  18098. */
  18099. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  18100. /**
  18101. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  18102. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  18103. * This should be used together with the simplification to avoid disappearing triangles.
  18104. * Returns the Mesh.
  18105. * @param successCallback an optional success callback to be called after the optimization finished.
  18106. */
  18107. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  18108. serialize(serializationObject: any): void;
  18109. _syncGeometryWithMorphTargetManager(): void;
  18110. /**
  18111. * Returns a new Mesh object parsed from the source provided.
  18112. * The parameter `parsedMesh` is the source.
  18113. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  18114. */
  18115. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  18116. /**
  18117. * Creates a ribbon mesh.
  18118. * Please consider using the same method from the MeshBuilder class instead.
  18119. * 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.
  18120. *
  18121. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  18122. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  18123. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  18124. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  18125. * 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.
  18126. * 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.
  18127. * 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
  18128. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18129. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18130. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18131. */
  18132. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  18133. /**
  18134. * Creates a plane polygonal mesh. By default, this is a disc.
  18135. * Please consider using the same method from the MeshBuilder class instead.
  18136. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  18137. * 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.
  18138. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18139. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18140. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18141. */
  18142. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  18143. /**
  18144. * Creates a box mesh.
  18145. * Please consider using the same method from the MeshBuilder class instead.
  18146. * The parameter `size` sets the size (float) of each box side (default 1).
  18147. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18148. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18149. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18150. */
  18151. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  18152. /**
  18153. * Creates a sphere mesh.
  18154. * Please consider using the same method from the MeshBuilder class instead.
  18155. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  18156. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  18157. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18158. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18159. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18160. */
  18161. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  18162. /**
  18163. * Creates a cylinder or a cone mesh.
  18164. * Please consider using the same method from the MeshBuilder class instead.
  18165. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  18166. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  18167. * 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.
  18168. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  18169. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  18170. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18171. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18172. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18173. */
  18174. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  18175. /**
  18176. * Creates a torus mesh.
  18177. * Please consider using the same method from the MeshBuilder class instead.
  18178. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  18179. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  18180. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  18181. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18182. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18183. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18184. */
  18185. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  18186. /**
  18187. * Creates a torus knot mesh.
  18188. * Please consider using the same method from the MeshBuilder class instead.
  18189. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  18190. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  18191. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  18192. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  18193. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18194. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18195. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18196. */
  18197. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  18198. /**
  18199. * Creates a line mesh.
  18200. * Please consider using the same method from the MeshBuilder class instead.
  18201. * 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.
  18202. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  18203. * The parameter `points` is an array successive Vector3.
  18204. * 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
  18205. * When updating an instance, remember that only point positions can change, not the number of points.
  18206. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18207. */
  18208. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  18209. /**
  18210. * Creates a dashed line mesh.
  18211. * Please consider using the same method from the MeshBuilder class instead.
  18212. * 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.
  18213. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  18214. * The parameter `points` is an array successive Vector3.
  18215. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  18216. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  18217. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  18218. * 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
  18219. * When updating an instance, remember that only point positions can change, not the number of points.
  18220. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18221. */
  18222. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  18223. /**
  18224. * Creates a polygon mesh.
  18225. * Please consider using the same method from the MeshBuilder class instead.
  18226. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  18227. * 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.
  18228. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18229. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18230. * Remember you can only change the shape positions, not their number when updating a polygon.
  18231. */
  18232. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  18233. /**
  18234. * Creates an extruded polygon mesh, with depth in the Y direction.
  18235. * Please consider using the same method from the MeshBuilder class instead.
  18236. */
  18237. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  18238. /**
  18239. * Creates an extruded shape mesh.
  18240. * 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.
  18241. * Please consider using the same method from the MeshBuilder class instead.
  18242. *
  18243. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  18244. * 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
  18245. * extruded along the Z axis.
  18246. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  18247. * 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.
  18248. * The parameter `scale` (float, default 1) is the value to scale the shape.
  18249. * 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
  18250. * 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
  18251. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  18252. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18253. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18254. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18255. */
  18256. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  18257. /**
  18258. * Creates an custom extruded shape mesh.
  18259. * 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.
  18260. * Please consider using the same method from the MeshBuilder class instead.
  18261. *
  18262. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  18263. * 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
  18264. * extruded along the Z axis.
  18265. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  18266. * 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
  18267. * and the distance of this point from the begining of the path :
  18268. * ```javascript
  18269. * var rotationFunction = function(i, distance) {
  18270. * // do things
  18271. * return rotationValue; }
  18272. * ```
  18273. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  18274. * 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
  18275. * and the distance of this point from the begining of the path :
  18276. * ```javascript
  18277. * var scaleFunction = function(i, distance) {
  18278. * // do things
  18279. * return scaleValue;}
  18280. * ```
  18281. * It must returns a float value that will be the scale value applied to the shape on each path point.
  18282. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  18283. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  18284. * 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
  18285. * 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
  18286. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  18287. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18288. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18289. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18290. */
  18291. 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;
  18292. /**
  18293. * Creates lathe mesh.
  18294. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  18295. * Please consider using the same method from the MeshBuilder class instead.
  18296. * 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
  18297. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  18298. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  18299. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  18300. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18301. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18302. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18303. */
  18304. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  18305. /**
  18306. * Creates a plane mesh.
  18307. * Please consider using the same method from the MeshBuilder class instead.
  18308. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  18309. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18310. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18311. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18312. */
  18313. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  18314. /**
  18315. * Creates a ground mesh.
  18316. * Please consider using the same method from the MeshBuilder class instead.
  18317. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  18318. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  18319. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18320. */
  18321. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  18322. /**
  18323. * Creates a tiled ground mesh.
  18324. * Please consider using the same method from the MeshBuilder class instead.
  18325. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  18326. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  18327. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  18328. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  18329. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  18330. * numbers of subdivisions on the ground width and height of each tile.
  18331. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18332. */
  18333. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  18334. w: number;
  18335. h: number;
  18336. }, precision: {
  18337. w: number;
  18338. h: number;
  18339. }, scene: Scene, updatable?: boolean): Mesh;
  18340. /**
  18341. * Creates a ground mesh from a height map.
  18342. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  18343. * Please consider using the same method from the MeshBuilder class instead.
  18344. * The parameter `url` sets the URL of the height map image resource.
  18345. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  18346. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  18347. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  18348. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  18349. * 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).
  18350. * This function is passed the newly built mesh :
  18351. * ```javascript
  18352. * function(mesh) { // do things
  18353. * return; }
  18354. * ```
  18355. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18356. */
  18357. 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;
  18358. /**
  18359. * Creates a tube mesh.
  18360. * 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.
  18361. * Please consider using the same method from the MeshBuilder class instead.
  18362. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  18363. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  18364. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  18365. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  18366. * 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.
  18367. * It must return a radius value (positive float) :
  18368. * ```javascript
  18369. * var radiusFunction = function(i, distance) {
  18370. * // do things
  18371. * return radius; }
  18372. * ```
  18373. * 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
  18374. * 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
  18375. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18376. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18377. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18378. */
  18379. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  18380. (i: number, distance: number): number;
  18381. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  18382. /**
  18383. * Creates a polyhedron mesh.
  18384. * Please consider using the same method from the MeshBuilder class instead.
  18385. * 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
  18386. * to choose the wanted type.
  18387. * The parameter `size` (positive float, default 1) sets the polygon size.
  18388. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  18389. * 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`.
  18390. * 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
  18391. * 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)`).
  18392. * 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
  18393. * 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.
  18394. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18395. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18396. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18397. */
  18398. static CreatePolyhedron(name: string, options: {
  18399. type?: number;
  18400. size?: number;
  18401. sizeX?: number;
  18402. sizeY?: number;
  18403. sizeZ?: number;
  18404. custom?: any;
  18405. faceUV?: Vector4[];
  18406. faceColors?: Color4[];
  18407. updatable?: boolean;
  18408. sideOrientation?: number;
  18409. }, scene: Scene): Mesh;
  18410. /**
  18411. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  18412. * Please consider using the same method from the MeshBuilder class instead.
  18413. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  18414. * 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`).
  18415. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  18416. * 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.
  18417. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18418. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18419. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18420. */
  18421. static CreateIcoSphere(name: string, options: {
  18422. radius?: number;
  18423. flat?: boolean;
  18424. subdivisions?: number;
  18425. sideOrientation?: number;
  18426. updatable?: boolean;
  18427. }, scene: Scene): Mesh;
  18428. /**
  18429. * Creates a decal mesh.
  18430. * Please consider using the same method from the MeshBuilder class instead.
  18431. * 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.
  18432. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  18433. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  18434. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  18435. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  18436. */
  18437. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  18438. /**
  18439. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  18440. */
  18441. setPositionsForCPUSkinning(): Float32Array;
  18442. /**
  18443. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  18444. */
  18445. setNormalsForCPUSkinning(): Float32Array;
  18446. /**
  18447. * Updates the vertex buffer by applying transformation from the bones.
  18448. * Returns the Mesh.
  18449. *
  18450. * @param {skeleton} skeleton to apply
  18451. */
  18452. applySkeleton(skeleton: Skeleton): Mesh;
  18453. /**
  18454. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  18455. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  18456. */
  18457. static MinMax(meshes: AbstractMesh[]): {
  18458. min: Vector3;
  18459. max: Vector3;
  18460. };
  18461. /**
  18462. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  18463. */
  18464. static Center(meshesOrMinMaxVector: {
  18465. min: Vector3;
  18466. max: Vector3;
  18467. } | AbstractMesh[]): Vector3;
  18468. /**
  18469. * Merge the array of meshes into a single mesh for performance reasons.
  18470. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  18471. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  18472. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  18473. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  18474. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  18475. */
  18476. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  18477. }
  18478. }
  18479. declare module BABYLON {
  18480. interface IGetSetVerticesData {
  18481. isVerticesDataPresent(kind: string): boolean;
  18482. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  18483. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  18484. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  18485. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  18486. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  18487. }
  18488. class VertexData {
  18489. positions: Nullable<FloatArray>;
  18490. normals: Nullable<FloatArray>;
  18491. tangents: Nullable<FloatArray>;
  18492. uvs: Nullable<FloatArray>;
  18493. uvs2: Nullable<FloatArray>;
  18494. uvs3: Nullable<FloatArray>;
  18495. uvs4: Nullable<FloatArray>;
  18496. uvs5: Nullable<FloatArray>;
  18497. uvs6: Nullable<FloatArray>;
  18498. colors: Nullable<FloatArray>;
  18499. matricesIndices: Nullable<FloatArray>;
  18500. matricesWeights: Nullable<FloatArray>;
  18501. matricesIndicesExtra: Nullable<FloatArray>;
  18502. matricesWeightsExtra: Nullable<FloatArray>;
  18503. indices: Nullable<IndicesArray>;
  18504. set(data: FloatArray, kind: string): void;
  18505. /**
  18506. * Associates the vertexData to the passed Mesh.
  18507. * Sets it as updatable or not (default `false`).
  18508. * Returns the VertexData.
  18509. */
  18510. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  18511. /**
  18512. * Associates the vertexData to the passed Geometry.
  18513. * Sets it as updatable or not (default `false`).
  18514. * Returns the VertexData.
  18515. */
  18516. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  18517. /**
  18518. * Updates the associated mesh.
  18519. * Returns the VertexData.
  18520. */
  18521. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  18522. /**
  18523. * Updates the associated geometry.
  18524. * Returns the VertexData.
  18525. */
  18526. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  18527. private _applyTo(meshOrGeometry, updatable?);
  18528. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  18529. /**
  18530. * Transforms each position and each normal of the vertexData according to the passed Matrix.
  18531. * Returns the VertexData.
  18532. */
  18533. transform(matrix: Matrix): VertexData;
  18534. /**
  18535. * Merges the passed VertexData into the current one.
  18536. * Returns the modified VertexData.
  18537. */
  18538. merge(other: VertexData): VertexData;
  18539. private _mergeElement(source, other);
  18540. private _validate();
  18541. /**
  18542. * Serializes the VertexData.
  18543. * Returns a serialized object.
  18544. */
  18545. serialize(): any;
  18546. /**
  18547. * Returns the object VertexData associated to the passed mesh.
  18548. */
  18549. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  18550. /**
  18551. * Returns the object VertexData associated to the passed geometry.
  18552. */
  18553. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  18554. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  18555. /**
  18556. * Creates the vertexData of the Ribbon.
  18557. */
  18558. static CreateRibbon(options: {
  18559. pathArray: Vector3[][];
  18560. closeArray?: boolean;
  18561. closePath?: boolean;
  18562. offset?: number;
  18563. sideOrientation?: number;
  18564. frontUVs?: Vector4;
  18565. backUVs?: Vector4;
  18566. invertUV?: boolean;
  18567. uvs?: Vector2[];
  18568. colors?: Color4[];
  18569. }): VertexData;
  18570. /**
  18571. * Creates the VertexData of the Box.
  18572. */
  18573. static CreateBox(options: {
  18574. size?: number;
  18575. width?: number;
  18576. height?: number;
  18577. depth?: number;
  18578. faceUV?: Vector4[];
  18579. faceColors?: Color4[];
  18580. sideOrientation?: number;
  18581. frontUVs?: Vector4;
  18582. backUVs?: Vector4;
  18583. }): VertexData;
  18584. /**
  18585. * Creates the VertexData of the Sphere.
  18586. */
  18587. static CreateSphere(options: {
  18588. segments?: number;
  18589. diameter?: number;
  18590. diameterX?: number;
  18591. diameterY?: number;
  18592. diameterZ?: number;
  18593. arc?: number;
  18594. slice?: number;
  18595. sideOrientation?: number;
  18596. frontUVs?: Vector4;
  18597. backUVs?: Vector4;
  18598. }): VertexData;
  18599. /**
  18600. * Creates the VertexData of the Cylinder or Cone.
  18601. */
  18602. static CreateCylinder(options: {
  18603. height?: number;
  18604. diameterTop?: number;
  18605. diameterBottom?: number;
  18606. diameter?: number;
  18607. tessellation?: number;
  18608. subdivisions?: number;
  18609. arc?: number;
  18610. faceColors?: Color4[];
  18611. faceUV?: Vector4[];
  18612. hasRings?: boolean;
  18613. enclose?: boolean;
  18614. sideOrientation?: number;
  18615. frontUVs?: Vector4;
  18616. backUVs?: Vector4;
  18617. }): VertexData;
  18618. /**
  18619. * Creates the VertexData of the Torus.
  18620. */
  18621. static CreateTorus(options: {
  18622. diameter?: number;
  18623. thickness?: number;
  18624. tessellation?: number;
  18625. sideOrientation?: number;
  18626. frontUVs?: Vector4;
  18627. backUVs?: Vector4;
  18628. }): VertexData;
  18629. /**
  18630. * Creates the VertexData of the LineSystem.
  18631. */
  18632. static CreateLineSystem(options: {
  18633. lines: Vector3[][];
  18634. colors?: Nullable<Color4[][]>;
  18635. }): VertexData;
  18636. /**
  18637. * Create the VertexData of the DashedLines.
  18638. */
  18639. static CreateDashedLines(options: {
  18640. points: Vector3[];
  18641. dashSize?: number;
  18642. gapSize?: number;
  18643. dashNb?: number;
  18644. }): VertexData;
  18645. /**
  18646. * Creates the VertexData of the Ground.
  18647. */
  18648. static CreateGround(options: {
  18649. width?: number;
  18650. height?: number;
  18651. subdivisions?: number;
  18652. subdivisionsX?: number;
  18653. subdivisionsY?: number;
  18654. }): VertexData;
  18655. /**
  18656. * Creates the VertexData of the TiledGround.
  18657. */
  18658. static CreateTiledGround(options: {
  18659. xmin: number;
  18660. zmin: number;
  18661. xmax: number;
  18662. zmax: number;
  18663. subdivisions?: {
  18664. w: number;
  18665. h: number;
  18666. };
  18667. precision?: {
  18668. w: number;
  18669. h: number;
  18670. };
  18671. }): VertexData;
  18672. /**
  18673. * Creates the VertexData of the Ground designed from a heightmap.
  18674. */
  18675. static CreateGroundFromHeightMap(options: {
  18676. width: number;
  18677. height: number;
  18678. subdivisions: number;
  18679. minHeight: number;
  18680. maxHeight: number;
  18681. colorFilter: Color3;
  18682. buffer: Uint8Array;
  18683. bufferWidth: number;
  18684. bufferHeight: number;
  18685. }): VertexData;
  18686. /**
  18687. * Creates the VertexData of the Plane.
  18688. */
  18689. static CreatePlane(options: {
  18690. size?: number;
  18691. width?: number;
  18692. height?: number;
  18693. sideOrientation?: number;
  18694. frontUVs?: Vector4;
  18695. backUVs?: Vector4;
  18696. }): VertexData;
  18697. /**
  18698. * Creates the VertexData of the Disc or regular Polygon.
  18699. */
  18700. static CreateDisc(options: {
  18701. radius?: number;
  18702. tessellation?: number;
  18703. arc?: number;
  18704. sideOrientation?: number;
  18705. frontUVs?: Vector4;
  18706. backUVs?: Vector4;
  18707. }): VertexData;
  18708. /**
  18709. * Re-creates the VertexData of the Polygon for sideOrientation.
  18710. */
  18711. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  18712. /**
  18713. * Creates the VertexData of the IcoSphere.
  18714. */
  18715. static CreateIcoSphere(options: {
  18716. radius?: number;
  18717. radiusX?: number;
  18718. radiusY?: number;
  18719. radiusZ?: number;
  18720. flat?: boolean;
  18721. subdivisions?: number;
  18722. sideOrientation?: number;
  18723. frontUVs?: Vector4;
  18724. backUVs?: Vector4;
  18725. }): VertexData;
  18726. /**
  18727. * Creates the VertexData of the Polyhedron.
  18728. */
  18729. static CreatePolyhedron(options: {
  18730. type?: number;
  18731. size?: number;
  18732. sizeX?: number;
  18733. sizeY?: number;
  18734. sizeZ?: number;
  18735. custom?: any;
  18736. faceUV?: Vector4[];
  18737. faceColors?: Color4[];
  18738. flat?: boolean;
  18739. sideOrientation?: number;
  18740. frontUVs?: Vector4;
  18741. backUVs?: Vector4;
  18742. }): VertexData;
  18743. /**
  18744. * Creates the VertexData of the Torus Knot.
  18745. */
  18746. static CreateTorusKnot(options: {
  18747. radius?: number;
  18748. tube?: number;
  18749. radialSegments?: number;
  18750. tubularSegments?: number;
  18751. p?: number;
  18752. q?: number;
  18753. sideOrientation?: number;
  18754. frontUVs?: Vector4;
  18755. backUVs?: Vector4;
  18756. }): VertexData;
  18757. /**
  18758. * @param {any} - positions (number[] or Float32Array)
  18759. * @param {any} - indices (number[] or Uint16Array)
  18760. * @param {any} - normals (number[] or Float32Array)
  18761. * options (optional) :
  18762. * facetPositions : optional array of facet positions (vector3)
  18763. * facetNormals : optional array of facet normals (vector3)
  18764. * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  18765. * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  18766. * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  18767. * bbSize : optional bounding box size data, required for facetPartitioning computation
  18768. * bInfo : optional bounding info, required for facetPartitioning computation
  18769. * useRightHandedSystem: optional boolean to for right handed system computation
  18770. * depthSort : optional boolean to enable the facet depth sort computation
  18771. * distanceTo : optional Vector3 to compute the facet depth from this location
  18772. * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  18773. */
  18774. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  18775. facetNormals?: any;
  18776. facetPositions?: any;
  18777. facetPartitioning?: any;
  18778. ratio?: number;
  18779. bInfo?: any;
  18780. bbSize?: Vector3;
  18781. subDiv?: any;
  18782. useRightHandedSystem?: boolean;
  18783. depthSort?: boolean;
  18784. distanceTo?: Vector3;
  18785. depthSortedFacets?: any;
  18786. }): void;
  18787. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  18788. /**
  18789. * Creates a new VertexData from the imported parameters.
  18790. */
  18791. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  18792. }
  18793. }
  18794. declare module BABYLON {
  18795. class MeshBuilder {
  18796. private static updateSideOrientation(orientation?);
  18797. /**
  18798. * Creates a box mesh.
  18799. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  18800. * The parameter `size` sets the size (float) of each box side (default 1).
  18801. * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`).
  18802. * 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).
  18803. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  18804. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18805. * 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).
  18806. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18807. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18808. */
  18809. static CreateBox(name: string, options: {
  18810. size?: number;
  18811. width?: number;
  18812. height?: number;
  18813. depth?: number;
  18814. faceUV?: Vector4[];
  18815. faceColors?: Color4[];
  18816. sideOrientation?: number;
  18817. frontUVs?: Vector4;
  18818. backUVs?: Vector4;
  18819. updatable?: boolean;
  18820. }, scene?: Nullable<Scene>): Mesh;
  18821. /**
  18822. * Creates a sphere mesh.
  18823. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  18824. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  18825. * 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`).
  18826. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  18827. * 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
  18828. * 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).
  18829. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18830. * 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).
  18831. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18832. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18833. */
  18834. static CreateSphere(name: string, options: {
  18835. segments?: number;
  18836. diameter?: number;
  18837. diameterX?: number;
  18838. diameterY?: number;
  18839. diameterZ?: number;
  18840. arc?: number;
  18841. slice?: number;
  18842. sideOrientation?: number;
  18843. frontUVs?: Vector4;
  18844. backUVs?: Vector4;
  18845. updatable?: boolean;
  18846. }, scene: any): Mesh;
  18847. /**
  18848. * Creates a plane polygonal mesh. By default, this is a disc.
  18849. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#disc
  18850. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  18851. * 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.
  18852. * 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
  18853. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18854. * 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).
  18855. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18856. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18857. */
  18858. static CreateDisc(name: string, options: {
  18859. radius?: number;
  18860. tessellation?: number;
  18861. arc?: number;
  18862. updatable?: boolean;
  18863. sideOrientation?: number;
  18864. frontUVs?: Vector4;
  18865. backUVs?: Vector4;
  18866. }, scene?: Nullable<Scene>): Mesh;
  18867. /**
  18868. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  18869. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#icosphere
  18870. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  18871. * 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`).
  18872. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  18873. * 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.
  18874. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18875. * 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).
  18876. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18877. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18878. */
  18879. static CreateIcoSphere(name: string, options: {
  18880. radius?: number;
  18881. radiusX?: number;
  18882. radiusY?: number;
  18883. radiusZ?: number;
  18884. flat?: boolean;
  18885. subdivisions?: number;
  18886. sideOrientation?: number;
  18887. frontUVs?: Vector4;
  18888. backUVs?: Vector4;
  18889. updatable?: boolean;
  18890. }, scene: Scene): Mesh;
  18891. /**
  18892. * Creates a ribbon mesh.
  18893. * 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.
  18894. *
  18895. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  18896. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  18897. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  18898. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  18899. * 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.
  18900. * 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.
  18901. * 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
  18902. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18903. * 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).
  18904. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18905. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  18906. * 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.
  18907. * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values.
  18908. * 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
  18909. * if you set `closePath` to `true`, there's one extra vertex per path in the geometry.
  18910. * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time.
  18911. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18912. */
  18913. static CreateRibbon(name: string, options: {
  18914. pathArray: Vector3[][];
  18915. closeArray?: boolean;
  18916. closePath?: boolean;
  18917. offset?: number;
  18918. updatable?: boolean;
  18919. sideOrientation?: number;
  18920. frontUVs?: Vector4;
  18921. backUVs?: Vector4;
  18922. instance?: Mesh;
  18923. invertUV?: boolean;
  18924. uvs?: Vector2[];
  18925. colors?: Color4[];
  18926. }, scene?: Nullable<Scene>): Mesh;
  18927. /**
  18928. * Creates a cylinder or a cone mesh.
  18929. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  18930. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  18931. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  18932. * 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.
  18933. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  18934. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  18935. * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  18936. * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  18937. * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  18938. * 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).
  18939. * 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
  18940. * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  18941. * 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
  18942. * 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.
  18943. * If `enclose` is false, a ring surface is one element.
  18944. * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  18945. * 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
  18946. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18947. * 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).
  18948. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18949. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18950. */
  18951. static CreateCylinder(name: string, options: {
  18952. height?: number;
  18953. diameterTop?: number;
  18954. diameterBottom?: number;
  18955. diameter?: number;
  18956. tessellation?: number;
  18957. subdivisions?: number;
  18958. arc?: number;
  18959. faceColors?: Color4[];
  18960. faceUV?: Vector4[];
  18961. updatable?: boolean;
  18962. hasRings?: boolean;
  18963. enclose?: boolean;
  18964. sideOrientation?: number;
  18965. frontUVs?: Vector4;
  18966. backUVs?: Vector4;
  18967. }, scene: any): Mesh;
  18968. /**
  18969. * Creates a torus mesh.
  18970. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  18971. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  18972. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  18973. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  18974. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18975. * 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).
  18976. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18977. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18978. */
  18979. static CreateTorus(name: string, options: {
  18980. diameter?: number;
  18981. thickness?: number;
  18982. tessellation?: number;
  18983. updatable?: boolean;
  18984. sideOrientation?: number;
  18985. frontUVs?: Vector4;
  18986. backUVs?: Vector4;
  18987. }, scene: any): Mesh;
  18988. /**
  18989. * Creates a torus knot mesh.
  18990. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  18991. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  18992. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  18993. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  18994. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  18995. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18996. * 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).
  18997. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18998. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18999. */
  19000. static CreateTorusKnot(name: string, options: {
  19001. radius?: number;
  19002. tube?: number;
  19003. radialSegments?: number;
  19004. tubularSegments?: number;
  19005. p?: number;
  19006. q?: number;
  19007. updatable?: boolean;
  19008. sideOrientation?: number;
  19009. frontUVs?: Vector4;
  19010. backUVs?: Vector4;
  19011. }, scene: any): Mesh;
  19012. /**
  19013. * Creates a line system mesh.
  19014. * A line system is a pool of many lines gathered in a single mesh.
  19015. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#linesystem
  19016. * 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.
  19017. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function.
  19018. * The parameter `lines` is an array of lines, each line being an array of successive Vector3.
  19019. * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter. The way to update it is the same than for
  19020. * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point.
  19021. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need the alpha blending (faster).
  19022. * 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
  19023. * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines.
  19024. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19025. */
  19026. static CreateLineSystem(name: string, options: {
  19027. lines: Vector3[][];
  19028. updatable: boolean;
  19029. instance: Nullable<LinesMesh>;
  19030. colors?: Nullable<Color4[][]>;
  19031. useVertexAlpha?: boolean;
  19032. }, scene: Nullable<Scene>): LinesMesh;
  19033. /**
  19034. * Creates a line mesh.
  19035. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lines
  19036. * 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.
  19037. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  19038. * The parameter `points` is an array successive Vector3.
  19039. * 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
  19040. * The optional parameter `colors` is an array of successive Color4, one per line point.
  19041. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need alpha blending (faster).
  19042. * When updating an instance, remember that only point positions can change, not the number of points.
  19043. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19044. */
  19045. static CreateLines(name: string, options: {
  19046. points: Vector3[];
  19047. updatable: boolean;
  19048. instance: Nullable<LinesMesh>;
  19049. colors?: Color4[];
  19050. useVertexAlpha?: boolean;
  19051. }, scene?: Nullable<Scene>): LinesMesh;
  19052. /**
  19053. * Creates a dashed line mesh.
  19054. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#dashed-lines
  19055. * 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.
  19056. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  19057. * The parameter `points` is an array successive Vector3.
  19058. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  19059. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  19060. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  19061. * 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
  19062. * When updating an instance, remember that only point positions can change, not the number of points.
  19063. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19064. */
  19065. static CreateDashedLines(name: string, options: {
  19066. points: Vector3[];
  19067. dashSize?: number;
  19068. gapSize?: number;
  19069. dashNb?: number;
  19070. updatable?: boolean;
  19071. instance?: LinesMesh;
  19072. }, scene?: Nullable<Scene>): LinesMesh;
  19073. /**
  19074. * Creates an extruded shape mesh.
  19075. * 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.
  19076. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#extruded-shapes
  19077. *
  19078. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  19079. * 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
  19080. * extruded along the Z axis.
  19081. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  19082. * 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.
  19083. * The parameter `scale` (float, default 1) is the value to scale the shape.
  19084. * 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
  19085. * 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
  19086. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  19087. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19088. * 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).
  19089. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  19090. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  19091. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19092. */
  19093. static ExtrudeShape(name: string, options: {
  19094. shape: Vector3[];
  19095. path: Vector3[];
  19096. scale?: number;
  19097. rotation?: number;
  19098. cap?: number;
  19099. updatable?: boolean;
  19100. sideOrientation?: number;
  19101. frontUVs?: Vector4;
  19102. backUVs?: Vector4;
  19103. instance?: Mesh;
  19104. invertUV?: boolean;
  19105. }, scene?: Nullable<Scene>): Mesh;
  19106. /**
  19107. * Creates an custom extruded shape mesh.
  19108. * 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.
  19109. * tuto :http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#custom-extruded-shapes
  19110. *
  19111. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  19112. * 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
  19113. * extruded along the Z axis.
  19114. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  19115. * 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
  19116. * and the distance of this point from the begining of the path :
  19117. * ```javascript
  19118. * var rotationFunction = function(i, distance) {
  19119. * // do things
  19120. * return rotationValue; }
  19121. * ```
  19122. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  19123. * 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
  19124. * and the distance of this point from the begining of the path :
  19125. * ```javascript
  19126. * var scaleFunction = function(i, distance) {
  19127. * // do things
  19128. * return scaleValue;}
  19129. * ```
  19130. * It must returns a float value that will be the scale value applied to the shape on each path point.
  19131. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  19132. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  19133. * 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
  19134. * 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
  19135. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  19136. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19137. * 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).
  19138. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  19139. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  19140. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19141. */
  19142. static ExtrudeShapeCustom(name: string, options: {
  19143. shape: Vector3[];
  19144. path: Vector3[];
  19145. scaleFunction?: any;
  19146. rotationFunction?: any;
  19147. ribbonCloseArray?: boolean;
  19148. ribbonClosePath?: boolean;
  19149. cap?: number;
  19150. updatable?: boolean;
  19151. sideOrientation?: number;
  19152. frontUVs?: Vector4;
  19153. backUVs?: Vector4;
  19154. instance?: Mesh;
  19155. invertUV?: boolean;
  19156. }, scene: Scene): Mesh;
  19157. /**
  19158. * Creates lathe mesh.
  19159. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  19160. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lathe
  19161. *
  19162. * 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
  19163. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  19164. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  19165. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  19166. * 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.
  19167. * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc".
  19168. * 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
  19169. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19170. * 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).
  19171. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  19172. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  19173. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19174. */
  19175. static CreateLathe(name: string, options: {
  19176. shape: Vector3[];
  19177. radius?: number;
  19178. tessellation?: number;
  19179. arc?: number;
  19180. closed?: boolean;
  19181. updatable?: boolean;
  19182. sideOrientation?: number;
  19183. frontUVs?: Vector4;
  19184. backUVs?: Vector4;
  19185. cap?: number;
  19186. invertUV?: boolean;
  19187. }, scene: Scene): Mesh;
  19188. /**
  19189. * Creates a plane mesh.
  19190. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  19191. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  19192. * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`).
  19193. * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane.
  19194. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19195. * 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).
  19196. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  19197. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19198. */
  19199. static CreatePlane(name: string, options: {
  19200. size?: number;
  19201. width?: number;
  19202. height?: number;
  19203. sideOrientation?: number;
  19204. frontUVs?: Vector4;
  19205. backUVs?: Vector4;
  19206. updatable?: boolean;
  19207. sourcePlane?: Plane;
  19208. }, scene: Scene): Mesh;
  19209. /**
  19210. * Creates a ground mesh.
  19211. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  19212. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  19213. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  19214. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19215. */
  19216. static CreateGround(name: string, options: {
  19217. width?: number;
  19218. height?: number;
  19219. subdivisions?: number;
  19220. subdivisionsX?: number;
  19221. subdivisionsY?: number;
  19222. updatable?: boolean;
  19223. }, scene: any): Mesh;
  19224. /**
  19225. * Creates a tiled ground mesh.
  19226. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  19227. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  19228. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  19229. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  19230. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  19231. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  19232. * numbers of subdivisions on the ground width and height of each tile.
  19233. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19234. */
  19235. static CreateTiledGround(name: string, options: {
  19236. xmin: number;
  19237. zmin: number;
  19238. xmax: number;
  19239. zmax: number;
  19240. subdivisions?: {
  19241. w: number;
  19242. h: number;
  19243. };
  19244. precision?: {
  19245. w: number;
  19246. h: number;
  19247. };
  19248. updatable?: boolean;
  19249. }, scene: Scene): Mesh;
  19250. /**
  19251. * Creates a ground mesh from a height map.
  19252. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  19253. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  19254. * The parameter `url` sets the URL of the height map image resource.
  19255. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  19256. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  19257. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  19258. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  19259. * 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.
  19260. * 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).
  19261. * This function is passed the newly built mesh :
  19262. * ```javascript
  19263. * function(mesh) { // do things
  19264. * return; }
  19265. * ```
  19266. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19267. */
  19268. static CreateGroundFromHeightMap(name: string, url: string, options: {
  19269. width?: number;
  19270. height?: number;
  19271. subdivisions?: number;
  19272. minHeight?: number;
  19273. maxHeight?: number;
  19274. colorFilter?: Color3;
  19275. updatable?: boolean;
  19276. onReady?: (mesh: GroundMesh) => void;
  19277. }, scene: Scene): GroundMesh;
  19278. /**
  19279. * Creates a polygon mesh.
  19280. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  19281. * 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.
  19282. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19283. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19284. * 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).
  19285. * Remember you can only change the shape positions, not their number when updating a polygon.
  19286. */
  19287. static CreatePolygon(name: string, options: {
  19288. shape: Vector3[];
  19289. holes?: Vector3[][];
  19290. depth?: number;
  19291. faceUV?: Vector4[];
  19292. faceColors?: Color4[];
  19293. updatable?: boolean;
  19294. sideOrientation?: number;
  19295. frontUVs?: Vector4;
  19296. backUVs?: Vector4;
  19297. }, scene: Scene): Mesh;
  19298. /**
  19299. * Creates an extruded polygon mesh, with depth in the Y direction.
  19300. * 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).
  19301. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  19302. */
  19303. static ExtrudePolygon(name: string, options: {
  19304. shape: Vector3[];
  19305. holes?: Vector3[][];
  19306. depth?: number;
  19307. faceUV?: Vector4[];
  19308. faceColors?: Color4[];
  19309. updatable?: boolean;
  19310. sideOrientation?: number;
  19311. frontUVs?: Vector4;
  19312. backUVs?: Vector4;
  19313. }, scene: Scene): Mesh;
  19314. /**
  19315. * Creates a tube mesh.
  19316. * 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.
  19317. *
  19318. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  19319. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  19320. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  19321. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  19322. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  19323. * 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.
  19324. * It must return a radius value (positive float) :
  19325. * ```javascript
  19326. * var radiusFunction = function(i, distance) {
  19327. * // do things
  19328. * return radius; }
  19329. * ```
  19330. * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc.
  19331. * 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
  19332. * 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
  19333. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19334. * 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).
  19335. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  19336. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  19337. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19338. */
  19339. static CreateTube(name: string, options: {
  19340. path: Vector3[];
  19341. radius?: number;
  19342. tessellation?: number;
  19343. radiusFunction?: {
  19344. (i: number, distance: number): number;
  19345. };
  19346. cap?: number;
  19347. arc?: number;
  19348. updatable?: boolean;
  19349. sideOrientation?: number;
  19350. frontUVs?: Vector4;
  19351. backUVs?: Vector4;
  19352. instance?: Mesh;
  19353. invertUV?: boolean;
  19354. }, scene: Scene): Mesh;
  19355. /**
  19356. * Creates a polyhedron mesh.
  19357. *
  19358. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#polyhedron
  19359. * 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
  19360. * to choose the wanted type.
  19361. * The parameter `size` (positive float, default 1) sets the polygon size.
  19362. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  19363. * 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`.
  19364. * 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
  19365. * 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)`).
  19366. * 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
  19367. * 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.
  19368. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19369. * 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).
  19370. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  19371. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19372. */
  19373. static CreatePolyhedron(name: string, options: {
  19374. type?: number;
  19375. size?: number;
  19376. sizeX?: number;
  19377. sizeY?: number;
  19378. sizeZ?: number;
  19379. custom?: any;
  19380. faceUV?: Vector4[];
  19381. faceColors?: Color4[];
  19382. flat?: boolean;
  19383. updatable?: boolean;
  19384. sideOrientation?: number;
  19385. frontUVs?: Vector4;
  19386. backUVs?: Vector4;
  19387. }, scene: Scene): Mesh;
  19388. /**
  19389. * Creates a decal mesh.
  19390. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#decals
  19391. * 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.
  19392. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  19393. * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates.
  19394. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  19395. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  19396. */
  19397. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  19398. position?: Vector3;
  19399. normal?: Vector3;
  19400. size?: Vector3;
  19401. angle?: number;
  19402. }): Mesh;
  19403. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  19404. }
  19405. }
  19406. declare module BABYLON {
  19407. class MeshLODLevel {
  19408. distance: number;
  19409. mesh: Mesh;
  19410. constructor(distance: number, mesh: Mesh);
  19411. }
  19412. }
  19413. declare module BABYLON {
  19414. /**
  19415. * A simplifier interface for future simplification implementations.
  19416. */
  19417. interface ISimplifier {
  19418. /**
  19419. * Simplification of a given mesh according to the given settings.
  19420. * Since this requires computation, it is assumed that the function runs async.
  19421. * @param settings The settings of the simplification, including quality and distance
  19422. * @param successCallback A callback that will be called after the mesh was simplified.
  19423. * @param errorCallback in case of an error, this callback will be called. optional.
  19424. */
  19425. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  19426. }
  19427. /**
  19428. * Expected simplification settings.
  19429. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  19430. */
  19431. interface ISimplificationSettings {
  19432. quality: number;
  19433. distance: number;
  19434. optimizeMesh?: boolean;
  19435. }
  19436. class SimplificationSettings implements ISimplificationSettings {
  19437. quality: number;
  19438. distance: number;
  19439. optimizeMesh: boolean | undefined;
  19440. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  19441. }
  19442. interface ISimplificationTask {
  19443. settings: Array<ISimplificationSettings>;
  19444. simplificationType: SimplificationType;
  19445. mesh: Mesh;
  19446. successCallback?: () => void;
  19447. parallelProcessing: boolean;
  19448. }
  19449. class SimplificationQueue {
  19450. private _simplificationArray;
  19451. running: boolean;
  19452. constructor();
  19453. addTask(task: ISimplificationTask): void;
  19454. executeNext(): void;
  19455. runSimplification(task: ISimplificationTask): void;
  19456. private getSimplifier(task);
  19457. }
  19458. /**
  19459. * The implemented types of simplification.
  19460. * At the moment only Quadratic Error Decimation is implemented.
  19461. */
  19462. enum SimplificationType {
  19463. QUADRATIC = 0,
  19464. }
  19465. class DecimationTriangle {
  19466. vertices: Array<DecimationVertex>;
  19467. normal: Vector3;
  19468. error: Array<number>;
  19469. deleted: boolean;
  19470. isDirty: boolean;
  19471. borderFactor: number;
  19472. deletePending: boolean;
  19473. originalOffset: number;
  19474. constructor(vertices: Array<DecimationVertex>);
  19475. }
  19476. class DecimationVertex {
  19477. position: Vector3;
  19478. id: number;
  19479. q: QuadraticMatrix;
  19480. isBorder: boolean;
  19481. triangleStart: number;
  19482. triangleCount: number;
  19483. originalOffsets: Array<number>;
  19484. constructor(position: Vector3, id: number);
  19485. updatePosition(newPosition: Vector3): void;
  19486. }
  19487. class QuadraticMatrix {
  19488. data: Array<number>;
  19489. constructor(data?: Array<number>);
  19490. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  19491. addInPlace(matrix: QuadraticMatrix): void;
  19492. addArrayInPlace(data: Array<number>): void;
  19493. add(matrix: QuadraticMatrix): QuadraticMatrix;
  19494. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  19495. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  19496. }
  19497. class Reference {
  19498. vertexId: number;
  19499. triangleId: number;
  19500. constructor(vertexId: number, triangleId: number);
  19501. }
  19502. /**
  19503. * An implementation of the Quadratic Error simplification algorithm.
  19504. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  19505. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  19506. * @author RaananW
  19507. */
  19508. class QuadraticErrorSimplification implements ISimplifier {
  19509. private _mesh;
  19510. private triangles;
  19511. private vertices;
  19512. private references;
  19513. private _reconstructedMesh;
  19514. syncIterations: number;
  19515. aggressiveness: number;
  19516. decimationIterations: number;
  19517. boundingBoxEpsilon: number;
  19518. constructor(_mesh: Mesh);
  19519. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  19520. private runDecimation(settings, submeshIndex, successCallback);
  19521. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  19522. private init(callback);
  19523. private reconstructMesh(submeshIndex);
  19524. private initDecimatedMesh();
  19525. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  19526. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  19527. private identifyBorder();
  19528. private updateMesh(identifyBorders?);
  19529. private vertexError(q, point);
  19530. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  19531. }
  19532. }
  19533. declare module BABYLON {
  19534. class Polygon {
  19535. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  19536. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  19537. static Parse(input: string): Vector2[];
  19538. static StartingAt(x: number, y: number): Path2;
  19539. }
  19540. class PolygonMeshBuilder {
  19541. private _points;
  19542. private _outlinepoints;
  19543. private _holes;
  19544. private _name;
  19545. private _scene;
  19546. private _epoints;
  19547. private _eholes;
  19548. private _addToepoint(points);
  19549. constructor(name: string, contours: Path2, scene: Scene);
  19550. constructor(name: string, contours: Vector2[], scene: Scene);
  19551. addHole(hole: Vector2[]): PolygonMeshBuilder;
  19552. build(updatable?: boolean, depth?: number): Mesh;
  19553. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  19554. }
  19555. }
  19556. declare module BABYLON {
  19557. class BaseSubMesh {
  19558. _materialDefines: Nullable<MaterialDefines>;
  19559. _materialEffect: Nullable<Effect>;
  19560. readonly effect: Nullable<Effect>;
  19561. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  19562. }
  19563. class SubMesh extends BaseSubMesh implements ICullable {
  19564. materialIndex: number;
  19565. verticesStart: number;
  19566. verticesCount: number;
  19567. indexStart: number;
  19568. indexCount: number;
  19569. linesIndexCount: number;
  19570. private _mesh;
  19571. private _renderingMesh;
  19572. private _boundingInfo;
  19573. private _linesIndexBuffer;
  19574. _lastColliderWorldVertices: Nullable<Vector3[]>;
  19575. _trianglePlanes: Plane[];
  19576. _lastColliderTransformMatrix: Matrix;
  19577. _renderId: number;
  19578. _alphaIndex: number;
  19579. _distanceToCamera: number;
  19580. _id: number;
  19581. private _currentMaterial;
  19582. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  19583. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  19584. readonly IsGlobal: boolean;
  19585. /**
  19586. * Returns the submesh BoudingInfo object.
  19587. */
  19588. getBoundingInfo(): BoundingInfo;
  19589. /**
  19590. * Sets the submesh BoundingInfo.
  19591. * Return the SubMesh.
  19592. */
  19593. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  19594. /**
  19595. * Returns the mesh of the current submesh.
  19596. */
  19597. getMesh(): AbstractMesh;
  19598. /**
  19599. * Returns the rendering mesh of the submesh.
  19600. */
  19601. getRenderingMesh(): Mesh;
  19602. /**
  19603. * Returns the submesh material.
  19604. */
  19605. getMaterial(): Nullable<Material>;
  19606. /**
  19607. * Sets a new updated BoundingInfo object to the submesh.
  19608. * Returns the SubMesh.
  19609. */
  19610. refreshBoundingInfo(): SubMesh;
  19611. _checkCollision(collider: Collider): boolean;
  19612. /**
  19613. * Updates the submesh BoundingInfo.
  19614. * Returns the Submesh.
  19615. */
  19616. updateBoundingInfo(world: Matrix): SubMesh;
  19617. /**
  19618. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  19619. * Boolean returned.
  19620. */
  19621. isInFrustum(frustumPlanes: Plane[]): boolean;
  19622. /**
  19623. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  19624. * Boolean returned.
  19625. */
  19626. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19627. /**
  19628. * Renders the submesh.
  19629. * Returns it.
  19630. */
  19631. render(enableAlphaMode: boolean): SubMesh;
  19632. /**
  19633. * Returns a new Index Buffer.
  19634. * Type returned : WebGLBuffer.
  19635. */
  19636. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  19637. /**
  19638. * True is the passed Ray intersects the submesh bounding box.
  19639. * Boolean returned.
  19640. */
  19641. canIntersects(ray: Ray): boolean;
  19642. /**
  19643. * Returns an object IntersectionInfo.
  19644. */
  19645. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  19646. _rebuild(): void;
  19647. /**
  19648. * Creates a new Submesh from the passed Mesh.
  19649. */
  19650. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  19651. /**
  19652. * Disposes the Submesh.
  19653. * Returns nothing.
  19654. */
  19655. dispose(): void;
  19656. /**
  19657. * Creates a new Submesh from the passed parameters :
  19658. * - materialIndex (integer) : the index of the main mesh material.
  19659. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  19660. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  19661. * - mesh (Mesh) : the main mesh to create the submesh from.
  19662. * - renderingMesh (optional Mesh) : rendering mesh.
  19663. */
  19664. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  19665. }
  19666. }
  19667. declare module BABYLON {
  19668. class TransformNode extends Node {
  19669. static BILLBOARDMODE_NONE: number;
  19670. static BILLBOARDMODE_X: number;
  19671. static BILLBOARDMODE_Y: number;
  19672. static BILLBOARDMODE_Z: number;
  19673. static BILLBOARDMODE_ALL: number;
  19674. private _forward;
  19675. private _forwardInverted;
  19676. private _up;
  19677. private _right;
  19678. private _rightInverted;
  19679. private _rotation;
  19680. private _rotationQuaternion;
  19681. protected _scaling: Vector3;
  19682. protected _isDirty: boolean;
  19683. private _transformToBoneReferal;
  19684. billboardMode: number;
  19685. scalingDeterminant: number;
  19686. infiniteDistance: boolean;
  19687. position: Vector3;
  19688. _poseMatrix: Matrix;
  19689. private _localWorld;
  19690. _worldMatrix: Matrix;
  19691. _worldMatrixDeterminant: number;
  19692. private _absolutePosition;
  19693. private _pivotMatrix;
  19694. private _pivotMatrixInverse;
  19695. private _postMultiplyPivotMatrix;
  19696. protected _isWorldMatrixFrozen: boolean;
  19697. /**
  19698. * An event triggered after the world matrix is updated
  19699. */
  19700. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  19701. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  19702. /**
  19703. * Gets a string idenfifying the name of the class
  19704. * @returns "TransformNode" string
  19705. */
  19706. getClassName(): string;
  19707. /**
  19708. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  19709. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  19710. * Default : (0.0, 0.0, 0.0)
  19711. */
  19712. rotation: Vector3;
  19713. /**
  19714. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  19715. * Default : (1.0, 1.0, 1.0)
  19716. */
  19717. /**
  19718. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  19719. * Default : (1.0, 1.0, 1.0)
  19720. */
  19721. scaling: Vector3;
  19722. /**
  19723. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  19724. * It's null by default.
  19725. * 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)
  19726. */
  19727. rotationQuaternion: Nullable<Quaternion>;
  19728. /**
  19729. * The forward direction of that transform in world space.
  19730. */
  19731. readonly forward: Vector3;
  19732. /**
  19733. * The up direction of that transform in world space.
  19734. */
  19735. readonly up: Vector3;
  19736. /**
  19737. * The right direction of that transform in world space.
  19738. */
  19739. readonly right: Vector3;
  19740. /**
  19741. * Returns the latest update of the World matrix
  19742. * Returns a Matrix.
  19743. */
  19744. getWorldMatrix(): Matrix;
  19745. /**
  19746. * Returns the latest update of the World matrix determinant.
  19747. */
  19748. protected _getWorldMatrixDeterminant(): number;
  19749. /**
  19750. * Returns directly the latest state of the mesh World matrix.
  19751. * A Matrix is returned.
  19752. */
  19753. readonly worldMatrixFromCache: Matrix;
  19754. /**
  19755. * Copies the paramater passed Matrix into the mesh Pose matrix.
  19756. * Returns the TransformNode.
  19757. */
  19758. updatePoseMatrix(matrix: Matrix): TransformNode;
  19759. /**
  19760. * Returns the mesh Pose matrix.
  19761. * Returned object : Matrix
  19762. */
  19763. getPoseMatrix(): Matrix;
  19764. _isSynchronized(): boolean;
  19765. _initCache(): void;
  19766. markAsDirty(property: string): TransformNode;
  19767. /**
  19768. * Returns the current mesh absolute position.
  19769. * Retuns a Vector3.
  19770. */
  19771. readonly absolutePosition: Vector3;
  19772. /**
  19773. * Sets a new matrix to apply before all other transformation
  19774. * @param matrix defines the transform matrix
  19775. * @returns the current TransformNode
  19776. */
  19777. setPreTransformMatrix(matrix: Matrix): TransformNode;
  19778. /**
  19779. * Sets a new pivot matrix to the current node
  19780. * @param matrix defines the new pivot matrix to use
  19781. * @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
  19782. * @returns the current TransformNode
  19783. */
  19784. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  19785. /**
  19786. * Returns the mesh pivot matrix.
  19787. * Default : Identity.
  19788. * A Matrix is returned.
  19789. */
  19790. getPivotMatrix(): Matrix;
  19791. /**
  19792. * Prevents the World matrix to be computed any longer.
  19793. * Returns the TransformNode.
  19794. */
  19795. freezeWorldMatrix(): TransformNode;
  19796. /**
  19797. * Allows back the World matrix computation.
  19798. * Returns the TransformNode.
  19799. */
  19800. unfreezeWorldMatrix(): this;
  19801. /**
  19802. * True if the World matrix has been frozen.
  19803. * Returns a boolean.
  19804. */
  19805. readonly isWorldMatrixFrozen: boolean;
  19806. /**
  19807. * Retuns the mesh absolute position in the World.
  19808. * Returns a Vector3.
  19809. */
  19810. getAbsolutePosition(): Vector3;
  19811. /**
  19812. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  19813. * Returns the TransformNode.
  19814. */
  19815. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19816. /**
  19817. * Sets the mesh position in its local space.
  19818. * Returns the TransformNode.
  19819. */
  19820. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  19821. /**
  19822. * Returns the mesh position in the local space from the current World matrix values.
  19823. * Returns a new Vector3.
  19824. */
  19825. getPositionExpressedInLocalSpace(): Vector3;
  19826. /**
  19827. * Translates the mesh along the passed Vector3 in its local space.
  19828. * Returns the TransformNode.
  19829. */
  19830. locallyTranslate(vector3: Vector3): TransformNode;
  19831. private static _lookAtVectorCache;
  19832. /**
  19833. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  19834. * @param targetPoint the position (must be in same space as current mesh) to look at
  19835. * @param yawCor optional yaw (y-axis) correction in radians
  19836. * @param pitchCor optional pitch (x-axis) correction in radians
  19837. * @param rollCor optional roll (z-axis) correction in radians
  19838. * @param space the choosen space of the target
  19839. * @returns the TransformNode.
  19840. */
  19841. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  19842. /**
  19843. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  19844. * This Vector3 is expressed in the World space.
  19845. */
  19846. getDirection(localAxis: Vector3): Vector3;
  19847. /**
  19848. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  19849. * localAxis is expressed in the mesh local space.
  19850. * result is computed in the Wordl space from the mesh World matrix.
  19851. * Returns the TransformNode.
  19852. */
  19853. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  19854. /**
  19855. * Sets a new pivot point to the current node
  19856. * @param point defines the new pivot point to use
  19857. * @param space defines if the point is in world or local space (local by default)
  19858. * @returns the current TransformNode
  19859. */
  19860. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  19861. /**
  19862. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  19863. */
  19864. getPivotPoint(): Vector3;
  19865. /**
  19866. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  19867. * Returns the TransformNode.
  19868. */
  19869. getPivotPointToRef(result: Vector3): TransformNode;
  19870. /**
  19871. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  19872. */
  19873. getAbsolutePivotPoint(): Vector3;
  19874. /**
  19875. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  19876. * Returns the TransformNode.
  19877. */
  19878. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  19879. /**
  19880. * Defines the passed node as the parent of the current node.
  19881. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  19882. * Returns the TransformNode.
  19883. */
  19884. setParent(node: Nullable<Node>): TransformNode;
  19885. private _nonUniformScaling;
  19886. readonly nonUniformScaling: boolean;
  19887. _updateNonUniformScalingState(value: boolean): boolean;
  19888. /**
  19889. * Attach the current TransformNode to another TransformNode associated with a bone
  19890. * @param bone Bone affecting the TransformNode
  19891. * @param affectedTransformNode TransformNode associated with the bone
  19892. */
  19893. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  19894. detachFromBone(): TransformNode;
  19895. private static _rotationAxisCache;
  19896. /**
  19897. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  19898. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  19899. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  19900. * The passed axis is also normalized.
  19901. * Returns the TransformNode.
  19902. */
  19903. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19904. /**
  19905. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  19906. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  19907. * The passed axis is also normalized.
  19908. * Returns the TransformNode.
  19909. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  19910. */
  19911. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  19912. /**
  19913. * Translates the mesh along the axis vector for the passed distance in the given space.
  19914. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  19915. * Returns the TransformNode.
  19916. */
  19917. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19918. /**
  19919. * Adds a rotation step to the mesh current rotation.
  19920. * x, y, z are Euler angles expressed in radians.
  19921. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  19922. * This means this rotation is made in the mesh local space only.
  19923. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  19924. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  19925. * ```javascript
  19926. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  19927. * ```
  19928. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  19929. * 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.
  19930. * Returns the TransformNode.
  19931. */
  19932. addRotation(x: number, y: number, z: number): TransformNode;
  19933. /**
  19934. * Computes the mesh World matrix and returns it.
  19935. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  19936. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  19937. * If the parameter `force`is set to `true`, the actual computation is done.
  19938. * Returns the mesh World Matrix.
  19939. */
  19940. computeWorldMatrix(force?: boolean): Matrix;
  19941. protected _afterComputeWorldMatrix(): void;
  19942. /**
  19943. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  19944. * @param func: callback function to add
  19945. *
  19946. * Returns the TransformNode.
  19947. */
  19948. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  19949. /**
  19950. * Removes a registered callback function.
  19951. * Returns the TransformNode.
  19952. */
  19953. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  19954. /**
  19955. * Clone the current transform node
  19956. * Returns the new transform node
  19957. * @param name Name of the new clone
  19958. * @param newParent New parent for the clone
  19959. * @param doNotCloneChildren Do not clone children hierarchy
  19960. */
  19961. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  19962. serialize(currentSerializationObject?: any): any;
  19963. /**
  19964. * Returns a new TransformNode object parsed from the source provided.
  19965. * The parameter `parsedMesh` is the source.
  19966. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  19967. */
  19968. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  19969. /**
  19970. * Releases resources associated with this transform node.
  19971. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19972. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19973. */
  19974. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19975. }
  19976. }
  19977. declare module BABYLON {
  19978. class VertexBuffer {
  19979. private _buffer;
  19980. private _kind;
  19981. private _size;
  19982. private _ownsBuffer;
  19983. private _instanced;
  19984. private _instanceDivisor;
  19985. /**
  19986. * The byte type.
  19987. */
  19988. static readonly BYTE: number;
  19989. /**
  19990. * The unsigned byte type.
  19991. */
  19992. static readonly UNSIGNED_BYTE: number;
  19993. /**
  19994. * The short type.
  19995. */
  19996. static readonly SHORT: number;
  19997. /**
  19998. * The unsigned short type.
  19999. */
  20000. static readonly UNSIGNED_SHORT: number;
  20001. /**
  20002. * The integer type.
  20003. */
  20004. static readonly INT: number;
  20005. /**
  20006. * The unsigned integer type.
  20007. */
  20008. static readonly UNSIGNED_INT: number;
  20009. /**
  20010. * The float type.
  20011. */
  20012. static readonly FLOAT: number;
  20013. /**
  20014. * Gets or sets the instance divisor when in instanced mode
  20015. */
  20016. instanceDivisor: number;
  20017. /**
  20018. * Gets the byte stride.
  20019. */
  20020. readonly byteStride: number;
  20021. /**
  20022. * Gets the byte offset.
  20023. */
  20024. readonly byteOffset: number;
  20025. /**
  20026. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  20027. */
  20028. readonly normalized: boolean;
  20029. /**
  20030. * Gets the data type of each component in the array.
  20031. */
  20032. readonly type: number;
  20033. /**
  20034. * Constructor
  20035. * @param engine the engine
  20036. * @param data the data to use for this vertex buffer
  20037. * @param kind the vertex buffer kind
  20038. * @param updatable whether the data is updatable
  20039. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  20040. * @param stride the stride (optional)
  20041. * @param instanced whether the buffer is instanced (optional)
  20042. * @param offset the offset of the data (optional)
  20043. * @param size the number of components (optional)
  20044. * @param type the type of the component (optional)
  20045. * @param normalized whether the data contains normalized data (optional)
  20046. * @param useBytes set to true if stride and offset are in bytes (optional)
  20047. */
  20048. 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);
  20049. _rebuild(): void;
  20050. /**
  20051. * Returns the kind of the VertexBuffer (string).
  20052. */
  20053. getKind(): string;
  20054. /**
  20055. * Boolean : is the VertexBuffer updatable ?
  20056. */
  20057. isUpdatable(): boolean;
  20058. /**
  20059. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  20060. */
  20061. getData(): Nullable<DataArray>;
  20062. /**
  20063. * Returns the WebGLBuffer associated to the VertexBuffer.
  20064. */
  20065. getBuffer(): Nullable<WebGLBuffer>;
  20066. /**
  20067. * Returns the stride as a multiple of the type byte length.
  20068. * DEPRECATED. Use byteStride instead.
  20069. */
  20070. getStrideSize(): number;
  20071. /**
  20072. * Returns the offset as a multiple of the type byte length.
  20073. * DEPRECATED. Use byteOffset instead.
  20074. */
  20075. getOffset(): number;
  20076. /**
  20077. * Returns the number of components per vertex attribute (integer).
  20078. */
  20079. getSize(): number;
  20080. /**
  20081. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  20082. */
  20083. getIsInstanced(): boolean;
  20084. /**
  20085. * Returns the instancing divisor, zero for non-instanced (integer).
  20086. */
  20087. getInstanceDivisor(): number;
  20088. /**
  20089. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  20090. * Returns the created WebGLBuffer.
  20091. */
  20092. create(data?: DataArray): void;
  20093. /**
  20094. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  20095. * This function will create a new buffer if the current one is not updatable
  20096. * Returns the updated WebGLBuffer.
  20097. */
  20098. update(data: DataArray): void;
  20099. /**
  20100. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  20101. * Returns the directly updated WebGLBuffer.
  20102. */
  20103. updateDirectly(data: DataArray, offset: number): void;
  20104. /**
  20105. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  20106. */
  20107. dispose(): void;
  20108. /**
  20109. * Enumerates each value of this vertex buffer as numbers.
  20110. * @param count the number of values to enumerate
  20111. * @param callback the callback function called for each value
  20112. */
  20113. forEach(count: number, callback: (value: number, index: number) => void): void;
  20114. private static _PositionKind;
  20115. private static _NormalKind;
  20116. private static _TangentKind;
  20117. private static _UVKind;
  20118. private static _UV2Kind;
  20119. private static _UV3Kind;
  20120. private static _UV4Kind;
  20121. private static _UV5Kind;
  20122. private static _UV6Kind;
  20123. private static _ColorKind;
  20124. private static _MatricesIndicesKind;
  20125. private static _MatricesWeightsKind;
  20126. private static _MatricesIndicesExtraKind;
  20127. private static _MatricesWeightsExtraKind;
  20128. static readonly PositionKind: string;
  20129. static readonly NormalKind: string;
  20130. static readonly TangentKind: string;
  20131. static readonly UVKind: string;
  20132. static readonly UV2Kind: string;
  20133. static readonly UV3Kind: string;
  20134. static readonly UV4Kind: string;
  20135. static readonly UV5Kind: string;
  20136. static readonly UV6Kind: string;
  20137. static readonly ColorKind: string;
  20138. static readonly MatricesIndicesKind: string;
  20139. static readonly MatricesWeightsKind: string;
  20140. static readonly MatricesIndicesExtraKind: string;
  20141. static readonly MatricesWeightsExtraKind: string;
  20142. /**
  20143. * Deduces the stride given a kind.
  20144. * @param kind The kind string to deduce
  20145. * @returns The deduced stride
  20146. */
  20147. static DeduceStride(kind: string): number;
  20148. /**
  20149. * Gets the byte length of the given type.
  20150. * @param type the type
  20151. * @returns the number of bytes
  20152. */
  20153. static GetTypeByteLength(type: number): number;
  20154. /**
  20155. * Enumerates each value of the given parameters as numbers.
  20156. * @param data the data to enumerate
  20157. * @param byteOffset the byte offset of the data
  20158. * @param byteStride the byte stride of the data
  20159. * @param componentCount the number of components per element
  20160. * @param componentType the type of the component
  20161. * @param count the total number of components
  20162. * @param normalized whether the data is normalized
  20163. * @param callback the callback function called for each value
  20164. */
  20165. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  20166. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  20167. }
  20168. }
  20169. declare module BABYLON {
  20170. /**
  20171. * This represents a GPU particle system in Babylon
  20172. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  20173. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  20174. */
  20175. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  20176. /**
  20177. * The id of the Particle system.
  20178. */
  20179. id: string;
  20180. /**
  20181. * The friendly name of the Particle system.
  20182. */
  20183. name: string;
  20184. /**
  20185. * The emitter represents the Mesh or position we are attaching the particle system to.
  20186. */
  20187. emitter: Nullable<AbstractMesh | Vector3>;
  20188. /**
  20189. * The rendering group used by the Particle system to chose when to render.
  20190. */
  20191. renderingGroupId: number;
  20192. /**
  20193. * The layer mask we are rendering the particles through.
  20194. */
  20195. layerMask: number;
  20196. private _capacity;
  20197. private _activeCount;
  20198. private _currentActiveCount;
  20199. private _renderEffect;
  20200. private _updateEffect;
  20201. private _buffer0;
  20202. private _buffer1;
  20203. private _spriteBuffer;
  20204. private _updateVAO;
  20205. private _renderVAO;
  20206. private _targetIndex;
  20207. private _sourceBuffer;
  20208. private _targetBuffer;
  20209. private _scene;
  20210. private _engine;
  20211. private _currentRenderId;
  20212. private _started;
  20213. private _stopped;
  20214. private _timeDelta;
  20215. private _randomTexture;
  20216. private readonly _attributesStrideSize;
  20217. private _updateEffectOptions;
  20218. private _randomTextureSize;
  20219. private _actualFrame;
  20220. /**
  20221. * List of animations used by the particle system.
  20222. */
  20223. animations: Animation[];
  20224. /**
  20225. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  20226. */
  20227. static readonly IsSupported: boolean;
  20228. /**
  20229. * An event triggered when the system is disposed.
  20230. */
  20231. onDisposeObservable: Observable<GPUParticleSystem>;
  20232. /**
  20233. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  20234. */
  20235. updateSpeed: number;
  20236. /**
  20237. * The amount of time the particle system is running (depends of the overall update speed).
  20238. */
  20239. targetStopDuration: number;
  20240. /**
  20241. * The texture used to render each particle. (this can be a spritesheet)
  20242. */
  20243. particleTexture: Nullable<Texture>;
  20244. /**
  20245. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  20246. */
  20247. blendMode: number;
  20248. /**
  20249. * Minimum life time of emitting particles.
  20250. */
  20251. minLifeTime: number;
  20252. /**
  20253. * Maximum life time of emitting particles.
  20254. */
  20255. maxLifeTime: number;
  20256. /**
  20257. * Minimum Size of emitting particles.
  20258. */
  20259. minSize: number;
  20260. /**
  20261. * Maximum Size of emitting particles.
  20262. */
  20263. maxSize: number;
  20264. /**
  20265. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20266. */
  20267. color1: Color4;
  20268. /**
  20269. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20270. */
  20271. color2: Color4;
  20272. /**
  20273. * Color the particle will have at the end of its lifetime.
  20274. */
  20275. colorDead: Color4;
  20276. /**
  20277. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  20278. */
  20279. emitRate: number;
  20280. /**
  20281. * You can use gravity if you want to give an orientation to your particles.
  20282. */
  20283. gravity: Vector3;
  20284. /**
  20285. * Minimum power of emitting particles.
  20286. */
  20287. minEmitPower: number;
  20288. /**
  20289. * Maximum power of emitting particles.
  20290. */
  20291. maxEmitPower: number;
  20292. /**
  20293. * The particle emitter type defines the emitter used by the particle system.
  20294. * It can be for example box, sphere, or cone...
  20295. */
  20296. particleEmitterType: Nullable<IParticleEmitterType>;
  20297. /**
  20298. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20299. * This only works when particleEmitterTyps is a BoxParticleEmitter
  20300. */
  20301. direction1: Vector3;
  20302. /**
  20303. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20304. * This only works when particleEmitterTyps is a BoxParticleEmitter
  20305. */
  20306. direction2: Vector3;
  20307. /**
  20308. * 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.
  20309. * This only works when particleEmitterTyps is a BoxParticleEmitter
  20310. */
  20311. minEmitBox: Vector3;
  20312. /**
  20313. * 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.
  20314. * This only works when particleEmitterTyps is a BoxParticleEmitter
  20315. */
  20316. maxEmitBox: Vector3;
  20317. /**
  20318. * Gets the maximum number of particles active at the same time.
  20319. * @returns The max number of active particles.
  20320. */
  20321. getCapacity(): number;
  20322. /**
  20323. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  20324. * to override the particles.
  20325. */
  20326. forceDepthWrite: boolean;
  20327. /**
  20328. * Gets or set the number of active particles
  20329. */
  20330. activeParticleCount: number;
  20331. /**
  20332. * Is this system ready to be used/rendered
  20333. * @return true if the system is ready
  20334. */
  20335. isReady(): boolean;
  20336. /**
  20337. * Gets Wether the system has been started.
  20338. * @returns True if it has been started, otherwise false.
  20339. */
  20340. isStarted(): boolean;
  20341. /**
  20342. * Starts the particle system and begins to emit.
  20343. */
  20344. start(): void;
  20345. /**
  20346. * Stops the particle system.
  20347. */
  20348. stop(): void;
  20349. /**
  20350. * Remove all active particles
  20351. */
  20352. reset(): void;
  20353. /**
  20354. * Returns the string "GPUParticleSystem"
  20355. * @returns a string containing the class name
  20356. */
  20357. getClassName(): string;
  20358. /**
  20359. * Instantiates a GPU particle system.
  20360. * 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.
  20361. * @param name The name of the particle system
  20362. * @param capacity The max number of particles alive at the same time
  20363. * @param scene The scene the particle system belongs to
  20364. */
  20365. constructor(name: string, options: Partial<{
  20366. capacity: number;
  20367. randomTextureSize: number;
  20368. }>, scene: Scene);
  20369. private _createUpdateVAO(source);
  20370. private _createRenderVAO(source, spriteSource);
  20371. private _initialize(force?);
  20372. /** @ignore */
  20373. _recreateUpdateEffect(): void;
  20374. /** @ignore */
  20375. _recreateRenderEffect(): void;
  20376. /**
  20377. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  20378. */
  20379. animate(): void;
  20380. /**
  20381. * Renders the particle system in its current state.
  20382. * @returns the current number of particles
  20383. */
  20384. render(): number;
  20385. /**
  20386. * Rebuilds the particle system
  20387. */
  20388. rebuild(): void;
  20389. private _releaseBuffers();
  20390. private _releaseVAOs();
  20391. /**
  20392. * Disposes the particle system and free the associated resources
  20393. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20394. */
  20395. dispose(disposeTexture?: boolean): void;
  20396. /**
  20397. * Clones the particle system.
  20398. * @param name The name of the cloned object
  20399. * @param newEmitter The new emitter to use
  20400. * @returns the cloned particle system
  20401. */
  20402. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  20403. /**
  20404. * Serializes the particle system to a JSON object.
  20405. * @returns the JSON object
  20406. */
  20407. serialize(): any;
  20408. /**
  20409. * Parses a JSON object to create a GPU particle system.
  20410. * @param parsedParticleSystem The JSON object to parse
  20411. * @param scene The scene to create the particle system in
  20412. * @param rootUrl The root url to use to load external dependencies like texture
  20413. * @returns the parsed GPU particle system
  20414. */
  20415. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  20416. }
  20417. }
  20418. declare module BABYLON {
  20419. /**
  20420. * Interface representing a particle system in Babylon.
  20421. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  20422. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  20423. */
  20424. interface IParticleSystem {
  20425. /**
  20426. * The id of the Particle system.
  20427. */
  20428. id: string;
  20429. /**
  20430. * The name of the Particle system.
  20431. */
  20432. name: string;
  20433. /**
  20434. * The emitter represents the Mesh or position we are attaching the particle system to.
  20435. */
  20436. emitter: Nullable<AbstractMesh | Vector3>;
  20437. /**
  20438. * The rendering group used by the Particle system to chose when to render.
  20439. */
  20440. renderingGroupId: number;
  20441. /**
  20442. * The layer mask we are rendering the particles through.
  20443. */
  20444. layerMask: number;
  20445. /**
  20446. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  20447. */
  20448. updateSpeed: number;
  20449. /**
  20450. * The amount of time the particle system is running (depends of the overall update speed).
  20451. */
  20452. targetStopDuration: number;
  20453. /**
  20454. * The texture used to render each particle. (this can be a spritesheet)
  20455. */
  20456. particleTexture: Nullable<Texture>;
  20457. /**
  20458. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  20459. */
  20460. blendMode: number;
  20461. /**
  20462. * Minimum life time of emitting particles.
  20463. */
  20464. minLifeTime: number;
  20465. /**
  20466. * Maximum life time of emitting particles.
  20467. */
  20468. maxLifeTime: number;
  20469. /**
  20470. * Minimum Size of emitting particles.
  20471. */
  20472. minSize: number;
  20473. /**
  20474. * Maximum Size of emitting particles.
  20475. */
  20476. maxSize: number;
  20477. /**
  20478. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20479. */
  20480. color1: Color4;
  20481. /**
  20482. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20483. */
  20484. color2: Color4;
  20485. /**
  20486. * Color the particle will have at the end of its lifetime.
  20487. */
  20488. colorDead: Color4;
  20489. /**
  20490. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  20491. */
  20492. emitRate: number;
  20493. /**
  20494. * You can use gravity if you want to give an orientation to your particles.
  20495. */
  20496. gravity: Vector3;
  20497. /**
  20498. * Minimum power of emitting particles.
  20499. */
  20500. minEmitPower: number;
  20501. /**
  20502. * Maximum power of emitting particles.
  20503. */
  20504. maxEmitPower: number;
  20505. /**
  20506. * The particle emitter type defines the emitter used by the particle system.
  20507. * It can be for example box, sphere, or cone...
  20508. */
  20509. particleEmitterType: Nullable<IParticleEmitterType>;
  20510. /**
  20511. * Gets the maximum number of particles active at the same time.
  20512. * @returns The max number of active particles.
  20513. */
  20514. getCapacity(): number;
  20515. /**
  20516. * Gets Wether the system has been started.
  20517. * @returns True if it has been started, otherwise false.
  20518. */
  20519. isStarted(): boolean;
  20520. /**
  20521. * Gets if the particle system has been started.
  20522. * @return true if the system has been started, otherwise false.
  20523. */
  20524. isStarted(): boolean;
  20525. /**
  20526. * Animates the particle system for this frame.
  20527. */
  20528. animate(): void;
  20529. /**
  20530. * Renders the particle system in its current state.
  20531. * @returns the current number of particles
  20532. */
  20533. render(): number;
  20534. /**
  20535. * Dispose the particle system and frees its associated resources.
  20536. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20537. */
  20538. dispose(disposeTexture?: boolean): void;
  20539. /**
  20540. * Clones the particle system.
  20541. * @param name The name of the cloned object
  20542. * @param newEmitter The new emitter to use
  20543. * @returns the cloned particle system
  20544. */
  20545. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  20546. /**
  20547. * Serializes the particle system to a JSON object.
  20548. * @returns the JSON object
  20549. */
  20550. serialize(): any;
  20551. /**
  20552. * Rebuild the particle system
  20553. */
  20554. rebuild(): void;
  20555. /**
  20556. * Starts the particle system and begins to emit.
  20557. */
  20558. start(): void;
  20559. /**
  20560. * Stops the particle system.
  20561. */
  20562. stop(): void;
  20563. /**
  20564. * Remove all active particles
  20565. */
  20566. reset(): void;
  20567. /**
  20568. * Is this system ready to be used/rendered
  20569. * @return true if the system is ready
  20570. */
  20571. isReady(): boolean;
  20572. }
  20573. }
  20574. declare module BABYLON {
  20575. /**
  20576. * A particle represents one of the element emitted by a particle system.
  20577. * This is mainly define by its coordinates, direction, velocity and age.
  20578. */
  20579. class Particle {
  20580. /**
  20581. * particleSystem the particle system the particle belongs to.
  20582. */
  20583. particleSystem: ParticleSystem;
  20584. /**
  20585. * The world position of the particle in the scene.
  20586. */
  20587. position: Vector3;
  20588. /**
  20589. * The world direction of the particle in the scene.
  20590. */
  20591. direction: Vector3;
  20592. /**
  20593. * The color of the particle.
  20594. */
  20595. color: Color4;
  20596. /**
  20597. * The color change of the particle per step.
  20598. */
  20599. colorStep: Color4;
  20600. /**
  20601. * Defines how long will the life of the particle be.
  20602. */
  20603. lifeTime: number;
  20604. /**
  20605. * The current age of the particle.
  20606. */
  20607. age: number;
  20608. /**
  20609. * The current size of the particle.
  20610. */
  20611. size: number;
  20612. /**
  20613. * The current angle of the particle.
  20614. */
  20615. angle: number;
  20616. /**
  20617. * Defines how fast is the angle changing.
  20618. */
  20619. angularSpeed: number;
  20620. /**
  20621. * Defines the cell index used by the particle to be rendered from a sprite.
  20622. */
  20623. cellIndex: number;
  20624. private _currentFrameCounter;
  20625. /**
  20626. * Creates a new instance Particle
  20627. * @param particleSystem the particle system the particle belongs to
  20628. */
  20629. constructor(
  20630. /**
  20631. * particleSystem the particle system the particle belongs to.
  20632. */
  20633. particleSystem: ParticleSystem);
  20634. private updateCellInfoFromSystem();
  20635. /**
  20636. * Defines how the sprite cell index is updated for the particle. This is
  20637. * defined as a callback.
  20638. */
  20639. updateCellIndex: (scaledUpdateSpeed: number) => void;
  20640. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  20641. private _updateCellIndexWithCustomSpeed();
  20642. /**
  20643. * Copy the properties of particle to another one.
  20644. * @param other the particle to copy the information to.
  20645. */
  20646. copyTo(other: Particle): void;
  20647. }
  20648. }
  20649. declare module BABYLON {
  20650. /**
  20651. * This represents a particle system in Babylon.
  20652. * 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.
  20653. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  20654. * @example https://doc.babylonjs.com/babylon101/particles
  20655. */
  20656. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  20657. /**
  20658. * Source color is added to the destination color without alpha affecting the result.
  20659. */
  20660. static BLENDMODE_ONEONE: number;
  20661. /**
  20662. * Blend current color and particle color using particle’s alpha.
  20663. */
  20664. static BLENDMODE_STANDARD: number;
  20665. /**
  20666. * List of animations used by the particle system.
  20667. */
  20668. animations: Animation[];
  20669. /**
  20670. * The id of the Particle system.
  20671. */
  20672. id: string;
  20673. /**
  20674. * The friendly name of the Particle system.
  20675. */
  20676. name: string;
  20677. /**
  20678. * The rendering group used by the Particle system to chose when to render.
  20679. */
  20680. renderingGroupId: number;
  20681. /**
  20682. * The emitter represents the Mesh or position we are attaching the particle system to.
  20683. */
  20684. emitter: Nullable<AbstractMesh | Vector3>;
  20685. /**
  20686. * The maximum number of particles to emit per frame
  20687. */
  20688. emitRate: number;
  20689. /**
  20690. * If you want to launch only a few particles at once, that can be done, as well.
  20691. */
  20692. manualEmitCount: number;
  20693. /**
  20694. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  20695. */
  20696. updateSpeed: number;
  20697. /**
  20698. * The amount of time the particle system is running (depends of the overall update speed).
  20699. */
  20700. targetStopDuration: number;
  20701. /**
  20702. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  20703. */
  20704. disposeOnStop: boolean;
  20705. /**
  20706. * Minimum power of emitting particles.
  20707. */
  20708. minEmitPower: number;
  20709. /**
  20710. * Maximum power of emitting particles.
  20711. */
  20712. maxEmitPower: number;
  20713. /**
  20714. * Minimum life time of emitting particles.
  20715. */
  20716. minLifeTime: number;
  20717. /**
  20718. * Maximum life time of emitting particles.
  20719. */
  20720. maxLifeTime: number;
  20721. /**
  20722. * Minimum Size of emitting particles.
  20723. */
  20724. minSize: number;
  20725. /**
  20726. * Maximum Size of emitting particles.
  20727. */
  20728. maxSize: number;
  20729. /**
  20730. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  20731. */
  20732. minAngularSpeed: number;
  20733. /**
  20734. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  20735. */
  20736. maxAngularSpeed: number;
  20737. /**
  20738. * The texture used to render each particle. (this can be a spritesheet)
  20739. */
  20740. particleTexture: Nullable<Texture>;
  20741. /**
  20742. * The layer mask we are rendering the particles through.
  20743. */
  20744. layerMask: number;
  20745. /**
  20746. * This can help using your own shader to render the particle system.
  20747. * The according effect will be created
  20748. */
  20749. customShader: any;
  20750. /**
  20751. * By default particle system starts as soon as they are created. This prevents the
  20752. * automatic start to happen and let you decide when to start emitting particles.
  20753. */
  20754. preventAutoStart: boolean;
  20755. /**
  20756. * This function can be defined to provide custom update for active particles.
  20757. * This function will be called instead of regular update (age, position, color, etc.).
  20758. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  20759. */
  20760. updateFunction: (particles: Particle[]) => void;
  20761. /**
  20762. * Callback triggered when the particle animation is ending.
  20763. */
  20764. onAnimationEnd: Nullable<() => void>;
  20765. /**
  20766. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  20767. */
  20768. blendMode: number;
  20769. /**
  20770. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  20771. * to override the particles.
  20772. */
  20773. forceDepthWrite: boolean;
  20774. /**
  20775. * You can use gravity if you want to give an orientation to your particles.
  20776. */
  20777. gravity: Vector3;
  20778. /**
  20779. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20780. * This only works when particleEmitterTyps is a BoxParticleEmitter
  20781. */
  20782. direction1: Vector3;
  20783. /**
  20784. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20785. * This only works when particleEmitterTyps is a BoxParticleEmitter
  20786. */
  20787. direction2: Vector3;
  20788. /**
  20789. * 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.
  20790. * This only works when particleEmitterTyps is a BoxParticleEmitter
  20791. */
  20792. minEmitBox: Vector3;
  20793. /**
  20794. * 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.
  20795. * This only works when particleEmitterTyps is a BoxParticleEmitter
  20796. */
  20797. maxEmitBox: Vector3;
  20798. /**
  20799. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20800. */
  20801. color1: Color4;
  20802. /**
  20803. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20804. */
  20805. color2: Color4;
  20806. /**
  20807. * Color the particle will have at the end of its lifetime.
  20808. */
  20809. colorDead: Color4;
  20810. /**
  20811. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  20812. */
  20813. textureMask: Color4;
  20814. /**
  20815. * The particle emitter type defines the emitter used by the particle system.
  20816. * It can be for example box, sphere, or cone...
  20817. */
  20818. particleEmitterType: IParticleEmitterType;
  20819. /**
  20820. * This function can be defined to specify initial direction for every new particle.
  20821. * It by default use the emitterType defined function.
  20822. */
  20823. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  20824. /**
  20825. * This function can be defined to specify initial position for every new particle.
  20826. * It by default use the emitterType defined function.
  20827. */
  20828. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  20829. /**
  20830. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  20831. */
  20832. spriteCellLoop: boolean;
  20833. /**
  20834. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  20835. */
  20836. spriteCellChangeSpeed: number;
  20837. /**
  20838. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  20839. */
  20840. startSpriteCellID: number;
  20841. /**
  20842. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  20843. */
  20844. endSpriteCellID: number;
  20845. /**
  20846. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  20847. */
  20848. spriteCellWidth: number;
  20849. /**
  20850. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  20851. */
  20852. spriteCellHeight: number;
  20853. /**
  20854. * An event triggered when the system is disposed.
  20855. */
  20856. onDisposeObservable: Observable<ParticleSystem>;
  20857. private _onDisposeObserver;
  20858. /**
  20859. * Sets a callback that will be triggered when the system is disposed.
  20860. */
  20861. onDispose: () => void;
  20862. /**
  20863. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  20864. */
  20865. readonly isAnimationSheetEnabled: Boolean;
  20866. private _particles;
  20867. private _epsilon;
  20868. private _capacity;
  20869. private _scene;
  20870. private _stockParticles;
  20871. private _newPartsExcess;
  20872. private _vertexData;
  20873. private _vertexBuffer;
  20874. private _vertexBuffers;
  20875. private _indexBuffer;
  20876. private _effect;
  20877. private _customEffect;
  20878. private _cachedDefines;
  20879. private _scaledColorStep;
  20880. private _colorDiff;
  20881. private _scaledDirection;
  20882. private _scaledGravity;
  20883. private _currentRenderId;
  20884. private _alive;
  20885. private _started;
  20886. private _stopped;
  20887. private _actualFrame;
  20888. private _scaledUpdateSpeed;
  20889. private _vertexBufferSize;
  20890. private _isAnimationSheetEnabled;
  20891. /**
  20892. * 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.
  20893. */
  20894. subEmitters: ParticleSystem[];
  20895. /**
  20896. * The current active Sub-systems, this property is used by the root particle system only.
  20897. */
  20898. activeSubSystems: Array<ParticleSystem>;
  20899. private _rootParticleSystem;
  20900. /**
  20901. * Gets the current list of active particles
  20902. */
  20903. readonly particles: Particle[];
  20904. /**
  20905. * Returns the string "ParticleSystem"
  20906. * @returns a string containing the class name
  20907. */
  20908. getClassName(): string;
  20909. /**
  20910. * Instantiates a particle system.
  20911. * 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.
  20912. * @param name The name of the particle system
  20913. * @param capacity The max number of particles alive at the same time
  20914. * @param scene The scene the particle system belongs to
  20915. * @param customEffect a custom effect used to change the way particles are rendered by default
  20916. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  20917. * @param epsilon Offset used to render the particles
  20918. */
  20919. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  20920. private _createIndexBuffer();
  20921. /**
  20922. * Gets the maximum number of particles active at the same time.
  20923. * @returns The max number of active particles.
  20924. */
  20925. getCapacity(): number;
  20926. /**
  20927. * Gets Wether there are still active particles in the system.
  20928. * @returns True if it is alive, otherwise false.
  20929. */
  20930. isAlive(): boolean;
  20931. /**
  20932. * Gets Wether the system has been started.
  20933. * @returns True if it has been started, otherwise false.
  20934. */
  20935. isStarted(): boolean;
  20936. /**
  20937. * Starts the particle system and begins to emit.
  20938. */
  20939. start(): void;
  20940. /**
  20941. * Stops the particle system.
  20942. * @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.
  20943. */
  20944. stop(stopSubEmitters?: boolean): void;
  20945. /**
  20946. * Remove all active particles
  20947. */
  20948. reset(): void;
  20949. /**
  20950. * @ignore (for internal use only)
  20951. */
  20952. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  20953. /**
  20954. * @ignore (for internal use only)
  20955. */
  20956. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  20957. /**
  20958. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  20959. * Its lifetime will start back at 0.
  20960. */
  20961. recycleParticle: (particle: Particle) => void;
  20962. private _stopSubEmitters();
  20963. private _createParticle;
  20964. private _removeFromRoot();
  20965. private _emitFromParticle;
  20966. private _update(newParticles);
  20967. private _getEffect();
  20968. /**
  20969. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  20970. */
  20971. animate(): void;
  20972. private _appendParticleVertexes;
  20973. private _appenedParticleVertexesWithSheet(offset, particle);
  20974. private _appenedParticleVertexesNoSheet(offset, particle);
  20975. /**
  20976. * Rebuilds the particle system.
  20977. */
  20978. rebuild(): void;
  20979. /**
  20980. * Is this system ready to be used/rendered
  20981. * @return true if the system is ready
  20982. */
  20983. isReady(): boolean;
  20984. /**
  20985. * Renders the particle system in its current state.
  20986. * @returns the current number of particles
  20987. */
  20988. render(): number;
  20989. /**
  20990. * Disposes the particle system and free the associated resources
  20991. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20992. */
  20993. dispose(disposeTexture?: boolean): void;
  20994. /**
  20995. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  20996. * @param radius The radius of the sphere to emit from
  20997. * @returns the emitter
  20998. */
  20999. createSphereEmitter(radius?: number): SphereParticleEmitter;
  21000. /**
  21001. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  21002. * @param radius The radius of the sphere to emit from
  21003. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21004. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21005. * @returns the emitter
  21006. */
  21007. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  21008. /**
  21009. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  21010. * @param radius The radius of the cone to emit from
  21011. * @param angle The base angle of the cone
  21012. * @returns the emitter
  21013. */
  21014. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  21015. /**
  21016. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21017. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21018. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21019. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21020. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21021. * @returns the emitter
  21022. */
  21023. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21024. /**
  21025. * Clones the particle system.
  21026. * @param name The name of the cloned object
  21027. * @param newEmitter The new emitter to use
  21028. * @returns the cloned particle system
  21029. */
  21030. clone(name: string, newEmitter: any): ParticleSystem;
  21031. /**
  21032. * Serializes the particle system to a JSON object.
  21033. * @returns the JSON object
  21034. */
  21035. serialize(): any;
  21036. /**
  21037. * Parses a JSON object to create a particle system.
  21038. * @param parsedParticleSystem The JSON object to parse
  21039. * @param scene The scene to create the particle system in
  21040. * @param rootUrl The root url to use to load external dependencies like texture
  21041. * @returns the Parsed particle system
  21042. */
  21043. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  21044. }
  21045. }
  21046. declare module BABYLON {
  21047. /**
  21048. * Represents one particle of a solid particle system.
  21049. */
  21050. class SolidParticle {
  21051. /**
  21052. * particle global index
  21053. */
  21054. idx: number;
  21055. /**
  21056. * The color of the particle
  21057. */
  21058. color: Nullable<Color4>;
  21059. /**
  21060. * The world space position of the particle.
  21061. */
  21062. position: Vector3;
  21063. /**
  21064. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  21065. */
  21066. rotation: Vector3;
  21067. /**
  21068. * The world space rotation quaternion of the particle.
  21069. */
  21070. rotationQuaternion: Nullable<Quaternion>;
  21071. /**
  21072. * The scaling of the particle.
  21073. */
  21074. scaling: Vector3;
  21075. /**
  21076. * The uvs of the particle.
  21077. */
  21078. uvs: Vector4;
  21079. /**
  21080. * The current speed of the particle.
  21081. */
  21082. velocity: Vector3;
  21083. /**
  21084. * The pivot point in the particle local space.
  21085. */
  21086. pivot: Vector3;
  21087. /**
  21088. * Must the particle be translated from its pivot point in its local space ?
  21089. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  21090. * Default : false
  21091. */
  21092. translateFromPivot: boolean;
  21093. /**
  21094. * Is the particle active or not ?
  21095. */
  21096. alive: boolean;
  21097. /**
  21098. * Is the particle visible or not ?
  21099. */
  21100. isVisible: boolean;
  21101. /**
  21102. * Index of this particle in the global "positions" array (Internal use)
  21103. */
  21104. _pos: number;
  21105. /**
  21106. * Index of this particle in the global "indices" array (Internal use)
  21107. */
  21108. _ind: number;
  21109. /**
  21110. * ModelShape of this particle (Internal use)
  21111. */
  21112. _model: ModelShape;
  21113. /**
  21114. * ModelShape id of this particle
  21115. */
  21116. shapeId: number;
  21117. /**
  21118. * Index of the particle in its shape id (Internal use)
  21119. */
  21120. idxInShape: number;
  21121. /**
  21122. * Reference to the shape model BoundingInfo object (Internal use)
  21123. */
  21124. _modelBoundingInfo: BoundingInfo;
  21125. /**
  21126. * Particle BoundingInfo object (Internal use)
  21127. */
  21128. _boundingInfo: BoundingInfo;
  21129. /**
  21130. * Reference to the SPS what the particle belongs to (Internal use)
  21131. */
  21132. _sps: SolidParticleSystem;
  21133. /**
  21134. * Still set as invisible in order to skip useless computations (Internal use)
  21135. */
  21136. _stillInvisible: boolean;
  21137. /**
  21138. * Last computed particle rotation matrix
  21139. */
  21140. _rotationMatrix: number[];
  21141. /**
  21142. * Parent particle Id, if any.
  21143. * Default null.
  21144. */
  21145. parentId: Nullable<number>;
  21146. /**
  21147. * Internal global position in the SPS.
  21148. */
  21149. _globalPosition: Vector3;
  21150. /**
  21151. * Creates a Solid Particle object.
  21152. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  21153. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  21154. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  21155. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  21156. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  21157. * @param shapeId (integer) is the model shape identifier in the SPS.
  21158. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  21159. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  21160. */
  21161. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  21162. /**
  21163. * Legacy support, changed scale to scaling
  21164. */
  21165. /**
  21166. * Legacy support, changed scale to scaling
  21167. */
  21168. scale: Vector3;
  21169. /**
  21170. * Legacy support, changed quaternion to rotationQuaternion
  21171. */
  21172. /**
  21173. * Legacy support, changed quaternion to rotationQuaternion
  21174. */
  21175. quaternion: Nullable<Quaternion>;
  21176. /**
  21177. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  21178. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  21179. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  21180. * @returns true if it intersects
  21181. */
  21182. intersectsMesh(target: Mesh | SolidParticle): boolean;
  21183. }
  21184. /**
  21185. * Represents the shape of the model used by one particle of a solid particle system.
  21186. * SPS internal tool, don't use it manually.
  21187. */
  21188. class ModelShape {
  21189. /**
  21190. * The shape id.
  21191. */
  21192. shapeID: number;
  21193. /**
  21194. * flat array of model positions (internal use)
  21195. */
  21196. _shape: Vector3[];
  21197. /**
  21198. * flat array of model UVs (internal use)
  21199. */
  21200. _shapeUV: number[];
  21201. /**
  21202. * length of the shape in the model indices array (internal use)
  21203. */
  21204. _indicesLength: number;
  21205. /**
  21206. * Custom position function (internal use)
  21207. */
  21208. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  21209. /**
  21210. * Custom vertex function (internal use)
  21211. */
  21212. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  21213. /**
  21214. * 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.
  21215. * SPS internal tool, don't use it manually.
  21216. * @ignore
  21217. */
  21218. 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>);
  21219. }
  21220. /**
  21221. * Represents a Depth Sorted Particle in the solid particle system.
  21222. */
  21223. class DepthSortedParticle {
  21224. /**
  21225. * Index of the particle in the "indices" array
  21226. */
  21227. ind: number;
  21228. /**
  21229. * Length of the particle shape in the "indices" array
  21230. */
  21231. indicesLength: number;
  21232. /**
  21233. * Squared distance from the particle to the camera
  21234. */
  21235. sqDistance: number;
  21236. }
  21237. }
  21238. declare module BABYLON {
  21239. /**
  21240. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  21241. *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.
  21242. * The SPS is also a particle system. It provides some methods to manage the particles.
  21243. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  21244. *
  21245. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  21246. */
  21247. class SolidParticleSystem implements IDisposable {
  21248. /**
  21249. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  21250. * Example : var p = SPS.particles[i];
  21251. */
  21252. particles: SolidParticle[];
  21253. /**
  21254. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  21255. */
  21256. nbParticles: number;
  21257. /**
  21258. * If the particles must ever face the camera (default false). Useful for planar particles.
  21259. */
  21260. billboard: boolean;
  21261. /**
  21262. * Recompute normals when adding a shape
  21263. */
  21264. recomputeNormals: boolean;
  21265. /**
  21266. * This a counter ofr your own usage. It's not set by any SPS functions.
  21267. */
  21268. counter: number;
  21269. /**
  21270. * The SPS name. This name is also given to the underlying mesh.
  21271. */
  21272. name: string;
  21273. /**
  21274. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  21275. */
  21276. mesh: Mesh;
  21277. /**
  21278. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  21279. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  21280. */
  21281. vars: any;
  21282. /**
  21283. * This array is populated when the SPS is set as 'pickable'.
  21284. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  21285. * Each element of this array is an object `{idx: int, faceId: int}`.
  21286. * `idx` is the picked particle index in the `SPS.particles` array
  21287. * `faceId` is the picked face index counted within this particle.
  21288. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  21289. */
  21290. pickedParticles: {
  21291. idx: number;
  21292. faceId: number;
  21293. }[];
  21294. /**
  21295. * This array is populated when `enableDepthSort` is set to true.
  21296. * Each element of this array is an instance of the class DepthSortedParticle.
  21297. */
  21298. depthSortedParticles: DepthSortedParticle[];
  21299. /**
  21300. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  21301. */
  21302. _bSphereOnly: boolean;
  21303. /**
  21304. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  21305. */
  21306. _bSphereRadiusFactor: number;
  21307. private _scene;
  21308. private _positions;
  21309. private _indices;
  21310. private _normals;
  21311. private _colors;
  21312. private _uvs;
  21313. private _indices32;
  21314. private _positions32;
  21315. private _normals32;
  21316. private _fixedNormal32;
  21317. private _colors32;
  21318. private _uvs32;
  21319. private _index;
  21320. private _updatable;
  21321. private _pickable;
  21322. private _isVisibilityBoxLocked;
  21323. private _alwaysVisible;
  21324. private _depthSort;
  21325. private _shapeCounter;
  21326. private _copy;
  21327. private _shape;
  21328. private _shapeUV;
  21329. private _color;
  21330. private _computeParticleColor;
  21331. private _computeParticleTexture;
  21332. private _computeParticleRotation;
  21333. private _computeParticleVertex;
  21334. private _computeBoundingBox;
  21335. private _depthSortParticles;
  21336. private _cam_axisZ;
  21337. private _cam_axisY;
  21338. private _cam_axisX;
  21339. private _axisZ;
  21340. private _camera;
  21341. private _particle;
  21342. private _camDir;
  21343. private _camInvertedPosition;
  21344. private _rotMatrix;
  21345. private _invertMatrix;
  21346. private _rotated;
  21347. private _quaternion;
  21348. private _vertex;
  21349. private _normal;
  21350. private _yaw;
  21351. private _pitch;
  21352. private _roll;
  21353. private _halfroll;
  21354. private _halfpitch;
  21355. private _halfyaw;
  21356. private _sinRoll;
  21357. private _cosRoll;
  21358. private _sinPitch;
  21359. private _cosPitch;
  21360. private _sinYaw;
  21361. private _cosYaw;
  21362. private _mustUnrotateFixedNormals;
  21363. private _minimum;
  21364. private _maximum;
  21365. private _minBbox;
  21366. private _maxBbox;
  21367. private _particlesIntersect;
  21368. private _depthSortFunction;
  21369. private _needs32Bits;
  21370. private _pivotBackTranslation;
  21371. private _scaledPivot;
  21372. private _particleHasParent;
  21373. private _parent;
  21374. /**
  21375. * Creates a SPS (Solid Particle System) object.
  21376. * @param name (String) is the SPS name, this will be the underlying mesh name.
  21377. * @param scene (Scene) is the scene in which the SPS is added.
  21378. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  21379. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  21380. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  21381. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  21382. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  21383. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  21384. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  21385. */
  21386. constructor(name: string, scene: Scene, options?: {
  21387. updatable?: boolean;
  21388. isPickable?: boolean;
  21389. enableDepthSort?: boolean;
  21390. particleIntersection?: boolean;
  21391. boundingSphereOnly?: boolean;
  21392. bSphereRadiusFactor?: number;
  21393. });
  21394. /**
  21395. * Builds the SPS underlying mesh. Returns a standard Mesh.
  21396. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  21397. * @returns the created mesh
  21398. */
  21399. buildMesh(): Mesh;
  21400. /**
  21401. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  21402. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  21403. * Thus the particles generated from `digest()` have their property `position` set yet.
  21404. * @param mesh ( Mesh ) is the mesh to be digested
  21405. * @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
  21406. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  21407. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  21408. * @returns the current SPS
  21409. */
  21410. digest(mesh: Mesh, options?: {
  21411. facetNb?: number;
  21412. number?: number;
  21413. delta?: number;
  21414. }): SolidParticleSystem;
  21415. private _unrotateFixedNormals();
  21416. private _resetCopy();
  21417. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  21418. private _posToShape(positions);
  21419. private _uvsToShapeUV(uvs);
  21420. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  21421. /**
  21422. * Adds some particles to the SPS from the model shape. Returns the shape id.
  21423. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  21424. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  21425. * @param nb (positive integer) the number of particles to be created from this model
  21426. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  21427. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  21428. * @returns the number of shapes in the system
  21429. */
  21430. addShape(mesh: Mesh, nb: number, options?: {
  21431. positionFunction?: any;
  21432. vertexFunction?: any;
  21433. }): number;
  21434. private _rebuildParticle(particle);
  21435. /**
  21436. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  21437. * @returns the SPS.
  21438. */
  21439. rebuildMesh(): SolidParticleSystem;
  21440. /**
  21441. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  21442. * This method calls `updateParticle()` for each particle of the SPS.
  21443. * For an animated SPS, it is usually called within the render loop.
  21444. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  21445. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  21446. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  21447. * @returns the SPS.
  21448. */
  21449. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  21450. private _quaternionRotationYPR();
  21451. private _quaternionToRotationMatrix();
  21452. /**
  21453. * Disposes the SPS.
  21454. */
  21455. dispose(): void;
  21456. /**
  21457. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  21458. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21459. * @returns the SPS.
  21460. */
  21461. refreshVisibleSize(): SolidParticleSystem;
  21462. /**
  21463. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  21464. * @param size the size (float) of the visibility box
  21465. * note : this doesn't lock the SPS mesh bounding box.
  21466. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21467. */
  21468. setVisibilityBox(size: number): void;
  21469. /**
  21470. * Gets whether the SPS as always visible or not
  21471. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21472. */
  21473. /**
  21474. * Sets the SPS as always visible or not
  21475. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21476. */
  21477. isAlwaysVisible: boolean;
  21478. /**
  21479. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  21480. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21481. */
  21482. /**
  21483. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  21484. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21485. */
  21486. isVisibilityBoxLocked: boolean;
  21487. /**
  21488. * Gets if `setParticles()` computes the particle rotations or not.
  21489. * Default value : true. The SPS is faster when it's set to false.
  21490. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  21491. */
  21492. /**
  21493. * Tells to `setParticles()` to compute the particle rotations or not.
  21494. * Default value : true. The SPS is faster when it's set to false.
  21495. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  21496. */
  21497. computeParticleRotation: boolean;
  21498. /**
  21499. * Gets if `setParticles()` computes the particle colors or not.
  21500. * Default value : true. The SPS is faster when it's set to false.
  21501. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  21502. */
  21503. /**
  21504. * Tells to `setParticles()` to compute the particle colors or not.
  21505. * Default value : true. The SPS is faster when it's set to false.
  21506. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  21507. */
  21508. computeParticleColor: boolean;
  21509. /**
  21510. * Gets if `setParticles()` computes the particle textures or not.
  21511. * Default value : true. The SPS is faster when it's set to false.
  21512. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  21513. */
  21514. computeParticleTexture: boolean;
  21515. /**
  21516. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  21517. * Default value : false. The SPS is faster when it's set to false.
  21518. * Note : the particle custom vertex positions aren't stored values.
  21519. */
  21520. /**
  21521. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  21522. * Default value : false. The SPS is faster when it's set to false.
  21523. * Note : the particle custom vertex positions aren't stored values.
  21524. */
  21525. computeParticleVertex: boolean;
  21526. /**
  21527. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  21528. */
  21529. /**
  21530. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  21531. */
  21532. computeBoundingBox: boolean;
  21533. /**
  21534. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  21535. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  21536. * Default : `true`
  21537. */
  21538. /**
  21539. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  21540. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  21541. * Default : `true`
  21542. */
  21543. depthSortParticles: boolean;
  21544. /**
  21545. * This function does nothing. It may be overwritten to set all the particle first values.
  21546. * The SPS doesn't call this function, you may have to call it by your own.
  21547. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  21548. */
  21549. initParticles(): void;
  21550. /**
  21551. * This function does nothing. It may be overwritten to recycle a particle.
  21552. * The SPS doesn't call this function, you may have to call it by your own.
  21553. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  21554. * @param particle The particle to recycle
  21555. * @returns the recycled particle
  21556. */
  21557. recycleParticle(particle: SolidParticle): SolidParticle;
  21558. /**
  21559. * Updates a particle : this function should be overwritten by the user.
  21560. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  21561. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  21562. * @example : just set a particle position or velocity and recycle conditions
  21563. * @param particle The particle to update
  21564. * @returns the updated particle
  21565. */
  21566. updateParticle(particle: SolidParticle): SolidParticle;
  21567. /**
  21568. * Updates a vertex of a particle : it can be overwritten by the user.
  21569. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  21570. * @param particle the current particle
  21571. * @param vertex the current index of the current particle
  21572. * @param pt the index of the current vertex in the particle shape
  21573. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  21574. * @example : just set a vertex particle position
  21575. * @returns the updated vertex
  21576. */
  21577. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  21578. /**
  21579. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  21580. * This does nothing and may be overwritten by the user.
  21581. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  21582. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  21583. * @param update the boolean update value actually passed to setParticles()
  21584. */
  21585. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  21586. /**
  21587. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  21588. * This will be passed three parameters.
  21589. * This does nothing and may be overwritten by the user.
  21590. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  21591. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  21592. * @param update the boolean update value actually passed to setParticles()
  21593. */
  21594. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  21595. }
  21596. }
  21597. declare module BABYLON {
  21598. class MorphTarget {
  21599. name: string;
  21600. animations: Animation[];
  21601. private _positions;
  21602. private _normals;
  21603. private _tangents;
  21604. private _influence;
  21605. onInfluenceChanged: Observable<boolean>;
  21606. influence: number;
  21607. constructor(name: string, influence?: number);
  21608. readonly hasPositions: boolean;
  21609. readonly hasNormals: boolean;
  21610. readonly hasTangents: boolean;
  21611. setPositions(data: Nullable<FloatArray>): void;
  21612. getPositions(): Nullable<FloatArray>;
  21613. setNormals(data: Nullable<FloatArray>): void;
  21614. getNormals(): Nullable<FloatArray>;
  21615. setTangents(data: Nullable<FloatArray>): void;
  21616. getTangents(): Nullable<FloatArray>;
  21617. /**
  21618. * Serializes the current target into a Serialization object.
  21619. * Returns the serialized object.
  21620. */
  21621. serialize(): any;
  21622. static Parse(serializationObject: any): MorphTarget;
  21623. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21624. }
  21625. }
  21626. declare module BABYLON {
  21627. class MorphTargetManager {
  21628. private _targets;
  21629. private _targetObservable;
  21630. private _activeTargets;
  21631. private _scene;
  21632. private _influences;
  21633. private _supportsNormals;
  21634. private _supportsTangents;
  21635. private _vertexCount;
  21636. private _uniqueId;
  21637. private _tempInfluences;
  21638. constructor(scene?: Nullable<Scene>);
  21639. readonly uniqueId: number;
  21640. readonly vertexCount: number;
  21641. readonly supportsNormals: boolean;
  21642. readonly supportsTangents: boolean;
  21643. readonly numTargets: number;
  21644. readonly numInfluencers: number;
  21645. readonly influences: Float32Array;
  21646. getActiveTarget(index: number): MorphTarget;
  21647. getTarget(index: number): MorphTarget;
  21648. addTarget(target: MorphTarget): void;
  21649. removeTarget(target: MorphTarget): void;
  21650. /**
  21651. * Serializes the current manager into a Serialization object.
  21652. * Returns the serialized object.
  21653. */
  21654. serialize(): any;
  21655. private _syncActiveTargets(needUpdate);
  21656. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21657. }
  21658. }
  21659. declare module BABYLON {
  21660. interface PhysicsImpostorJoint {
  21661. mainImpostor: PhysicsImpostor;
  21662. connectedImpostor: PhysicsImpostor;
  21663. joint: PhysicsJoint;
  21664. }
  21665. class PhysicsEngine {
  21666. private _physicsPlugin;
  21667. gravity: Vector3;
  21668. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  21669. setGravity(gravity: Vector3): void;
  21670. /**
  21671. * Set the time step of the physics engine.
  21672. * default is 1/60.
  21673. * To slow it down, enter 1/600 for example.
  21674. * To speed it up, 1/30
  21675. * @param {number} newTimeStep the new timestep to apply to this world.
  21676. */
  21677. setTimeStep(newTimeStep?: number): void;
  21678. /**
  21679. * Get the time step of the physics engine.
  21680. */
  21681. getTimeStep(): number;
  21682. dispose(): void;
  21683. getPhysicsPluginName(): string;
  21684. static Epsilon: number;
  21685. private _impostors;
  21686. private _joints;
  21687. /**
  21688. * Adding a new impostor for the impostor tracking.
  21689. * This will be done by the impostor itself.
  21690. * @param {PhysicsImpostor} impostor the impostor to add
  21691. */
  21692. addImpostor(impostor: PhysicsImpostor): void;
  21693. /**
  21694. * Remove an impostor from the engine.
  21695. * This impostor and its mesh will not longer be updated by the physics engine.
  21696. * @param {PhysicsImpostor} impostor the impostor to remove
  21697. */
  21698. removeImpostor(impostor: PhysicsImpostor): void;
  21699. /**
  21700. * Add a joint to the physics engine
  21701. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  21702. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  21703. * @param {PhysicsJoint} the joint that will connect both impostors.
  21704. */
  21705. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  21706. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  21707. /**
  21708. * Called by the scene. no need to call it.
  21709. */
  21710. _step(delta: number): void;
  21711. getPhysicsPlugin(): IPhysicsEnginePlugin;
  21712. getImpostors(): Array<PhysicsImpostor>;
  21713. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21714. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  21715. }
  21716. interface IPhysicsEnginePlugin {
  21717. world: any;
  21718. name: string;
  21719. setGravity(gravity: Vector3): void;
  21720. setTimeStep(timeStep: number): void;
  21721. getTimeStep(): number;
  21722. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  21723. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  21724. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  21725. generatePhysicsBody(impostor: PhysicsImpostor): void;
  21726. removePhysicsBody(impostor: PhysicsImpostor): void;
  21727. generateJoint(joint: PhysicsImpostorJoint): void;
  21728. removeJoint(joint: PhysicsImpostorJoint): void;
  21729. isSupported(): boolean;
  21730. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  21731. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  21732. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  21733. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  21734. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  21735. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  21736. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  21737. getBodyMass(impostor: PhysicsImpostor): number;
  21738. getBodyFriction(impostor: PhysicsImpostor): number;
  21739. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  21740. getBodyRestitution(impostor: PhysicsImpostor): number;
  21741. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  21742. sleepBody(impostor: PhysicsImpostor): void;
  21743. wakeUpBody(impostor: PhysicsImpostor): void;
  21744. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  21745. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  21746. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  21747. getRadius(impostor: PhysicsImpostor): number;
  21748. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  21749. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  21750. dispose(): void;
  21751. }
  21752. }
  21753. declare module BABYLON {
  21754. class PhysicsHelper {
  21755. private _scene;
  21756. private _physicsEngine;
  21757. constructor(scene: Scene);
  21758. /**
  21759. * @param {Vector3} origin the origin of the explosion
  21760. * @param {number} radius the explosion radius
  21761. * @param {number} strength the explosion strength
  21762. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  21763. */
  21764. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  21765. /**
  21766. * @param {Vector3} origin the origin of the explosion
  21767. * @param {number} radius the explosion radius
  21768. * @param {number} strength the explosion strength
  21769. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  21770. */
  21771. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  21772. /**
  21773. * @param {Vector3} origin the origin of the explosion
  21774. * @param {number} radius the explosion radius
  21775. * @param {number} strength the explosion strength
  21776. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  21777. */
  21778. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  21779. /**
  21780. * @param {Vector3} origin the origin of the updraft
  21781. * @param {number} radius the radius of the updraft
  21782. * @param {number} strength the strength of the updraft
  21783. * @param {number} height the height of the updraft
  21784. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  21785. */
  21786. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  21787. /**
  21788. * @param {Vector3} origin the of the vortex
  21789. * @param {number} radius the radius of the vortex
  21790. * @param {number} strength the strength of the vortex
  21791. * @param {number} height the height of the vortex
  21792. */
  21793. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  21794. }
  21795. /***** Radial explosion *****/
  21796. class PhysicsRadialExplosionEvent {
  21797. private _scene;
  21798. private _sphere;
  21799. private _sphereOptions;
  21800. private _rays;
  21801. private _dataFetched;
  21802. constructor(scene: Scene);
  21803. /**
  21804. * Returns the data related to the radial explosion event (sphere & rays).
  21805. * @returns {PhysicsRadialExplosionEventData}
  21806. */
  21807. getData(): PhysicsRadialExplosionEventData;
  21808. /**
  21809. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  21810. * @param impostor
  21811. * @param {Vector3} origin the origin of the explosion
  21812. * @param {number} radius the explosion radius
  21813. * @param {number} strength the explosion strength
  21814. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  21815. * @returns {Nullable<PhysicsForceAndContactPoint>}
  21816. */
  21817. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  21818. /**
  21819. * Disposes the sphere.
  21820. * @param {bolean} force
  21821. */
  21822. dispose(force?: boolean): void;
  21823. /*** Helpers ***/
  21824. private _prepareSphere();
  21825. private _intersectsWithSphere(impostor, origin, radius);
  21826. }
  21827. /***** Gravitational Field *****/
  21828. class PhysicsGravitationalFieldEvent {
  21829. private _physicsHelper;
  21830. private _scene;
  21831. private _origin;
  21832. private _radius;
  21833. private _strength;
  21834. private _falloff;
  21835. private _tickCallback;
  21836. private _sphere;
  21837. private _dataFetched;
  21838. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  21839. /**
  21840. * Returns the data related to the gravitational field event (sphere).
  21841. * @returns {PhysicsGravitationalFieldEventData}
  21842. */
  21843. getData(): PhysicsGravitationalFieldEventData;
  21844. /**
  21845. * Enables the gravitational field.
  21846. */
  21847. enable(): void;
  21848. /**
  21849. * Disables the gravitational field.
  21850. */
  21851. disable(): void;
  21852. /**
  21853. * Disposes the sphere.
  21854. * @param {bolean} force
  21855. */
  21856. dispose(force?: boolean): void;
  21857. private _tick();
  21858. }
  21859. /***** Updraft *****/
  21860. class PhysicsUpdraftEvent {
  21861. private _scene;
  21862. private _origin;
  21863. private _radius;
  21864. private _strength;
  21865. private _height;
  21866. private _updraftMode;
  21867. private _physicsEngine;
  21868. private _originTop;
  21869. private _originDirection;
  21870. private _tickCallback;
  21871. private _cylinder;
  21872. private _cylinderPosition;
  21873. private _dataFetched;
  21874. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  21875. /**
  21876. * Returns the data related to the updraft event (cylinder).
  21877. * @returns {PhysicsUpdraftEventData}
  21878. */
  21879. getData(): PhysicsUpdraftEventData;
  21880. /**
  21881. * Enables the updraft.
  21882. */
  21883. enable(): void;
  21884. /**
  21885. * Disables the cortex.
  21886. */
  21887. disable(): void;
  21888. /**
  21889. * Disposes the sphere.
  21890. * @param {bolean} force
  21891. */
  21892. dispose(force?: boolean): void;
  21893. private getImpostorForceAndContactPoint(impostor);
  21894. private _tick();
  21895. /*** Helpers ***/
  21896. private _prepareCylinder();
  21897. private _intersectsWithCylinder(impostor);
  21898. }
  21899. /***** Vortex *****/
  21900. class PhysicsVortexEvent {
  21901. private _scene;
  21902. private _origin;
  21903. private _radius;
  21904. private _strength;
  21905. private _height;
  21906. private _physicsEngine;
  21907. private _originTop;
  21908. private _centripetalForceThreshold;
  21909. private _updraftMultiplier;
  21910. private _tickCallback;
  21911. private _cylinder;
  21912. private _cylinderPosition;
  21913. private _dataFetched;
  21914. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  21915. /**
  21916. * Returns the data related to the vortex event (cylinder).
  21917. * @returns {PhysicsVortexEventData}
  21918. */
  21919. getData(): PhysicsVortexEventData;
  21920. /**
  21921. * Enables the vortex.
  21922. */
  21923. enable(): void;
  21924. /**
  21925. * Disables the cortex.
  21926. */
  21927. disable(): void;
  21928. /**
  21929. * Disposes the sphere.
  21930. * @param {bolean} force
  21931. */
  21932. dispose(force?: boolean): void;
  21933. private getImpostorForceAndContactPoint(impostor);
  21934. private _tick();
  21935. /*** Helpers ***/
  21936. private _prepareCylinder();
  21937. private _intersectsWithCylinder(impostor);
  21938. }
  21939. /***** Enums *****/
  21940. /**
  21941. * The strenght of the force in correspondence to the distance of the affected object
  21942. */
  21943. enum PhysicsRadialImpulseFalloff {
  21944. Constant = 0,
  21945. Linear = 1,
  21946. }
  21947. /**
  21948. * The strenght of the force in correspondence to the distance of the affected object
  21949. */
  21950. enum PhysicsUpdraftMode {
  21951. Center = 0,
  21952. Perpendicular = 1,
  21953. }
  21954. /***** Data interfaces *****/
  21955. interface PhysicsForceAndContactPoint {
  21956. force: Vector3;
  21957. contactPoint: Vector3;
  21958. }
  21959. interface PhysicsRadialExplosionEventData {
  21960. sphere: Mesh;
  21961. rays: Array<Ray>;
  21962. }
  21963. interface PhysicsGravitationalFieldEventData {
  21964. sphere: Mesh;
  21965. }
  21966. interface PhysicsUpdraftEventData {
  21967. cylinder: Mesh;
  21968. }
  21969. interface PhysicsVortexEventData {
  21970. cylinder: Mesh;
  21971. }
  21972. }
  21973. declare module BABYLON {
  21974. interface PhysicsImpostorParameters {
  21975. mass: number;
  21976. friction?: number;
  21977. restitution?: number;
  21978. nativeOptions?: any;
  21979. ignoreParent?: boolean;
  21980. disableBidirectionalTransformation?: boolean;
  21981. }
  21982. interface IPhysicsEnabledObject {
  21983. position: Vector3;
  21984. rotationQuaternion: Nullable<Quaternion>;
  21985. scaling: Vector3;
  21986. rotation?: Vector3;
  21987. parent?: any;
  21988. getBoundingInfo(): BoundingInfo;
  21989. computeWorldMatrix(force: boolean): Matrix;
  21990. getWorldMatrix?(): Matrix;
  21991. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  21992. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  21993. getIndices?(): Nullable<IndicesArray>;
  21994. getScene?(): Scene;
  21995. getAbsolutePosition(): Vector3;
  21996. getAbsolutePivotPoint(): Vector3;
  21997. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  21998. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  21999. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22000. getClassName(): string;
  22001. }
  22002. class PhysicsImpostor {
  22003. object: IPhysicsEnabledObject;
  22004. type: number;
  22005. private _options;
  22006. private _scene;
  22007. static DEFAULT_OBJECT_SIZE: Vector3;
  22008. static IDENTITY_QUATERNION: Quaternion;
  22009. private _physicsEngine;
  22010. private _physicsBody;
  22011. private _bodyUpdateRequired;
  22012. private _onBeforePhysicsStepCallbacks;
  22013. private _onAfterPhysicsStepCallbacks;
  22014. private _onPhysicsCollideCallbacks;
  22015. private _deltaPosition;
  22016. private _deltaRotation;
  22017. private _deltaRotationConjugated;
  22018. private _parent;
  22019. private _isDisposed;
  22020. private static _tmpVecs;
  22021. private static _tmpQuat;
  22022. readonly isDisposed: boolean;
  22023. mass: number;
  22024. friction: number;
  22025. restitution: number;
  22026. uniqueId: number;
  22027. private _joints;
  22028. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22029. /**
  22030. * This function will completly initialize this impostor.
  22031. * It will create a new body - but only if this mesh has no parent.
  22032. * If it has, this impostor will not be used other than to define the impostor
  22033. * of the child mesh.
  22034. */
  22035. _init(): void;
  22036. private _getPhysicsParent();
  22037. /**
  22038. * Should a new body be generated.
  22039. */
  22040. isBodyInitRequired(): boolean;
  22041. setScalingUpdated(updated: boolean): void;
  22042. /**
  22043. * Force a regeneration of this or the parent's impostor's body.
  22044. * Use under cautious - This will remove all joints already implemented.
  22045. */
  22046. forceUpdate(): void;
  22047. /**
  22048. * Gets the body that holds this impostor. Either its own, or its parent.
  22049. */
  22050. /**
  22051. * Set the physics body. Used mainly by the physics engine/plugin
  22052. */
  22053. physicsBody: any;
  22054. parent: Nullable<PhysicsImpostor>;
  22055. resetUpdateFlags(): void;
  22056. getObjectExtendSize(): Vector3;
  22057. getObjectCenter(): Vector3;
  22058. /**
  22059. * Get a specific parametes from the options parameter.
  22060. */
  22061. getParam(paramName: string): any;
  22062. /**
  22063. * Sets a specific parameter in the options given to the physics plugin
  22064. */
  22065. setParam(paramName: string, value: number): void;
  22066. /**
  22067. * Specifically change the body's mass option. Won't recreate the physics body object
  22068. */
  22069. setMass(mass: number): void;
  22070. getLinearVelocity(): Nullable<Vector3>;
  22071. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22072. getAngularVelocity(): Nullable<Vector3>;
  22073. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22074. /**
  22075. * Execute a function with the physics plugin native code.
  22076. * Provide a function the will have two variables - the world object and the physics body object.
  22077. */
  22078. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22079. /**
  22080. * Register a function that will be executed before the physics world is stepping forward.
  22081. */
  22082. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22083. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22084. /**
  22085. * Register a function that will be executed after the physics step
  22086. */
  22087. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22088. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22089. /**
  22090. * register a function that will be executed when this impostor collides against a different body.
  22091. */
  22092. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  22093. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  22094. private _tmpQuat;
  22095. private _tmpQuat2;
  22096. getParentsRotation(): Quaternion;
  22097. /**
  22098. * this function is executed by the physics engine.
  22099. */
  22100. beforeStep: () => void;
  22101. /**
  22102. * this function is executed by the physics engine.
  22103. */
  22104. afterStep: () => void;
  22105. /**
  22106. * Legacy collision detection event support
  22107. */
  22108. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  22109. onCollide: (e: {
  22110. body: any;
  22111. }) => void;
  22112. /**
  22113. * Apply a force
  22114. */
  22115. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22116. /**
  22117. * Apply an impulse
  22118. */
  22119. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22120. /**
  22121. * A help function to create a joint.
  22122. */
  22123. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  22124. /**
  22125. * Add a joint to this impostor with a different impostor.
  22126. */
  22127. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  22128. /**
  22129. * Will keep this body still, in a sleep mode.
  22130. */
  22131. sleep(): PhysicsImpostor;
  22132. /**
  22133. * Wake the body up.
  22134. */
  22135. wakeUp(): PhysicsImpostor;
  22136. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22137. dispose(): void;
  22138. setDeltaPosition(position: Vector3): void;
  22139. setDeltaRotation(rotation: Quaternion): void;
  22140. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  22141. getRadius(): number;
  22142. /**
  22143. * Sync a bone with this impostor
  22144. * @param bone The bone to sync to the impostor.
  22145. * @param boneMesh The mesh that the bone is influencing.
  22146. * @param jointPivot The pivot of the joint / bone in local space.
  22147. * @param distToJoint Optional distance from the impostor to the joint.
  22148. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  22149. */
  22150. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  22151. /**
  22152. * Sync impostor to a bone
  22153. * @param bone The bone that the impostor will be synced to.
  22154. * @param boneMesh The mesh that the bone is influencing.
  22155. * @param jointPivot The pivot of the joint / bone in local space.
  22156. * @param distToJoint Optional distance from the impostor to the joint.
  22157. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  22158. * @param boneAxis Optional vector3 axis the bone is aligned with
  22159. */
  22160. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  22161. static NoImpostor: number;
  22162. static SphereImpostor: number;
  22163. static BoxImpostor: number;
  22164. static PlaneImpostor: number;
  22165. static MeshImpostor: number;
  22166. static CylinderImpostor: number;
  22167. static ParticleImpostor: number;
  22168. static HeightmapImpostor: number;
  22169. }
  22170. }
  22171. declare module BABYLON {
  22172. interface PhysicsJointData {
  22173. mainPivot?: Vector3;
  22174. connectedPivot?: Vector3;
  22175. mainAxis?: Vector3;
  22176. connectedAxis?: Vector3;
  22177. collision?: boolean;
  22178. nativeParams?: any;
  22179. }
  22180. /**
  22181. * This is a holder class for the physics joint created by the physics plugin.
  22182. * It holds a set of functions to control the underlying joint.
  22183. */
  22184. class PhysicsJoint {
  22185. type: number;
  22186. jointData: PhysicsJointData;
  22187. private _physicsJoint;
  22188. protected _physicsPlugin: IPhysicsEnginePlugin;
  22189. constructor(type: number, jointData: PhysicsJointData);
  22190. physicsJoint: any;
  22191. physicsPlugin: IPhysicsEnginePlugin;
  22192. /**
  22193. * Execute a function that is physics-plugin specific.
  22194. * @param {Function} func the function that will be executed.
  22195. * It accepts two parameters: the physics world and the physics joint.
  22196. */
  22197. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22198. static DistanceJoint: number;
  22199. static HingeJoint: number;
  22200. static BallAndSocketJoint: number;
  22201. static WheelJoint: number;
  22202. static SliderJoint: number;
  22203. static PrismaticJoint: number;
  22204. static UniversalJoint: number;
  22205. static Hinge2Joint: number;
  22206. static PointToPointJoint: number;
  22207. static SpringJoint: number;
  22208. static LockJoint: number;
  22209. }
  22210. /**
  22211. * A class representing a physics distance joint.
  22212. */
  22213. class DistanceJoint extends PhysicsJoint {
  22214. constructor(jointData: DistanceJointData);
  22215. /**
  22216. * Update the predefined distance.
  22217. */
  22218. updateDistance(maxDistance: number, minDistance?: number): void;
  22219. }
  22220. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22221. constructor(type: number, jointData: PhysicsJointData);
  22222. /**
  22223. * Set the motor values.
  22224. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22225. * @param {number} force the force to apply
  22226. * @param {number} maxForce max force for this motor.
  22227. */
  22228. setMotor(force?: number, maxForce?: number): void;
  22229. /**
  22230. * Set the motor's limits.
  22231. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22232. */
  22233. setLimit(upperLimit: number, lowerLimit?: number): void;
  22234. }
  22235. /**
  22236. * This class represents a single hinge physics joint
  22237. */
  22238. class HingeJoint extends MotorEnabledJoint {
  22239. constructor(jointData: PhysicsJointData);
  22240. /**
  22241. * Set the motor values.
  22242. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22243. * @param {number} force the force to apply
  22244. * @param {number} maxForce max force for this motor.
  22245. */
  22246. setMotor(force?: number, maxForce?: number): void;
  22247. /**
  22248. * Set the motor's limits.
  22249. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22250. */
  22251. setLimit(upperLimit: number, lowerLimit?: number): void;
  22252. }
  22253. /**
  22254. * This class represents a dual hinge physics joint (same as wheel joint)
  22255. */
  22256. class Hinge2Joint extends MotorEnabledJoint {
  22257. constructor(jointData: PhysicsJointData);
  22258. /**
  22259. * Set the motor values.
  22260. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22261. * @param {number} force the force to apply
  22262. * @param {number} maxForce max force for this motor.
  22263. * @param {motorIndex} the motor's index, 0 or 1.
  22264. */
  22265. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22266. /**
  22267. * Set the motor limits.
  22268. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22269. * @param {number} upperLimit the upper limit
  22270. * @param {number} lowerLimit lower limit
  22271. * @param {motorIndex} the motor's index, 0 or 1.
  22272. */
  22273. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22274. }
  22275. interface IMotorEnabledJoint {
  22276. physicsJoint: any;
  22277. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22278. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22279. }
  22280. interface DistanceJointData extends PhysicsJointData {
  22281. maxDistance: number;
  22282. }
  22283. interface SpringJointData extends PhysicsJointData {
  22284. length: number;
  22285. stiffness: number;
  22286. damping: number;
  22287. }
  22288. }
  22289. declare module BABYLON {
  22290. class ReflectionProbe {
  22291. name: string;
  22292. private _scene;
  22293. private _renderTargetTexture;
  22294. private _projectionMatrix;
  22295. private _viewMatrix;
  22296. private _target;
  22297. private _add;
  22298. private _attachedMesh;
  22299. private _invertYAxis;
  22300. position: Vector3;
  22301. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  22302. samples: number;
  22303. refreshRate: number;
  22304. getScene(): Scene;
  22305. readonly cubeTexture: RenderTargetTexture;
  22306. readonly renderList: Nullable<AbstractMesh[]>;
  22307. attachToMesh(mesh: AbstractMesh): void;
  22308. /**
  22309. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22310. *
  22311. * @param renderingGroupId The rendering group id corresponding to its index
  22312. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22313. */
  22314. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22315. dispose(): void;
  22316. }
  22317. }
  22318. declare module BABYLON {
  22319. class AnaglyphPostProcess extends PostProcess {
  22320. private _passedProcess;
  22321. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  22322. }
  22323. }
  22324. declare module BABYLON {
  22325. class BlackAndWhitePostProcess extends PostProcess {
  22326. degree: number;
  22327. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  22328. }
  22329. }
  22330. declare module BABYLON {
  22331. /**
  22332. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  22333. */
  22334. class BloomEffect extends PostProcessRenderEffect {
  22335. private bloomScale;
  22336. /**
  22337. * Internal
  22338. */
  22339. _effects: Array<PostProcess>;
  22340. /**
  22341. * Internal
  22342. */
  22343. _downscale: ExtractHighlightsPostProcess;
  22344. private _blurX;
  22345. private _blurY;
  22346. private _merge;
  22347. /**
  22348. * The luminance threshold to find bright areas of the image to bloom.
  22349. */
  22350. threshold: number;
  22351. /**
  22352. * The strength of the bloom.
  22353. */
  22354. weight: number;
  22355. /**
  22356. * Specifies the size of the bloom blur kernel, relative to the final output size
  22357. */
  22358. kernel: number;
  22359. /**
  22360. * Creates a new instance of @see BloomEffect
  22361. * @param scene The scene the effect belongs to.
  22362. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  22363. * @param bloomKernel The size of the kernel to be used when applying the blur.
  22364. * @param bloomWeight The the strength of bloom.
  22365. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  22366. * @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)
  22367. */
  22368. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  22369. /**
  22370. * Disposes each of the internal effects for a given camera.
  22371. * @param camera The camera to dispose the effect on.
  22372. */
  22373. disposeEffects(camera: Camera): void;
  22374. /**
  22375. * Internal
  22376. */
  22377. _updateEffects(): void;
  22378. /**
  22379. * Internal
  22380. * @returns if all the contained post processes are ready.
  22381. */
  22382. _isReady(): boolean;
  22383. }
  22384. }
  22385. declare module BABYLON {
  22386. /**
  22387. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  22388. */
  22389. class BloomMergePostProcess extends PostProcess {
  22390. /** Weight of the bloom to be added to the original input. */ weight: number;
  22391. /**
  22392. * Creates a new instance of @see BloomMergePostProcess
  22393. * @param name The name of the effect.
  22394. * @param originalFromInput Post process which's input will be used for the merge.
  22395. * @param blurred Blurred highlights post process which's output will be used.
  22396. * @param weight Weight of the bloom to be added to the original input.
  22397. * @param options The required width/height ratio to downsize to before computing the render pass.
  22398. * @param camera The camera to apply the render pass to.
  22399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22400. * @param engine The engine which the post process will be applied. (default: current engine)
  22401. * @param reusable If the post process can be reused on the same frame. (default: false)
  22402. * @param textureType Type of textures used when performing the post process. (default: 0)
  22403. * @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)
  22404. */
  22405. 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);
  22406. }
  22407. }
  22408. declare module BABYLON {
  22409. /**
  22410. * The Blur Post Process which blurs an image based on a kernel and direction.
  22411. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22412. */
  22413. class BlurPostProcess extends PostProcess {
  22414. /** The direction in which to blur the image. */ direction: Vector2;
  22415. private blockCompilation;
  22416. protected _kernel: number;
  22417. protected _idealKernel: number;
  22418. protected _packedFloat: boolean;
  22419. private _staticDefines;
  22420. /**
  22421. * Gets the length in pixels of the blur sample region
  22422. */
  22423. /**
  22424. * Sets the length in pixels of the blur sample region
  22425. */
  22426. kernel: number;
  22427. /**
  22428. * Gets wether or not the blur is unpacking/repacking floats
  22429. */
  22430. /**
  22431. * Sets wether or not the blur needs to unpack/repack floats
  22432. */
  22433. packedFloat: boolean;
  22434. /**
  22435. * Creates a new instance BlurPostProcess
  22436. * @param name The name of the effect.
  22437. * @param direction The direction in which to blur the image.
  22438. * @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.
  22439. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22440. * @param camera The camera to apply the render pass to.
  22441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22442. * @param engine The engine which the post process will be applied. (default: current engine)
  22443. * @param reusable If the post process can be reused on the same frame. (default: false)
  22444. * @param textureType Type of textures used when performing the post process. (default: 0)
  22445. * @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)
  22446. */
  22447. 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);
  22448. /**
  22449. * Updates the effect with the current post process compile time values and recompiles the shader.
  22450. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22451. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22452. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22453. * @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
  22454. * @param onCompiled Called when the shader has been compiled.
  22455. * @param onError Called if there is an error when compiling a shader.
  22456. */
  22457. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22458. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22459. /**
  22460. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22461. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22462. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22463. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22464. * The gaps between physical kernels are compensated for in the weighting of the samples
  22465. * @param idealKernel Ideal blur kernel.
  22466. * @return Nearest best kernel.
  22467. */
  22468. protected _nearestBestKernel(idealKernel: number): number;
  22469. /**
  22470. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22471. * @param x The point on the Gaussian distribution to sample.
  22472. * @return the value of the Gaussian function at x.
  22473. */
  22474. protected _gaussianWeight(x: number): number;
  22475. /**
  22476. * Generates a string that can be used as a floating point number in GLSL.
  22477. * @param x Value to print.
  22478. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22479. * @return GLSL float string.
  22480. */
  22481. protected _glslFloat(x: number, decimalFigures?: number): string;
  22482. }
  22483. }
  22484. declare module BABYLON {
  22485. /**
  22486. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  22487. */
  22488. class ChromaticAberrationPostProcess extends PostProcess {
  22489. /**
  22490. * The amount of seperation of rgb channels (default: 30)
  22491. */
  22492. aberrationAmount: number;
  22493. /**
  22494. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  22495. */
  22496. radialIntensity: number;
  22497. /**
  22498. * 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))
  22499. */
  22500. direction: Vector2;
  22501. /**
  22502. * 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))
  22503. */
  22504. centerPosition: Vector2;
  22505. /**
  22506. * Creates a new instance ChromaticAberrationPostProcess
  22507. * @param name The name of the effect.
  22508. * @param screenWidth The width of the screen to apply the effect on.
  22509. * @param screenHeight The height of the screen to apply the effect on.
  22510. * @param options The required width/height ratio to downsize to before computing the render pass.
  22511. * @param camera The camera to apply the render pass to.
  22512. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22513. * @param engine The engine which the post process will be applied. (default: current engine)
  22514. * @param reusable If the post process can be reused on the same frame. (default: false)
  22515. * @param textureType Type of textures used when performing the post process. (default: 0)
  22516. * @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)
  22517. */
  22518. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  22519. }
  22520. }
  22521. declare module BABYLON {
  22522. /**
  22523. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  22524. */
  22525. class CircleOfConfusionPostProcess extends PostProcess {
  22526. /**
  22527. * 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.
  22528. */
  22529. lensSize: number;
  22530. /**
  22531. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  22532. */
  22533. fStop: number;
  22534. /**
  22535. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  22536. */
  22537. focusDistance: number;
  22538. /**
  22539. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  22540. */
  22541. focalLength: number;
  22542. private _depthTexture;
  22543. /**
  22544. * Creates a new instance CircleOfConfusionPostProcess
  22545. * @param name The name of the effect.
  22546. * @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.
  22547. * @param options The required width/height ratio to downsize to before computing the render pass.
  22548. * @param camera The camera to apply the render pass to.
  22549. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22550. * @param engine The engine which the post process will be applied. (default: current engine)
  22551. * @param reusable If the post process can be reused on the same frame. (default: false)
  22552. * @param textureType Type of textures used when performing the post process. (default: 0)
  22553. * @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)
  22554. */
  22555. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  22556. /**
  22557. * 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.
  22558. */
  22559. depthTexture: RenderTargetTexture;
  22560. }
  22561. }
  22562. declare module BABYLON {
  22563. class ColorCorrectionPostProcess extends PostProcess {
  22564. private _colorTableTexture;
  22565. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  22566. }
  22567. }
  22568. declare module BABYLON {
  22569. /**
  22570. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  22571. * input texture to perform effects such as edge detection or sharpening
  22572. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  22573. */
  22574. class ConvolutionPostProcess extends PostProcess {
  22575. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  22576. /**
  22577. * Creates a new instance ConvolutionPostProcess
  22578. * @param name The name of the effect.
  22579. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  22580. * @param options The required width/height ratio to downsize to before computing the render pass.
  22581. * @param camera The camera to apply the render pass to.
  22582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22583. * @param engine The engine which the post process will be applied. (default: current engine)
  22584. * @param reusable If the post process can be reused on the same frame. (default: false)
  22585. * @param textureType Type of textures used when performing the post process. (default: 0)
  22586. */
  22587. 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);
  22588. /**
  22589. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  22590. */
  22591. static EdgeDetect0Kernel: number[];
  22592. /**
  22593. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  22594. */
  22595. static EdgeDetect1Kernel: number[];
  22596. /**
  22597. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  22598. */
  22599. static EdgeDetect2Kernel: number[];
  22600. /**
  22601. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  22602. */
  22603. static SharpenKernel: number[];
  22604. /**
  22605. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  22606. */
  22607. static EmbossKernel: number[];
  22608. /**
  22609. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  22610. */
  22611. static GaussianKernel: number[];
  22612. }
  22613. }
  22614. declare module BABYLON {
  22615. /**
  22616. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  22617. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  22618. * based on samples that have a large difference in distance than the center pixel.
  22619. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  22620. */
  22621. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  22622. direction: Vector2;
  22623. /**
  22624. * Creates a new instance CircleOfConfusionPostProcess
  22625. * @param name The name of the effect.
  22626. * @param scene The scene the effect belongs to.
  22627. * @param direction The direction the blur should be applied.
  22628. * @param kernel The size of the kernel used to blur.
  22629. * @param options The required width/height ratio to downsize to before computing the render pass.
  22630. * @param camera The camera to apply the render pass to.
  22631. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  22632. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  22633. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22634. * @param engine The engine which the post process will be applied. (default: current engine)
  22635. * @param reusable If the post process can be reused on the same frame. (default: false)
  22636. * @param textureType Type of textures used when performing the post process. (default: 0)
  22637. * @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)
  22638. */
  22639. 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);
  22640. }
  22641. }
  22642. declare module BABYLON {
  22643. /**
  22644. * Specifies the level of max blur that should be applied when using the depth of field effect
  22645. */
  22646. enum DepthOfFieldEffectBlurLevel {
  22647. /**
  22648. * Subtle blur
  22649. */
  22650. Low = 0,
  22651. /**
  22652. * Medium blur
  22653. */
  22654. Medium = 1,
  22655. /**
  22656. * Large blur
  22657. */
  22658. High = 2,
  22659. }
  22660. /**
  22661. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  22662. */
  22663. class DepthOfFieldEffect extends PostProcessRenderEffect {
  22664. private _circleOfConfusion;
  22665. /**
  22666. * Internal, blurs from high to low
  22667. */
  22668. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  22669. private _depthOfFieldBlurY;
  22670. private _dofMerge;
  22671. /**
  22672. * Internal post processes in depth of field effect
  22673. */
  22674. _effects: Array<PostProcess>;
  22675. /**
  22676. * The focal the length of the camera used in the effect
  22677. */
  22678. focalLength: number;
  22679. /**
  22680. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  22681. */
  22682. fStop: number;
  22683. /**
  22684. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  22685. */
  22686. focusDistance: number;
  22687. /**
  22688. * 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.
  22689. */
  22690. lensSize: number;
  22691. /**
  22692. * Creates a new instance DepthOfFieldEffect
  22693. * @param scene The scene the effect belongs to.
  22694. * @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.
  22695. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  22696. * @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)
  22697. */
  22698. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  22699. /**
  22700. * 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.
  22701. */
  22702. depthTexture: RenderTargetTexture;
  22703. /**
  22704. * Disposes each of the internal effects for a given camera.
  22705. * @param camera The camera to dispose the effect on.
  22706. */
  22707. disposeEffects(camera: Camera): void;
  22708. /**
  22709. * Internal
  22710. */
  22711. _updateEffects(): void;
  22712. /**
  22713. * Internal
  22714. * @returns if all the contained post processes are ready.
  22715. */
  22716. _isReady(): boolean;
  22717. }
  22718. }
  22719. declare module BABYLON {
  22720. /**
  22721. * Options to be set when merging outputs from the default pipeline.
  22722. */
  22723. class DepthOfFieldMergePostProcessOptions {
  22724. /**
  22725. * The original image to merge on top of
  22726. */
  22727. originalFromInput: PostProcess;
  22728. /**
  22729. * Parameters to perform the merge of the depth of field effect
  22730. */
  22731. depthOfField?: {
  22732. circleOfConfusion: PostProcess;
  22733. blurSteps: Array<PostProcess>;
  22734. };
  22735. /**
  22736. * Parameters to perform the merge of bloom effect
  22737. */
  22738. bloom?: {
  22739. blurred: PostProcess;
  22740. weight: number;
  22741. };
  22742. }
  22743. /**
  22744. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  22745. */
  22746. class DepthOfFieldMergePostProcess extends PostProcess {
  22747. private blurSteps;
  22748. /**
  22749. * Creates a new instance of DepthOfFieldMergePostProcess
  22750. * @param name The name of the effect.
  22751. * @param originalFromInput Post process which's input will be used for the merge.
  22752. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  22753. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  22754. * @param options The required width/height ratio to downsize to before computing the render pass.
  22755. * @param camera The camera to apply the render pass to.
  22756. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22757. * @param engine The engine which the post process will be applied. (default: current engine)
  22758. * @param reusable If the post process can be reused on the same frame. (default: false)
  22759. * @param textureType Type of textures used when performing the post process. (default: 0)
  22760. * @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)
  22761. */
  22762. 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);
  22763. /**
  22764. * Updates the effect with the current post process compile time values and recompiles the shader.
  22765. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22766. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22767. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22768. * @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
  22769. * @param onCompiled Called when the shader has been compiled.
  22770. * @param onError Called if there is an error when compiling a shader.
  22771. */
  22772. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22773. }
  22774. }
  22775. declare module BABYLON {
  22776. class DisplayPassPostProcess extends PostProcess {
  22777. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  22778. }
  22779. }
  22780. declare module BABYLON {
  22781. /**
  22782. * 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.
  22783. */
  22784. class ExtractHighlightsPostProcess extends PostProcess {
  22785. /**
  22786. * The luminance threshold, pixels below this value will be set to black.
  22787. */
  22788. threshold: number;
  22789. /**
  22790. * Internal
  22791. */
  22792. _exposure: number;
  22793. /**
  22794. * Post process which has the input texture to be used when performing highlight extraction
  22795. */
  22796. _inputPostProcess: Nullable<PostProcess>;
  22797. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  22798. }
  22799. }
  22800. declare module BABYLON {
  22801. class FilterPostProcess extends PostProcess {
  22802. kernelMatrix: Matrix;
  22803. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  22804. }
  22805. }
  22806. declare module BABYLON {
  22807. class FxaaPostProcess extends PostProcess {
  22808. texelWidth: number;
  22809. texelHeight: number;
  22810. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  22811. }
  22812. }
  22813. declare module BABYLON {
  22814. /**
  22815. * The GrainPostProcess adds noise to the image at mid luminance levels
  22816. */
  22817. class GrainPostProcess extends PostProcess {
  22818. /**
  22819. * The intensity of the grain added (default: 30)
  22820. */
  22821. intensity: number;
  22822. /**
  22823. * If the grain should be randomized on every frame
  22824. */
  22825. animated: boolean;
  22826. /**
  22827. * Creates a new instance of @see GrainPostProcess
  22828. * @param name The name of the effect.
  22829. * @param options The required width/height ratio to downsize to before computing the render pass.
  22830. * @param camera The camera to apply the render pass to.
  22831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22832. * @param engine The engine which the post process will be applied. (default: current engine)
  22833. * @param reusable If the post process can be reused on the same frame. (default: false)
  22834. * @param textureType Type of textures used when performing the post process. (default: 0)
  22835. * @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)
  22836. */
  22837. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  22838. }
  22839. }
  22840. declare module BABYLON {
  22841. class HighlightsPostProcess extends PostProcess {
  22842. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  22843. }
  22844. }
  22845. declare module BABYLON {
  22846. class ImageProcessingPostProcess extends PostProcess {
  22847. /**
  22848. * Default configuration related to image processing available in the PBR Material.
  22849. */
  22850. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22851. /**
  22852. * Gets the image processing configuration used either in this material.
  22853. */
  22854. /**
  22855. * Sets the Default image processing configuration used either in the this material.
  22856. *
  22857. * If sets to null, the scene one is in use.
  22858. */
  22859. imageProcessingConfiguration: ImageProcessingConfiguration;
  22860. /**
  22861. * Keep track of the image processing observer to allow dispose and replace.
  22862. */
  22863. private _imageProcessingObserver;
  22864. /**
  22865. * Attaches a new image processing configuration to the PBR Material.
  22866. * @param configuration
  22867. */
  22868. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  22869. /**
  22870. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  22871. */
  22872. /**
  22873. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  22874. */
  22875. colorCurves: Nullable<ColorCurves>;
  22876. /**
  22877. * Gets wether the color curves effect is enabled.
  22878. */
  22879. /**
  22880. * Sets wether the color curves effect is enabled.
  22881. */
  22882. colorCurvesEnabled: boolean;
  22883. /**
  22884. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  22885. */
  22886. /**
  22887. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  22888. */
  22889. colorGradingTexture: Nullable<BaseTexture>;
  22890. /**
  22891. * Gets wether the color grading effect is enabled.
  22892. */
  22893. /**
  22894. * Gets wether the color grading effect is enabled.
  22895. */
  22896. colorGradingEnabled: boolean;
  22897. /**
  22898. * Gets exposure used in the effect.
  22899. */
  22900. /**
  22901. * Sets exposure used in the effect.
  22902. */
  22903. exposure: number;
  22904. /**
  22905. * Gets wether tonemapping is enabled or not.
  22906. */
  22907. /**
  22908. * Sets wether tonemapping is enabled or not
  22909. */
  22910. toneMappingEnabled: boolean;
  22911. /**
  22912. * Gets contrast used in the effect.
  22913. */
  22914. /**
  22915. * Sets contrast used in the effect.
  22916. */
  22917. contrast: number;
  22918. /**
  22919. * Gets Vignette stretch size.
  22920. */
  22921. /**
  22922. * Sets Vignette stretch size.
  22923. */
  22924. vignetteStretch: number;
  22925. /**
  22926. * Gets Vignette centre X Offset.
  22927. */
  22928. /**
  22929. * Sets Vignette centre X Offset.
  22930. */
  22931. vignetteCentreX: number;
  22932. /**
  22933. * Gets Vignette centre Y Offset.
  22934. */
  22935. /**
  22936. * Sets Vignette centre Y Offset.
  22937. */
  22938. vignetteCentreY: number;
  22939. /**
  22940. * Gets Vignette weight or intensity of the vignette effect.
  22941. */
  22942. /**
  22943. * Sets Vignette weight or intensity of the vignette effect.
  22944. */
  22945. vignetteWeight: number;
  22946. /**
  22947. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  22948. * if vignetteEnabled is set to true.
  22949. */
  22950. /**
  22951. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  22952. * if vignetteEnabled is set to true.
  22953. */
  22954. vignetteColor: Color4;
  22955. /**
  22956. * Gets Camera field of view used by the Vignette effect.
  22957. */
  22958. /**
  22959. * Sets Camera field of view used by the Vignette effect.
  22960. */
  22961. vignetteCameraFov: number;
  22962. /**
  22963. * Gets the vignette blend mode allowing different kind of effect.
  22964. */
  22965. /**
  22966. * Sets the vignette blend mode allowing different kind of effect.
  22967. */
  22968. vignetteBlendMode: number;
  22969. /**
  22970. * Gets wether the vignette effect is enabled.
  22971. */
  22972. /**
  22973. * Sets wether the vignette effect is enabled.
  22974. */
  22975. vignetteEnabled: boolean;
  22976. private _fromLinearSpace;
  22977. /**
  22978. * Gets wether the input of the processing is in Gamma or Linear Space.
  22979. */
  22980. /**
  22981. * Sets wether the input of the processing is in Gamma or Linear Space.
  22982. */
  22983. fromLinearSpace: boolean;
  22984. /**
  22985. * Defines cache preventing GC.
  22986. */
  22987. private _defines;
  22988. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  22989. getClassName(): string;
  22990. protected _updateParameters(): void;
  22991. dispose(camera?: Camera): void;
  22992. }
  22993. }
  22994. declare module BABYLON {
  22995. class PassPostProcess extends PostProcess {
  22996. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  22997. }
  22998. }
  22999. declare module BABYLON {
  23000. type PostProcessOptions = {
  23001. width: number;
  23002. height: number;
  23003. };
  23004. /**
  23005. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23006. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23007. */
  23008. class PostProcess {
  23009. /** Name of the PostProcess. */ name: string;
  23010. /**
  23011. * Width of the texture to apply the post process on
  23012. */
  23013. width: number;
  23014. /**
  23015. * Height of the texture to apply the post process on
  23016. */
  23017. height: number;
  23018. /**
  23019. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23020. */
  23021. _outputTexture: Nullable<InternalTexture>;
  23022. /**
  23023. * Sampling mode used by the shader
  23024. * See https://doc.babylonjs.com/classes/3.1/texture
  23025. */
  23026. renderTargetSamplingMode: number;
  23027. /**
  23028. * Clear color to use when screen clearing
  23029. */
  23030. clearColor: Color4;
  23031. /**
  23032. * If the buffer needs to be cleared before applying the post process. (default: true)
  23033. * Should be set to false if shader will overwrite all previous pixels.
  23034. */
  23035. autoClear: boolean;
  23036. /**
  23037. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23038. */
  23039. alphaMode: number;
  23040. /**
  23041. * Sets the setAlphaBlendConstants of the babylon engine
  23042. */
  23043. alphaConstants: Color4;
  23044. /**
  23045. * Animations to be used for the post processing
  23046. */
  23047. animations: Animation[];
  23048. /**
  23049. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23050. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23051. */
  23052. enablePixelPerfectMode: boolean;
  23053. /**
  23054. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23055. */
  23056. scaleMode: number;
  23057. /**
  23058. * Force textures to be a power of two (default: false)
  23059. */
  23060. alwaysForcePOT: boolean;
  23061. /**
  23062. * Number of sample textures (default: 1)
  23063. */
  23064. samples: number;
  23065. /**
  23066. * Modify the scale of the post process to be the same as the viewport (default: false)
  23067. */
  23068. adaptScaleToCurrentViewport: boolean;
  23069. private _camera;
  23070. private _scene;
  23071. private _engine;
  23072. private _options;
  23073. private _reusable;
  23074. private _textureType;
  23075. /**
  23076. * Smart array of input and output textures for the post process.
  23077. */
  23078. _textures: SmartArray<InternalTexture>;
  23079. /**
  23080. * The index in _textures that corresponds to the output texture.
  23081. */
  23082. _currentRenderTextureInd: number;
  23083. private _effect;
  23084. private _samplers;
  23085. private _fragmentUrl;
  23086. private _vertexUrl;
  23087. private _parameters;
  23088. private _scaleRatio;
  23089. protected _indexParameters: any;
  23090. private _shareOutputWithPostProcess;
  23091. private _texelSize;
  23092. private _forcedOutputTexture;
  23093. /**
  23094. * An event triggered when the postprocess is activated.
  23095. */
  23096. onActivateObservable: Observable<Camera>;
  23097. private _onActivateObserver;
  23098. /**
  23099. * A function that is added to the onActivateObservable
  23100. */
  23101. onActivate: Nullable<(camera: Camera) => void>;
  23102. /**
  23103. * An event triggered when the postprocess changes its size.
  23104. */
  23105. onSizeChangedObservable: Observable<PostProcess>;
  23106. private _onSizeChangedObserver;
  23107. /**
  23108. * A function that is added to the onSizeChangedObservable
  23109. */
  23110. onSizeChanged: (postProcess: PostProcess) => void;
  23111. /**
  23112. * An event triggered when the postprocess applies its effect.
  23113. */
  23114. onApplyObservable: Observable<Effect>;
  23115. private _onApplyObserver;
  23116. /**
  23117. * A function that is added to the onApplyObservable
  23118. */
  23119. onApply: (effect: Effect) => void;
  23120. /**
  23121. * An event triggered before rendering the postprocess
  23122. */
  23123. onBeforeRenderObservable: Observable<Effect>;
  23124. private _onBeforeRenderObserver;
  23125. /**
  23126. * A function that is added to the onBeforeRenderObservable
  23127. */
  23128. onBeforeRender: (effect: Effect) => void;
  23129. /**
  23130. * An event triggered after rendering the postprocess
  23131. */
  23132. onAfterRenderObservable: Observable<Effect>;
  23133. private _onAfterRenderObserver;
  23134. /**
  23135. * A function that is added to the onAfterRenderObservable
  23136. */
  23137. onAfterRender: (efect: Effect) => void;
  23138. /**
  23139. * 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
  23140. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23141. */
  23142. inputTexture: InternalTexture;
  23143. /**
  23144. * Gets the camera which post process is applied to.
  23145. * @returns The camera the post process is applied to.
  23146. */
  23147. getCamera(): Camera;
  23148. /**
  23149. * Gets the texel size of the postprocess.
  23150. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23151. */
  23152. readonly texelSize: Vector2;
  23153. /**
  23154. * Creates a new instance PostProcess
  23155. * @param name The name of the PostProcess.
  23156. * @param fragmentUrl The url of the fragment shader to be used.
  23157. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23158. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23159. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23160. * @param camera The camera to apply the render pass to.
  23161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23162. * @param engine The engine which the post process will be applied. (default: current engine)
  23163. * @param reusable If the post process can be reused on the same frame. (default: false)
  23164. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23165. * @param textureType Type of textures used when performing the post process. (default: 0)
  23166. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23167. * @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
  23168. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23169. */
  23170. 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);
  23171. /**
  23172. * Gets the engine which this post process belongs to.
  23173. * @returns The engine the post process was enabled with.
  23174. */
  23175. getEngine(): Engine;
  23176. /**
  23177. * The effect that is created when initializing the post process.
  23178. * @returns The created effect corrisponding the the postprocess.
  23179. */
  23180. getEffect(): Effect;
  23181. /**
  23182. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23183. * @param postProcess The post process to share the output with.
  23184. * @returns This post process.
  23185. */
  23186. shareOutputWith(postProcess: PostProcess): PostProcess;
  23187. /**
  23188. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23189. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23190. */
  23191. useOwnOutput(): void;
  23192. /**
  23193. * Updates the effect with the current post process compile time values and recompiles the shader.
  23194. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23195. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23196. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23197. * @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
  23198. * @param onCompiled Called when the shader has been compiled.
  23199. * @param onError Called if there is an error when compiling a shader.
  23200. */
  23201. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23202. /**
  23203. * The post process is reusable if it can be used multiple times within one frame.
  23204. * @returns If the post process is reusable
  23205. */
  23206. isReusable(): boolean;
  23207. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23208. markTextureDirty(): void;
  23209. /**
  23210. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23211. * 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.
  23212. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23213. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23214. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23215. * @returns The target texture that was bound to be written to.
  23216. */
  23217. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23218. /**
  23219. * If the post process is supported.
  23220. */
  23221. readonly isSupported: boolean;
  23222. /**
  23223. * The aspect ratio of the output texture.
  23224. */
  23225. readonly aspectRatio: number;
  23226. /**
  23227. * Get a value indicating if the post-process is ready to be used
  23228. * @returns true if the post-process is ready (shader is compiled)
  23229. */
  23230. isReady(): boolean;
  23231. /**
  23232. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23233. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  23234. */
  23235. apply(): Nullable<Effect>;
  23236. private _disposeTextures();
  23237. /**
  23238. * Disposes the post process.
  23239. * @param camera The camera to dispose the post process on.
  23240. */
  23241. dispose(camera?: Camera): void;
  23242. }
  23243. }
  23244. declare module BABYLON {
  23245. /**
  23246. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23247. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23248. */
  23249. class PostProcessManager {
  23250. private _scene;
  23251. private _indexBuffer;
  23252. private _vertexBuffers;
  23253. /**
  23254. * Creates a new instance PostProcess
  23255. * @param scene The scene that the post process is associated with.
  23256. */
  23257. constructor(scene: Scene);
  23258. private _prepareBuffers();
  23259. private _buildIndexBuffer();
  23260. /**
  23261. * Rebuilds the vertex buffers of the manager.
  23262. */
  23263. _rebuild(): void;
  23264. /**
  23265. * Prepares a frame to be run through a post process.
  23266. * @param sourceTexture The input texture to the post procesess. (default: null)
  23267. * @param postProcesses An array of post processes to be run. (default: null)
  23268. * @returns True if the post processes were able to be run.
  23269. */
  23270. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23271. /**
  23272. * Manually render a set of post processes to a texture.
  23273. * @param postProcesses An array of post processes to be run.
  23274. * @param targetTexture The target texture to render to.
  23275. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23276. */
  23277. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  23278. /**
  23279. * Finalize the result of the output of the postprocesses.
  23280. * @param doNotPresent If true the result will not be displayed to the screen.
  23281. * @param targetTexture The target texture to render to.
  23282. * @param faceIndex The index of the face to bind the target texture to.
  23283. * @param postProcesses The array of post processes to render.
  23284. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23285. */
  23286. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23287. /**
  23288. * Disposes of the post process manager.
  23289. */
  23290. dispose(): void;
  23291. }
  23292. }
  23293. declare module BABYLON {
  23294. class RefractionPostProcess extends PostProcess {
  23295. color: Color3;
  23296. depth: number;
  23297. colorLevel: number;
  23298. private _refTexture;
  23299. private _ownRefractionTexture;
  23300. /**
  23301. * Gets or sets the refraction texture
  23302. * Please note that you are responsible for disposing the texture if you set it manually
  23303. */
  23304. refractionTexture: Texture;
  23305. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  23306. dispose(camera: Camera): void;
  23307. }
  23308. }
  23309. declare module BABYLON {
  23310. /**
  23311. * The SharpenPostProcess applies a sharpen kernel to every pixel
  23312. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  23313. */
  23314. class SharpenPostProcess extends PostProcess {
  23315. /**
  23316. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  23317. */
  23318. colorAmount: number;
  23319. /**
  23320. * How much sharpness should be applied (default: 0.3)
  23321. */
  23322. edgeAmount: number;
  23323. /**
  23324. * Creates a new instance ConvolutionPostProcess
  23325. * @param name The name of the effect.
  23326. * @param options The required width/height ratio to downsize to before computing the render pass.
  23327. * @param camera The camera to apply the render pass to.
  23328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23329. * @param engine The engine which the post process will be applied. (default: current engine)
  23330. * @param reusable If the post process can be reused on the same frame. (default: false)
  23331. * @param textureType Type of textures used when performing the post process. (default: 0)
  23332. * @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)
  23333. */
  23334. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  23335. }
  23336. }
  23337. declare module BABYLON {
  23338. class StereoscopicInterlacePostProcess extends PostProcess {
  23339. private _stepSize;
  23340. private _passedProcess;
  23341. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  23342. }
  23343. }
  23344. declare module BABYLON {
  23345. enum TonemappingOperator {
  23346. Hable = 0,
  23347. Reinhard = 1,
  23348. HejiDawson = 2,
  23349. Photographic = 3,
  23350. }
  23351. class TonemapPostProcess extends PostProcess {
  23352. private _operator;
  23353. exposureAdjustment: number;
  23354. constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  23355. }
  23356. }
  23357. declare module BABYLON {
  23358. class VolumetricLightScatteringPostProcess extends PostProcess {
  23359. private _volumetricLightScatteringPass;
  23360. private _volumetricLightScatteringRTT;
  23361. private _viewPort;
  23362. private _screenCoordinates;
  23363. private _cachedDefines;
  23364. /**
  23365. * If not undefined, the mesh position is computed from the attached node position
  23366. */
  23367. attachedNode: {
  23368. position: Vector3;
  23369. };
  23370. /**
  23371. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  23372. */
  23373. customMeshPosition: Vector3;
  23374. /**
  23375. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  23376. */
  23377. useCustomMeshPosition: boolean;
  23378. /**
  23379. * If the post-process should inverse the light scattering direction
  23380. */
  23381. invert: boolean;
  23382. /**
  23383. * The internal mesh used by the post-process
  23384. */
  23385. mesh: Mesh;
  23386. useDiffuseColor: boolean;
  23387. /**
  23388. * Array containing the excluded meshes not rendered in the internal pass
  23389. */
  23390. excludedMeshes: AbstractMesh[];
  23391. /**
  23392. * Controls the overall intensity of the post-process
  23393. */
  23394. exposure: number;
  23395. /**
  23396. * Dissipates each sample's contribution in range [0, 1]
  23397. */
  23398. decay: number;
  23399. /**
  23400. * Controls the overall intensity of each sample
  23401. */
  23402. weight: number;
  23403. /**
  23404. * Controls the density of each sample
  23405. */
  23406. density: number;
  23407. /**
  23408. * @constructor
  23409. * @param {string} name - The post-process name
  23410. * @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)
  23411. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  23412. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  23413. * @param {number} samples - The post-process quality, default 100
  23414. * @param {number} samplingMode - The post-process filtering mode
  23415. * @param {BABYLON.Engine} engine - The babylon engine
  23416. * @param {boolean} reusable - If the post-process is reusable
  23417. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  23418. */
  23419. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  23420. getClassName(): string;
  23421. private _isReady(subMesh, useInstances);
  23422. /**
  23423. * Sets the new light position for light scattering effect
  23424. * @param {BABYLON.Vector3} The new custom light position
  23425. */
  23426. setCustomMeshPosition(position: Vector3): void;
  23427. /**
  23428. * Returns the light position for light scattering effect
  23429. * @return {BABYLON.Vector3} The custom light position
  23430. */
  23431. getCustomMeshPosition(): Vector3;
  23432. /**
  23433. * Disposes the internal assets and detaches the post-process from the camera
  23434. */
  23435. dispose(camera: Camera): void;
  23436. /**
  23437. * Returns the render target texture used by the post-process
  23438. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  23439. */
  23440. getPass(): RenderTargetTexture;
  23441. private _meshExcluded(mesh);
  23442. private _createPass(scene, ratio);
  23443. private _updateMeshScreenCoordinates(scene);
  23444. /**
  23445. * Creates a default mesh for the Volumeric Light Scattering post-process
  23446. * @param {string} The mesh name
  23447. * @param {BABYLON.Scene} The scene where to create the mesh
  23448. * @return {BABYLON.Mesh} the default mesh
  23449. */
  23450. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  23451. }
  23452. }
  23453. declare module BABYLON {
  23454. class VRDistortionCorrectionPostProcess extends PostProcess {
  23455. private _isRightEye;
  23456. private _distortionFactors;
  23457. private _postProcessScaleFactor;
  23458. private _lensCenterOffset;
  23459. private _scaleIn;
  23460. private _scaleFactor;
  23461. private _lensCenter;
  23462. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  23463. }
  23464. }
  23465. declare module BABYLON {
  23466. class BoundingBoxRenderer {
  23467. frontColor: Color3;
  23468. backColor: Color3;
  23469. showBackLines: boolean;
  23470. renderList: SmartArray<BoundingBox>;
  23471. private _scene;
  23472. private _colorShader;
  23473. private _vertexBuffers;
  23474. private _indexBuffer;
  23475. constructor(scene: Scene);
  23476. private _prepareRessources();
  23477. private _createIndexBuffer();
  23478. _rebuild(): void;
  23479. reset(): void;
  23480. render(): void;
  23481. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  23482. dispose(): void;
  23483. }
  23484. }
  23485. declare module BABYLON {
  23486. /**
  23487. * This represents a depth renderer in Babylon.
  23488. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  23489. */
  23490. class DepthRenderer {
  23491. private _scene;
  23492. private _depthMap;
  23493. private _effect;
  23494. private _cachedDefines;
  23495. private _camera;
  23496. /**
  23497. * Instantiates a depth renderer
  23498. * @param scene The scene the renderer belongs to
  23499. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  23500. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  23501. */
  23502. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  23503. /**
  23504. * Creates the depth rendering effect and checks if the effect is ready.
  23505. * @param subMesh The submesh to be used to render the depth map of
  23506. * @param useInstances If multiple world instances should be used
  23507. * @returns if the depth renderer is ready to render the depth map
  23508. */
  23509. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23510. /**
  23511. * Gets the texture which the depth map will be written to.
  23512. * @returns The depth map texture
  23513. */
  23514. getDepthMap(): RenderTargetTexture;
  23515. /**
  23516. * Disposes of the depth renderer.
  23517. */
  23518. dispose(): void;
  23519. }
  23520. }
  23521. declare module BABYLON {
  23522. class EdgesRenderer {
  23523. edgesWidthScalerForOrthographic: number;
  23524. edgesWidthScalerForPerspective: number;
  23525. private _source;
  23526. private _linesPositions;
  23527. private _linesNormals;
  23528. private _linesIndices;
  23529. private _epsilon;
  23530. private _indicesCount;
  23531. private _lineShader;
  23532. private _ib;
  23533. private _buffers;
  23534. private _checkVerticesInsteadOfIndices;
  23535. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  23536. private _prepareRessources();
  23537. _rebuild(): void;
  23538. dispose(): void;
  23539. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  23540. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  23541. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  23542. _generateEdgesLines(): void;
  23543. render(): void;
  23544. }
  23545. }
  23546. declare module BABYLON {
  23547. /**
  23548. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  23549. */
  23550. class GeometryBufferRenderer {
  23551. private _scene;
  23552. private _multiRenderTarget;
  23553. private _ratio;
  23554. private _enablePosition;
  23555. protected _effect: Effect;
  23556. protected _cachedDefines: string;
  23557. /**
  23558. * Set the render list (meshes to be rendered) used in the G buffer.
  23559. */
  23560. renderList: Mesh[];
  23561. /**
  23562. * Gets wether or not G buffer are supported by the running hardware.
  23563. * This requires draw buffer supports
  23564. */
  23565. readonly isSupported: boolean;
  23566. /**
  23567. * Gets wether or not position are enabled for the G buffer.
  23568. */
  23569. /**
  23570. * Sets wether or not position are enabled for the G buffer.
  23571. */
  23572. enablePosition: boolean;
  23573. /**
  23574. * Gets the scene associated with the buffer.
  23575. */
  23576. readonly scene: Scene;
  23577. /**
  23578. * Gets the ratio used by the buffer during its creation.
  23579. * How big is the buffer related to the main canvas.
  23580. */
  23581. readonly ratio: number;
  23582. /**
  23583. * Creates a new G Buffer for the scene
  23584. * @param scene The scene the buffer belongs to
  23585. * @param ratio How big is the buffer related to the main canvas.
  23586. */
  23587. constructor(scene: Scene, ratio?: number);
  23588. /**
  23589. * Checks wether everything is ready to render a submesh to the G buffer.
  23590. * @param subMesh the submesh to check readiness for
  23591. * @param useInstances is the mesh drawn using instance or not
  23592. * @returns true if ready otherwise false
  23593. */
  23594. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23595. /**
  23596. * Gets the current underlying G Buffer.
  23597. * @returns the buffer
  23598. */
  23599. getGBuffer(): MultiRenderTarget;
  23600. /**
  23601. * Gets the number of samples used to render the buffer (anti aliasing).
  23602. */
  23603. /**
  23604. * Sets the number of samples used to render the buffer (anti aliasing).
  23605. */
  23606. samples: number;
  23607. /**
  23608. * Disposes the renderer and frees up associated resources.
  23609. */
  23610. dispose(): void;
  23611. protected _createRenderTargets(): void;
  23612. }
  23613. }
  23614. declare module BABYLON {
  23615. class OutlineRenderer {
  23616. private _scene;
  23617. private _effect;
  23618. private _cachedDefines;
  23619. zOffset: number;
  23620. constructor(scene: Scene);
  23621. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  23622. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23623. }
  23624. }
  23625. declare module BABYLON {
  23626. class RenderingGroup {
  23627. index: number;
  23628. private _scene;
  23629. private _opaqueSubMeshes;
  23630. private _transparentSubMeshes;
  23631. private _alphaTestSubMeshes;
  23632. private _depthOnlySubMeshes;
  23633. private _particleSystems;
  23634. private _spriteManagers;
  23635. private _opaqueSortCompareFn;
  23636. private _alphaTestSortCompareFn;
  23637. private _transparentSortCompareFn;
  23638. private _renderOpaque;
  23639. private _renderAlphaTest;
  23640. private _renderTransparent;
  23641. private _edgesRenderers;
  23642. onBeforeTransparentRendering: () => void;
  23643. /**
  23644. * Set the opaque sort comparison function.
  23645. * If null the sub meshes will be render in the order they were created
  23646. */
  23647. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  23648. /**
  23649. * Set the alpha test sort comparison function.
  23650. * If null the sub meshes will be render in the order they were created
  23651. */
  23652. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  23653. /**
  23654. * Set the transparent sort comparison function.
  23655. * If null the sub meshes will be render in the order they were created
  23656. */
  23657. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  23658. /**
  23659. * Creates a new rendering group.
  23660. * @param index The rendering group index
  23661. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  23662. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  23663. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  23664. */
  23665. 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>);
  23666. /**
  23667. * Render all the sub meshes contained in the group.
  23668. * @param customRenderFunction Used to override the default render behaviour of the group.
  23669. * @returns true if rendered some submeshes.
  23670. */
  23671. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  23672. /**
  23673. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  23674. * @param subMeshes The submeshes to render
  23675. */
  23676. private renderOpaqueSorted(subMeshes);
  23677. /**
  23678. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  23679. * @param subMeshes The submeshes to render
  23680. */
  23681. private renderAlphaTestSorted(subMeshes);
  23682. /**
  23683. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  23684. * @param subMeshes The submeshes to render
  23685. */
  23686. private renderTransparentSorted(subMeshes);
  23687. /**
  23688. * Renders the submeshes in a specified order.
  23689. * @param subMeshes The submeshes to sort before render
  23690. * @param sortCompareFn The comparison function use to sort
  23691. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  23692. * @param transparent Specifies to activate blending if true
  23693. */
  23694. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  23695. /**
  23696. * Renders the submeshes in the order they were dispatched (no sort applied).
  23697. * @param subMeshes The submeshes to render
  23698. */
  23699. private static renderUnsorted(subMeshes);
  23700. /**
  23701. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  23702. * are rendered back to front if in the same alpha index.
  23703. *
  23704. * @param a The first submesh
  23705. * @param b The second submesh
  23706. * @returns The result of the comparison
  23707. */
  23708. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  23709. /**
  23710. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  23711. * are rendered back to front.
  23712. *
  23713. * @param a The first submesh
  23714. * @param b The second submesh
  23715. * @returns The result of the comparison
  23716. */
  23717. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  23718. /**
  23719. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  23720. * are rendered front to back (prevent overdraw).
  23721. *
  23722. * @param a The first submesh
  23723. * @param b The second submesh
  23724. * @returns The result of the comparison
  23725. */
  23726. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  23727. /**
  23728. * Resets the different lists of submeshes to prepare a new frame.
  23729. */
  23730. prepare(): void;
  23731. dispose(): void;
  23732. /**
  23733. * Inserts the submesh in its correct queue depending on its material.
  23734. * @param subMesh The submesh to dispatch
  23735. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  23736. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  23737. */
  23738. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  23739. dispatchSprites(spriteManager: SpriteManager): void;
  23740. dispatchParticles(particleSystem: IParticleSystem): void;
  23741. private _renderParticles(activeMeshes);
  23742. private _renderSprites();
  23743. }
  23744. }
  23745. declare module BABYLON {
  23746. class RenderingManager {
  23747. /**
  23748. * The max id used for rendering groups (not included)
  23749. */
  23750. static MAX_RENDERINGGROUPS: number;
  23751. /**
  23752. * The min id used for rendering groups (included)
  23753. */
  23754. static MIN_RENDERINGGROUPS: number;
  23755. /**
  23756. * Used to globally prevent autoclearing scenes.
  23757. */
  23758. static AUTOCLEAR: boolean;
  23759. private _scene;
  23760. private _renderingGroups;
  23761. private _depthStencilBufferAlreadyCleaned;
  23762. private _autoClearDepthStencil;
  23763. private _customOpaqueSortCompareFn;
  23764. private _customAlphaTestSortCompareFn;
  23765. private _customTransparentSortCompareFn;
  23766. private _renderinGroupInfo;
  23767. constructor(scene: Scene);
  23768. private _clearDepthStencilBuffer(depth?, stencil?);
  23769. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  23770. reset(): void;
  23771. dispose(): void;
  23772. /**
  23773. * Clear the info related to rendering groups preventing retention points during dispose.
  23774. */
  23775. freeRenderingGroups(): void;
  23776. private _prepareRenderingGroup(renderingGroupId);
  23777. dispatchSprites(spriteManager: SpriteManager): void;
  23778. dispatchParticles(particleSystem: IParticleSystem): void;
  23779. /**
  23780. * @param subMesh The submesh to dispatch
  23781. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  23782. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  23783. */
  23784. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  23785. /**
  23786. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23787. * This allowed control for front to back rendering or reversly depending of the special needs.
  23788. *
  23789. * @param renderingGroupId The rendering group id corresponding to its index
  23790. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23791. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23792. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23793. */
  23794. 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;
  23795. /**
  23796. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23797. *
  23798. * @param renderingGroupId The rendering group id corresponding to its index
  23799. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23800. * @param depth Automatically clears depth between groups if true and autoClear is true.
  23801. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  23802. */
  23803. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  23804. }
  23805. }
  23806. declare module BABYLON {
  23807. class Sprite {
  23808. name: string;
  23809. position: Vector3;
  23810. color: Color4;
  23811. width: number;
  23812. height: number;
  23813. angle: number;
  23814. cellIndex: number;
  23815. invertU: number;
  23816. invertV: number;
  23817. disposeWhenFinishedAnimating: boolean;
  23818. animations: Animation[];
  23819. isPickable: boolean;
  23820. actionManager: ActionManager;
  23821. private _animationStarted;
  23822. private _loopAnimation;
  23823. private _fromIndex;
  23824. private _toIndex;
  23825. private _delay;
  23826. private _direction;
  23827. private _manager;
  23828. private _time;
  23829. private _onAnimationEnd;
  23830. size: number;
  23831. constructor(name: string, manager: SpriteManager);
  23832. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  23833. stopAnimation(): void;
  23834. _animate(deltaTime: number): void;
  23835. dispose(): void;
  23836. }
  23837. }
  23838. declare module BABYLON {
  23839. class SpriteManager {
  23840. name: string;
  23841. sprites: Sprite[];
  23842. renderingGroupId: number;
  23843. layerMask: number;
  23844. fogEnabled: boolean;
  23845. isPickable: boolean;
  23846. cellWidth: number;
  23847. cellHeight: number;
  23848. /**
  23849. * An event triggered when the manager is disposed.
  23850. */
  23851. onDisposeObservable: Observable<SpriteManager>;
  23852. private _onDisposeObserver;
  23853. onDispose: () => void;
  23854. private _capacity;
  23855. private _spriteTexture;
  23856. private _epsilon;
  23857. private _scene;
  23858. private _vertexData;
  23859. private _buffer;
  23860. private _vertexBuffers;
  23861. private _indexBuffer;
  23862. private _effectBase;
  23863. private _effectFog;
  23864. texture: Texture;
  23865. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  23866. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  23867. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23868. render(): void;
  23869. dispose(): void;
  23870. }
  23871. }
  23872. declare module BABYLON {
  23873. class _AlphaState {
  23874. private _isAlphaBlendDirty;
  23875. private _isBlendFunctionParametersDirty;
  23876. private _isBlendEquationParametersDirty;
  23877. private _isBlendConstantsDirty;
  23878. private _alphaBlend;
  23879. private _blendFunctionParameters;
  23880. private _blendEquationParameters;
  23881. private _blendConstants;
  23882. /**
  23883. * Initializes the state.
  23884. */
  23885. constructor();
  23886. readonly isDirty: boolean;
  23887. alphaBlend: boolean;
  23888. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  23889. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  23890. setAlphaEquationParameters(rgb: number, alpha: number): void;
  23891. reset(): void;
  23892. apply(gl: WebGLRenderingContext): void;
  23893. }
  23894. }
  23895. declare module BABYLON {
  23896. class _DepthCullingState {
  23897. private _isDepthTestDirty;
  23898. private _isDepthMaskDirty;
  23899. private _isDepthFuncDirty;
  23900. private _isCullFaceDirty;
  23901. private _isCullDirty;
  23902. private _isZOffsetDirty;
  23903. private _isFrontFaceDirty;
  23904. private _depthTest;
  23905. private _depthMask;
  23906. private _depthFunc;
  23907. private _cull;
  23908. private _cullFace;
  23909. private _zOffset;
  23910. private _frontFace;
  23911. /**
  23912. * Initializes the state.
  23913. */
  23914. constructor();
  23915. readonly isDirty: boolean;
  23916. zOffset: number;
  23917. cullFace: Nullable<number>;
  23918. cull: Nullable<boolean>;
  23919. depthFunc: Nullable<number>;
  23920. depthMask: boolean;
  23921. depthTest: boolean;
  23922. frontFace: Nullable<number>;
  23923. reset(): void;
  23924. apply(gl: WebGLRenderingContext): void;
  23925. }
  23926. }
  23927. declare module BABYLON {
  23928. class _StencilState {
  23929. private _isStencilTestDirty;
  23930. private _isStencilMaskDirty;
  23931. private _isStencilFuncDirty;
  23932. private _isStencilOpDirty;
  23933. private _stencilTest;
  23934. private _stencilMask;
  23935. private _stencilFunc;
  23936. private _stencilFuncRef;
  23937. private _stencilFuncMask;
  23938. private _stencilOpStencilFail;
  23939. private _stencilOpDepthFail;
  23940. private _stencilOpStencilDepthPass;
  23941. readonly isDirty: boolean;
  23942. stencilFunc: number;
  23943. stencilFuncRef: number;
  23944. stencilFuncMask: number;
  23945. stencilOpStencilFail: number;
  23946. stencilOpDepthFail: number;
  23947. stencilOpStencilDepthPass: number;
  23948. stencilMask: number;
  23949. stencilTest: boolean;
  23950. constructor();
  23951. reset(): void;
  23952. apply(gl: WebGLRenderingContext): void;
  23953. }
  23954. }
  23955. declare module BABYLON {
  23956. class AndOrNotEvaluator {
  23957. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  23958. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  23959. private static _SimplifyNegation(booleanString);
  23960. }
  23961. }
  23962. declare module BABYLON {
  23963. /**
  23964. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  23965. */
  23966. enum AssetTaskState {
  23967. /**
  23968. * Initialization
  23969. */
  23970. INIT = 0,
  23971. /**
  23972. * Running
  23973. */
  23974. RUNNING = 1,
  23975. /**
  23976. * Done
  23977. */
  23978. DONE = 2,
  23979. /**
  23980. * Error
  23981. */
  23982. ERROR = 3,
  23983. }
  23984. /**
  23985. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  23986. */
  23987. abstract class AbstractAssetTask {
  23988. /**
  23989. * Task name
  23990. */ name: string;
  23991. /**
  23992. * Callback called when the task is successful
  23993. */
  23994. onSuccess: (task: any) => void;
  23995. /**
  23996. * Callback called when the task is not successful
  23997. */
  23998. onError: (task: any, message?: string, exception?: any) => void;
  23999. /**
  24000. * Creates a new {BABYLON.AssetsManager}
  24001. * @param name defines the name of the task
  24002. */
  24003. constructor(
  24004. /**
  24005. * Task name
  24006. */ name: string);
  24007. private _isCompleted;
  24008. private _taskState;
  24009. private _errorObject;
  24010. /**
  24011. * Get if the task is completed
  24012. */
  24013. readonly isCompleted: boolean;
  24014. /**
  24015. * Gets the current state of the task
  24016. */
  24017. readonly taskState: AssetTaskState;
  24018. /**
  24019. * Gets the current error object (if task is in error)
  24020. */
  24021. readonly errorObject: {
  24022. message?: string;
  24023. exception?: any;
  24024. };
  24025. /**
  24026. * Internal only
  24027. * @ignore
  24028. */
  24029. _setErrorObject(message?: string, exception?: any): void;
  24030. /**
  24031. * Execute the current task
  24032. * @param scene defines the scene where you want your assets to be loaded
  24033. * @param onSuccess is a callback called when the task is successfully executed
  24034. * @param onError is a callback called if an error occurs
  24035. */
  24036. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  24037. /**
  24038. * Execute the current task
  24039. * @param scene defines the scene where you want your assets to be loaded
  24040. * @param onSuccess is a callback called when the task is successfully executed
  24041. * @param onError is a callback called if an error occurs
  24042. */
  24043. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  24044. private onErrorCallback(onError, message?, exception?);
  24045. private onDoneCallback(onSuccess, onError);
  24046. }
  24047. /**
  24048. * Define the interface used by progress events raised during assets loading
  24049. */
  24050. interface IAssetsProgressEvent {
  24051. /**
  24052. * Defines the number of remaining tasks to process
  24053. */
  24054. remainingCount: number;
  24055. /**
  24056. * Defines the total number of tasks
  24057. */
  24058. totalCount: number;
  24059. /**
  24060. * Defines the task that was just processed
  24061. */
  24062. task: AbstractAssetTask;
  24063. }
  24064. /**
  24065. * Class used to share progress information about assets loading
  24066. */
  24067. class AssetsProgressEvent implements IAssetsProgressEvent {
  24068. /**
  24069. * Defines the number of remaining tasks to process
  24070. */
  24071. remainingCount: number;
  24072. /**
  24073. * Defines the total number of tasks
  24074. */
  24075. totalCount: number;
  24076. /**
  24077. * Defines the task that was just processed
  24078. */
  24079. task: AbstractAssetTask;
  24080. /**
  24081. * Creates a {BABYLON.AssetsProgressEvent}
  24082. * @param remainingCount defines the number of remaining tasks to process
  24083. * @param totalCount defines the total number of tasks
  24084. * @param task defines the task that was just processed
  24085. */
  24086. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  24087. }
  24088. /**
  24089. * Define a task used by {BABYLON.AssetsManager} to load meshes
  24090. */
  24091. class MeshAssetTask extends AbstractAssetTask {
  24092. /**
  24093. * Defines the name of the task
  24094. */
  24095. name: string;
  24096. /**
  24097. * Defines the list of mesh's names you want to load
  24098. */
  24099. meshesNames: any;
  24100. /**
  24101. * Defines the root url to use as a base to load your meshes and associated resources
  24102. */
  24103. rootUrl: string;
  24104. /**
  24105. * Defines the filename of the scene to load from
  24106. */
  24107. sceneFilename: string;
  24108. /**
  24109. * Gets the list of loaded meshes
  24110. */
  24111. loadedMeshes: Array<AbstractMesh>;
  24112. /**
  24113. * Gets the list of loaded particle systems
  24114. */
  24115. loadedParticleSystems: Array<ParticleSystem>;
  24116. /**
  24117. * Gets the list of loaded skeletons
  24118. */
  24119. loadedSkeletons: Array<Skeleton>;
  24120. /**
  24121. * Callback called when the task is successful
  24122. */
  24123. onSuccess: (task: MeshAssetTask) => void;
  24124. /**
  24125. * Callback called when the task is successful
  24126. */
  24127. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  24128. /**
  24129. * Creates a new {BABYLON.MeshAssetTask}
  24130. * @param name defines the name of the task
  24131. * @param meshesNames defines the list of mesh's names you want to load
  24132. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  24133. * @param sceneFilename defines the filename of the scene to load from
  24134. */
  24135. constructor(
  24136. /**
  24137. * Defines the name of the task
  24138. */
  24139. name: string,
  24140. /**
  24141. * Defines the list of mesh's names you want to load
  24142. */
  24143. meshesNames: any,
  24144. /**
  24145. * Defines the root url to use as a base to load your meshes and associated resources
  24146. */
  24147. rootUrl: string,
  24148. /**
  24149. * Defines the filename of the scene to load from
  24150. */
  24151. sceneFilename: string);
  24152. /**
  24153. * Execute the current task
  24154. * @param scene defines the scene where you want your assets to be loaded
  24155. * @param onSuccess is a callback called when the task is successfully executed
  24156. * @param onError is a callback called if an error occurs
  24157. */
  24158. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  24159. }
  24160. /**
  24161. * Define a task used by {BABYLON.AssetsManager} to load text content
  24162. */
  24163. class TextFileAssetTask extends AbstractAssetTask {
  24164. /**
  24165. * Defines the name of the task
  24166. */
  24167. name: string;
  24168. /**
  24169. * Defines the location of the file to load
  24170. */
  24171. url: string;
  24172. /**
  24173. * Gets the loaded text string
  24174. */
  24175. text: string;
  24176. /**
  24177. * Callback called when the task is successful
  24178. */
  24179. onSuccess: (task: TextFileAssetTask) => void;
  24180. /**
  24181. * Callback called when the task is successful
  24182. */
  24183. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  24184. /**
  24185. * Creates a new TextFileAssetTask object
  24186. * @param name defines the name of the task
  24187. * @param url defines the location of the file to load
  24188. */
  24189. constructor(
  24190. /**
  24191. * Defines the name of the task
  24192. */
  24193. name: string,
  24194. /**
  24195. * Defines the location of the file to load
  24196. */
  24197. url: string);
  24198. /**
  24199. * Execute the current task
  24200. * @param scene defines the scene where you want your assets to be loaded
  24201. * @param onSuccess is a callback called when the task is successfully executed
  24202. * @param onError is a callback called if an error occurs
  24203. */
  24204. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  24205. }
  24206. /**
  24207. * Define a task used by {BABYLON.AssetsManager} to load binary data
  24208. */
  24209. class BinaryFileAssetTask extends AbstractAssetTask {
  24210. /**
  24211. * Defines the name of the task
  24212. */
  24213. name: string;
  24214. /**
  24215. * Defines the location of the file to load
  24216. */
  24217. url: string;
  24218. /**
  24219. * Gets the lodaded data (as an array buffer)
  24220. */
  24221. data: ArrayBuffer;
  24222. /**
  24223. * Callback called when the task is successful
  24224. */
  24225. onSuccess: (task: BinaryFileAssetTask) => void;
  24226. /**
  24227. * Callback called when the task is successful
  24228. */
  24229. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  24230. /**
  24231. * Creates a new BinaryFileAssetTask object
  24232. * @param name defines the name of the new task
  24233. * @param url defines the location of the file to load
  24234. */
  24235. constructor(
  24236. /**
  24237. * Defines the name of the task
  24238. */
  24239. name: string,
  24240. /**
  24241. * Defines the location of the file to load
  24242. */
  24243. url: string);
  24244. /**
  24245. * Execute the current task
  24246. * @param scene defines the scene where you want your assets to be loaded
  24247. * @param onSuccess is a callback called when the task is successfully executed
  24248. * @param onError is a callback called if an error occurs
  24249. */
  24250. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  24251. }
  24252. /**
  24253. * Define a task used by {BABYLON.AssetsManager} to load images
  24254. */
  24255. class ImageAssetTask extends AbstractAssetTask {
  24256. /**
  24257. * Defines the name of the task
  24258. */
  24259. name: string;
  24260. /**
  24261. * Defines the location of the image to load
  24262. */
  24263. url: string;
  24264. /**
  24265. * Gets the loaded images
  24266. */
  24267. image: HTMLImageElement;
  24268. /**
  24269. * Callback called when the task is successful
  24270. */
  24271. onSuccess: (task: ImageAssetTask) => void;
  24272. /**
  24273. * Callback called when the task is successful
  24274. */
  24275. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  24276. /**
  24277. * Creates a new ImageAssetTask
  24278. * @param name defines the name of the task
  24279. * @param url defines the location of the image to load
  24280. */
  24281. constructor(
  24282. /**
  24283. * Defines the name of the task
  24284. */
  24285. name: string,
  24286. /**
  24287. * Defines the location of the image to load
  24288. */
  24289. url: string);
  24290. /**
  24291. * Execute the current task
  24292. * @param scene defines the scene where you want your assets to be loaded
  24293. * @param onSuccess is a callback called when the task is successfully executed
  24294. * @param onError is a callback called if an error occurs
  24295. */
  24296. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  24297. }
  24298. /**
  24299. * Defines the interface used by texture loading tasks
  24300. */
  24301. interface ITextureAssetTask<TEX extends BaseTexture> {
  24302. /**
  24303. * Gets the loaded texture
  24304. */
  24305. texture: TEX;
  24306. }
  24307. /**
  24308. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  24309. */
  24310. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  24311. /**
  24312. * Defines the name of the task
  24313. */
  24314. name: string;
  24315. /**
  24316. * Defines the location of the file to load
  24317. */
  24318. url: string;
  24319. /**
  24320. * Defines if mipmap should not be generated (default is false)
  24321. */
  24322. noMipmap: boolean | undefined;
  24323. /**
  24324. * Defines if texture must be inverted on Y axis (default is false)
  24325. */
  24326. invertY: boolean | undefined;
  24327. /**
  24328. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  24329. */
  24330. samplingMode: number;
  24331. /**
  24332. * Gets the loaded texture
  24333. */
  24334. texture: Texture;
  24335. /**
  24336. * Callback called when the task is successful
  24337. */
  24338. onSuccess: (task: TextureAssetTask) => void;
  24339. /**
  24340. * Callback called when the task is successful
  24341. */
  24342. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  24343. /**
  24344. * Creates a new TextureAssetTask object
  24345. * @param name defines the name of the task
  24346. * @param url defines the location of the file to load
  24347. * @param noMipmap defines if mipmap should not be generated (default is false)
  24348. * @param invertY defines if texture must be inverted on Y axis (default is false)
  24349. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  24350. */
  24351. constructor(
  24352. /**
  24353. * Defines the name of the task
  24354. */
  24355. name: string,
  24356. /**
  24357. * Defines the location of the file to load
  24358. */
  24359. url: string,
  24360. /**
  24361. * Defines if mipmap should not be generated (default is false)
  24362. */
  24363. noMipmap?: boolean | undefined,
  24364. /**
  24365. * Defines if texture must be inverted on Y axis (default is false)
  24366. */
  24367. invertY?: boolean | undefined,
  24368. /**
  24369. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  24370. */
  24371. samplingMode?: number);
  24372. /**
  24373. * Execute the current task
  24374. * @param scene defines the scene where you want your assets to be loaded
  24375. * @param onSuccess is a callback called when the task is successfully executed
  24376. * @param onError is a callback called if an error occurs
  24377. */
  24378. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  24379. }
  24380. /**
  24381. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  24382. */
  24383. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  24384. /**
  24385. * Defines the name of the task
  24386. */
  24387. name: string;
  24388. /**
  24389. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  24390. */
  24391. url: string;
  24392. /**
  24393. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  24394. */
  24395. extensions: string[] | undefined;
  24396. /**
  24397. * Defines if mipmaps should not be generated (default is false)
  24398. */
  24399. noMipmap: boolean | undefined;
  24400. /**
  24401. * Defines the explicit list of files (undefined by default)
  24402. */
  24403. files: string[] | undefined;
  24404. /**
  24405. * Gets the loaded texture
  24406. */
  24407. texture: CubeTexture;
  24408. /**
  24409. * Callback called when the task is successful
  24410. */
  24411. onSuccess: (task: CubeTextureAssetTask) => void;
  24412. /**
  24413. * Callback called when the task is successful
  24414. */
  24415. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  24416. /**
  24417. * Creates a new CubeTextureAssetTask
  24418. * @param name defines the name of the task
  24419. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  24420. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  24421. * @param noMipmap defines if mipmaps should not be generated (default is false)
  24422. * @param files defines the explicit list of files (undefined by default)
  24423. */
  24424. constructor(
  24425. /**
  24426. * Defines the name of the task
  24427. */
  24428. name: string,
  24429. /**
  24430. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  24431. */
  24432. url: string,
  24433. /**
  24434. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  24435. */
  24436. extensions?: string[] | undefined,
  24437. /**
  24438. * Defines if mipmaps should not be generated (default is false)
  24439. */
  24440. noMipmap?: boolean | undefined,
  24441. /**
  24442. * Defines the explicit list of files (undefined by default)
  24443. */
  24444. files?: string[] | undefined);
  24445. /**
  24446. * Execute the current task
  24447. * @param scene defines the scene where you want your assets to be loaded
  24448. * @param onSuccess is a callback called when the task is successfully executed
  24449. * @param onError is a callback called if an error occurs
  24450. */
  24451. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  24452. }
  24453. /**
  24454. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  24455. */
  24456. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  24457. /**
  24458. * Defines the name of the task
  24459. */
  24460. name: string;
  24461. /**
  24462. * Defines the location of the file to load
  24463. */
  24464. url: string;
  24465. /**
  24466. * 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.
  24467. */
  24468. size: number | undefined;
  24469. /**
  24470. * Defines if mipmaps should not be generated (default is false)
  24471. */
  24472. noMipmap: boolean;
  24473. /**
  24474. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  24475. */
  24476. generateHarmonics: boolean;
  24477. /**
  24478. * 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)
  24479. */
  24480. useInGammaSpace: boolean;
  24481. /**
  24482. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  24483. */
  24484. usePMREMGenerator: boolean;
  24485. /**
  24486. * Gets the loaded texture
  24487. */
  24488. texture: HDRCubeTexture;
  24489. /**
  24490. * Callback called when the task is successful
  24491. */
  24492. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  24493. /**
  24494. * Callback called when the task is successful
  24495. */
  24496. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  24497. /**
  24498. * Creates a new HDRCubeTextureAssetTask object
  24499. * @param name defines the name of the task
  24500. * @param url defines the location of the file to load
  24501. * @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.
  24502. * @param noMipmap defines if mipmaps should not be generated (default is false)
  24503. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  24504. * @param useInGammaSpace 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)
  24505. * @param usePMREMGenerator specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  24506. */
  24507. constructor(
  24508. /**
  24509. * Defines the name of the task
  24510. */
  24511. name: string,
  24512. /**
  24513. * Defines the location of the file to load
  24514. */
  24515. url: string,
  24516. /**
  24517. * 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.
  24518. */
  24519. size?: number | undefined,
  24520. /**
  24521. * Defines if mipmaps should not be generated (default is false)
  24522. */
  24523. noMipmap?: boolean,
  24524. /**
  24525. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  24526. */
  24527. generateHarmonics?: boolean,
  24528. /**
  24529. * 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)
  24530. */
  24531. useInGammaSpace?: boolean,
  24532. /**
  24533. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  24534. */
  24535. usePMREMGenerator?: boolean);
  24536. /**
  24537. * Execute the current task
  24538. * @param scene defines the scene where you want your assets to be loaded
  24539. * @param onSuccess is a callback called when the task is successfully executed
  24540. * @param onError is a callback called if an error occurs
  24541. */
  24542. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  24543. }
  24544. /**
  24545. * This class can be used to easily import assets into a scene
  24546. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  24547. */
  24548. class AssetsManager {
  24549. private _scene;
  24550. private _isLoading;
  24551. protected _tasks: AbstractAssetTask[];
  24552. protected _waitingTasksCount: number;
  24553. protected _totalTasksCount: number;
  24554. /**
  24555. * Callback called when all tasks are processed
  24556. */
  24557. onFinish: (tasks: AbstractAssetTask[]) => void;
  24558. /**
  24559. * Callback called when a task is successful
  24560. */
  24561. onTaskSuccess: (task: AbstractAssetTask) => void;
  24562. /**
  24563. * Callback called when a task had an error
  24564. */
  24565. onTaskError: (task: AbstractAssetTask) => void;
  24566. /**
  24567. * Callback called when a task is done (whatever the result is)
  24568. */
  24569. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  24570. /**
  24571. * Observable called when all tasks are processed
  24572. */
  24573. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  24574. /**
  24575. * Observable called when a task had an error
  24576. */
  24577. onTaskErrorObservable: Observable<AbstractAssetTask>;
  24578. /**
  24579. * Observable called when a task is successful
  24580. */
  24581. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  24582. /**
  24583. * Observable called when a task is done (whatever the result is)
  24584. */
  24585. onProgressObservable: Observable<IAssetsProgressEvent>;
  24586. /**
  24587. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  24588. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  24589. */
  24590. useDefaultLoadingScreen: boolean;
  24591. /**
  24592. * Creates a new AssetsManager
  24593. * @param scene defines the scene to work on
  24594. */
  24595. constructor(scene: Scene);
  24596. /**
  24597. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  24598. * @param taskName defines the name of the new task
  24599. * @param meshesNames defines the name of meshes to load
  24600. * @param rootUrl defines the root url to use to locate files
  24601. * @param sceneFilename defines the filename of the scene file
  24602. * @returns a new {BABYLON.MeshAssetTask} object
  24603. */
  24604. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  24605. /**
  24606. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  24607. * @param taskName defines the name of the new task
  24608. * @param url defines the url of the file to load
  24609. * @returns a new {BABYLON.TextFileAssetTask} object
  24610. */
  24611. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  24612. /**
  24613. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  24614. * @param taskName defines the name of the new task
  24615. * @param url defines the url of the file to load
  24616. * @returns a new {BABYLON.BinaryFileAssetTask} object
  24617. */
  24618. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  24619. /**
  24620. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  24621. * @param taskName defines the name of the new task
  24622. * @param url defines the url of the file to load
  24623. * @returns a new {BABYLON.ImageAssetTask} object
  24624. */
  24625. addImageTask(taskName: string, url: string): ImageAssetTask;
  24626. /**
  24627. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  24628. * @param taskName defines the name of the new task
  24629. * @param url defines the url of the file to load
  24630. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  24631. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  24632. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  24633. * @returns a new {BABYLON.TextureAssetTask} object
  24634. */
  24635. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  24636. /**
  24637. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  24638. * @param taskName defines the name of the new task
  24639. * @param url defines the url of the file to load
  24640. * @param extensions defines the extension to use to load the cube map (can be null)
  24641. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  24642. * @param files defines the list of files to load (can be null)
  24643. * @returns a new {BABYLON.CubeTextureAssetTask} object
  24644. */
  24645. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  24646. /**
  24647. *
  24648. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  24649. * @param taskName defines the name of the new task
  24650. * @param url defines the url of the file to load
  24651. * @param size defines the size you want for the cubemap (can be null)
  24652. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  24653. * @param generateHarmonics defines if you want to automatically generate (true by default)
  24654. * @param useInGammaSpace defines if the texture must be considered in gamma space (false by default)
  24655. * @param usePMREMGenerator is a reserved parameter and must be set to false or ignored
  24656. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  24657. */
  24658. addHDRCubeTextureTask(taskName: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean): HDRCubeTextureAssetTask;
  24659. private _decreaseWaitingTasksCount(task);
  24660. private _runTask(task);
  24661. /**
  24662. * Reset the {BABYLON.AssetsManager} and remove all tasks
  24663. * @return the current instance of the {BABYLON.AssetsManager}
  24664. */
  24665. reset(): AssetsManager;
  24666. /**
  24667. * Start the loading process
  24668. * @return the current instance of the {BABYLON.AssetsManager}
  24669. */
  24670. load(): AssetsManager;
  24671. }
  24672. }
  24673. declare module BABYLON {
  24674. class Database {
  24675. private callbackManifestChecked;
  24676. private currentSceneUrl;
  24677. private db;
  24678. private _enableSceneOffline;
  24679. private _enableTexturesOffline;
  24680. private manifestVersionFound;
  24681. private mustUpdateRessources;
  24682. private hasReachedQuota;
  24683. private isSupported;
  24684. private idbFactory;
  24685. static IsUASupportingBlobStorage: boolean;
  24686. static IDBStorageEnabled: boolean;
  24687. readonly enableSceneOffline: boolean;
  24688. readonly enableTexturesOffline: boolean;
  24689. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any);
  24690. static parseURL: (url: string) => string;
  24691. static ReturnFullUrlLocation: (url: string) => string;
  24692. checkManifestFile(): void;
  24693. openAsync(successCallback: () => void, errorCallback: () => void): void;
  24694. loadImageFromDB(url: string, image: HTMLImageElement): void;
  24695. private _loadImageFromDBAsync(url, image, notInDBCallback);
  24696. private _saveImageIntoDBAsync(url, image);
  24697. private _checkVersionFromDB(url, versionLoaded);
  24698. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  24699. private _saveVersionIntoDBAsync(url, callback);
  24700. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  24701. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  24702. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  24703. }
  24704. }
  24705. declare module BABYLON {
  24706. interface DDSInfo {
  24707. width: number;
  24708. height: number;
  24709. mipmapCount: number;
  24710. isFourCC: boolean;
  24711. isRGB: boolean;
  24712. isLuminance: boolean;
  24713. isCube: boolean;
  24714. isCompressed: boolean;
  24715. dxgiFormat: number;
  24716. textureType: number;
  24717. }
  24718. class DDSTools {
  24719. static StoreLODInAlphaChannel: boolean;
  24720. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  24721. private static _FloatView;
  24722. private static _Int32View;
  24723. private static _ToHalfFloat(value);
  24724. private static _FromHalfFloat(value);
  24725. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  24726. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  24727. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  24728. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  24729. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  24730. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  24731. private static _ExtractLongWordOrder(value);
  24732. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  24733. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  24734. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  24735. }
  24736. }
  24737. declare module BABYLON {
  24738. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  24739. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  24740. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  24741. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  24742. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  24743. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  24744. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  24745. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  24746. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  24747. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  24748. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  24749. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  24750. /**
  24751. * Decorator used to define property that can be serialized as reference to a camera
  24752. * @param sourceName defines the name of the property to decorate
  24753. */
  24754. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  24755. class SerializationHelper {
  24756. static Serialize<T>(entity: T, serializationObject?: any): any;
  24757. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  24758. static Clone<T>(creationFunction: () => T, source: T): T;
  24759. static Instanciate<T>(creationFunction: () => T, source: T): T;
  24760. }
  24761. }
  24762. declare module BABYLON {
  24763. /**
  24764. * Wrapper class for promise with external resolve and reject.
  24765. */
  24766. class Deferred<T> {
  24767. /**
  24768. * The promise associated with this deferred object.
  24769. */
  24770. readonly promise: Promise<T>;
  24771. private _resolve;
  24772. private _reject;
  24773. /**
  24774. * The resolve method of the promise associated with this deferred object.
  24775. */
  24776. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  24777. /**
  24778. * The reject method of the promise associated with this deferred object.
  24779. */
  24780. readonly reject: (reason?: any) => void;
  24781. /**
  24782. * Constructor for this deferred object.
  24783. */
  24784. constructor();
  24785. }
  24786. }
  24787. declare module BABYLON {
  24788. class FilesInput {
  24789. static FilesToLoad: {
  24790. [key: string]: File;
  24791. };
  24792. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  24793. private _engine;
  24794. private _currentScene;
  24795. private _sceneLoadedCallback;
  24796. private _progressCallback;
  24797. private _additionalRenderLoopLogicCallback;
  24798. private _textureLoadingCallback;
  24799. private _startingProcessingFilesCallback;
  24800. private _onReloadCallback;
  24801. private _errorCallback;
  24802. private _elementToMonitor;
  24803. private _sceneFileToLoad;
  24804. private _filesToLoad;
  24805. 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);
  24806. private _dragEnterHandler;
  24807. private _dragOverHandler;
  24808. private _dropHandler;
  24809. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  24810. dispose(): void;
  24811. private renderFunction();
  24812. private drag(e);
  24813. private drop(eventDrop);
  24814. private _traverseFolder(folder, files, remaining, callback);
  24815. private _processFiles(files);
  24816. loadFiles(event: any): void;
  24817. private _processReload();
  24818. reload(): void;
  24819. }
  24820. }
  24821. declare module BABYLON {
  24822. /**
  24823. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  24824. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  24825. */
  24826. class KhronosTextureContainer {
  24827. arrayBuffer: any;
  24828. static HEADER_LEN: number;
  24829. static COMPRESSED_2D: number;
  24830. static COMPRESSED_3D: number;
  24831. static TEX_2D: number;
  24832. static TEX_3D: number;
  24833. glType: number;
  24834. glTypeSize: number;
  24835. glFormat: number;
  24836. glInternalFormat: number;
  24837. glBaseInternalFormat: number;
  24838. pixelWidth: number;
  24839. pixelHeight: number;
  24840. pixelDepth: number;
  24841. numberOfArrayElements: number;
  24842. numberOfFaces: number;
  24843. numberOfMipmapLevels: number;
  24844. bytesOfKeyValueData: number;
  24845. loadType: number;
  24846. /**
  24847. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  24848. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  24849. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  24850. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  24851. */
  24852. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  24853. switchEndainness(val: number): number;
  24854. /**
  24855. * It is assumed that the texture has already been created & is currently bound
  24856. */
  24857. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  24858. private _upload2DCompressedLevels(gl, loadMipmaps);
  24859. }
  24860. }
  24861. declare module BABYLON {
  24862. /**
  24863. * A class serves as a medium between the observable and its observers
  24864. */
  24865. class EventState {
  24866. /**
  24867. * Create a new EventState
  24868. * @param mask defines the mask associated with this state
  24869. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  24870. * @param target defines the original target of the state
  24871. * @param currentTarget defines the current target of the state
  24872. */
  24873. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  24874. /**
  24875. * Initialize the current event state
  24876. * @param mask defines the mask associated with this state
  24877. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  24878. * @param target defines the original target of the state
  24879. * @param currentTarget defines the current target of the state
  24880. * @returns the current event state
  24881. */
  24882. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  24883. /**
  24884. * An Observer can set this property to true to prevent subsequent observers of being notified
  24885. */
  24886. skipNextObservers: boolean;
  24887. /**
  24888. * Get the mask value that were used to trigger the event corresponding to this EventState object
  24889. */
  24890. mask: number;
  24891. /**
  24892. * The object that originally notified the event
  24893. */
  24894. target?: any;
  24895. /**
  24896. * The current object in the bubbling phase
  24897. */
  24898. currentTarget?: any;
  24899. /**
  24900. * This will be populated with the return value of the last function that was executed.
  24901. * If it is the first function in the callback chain it will be the event data.
  24902. */
  24903. lastReturnValue?: any;
  24904. }
  24905. /**
  24906. * Represent an Observer registered to a given Observable object.
  24907. */
  24908. class Observer<T> {
  24909. /**
  24910. * Defines the callback to call when the observer is notified
  24911. */
  24912. callback: (eventData: T, eventState: EventState) => void;
  24913. /**
  24914. * Defines the mask of the observer (used to filter notifications)
  24915. */
  24916. mask: number;
  24917. /**
  24918. * Defines the current scope used to restore the JS context
  24919. */
  24920. scope: any;
  24921. /** @ignore */
  24922. _willBeUnregistered: boolean;
  24923. /**
  24924. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  24925. */
  24926. unregisterOnNextCall: boolean;
  24927. /**
  24928. * Creates a new observer
  24929. * @param callback defines the callback to call when the observer is notified
  24930. * @param mask defines the mask of the observer (used to filter notifications)
  24931. * @param scope defines the current scope used to restore the JS context
  24932. */
  24933. constructor(
  24934. /**
  24935. * Defines the callback to call when the observer is notified
  24936. */
  24937. callback: (eventData: T, eventState: EventState) => void,
  24938. /**
  24939. * Defines the mask of the observer (used to filter notifications)
  24940. */
  24941. mask: number,
  24942. /**
  24943. * Defines the current scope used to restore the JS context
  24944. */
  24945. scope?: any);
  24946. }
  24947. /**
  24948. * Represent a list of observers registered to multiple Observables object.
  24949. */
  24950. class MultiObserver<T> {
  24951. private _observers;
  24952. private _observables;
  24953. /**
  24954. * Release associated resources
  24955. */
  24956. dispose(): void;
  24957. /**
  24958. * Raise a callback when one of the observable will notify
  24959. * @param observables defines a list of observables to watch
  24960. * @param callback defines the callback to call on notification
  24961. * @param mask defines the mask used to filter notifications
  24962. * @param scope defines the current scope used to restore the JS context
  24963. * @returns the new MultiObserver
  24964. */
  24965. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  24966. }
  24967. /**
  24968. * The Observable class is a simple implementation of the Observable pattern.
  24969. *
  24970. * 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.
  24971. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  24972. * 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).
  24973. * 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.
  24974. */
  24975. class Observable<T> {
  24976. private _observers;
  24977. private _eventState;
  24978. private _onObserverAdded;
  24979. /**
  24980. * Creates a new observable
  24981. * @param onObserverAdded defines a callback to call when a new observer is added
  24982. */
  24983. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  24984. /**
  24985. * Create a new Observer with the specified callback
  24986. * @param callback the callback that will be executed for that Observer
  24987. * @param mask the mask used to filter observers
  24988. * @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.
  24989. * @param scope optional scope for the callback to be called from
  24990. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  24991. * @returns the new observer created for the callback
  24992. */
  24993. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  24994. /**
  24995. * Remove an Observer from the Observable object
  24996. * @param observer the instance of the Observer to remove
  24997. * @returns false if it doesn't belong to this Observable
  24998. */
  24999. remove(observer: Nullable<Observer<T>>): boolean;
  25000. /**
  25001. * Remove a callback from the Observable object
  25002. * @param callback the callback to remove
  25003. * @param scope optional scope. If used only the callbacks with this scope will be removed
  25004. * @returns false if it doesn't belong to this Observable
  25005. */
  25006. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  25007. private _deferUnregister(observer);
  25008. /**
  25009. * Notify all Observers by calling their respective callback with the given data
  25010. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  25011. * @param eventData defines the data to send to all observers
  25012. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  25013. * @param target defines the original target of the state
  25014. * @param currentTarget defines the current target of the state
  25015. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  25016. */
  25017. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  25018. /**
  25019. * Calling this will execute each callback, expecting it to be a promise or return a value.
  25020. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  25021. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  25022. * and it is crucial that all callbacks will be executed.
  25023. * The order of the callbacks is kept, callbacks are not executed parallel.
  25024. *
  25025. * @param eventData The data to be sent to each callback
  25026. * @param mask is used to filter observers defaults to -1
  25027. * @param target defines the callback target (see EventState)
  25028. * @param currentTarget defines he current object in the bubbling phase
  25029. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  25030. */
  25031. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  25032. /**
  25033. * Notify a specific observer
  25034. * @param observer defines the observer to notify
  25035. * @param eventData defines the data to be sent to each callback
  25036. * @param mask is used to filter observers defaults to -1
  25037. */
  25038. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  25039. /**
  25040. * Gets a boolean indicating if the observable has at least one observer
  25041. * @returns true is the Observable has at least one Observer registered
  25042. */
  25043. hasObservers(): boolean;
  25044. /**
  25045. * Clear the list of observers
  25046. */
  25047. clear(): void;
  25048. /**
  25049. * Clone the current observable
  25050. * @returns a new observable
  25051. */
  25052. clone(): Observable<T>;
  25053. /**
  25054. * Does this observable handles observer registered with a given mask
  25055. * @param mask defines the mask to be tested
  25056. * @return whether or not one observer registered with the given mask is handeled
  25057. **/
  25058. hasSpecificMask(mask?: number): boolean;
  25059. }
  25060. }
  25061. declare module BABYLON {
  25062. /**
  25063. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  25064. */
  25065. class PerformanceMonitor {
  25066. private _enabled;
  25067. private _rollingFrameTime;
  25068. private _lastFrameTimeMs;
  25069. /**
  25070. * constructor
  25071. * @param frameSampleSize The number of samples required to saturate the sliding window
  25072. */
  25073. constructor(frameSampleSize?: number);
  25074. /**
  25075. * Samples current frame
  25076. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  25077. */
  25078. sampleFrame(timeMs?: number): void;
  25079. /**
  25080. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  25081. * @return Average frame time in milliseconds
  25082. */
  25083. readonly averageFrameTime: number;
  25084. /**
  25085. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  25086. * @return Frame time variance in milliseconds squared
  25087. */
  25088. readonly averageFrameTimeVariance: number;
  25089. /**
  25090. * Returns the frame time of the most recent frame
  25091. * @return Frame time in milliseconds
  25092. */
  25093. readonly instantaneousFrameTime: number;
  25094. /**
  25095. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  25096. * @return Framerate in frames per second
  25097. */
  25098. readonly averageFPS: number;
  25099. /**
  25100. * Returns the average framerate in frames per second using the most recent frame time
  25101. * @return Framerate in frames per second
  25102. */
  25103. readonly instantaneousFPS: number;
  25104. /**
  25105. * Returns true if enough samples have been taken to completely fill the sliding window
  25106. * @return true if saturated
  25107. */
  25108. readonly isSaturated: boolean;
  25109. /**
  25110. * Enables contributions to the sliding window sample set
  25111. */
  25112. enable(): void;
  25113. /**
  25114. * Disables contributions to the sliding window sample set
  25115. * Samples will not be interpolated over the disabled period
  25116. */
  25117. disable(): void;
  25118. /**
  25119. * Returns true if sampling is enabled
  25120. * @return true if enabled
  25121. */
  25122. readonly isEnabled: boolean;
  25123. /**
  25124. * Resets performance monitor
  25125. */
  25126. reset(): void;
  25127. }
  25128. /**
  25129. * RollingAverage
  25130. *
  25131. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  25132. */
  25133. class RollingAverage {
  25134. /**
  25135. * Current average
  25136. */
  25137. average: number;
  25138. /**
  25139. * Current variance
  25140. */
  25141. variance: number;
  25142. protected _samples: Array<number>;
  25143. protected _sampleCount: number;
  25144. protected _pos: number;
  25145. protected _m2: number;
  25146. /**
  25147. * constructor
  25148. * @param length The number of samples required to saturate the sliding window
  25149. */
  25150. constructor(length: number);
  25151. /**
  25152. * Adds a sample to the sample set
  25153. * @param v The sample value
  25154. */
  25155. add(v: number): void;
  25156. /**
  25157. * Returns previously added values or null if outside of history or outside the sliding window domain
  25158. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  25159. * @return Value previously recorded with add() or null if outside of range
  25160. */
  25161. history(i: number): number;
  25162. /**
  25163. * Returns true if enough samples have been taken to completely fill the sliding window
  25164. * @return true if sample-set saturated
  25165. */
  25166. isSaturated(): boolean;
  25167. /**
  25168. * Resets the rolling average (equivalent to 0 samples taken so far)
  25169. */
  25170. reset(): void;
  25171. /**
  25172. * Wraps a value around the sample range boundaries
  25173. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  25174. * @return Wrapped position in sample range
  25175. */
  25176. protected _wrapPosition(i: number): number;
  25177. }
  25178. }
  25179. declare module BABYLON {
  25180. /**
  25181. * Helper class that provides a small promise polyfill
  25182. */
  25183. class PromisePolyfill {
  25184. /**
  25185. * Static function used to check if the polyfill is required
  25186. * If this is the case then the function will inject the polyfill to window.Promise
  25187. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  25188. */
  25189. static Apply(force?: boolean): void;
  25190. }
  25191. }
  25192. declare module BABYLON {
  25193. /**
  25194. * Defines the root class used to create scene optimization to use with SceneOptimizer
  25195. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  25196. */
  25197. class SceneOptimization {
  25198. /**
  25199. * Defines the priority of this optimization (0 by default which means first in the list)
  25200. */
  25201. priority: number;
  25202. /**
  25203. * Gets a string describing the action executed by the current optimization
  25204. * @returns description string
  25205. */
  25206. getDescription(): string;
  25207. /**
  25208. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  25209. * @param scene defines the current scene where to apply this optimization
  25210. * @param optimizer defines the current optimizer
  25211. * @returns true if everything that can be done was applied
  25212. */
  25213. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  25214. /**
  25215. * Creates the SceneOptimization object
  25216. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  25217. * @param desc defines the description associated with the optimization
  25218. */
  25219. constructor(
  25220. /**
  25221. * Defines the priority of this optimization (0 by default which means first in the list)
  25222. */
  25223. priority?: number);
  25224. }
  25225. /**
  25226. * Defines an optimization used to reduce the size of render target textures
  25227. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  25228. */
  25229. class TextureOptimization extends SceneOptimization {
  25230. /**
  25231. * Defines the priority of this optimization (0 by default which means first in the list)
  25232. */
  25233. priority: number;
  25234. /**
  25235. * 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
  25236. */
  25237. maximumSize: number;
  25238. /**
  25239. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  25240. */
  25241. step: number;
  25242. /**
  25243. * Gets a string describing the action executed by the current optimization
  25244. * @returns description string
  25245. */
  25246. getDescription(): string;
  25247. /**
  25248. * Creates the TextureOptimization object
  25249. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  25250. * @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
  25251. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  25252. */
  25253. constructor(
  25254. /**
  25255. * Defines the priority of this optimization (0 by default which means first in the list)
  25256. */
  25257. priority?: number,
  25258. /**
  25259. * 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
  25260. */
  25261. maximumSize?: number,
  25262. /**
  25263. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  25264. */
  25265. step?: number);
  25266. /**
  25267. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  25268. * @param scene defines the current scene where to apply this optimization
  25269. * @param optimizer defines the current optimizer
  25270. * @returns true if everything that can be done was applied
  25271. */
  25272. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  25273. }
  25274. /**
  25275. * Defines an optimization used to increase or decrease the rendering resolution
  25276. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  25277. */
  25278. class HardwareScalingOptimization extends SceneOptimization {
  25279. /**
  25280. * Defines the priority of this optimization (0 by default which means first in the list)
  25281. */
  25282. priority: number;
  25283. /**
  25284. * Defines the maximum scale to use (2 by default)
  25285. */
  25286. maximumScale: number;
  25287. /**
  25288. * Defines the step to use between two passes (0.5 by default)
  25289. */
  25290. step: number;
  25291. private _currentScale;
  25292. private _directionOffset;
  25293. /**
  25294. * Gets a string describing the action executed by the current optimization
  25295. * @return description string
  25296. */
  25297. getDescription(): string;
  25298. /**
  25299. * Creates the HardwareScalingOptimization object
  25300. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  25301. * @param maximumScale defines the maximum scale to use (2 by default)
  25302. * @param step defines the step to use between two passes (0.5 by default)
  25303. */
  25304. constructor(
  25305. /**
  25306. * Defines the priority of this optimization (0 by default which means first in the list)
  25307. */
  25308. priority?: number,
  25309. /**
  25310. * Defines the maximum scale to use (2 by default)
  25311. */
  25312. maximumScale?: number,
  25313. /**
  25314. * Defines the step to use between two passes (0.5 by default)
  25315. */
  25316. step?: number);
  25317. /**
  25318. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  25319. * @param scene defines the current scene where to apply this optimization
  25320. * @param optimizer defines the current optimizer
  25321. * @returns true if everything that can be done was applied
  25322. */
  25323. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  25324. }
  25325. /**
  25326. * Defines an optimization used to remove shadows
  25327. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  25328. */
  25329. class ShadowsOptimization extends SceneOptimization {
  25330. /**
  25331. * Gets a string describing the action executed by the current optimization
  25332. * @return description string
  25333. */
  25334. getDescription(): string;
  25335. /**
  25336. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  25337. * @param scene defines the current scene where to apply this optimization
  25338. * @param optimizer defines the current optimizer
  25339. * @returns true if everything that can be done was applied
  25340. */
  25341. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  25342. }
  25343. /**
  25344. * Defines an optimization used to turn post-processes off
  25345. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  25346. */
  25347. class PostProcessesOptimization extends SceneOptimization {
  25348. /**
  25349. * Gets a string describing the action executed by the current optimization
  25350. * @return description string
  25351. */
  25352. getDescription(): string;
  25353. /**
  25354. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  25355. * @param scene defines the current scene where to apply this optimization
  25356. * @param optimizer defines the current optimizer
  25357. * @returns true if everything that can be done was applied
  25358. */
  25359. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  25360. }
  25361. /**
  25362. * Defines an optimization used to turn lens flares off
  25363. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  25364. */
  25365. class LensFlaresOptimization extends SceneOptimization {
  25366. /**
  25367. * Gets a string describing the action executed by the current optimization
  25368. * @return description string
  25369. */
  25370. getDescription(): string;
  25371. /**
  25372. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  25373. * @param scene defines the current scene where to apply this optimization
  25374. * @param optimizer defines the current optimizer
  25375. * @returns true if everything that can be done was applied
  25376. */
  25377. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  25378. }
  25379. /**
  25380. * Defines an optimization based on user defined callback.
  25381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  25382. */
  25383. class CustomOptimization extends SceneOptimization {
  25384. /**
  25385. * Callback called to apply the custom optimization.
  25386. */
  25387. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  25388. /**
  25389. * Callback called to get custom description
  25390. */
  25391. onGetDescription: () => string;
  25392. /**
  25393. * Gets a string describing the action executed by the current optimization
  25394. * @returns description string
  25395. */
  25396. getDescription(): string;
  25397. /**
  25398. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  25399. * @param scene defines the current scene where to apply this optimization
  25400. * @param optimizer defines the current optimizer
  25401. * @returns true if everything that can be done was applied
  25402. */
  25403. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  25404. }
  25405. /**
  25406. * Defines an optimization used to turn particles off
  25407. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  25408. */
  25409. class ParticlesOptimization extends SceneOptimization {
  25410. /**
  25411. * Gets a string describing the action executed by the current optimization
  25412. * @return description string
  25413. */
  25414. getDescription(): string;
  25415. /**
  25416. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  25417. * @param scene defines the current scene where to apply this optimization
  25418. * @param optimizer defines the current optimizer
  25419. * @returns true if everything that can be done was applied
  25420. */
  25421. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  25422. }
  25423. /**
  25424. * Defines an optimization used to turn render targets off
  25425. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  25426. */
  25427. class RenderTargetsOptimization extends SceneOptimization {
  25428. /**
  25429. * Gets a string describing the action executed by the current optimization
  25430. * @return description string
  25431. */
  25432. getDescription(): string;
  25433. /**
  25434. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  25435. * @param scene defines the current scene where to apply this optimization
  25436. * @param optimizer defines the current optimizer
  25437. * @returns true if everything that can be done was applied
  25438. */
  25439. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  25440. }
  25441. /**
  25442. * Defines an optimization used to merge meshes with compatible materials
  25443. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  25444. */
  25445. class MergeMeshesOptimization extends SceneOptimization {
  25446. private static _UpdateSelectionTree;
  25447. /**
  25448. * Gets or sets a boolean which defines if optimization octree has to be updated
  25449. */
  25450. /**
  25451. * Gets or sets a boolean which defines if optimization octree has to be updated
  25452. */
  25453. static UpdateSelectionTree: boolean;
  25454. /**
  25455. * Gets a string describing the action executed by the current optimization
  25456. * @return description string
  25457. */
  25458. getDescription(): string;
  25459. private _canBeMerged;
  25460. /**
  25461. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  25462. * @param scene defines the current scene where to apply this optimization
  25463. * @param optimizer defines the current optimizer
  25464. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  25465. * @returns true if everything that can be done was applied
  25466. */
  25467. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  25468. }
  25469. /**
  25470. * Defines a list of options used by SceneOptimizer
  25471. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  25472. */
  25473. class SceneOptimizerOptions {
  25474. /**
  25475. * Defines the target frame rate to reach (60 by default)
  25476. */
  25477. targetFrameRate: number;
  25478. /**
  25479. * Defines the interval between two checkes (2000ms by default)
  25480. */
  25481. trackerDuration: number;
  25482. /**
  25483. * Gets the list of optimizations to apply
  25484. */
  25485. optimizations: SceneOptimization[];
  25486. /**
  25487. * Creates a new list of options used by SceneOptimizer
  25488. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  25489. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  25490. */
  25491. constructor(
  25492. /**
  25493. * Defines the target frame rate to reach (60 by default)
  25494. */
  25495. targetFrameRate?: number,
  25496. /**
  25497. * Defines the interval between two checkes (2000ms by default)
  25498. */
  25499. trackerDuration?: number);
  25500. /**
  25501. * Add a new optimization
  25502. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  25503. * @returns the current SceneOptimizerOptions
  25504. */
  25505. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  25506. /**
  25507. * Add a new custom optimization
  25508. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  25509. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  25510. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  25511. * @returns the current SceneOptimizerOptions
  25512. */
  25513. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  25514. /**
  25515. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  25516. * @param targetFrameRate defines the target frame rate (60 by default)
  25517. * @returns a SceneOptimizerOptions object
  25518. */
  25519. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  25520. /**
  25521. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  25522. * @param targetFrameRate defines the target frame rate (60 by default)
  25523. * @returns a SceneOptimizerOptions object
  25524. */
  25525. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  25526. /**
  25527. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  25528. * @param targetFrameRate defines the target frame rate (60 by default)
  25529. * @returns a SceneOptimizerOptions object
  25530. */
  25531. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  25532. }
  25533. /**
  25534. * Class used to run optimizations in order to reach a target frame rate
  25535. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  25536. */
  25537. class SceneOptimizer implements IDisposable {
  25538. private _isRunning;
  25539. private _options;
  25540. private _scene;
  25541. private _currentPriorityLevel;
  25542. private _targetFrameRate;
  25543. private _trackerDuration;
  25544. private _currentFrameRate;
  25545. private _sceneDisposeObserver;
  25546. private _improvementMode;
  25547. /**
  25548. * Defines an observable called when the optimizer reaches the target frame rate
  25549. */
  25550. onSuccessObservable: Observable<SceneOptimizer>;
  25551. /**
  25552. * Defines an observable called when the optimizer enables an optimization
  25553. */
  25554. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  25555. /**
  25556. * Defines an observable called when the optimizer is not able to reach the target frame rate
  25557. */
  25558. onFailureObservable: Observable<SceneOptimizer>;
  25559. /**
  25560. * Gets a boolean indicating if the optimizer is in improvement mode
  25561. */
  25562. readonly isInImprovementMode: boolean;
  25563. /**
  25564. * Gets the current priority level (0 at start)
  25565. */
  25566. readonly currentPriorityLevel: number;
  25567. /**
  25568. * Gets the current frame rate checked by the SceneOptimizer
  25569. */
  25570. readonly currentFrameRate: number;
  25571. /**
  25572. * Gets or sets the current target frame rate (60 by default)
  25573. */
  25574. /**
  25575. * Gets or sets the current target frame rate (60 by default)
  25576. */
  25577. targetFrameRate: number;
  25578. /**
  25579. * Gets or sets the current interval between two checks (every 2000ms by default)
  25580. */
  25581. /**
  25582. * Gets or sets the current interval between two checks (every 2000ms by default)
  25583. */
  25584. trackerDuration: number;
  25585. /**
  25586. * Gets the list of active optimizations
  25587. */
  25588. readonly optimizations: SceneOptimization[];
  25589. /**
  25590. * Creates a new SceneOptimizer
  25591. * @param scene defines the scene to work on
  25592. * @param options defines the options to use with the SceneOptimizer
  25593. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  25594. * @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)
  25595. */
  25596. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  25597. /**
  25598. * Stops the current optimizer
  25599. */
  25600. stop(): void;
  25601. /**
  25602. * Reset the optimizer to initial step (current priority level = 0)
  25603. */
  25604. reset(): void;
  25605. /**
  25606. * Start the optimizer. By default it will try to reach a specific framerate
  25607. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  25608. */
  25609. start(): void;
  25610. private _checkCurrentState();
  25611. /**
  25612. * Release all resources
  25613. */
  25614. dispose(): void;
  25615. /**
  25616. * Helper function to create a SceneOptimizer with one single line of code
  25617. * @param scene defines the scene to work on
  25618. * @param options defines the options to use with the SceneOptimizer
  25619. * @param onSuccess defines a callback to call on success
  25620. * @param onFailure defines a callback to call on failure
  25621. * @returns the new SceneOptimizer object
  25622. */
  25623. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  25624. }
  25625. }
  25626. declare module BABYLON {
  25627. class SceneSerializer {
  25628. static ClearCache(): void;
  25629. static Serialize(scene: Scene): any;
  25630. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  25631. }
  25632. }
  25633. declare module BABYLON {
  25634. class SmartArray<T> {
  25635. data: Array<T>;
  25636. length: number;
  25637. protected _id: number;
  25638. [index: number]: T;
  25639. constructor(capacity: number);
  25640. push(value: T): void;
  25641. forEach(func: (content: T) => void): void;
  25642. sort(compareFn: (a: T, b: T) => number): void;
  25643. reset(): void;
  25644. dispose(): void;
  25645. concat(array: any): void;
  25646. indexOf(value: T): number;
  25647. contains(value: T): boolean;
  25648. private static _GlobalId;
  25649. }
  25650. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  25651. private _duplicateId;
  25652. [index: number]: T;
  25653. push(value: T): void;
  25654. pushNoDuplicate(value: T): boolean;
  25655. reset(): void;
  25656. concatWithNoDuplicate(array: any): void;
  25657. }
  25658. }
  25659. declare module BABYLON {
  25660. /**
  25661. * This class implement a typical dictionary using a string as key and the generic type T as value.
  25662. * The underlying implementation relies on an associative array to ensure the best performances.
  25663. * The value can be anything including 'null' but except 'undefined'
  25664. */
  25665. class StringDictionary<T> {
  25666. /**
  25667. * This will clear this dictionary and copy the content from the 'source' one.
  25668. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  25669. * @param source the dictionary to take the content from and copy to this dictionary
  25670. */
  25671. copyFrom(source: StringDictionary<T>): void;
  25672. /**
  25673. * Get a value based from its key
  25674. * @param key the given key to get the matching value from
  25675. * @return the value if found, otherwise undefined is returned
  25676. */
  25677. get(key: string): T | undefined;
  25678. /**
  25679. * Get a value from its key or add it if it doesn't exist.
  25680. * This method will ensure you that a given key/data will be present in the dictionary.
  25681. * @param key the given key to get the matching value from
  25682. * @param factory the factory that will create the value if the key is not present in the dictionary.
  25683. * The factory will only be invoked if there's no data for the given key.
  25684. * @return the value corresponding to the key.
  25685. */
  25686. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  25687. /**
  25688. * Get a value from its key if present in the dictionary otherwise add it
  25689. * @param key the key to get the value from
  25690. * @param val if there's no such key/value pair in the dictionary add it with this value
  25691. * @return the value corresponding to the key
  25692. */
  25693. getOrAdd(key: string, val: T): T;
  25694. /**
  25695. * Check if there's a given key in the dictionary
  25696. * @param key the key to check for
  25697. * @return true if the key is present, false otherwise
  25698. */
  25699. contains(key: string): boolean;
  25700. /**
  25701. * Add a new key and its corresponding value
  25702. * @param key the key to add
  25703. * @param value the value corresponding to the key
  25704. * @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
  25705. */
  25706. add(key: string, value: T): boolean;
  25707. set(key: string, value: T): boolean;
  25708. /**
  25709. * Get the element of the given key and remove it from the dictionary
  25710. * @param key
  25711. */
  25712. getAndRemove(key: string): Nullable<T>;
  25713. /**
  25714. * Remove a key/value from the dictionary.
  25715. * @param key the key to remove
  25716. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  25717. */
  25718. remove(key: string): boolean;
  25719. /**
  25720. * Clear the whole content of the dictionary
  25721. */
  25722. clear(): void;
  25723. readonly count: number;
  25724. /**
  25725. * Execute a callback on each key/val of the dictionary.
  25726. * Note that you can remove any element in this dictionary in the callback implementation
  25727. * @param callback the callback to execute on a given key/value pair
  25728. */
  25729. forEach(callback: (key: string, val: T) => void): void;
  25730. /**
  25731. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  25732. * If the callback returns null or undefined the method will iterate to the next key/value pair
  25733. * Note that you can remove any element in this dictionary in the callback implementation
  25734. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  25735. */
  25736. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  25737. private _count;
  25738. private _data;
  25739. }
  25740. }
  25741. declare module BABYLON {
  25742. class Tags {
  25743. static EnableFor(obj: any): void;
  25744. static DisableFor(obj: any): void;
  25745. static HasTags(obj: any): boolean;
  25746. static GetTags(obj: any, asString?: boolean): any;
  25747. static AddTagsTo(obj: any, tagsString: string): void;
  25748. static _AddTagTo(obj: any, tag: string): void;
  25749. static RemoveTagsFrom(obj: any, tagsString: string): void;
  25750. static _RemoveTagFrom(obj: any, tag: string): void;
  25751. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  25752. }
  25753. }
  25754. declare module BABYLON {
  25755. class TextureTools {
  25756. /**
  25757. * Uses the GPU to create a copy texture rescaled at a given size
  25758. * @param texture Texture to copy from
  25759. * @param width Desired width
  25760. * @param height Desired height
  25761. * @return Generated texture
  25762. */
  25763. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  25764. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  25765. private static _environmentBRDFBase64Texture;
  25766. }
  25767. }
  25768. declare module BABYLON {
  25769. class TGATools {
  25770. private static _TYPE_INDEXED;
  25771. private static _TYPE_RGB;
  25772. private static _TYPE_GREY;
  25773. private static _TYPE_RLE_INDEXED;
  25774. private static _TYPE_RLE_RGB;
  25775. private static _TYPE_RLE_GREY;
  25776. private static _ORIGIN_MASK;
  25777. private static _ORIGIN_SHIFT;
  25778. private static _ORIGIN_BL;
  25779. private static _ORIGIN_BR;
  25780. private static _ORIGIN_UL;
  25781. private static _ORIGIN_UR;
  25782. static GetTGAHeader(data: Uint8Array): any;
  25783. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  25784. 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;
  25785. 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;
  25786. 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;
  25787. 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;
  25788. 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;
  25789. 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;
  25790. }
  25791. }
  25792. declare module BABYLON {
  25793. interface IAnimatable {
  25794. animations: Array<Animation>;
  25795. }
  25796. class LoadFileError extends Error {
  25797. request: XMLHttpRequest | undefined;
  25798. private static _setPrototypeOf;
  25799. constructor(message: string, request?: XMLHttpRequest | undefined);
  25800. }
  25801. class RetryStrategy {
  25802. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  25803. }
  25804. interface IFileRequest {
  25805. /**
  25806. * Raised when the request is complete (success or error).
  25807. */
  25808. onCompleteObservable: Observable<IFileRequest>;
  25809. /**
  25810. * Aborts the request for a file.
  25811. */
  25812. abort: () => void;
  25813. }
  25814. class Tools {
  25815. static BaseUrl: string;
  25816. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  25817. /**
  25818. * Default behaviour for cors in the application.
  25819. * It can be a string if the expected behavior is identical in the entire app.
  25820. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  25821. */
  25822. static CorsBehavior: string | ((url: string | string[]) => string);
  25823. static UseFallbackTexture: boolean;
  25824. /**
  25825. * Use this object to register external classes like custom textures or material
  25826. * to allow the laoders to instantiate them
  25827. */
  25828. static RegisteredExternalClasses: {
  25829. [key: string]: Object;
  25830. };
  25831. static fallbackTexture: string;
  25832. /**
  25833. * Interpolates between a and b via alpha
  25834. * @param a The lower value (returned when alpha = 0)
  25835. * @param b The upper value (returned when alpha = 1)
  25836. * @param alpha The interpolation-factor
  25837. * @return The mixed value
  25838. */
  25839. static Mix(a: number, b: number, alpha: number): number;
  25840. static Instantiate(className: string): any;
  25841. /**
  25842. * Provides a slice function that will work even on IE
  25843. * @param data defines the array to slice
  25844. * @param start defines the start of the data (optional)
  25845. * @param end defines the end of the data (optional)
  25846. * @returns the new sliced array
  25847. */
  25848. static Slice<T>(data: T, start?: number, end?: number): T;
  25849. static SetImmediate(action: () => void): void;
  25850. static IsExponentOfTwo(value: number): boolean;
  25851. /**
  25852. * Find the next highest power of two.
  25853. * @param x Number to start search from.
  25854. * @return Next highest power of two.
  25855. */
  25856. static CeilingPOT(x: number): number;
  25857. /**
  25858. * Find the next lowest power of two.
  25859. * @param x Number to start search from.
  25860. * @return Next lowest power of two.
  25861. */
  25862. static FloorPOT(x: number): number;
  25863. /**
  25864. * Find the nearest power of two.
  25865. * @param x Number to start search from.
  25866. * @return Next nearest power of two.
  25867. */
  25868. static NearestPOT(x: number): number;
  25869. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  25870. static GetFilename(path: string): string;
  25871. /**
  25872. * Extracts the "folder" part of a path (everything before the filename).
  25873. * @param uri The URI to extract the info from
  25874. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  25875. * @returns The "folder" part of the path
  25876. */
  25877. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  25878. static GetDOMTextContent(element: HTMLElement): string;
  25879. static ToDegrees(angle: number): number;
  25880. static ToRadians(angle: number): number;
  25881. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  25882. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  25883. minimum: Vector3;
  25884. maximum: Vector3;
  25885. };
  25886. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  25887. minimum: Vector3;
  25888. maximum: Vector3;
  25889. };
  25890. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  25891. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  25892. minimum: Vector2;
  25893. maximum: Vector2;
  25894. };
  25895. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  25896. static GetPointerPrefix(): string;
  25897. /**
  25898. * @param func - the function to be called
  25899. * @param requester - the object that will request the next frame. Falls back to window.
  25900. */
  25901. static QueueNewFrame(func: () => void, requester?: any): number;
  25902. static RequestFullscreen(element: HTMLElement): void;
  25903. static ExitFullscreen(): void;
  25904. static SetCorsBehavior(url: string | string[], element: {
  25905. crossOrigin: string | null;
  25906. }): void;
  25907. static CleanUrl(url: string): string;
  25908. static PreprocessUrl: (url: string) => string;
  25909. static LoadImage(url: any, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  25910. 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;
  25911. /**
  25912. * Load a script (identified by an url). When the url returns, the
  25913. * content of this file is added into a new script element, attached to the DOM (body element)
  25914. */
  25915. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  25916. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (this: MSBaseReader, ev: ProgressEvent) => any): IFileRequest;
  25917. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (this: MSBaseReader, ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  25918. static FileAsURL(content: string): string;
  25919. static Format(value: number, decimals?: number): string;
  25920. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  25921. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  25922. static IsEmpty(obj: any): boolean;
  25923. static RegisterTopRootEvents(events: {
  25924. name: string;
  25925. handler: Nullable<(e: FocusEvent) => any>;
  25926. }[]): void;
  25927. static UnregisterTopRootEvents(events: {
  25928. name: string;
  25929. handler: Nullable<(e: FocusEvent) => any>;
  25930. }[]): void;
  25931. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  25932. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  25933. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  25934. /**
  25935. * Generates an image screenshot from the specified camera.
  25936. *
  25937. * @param engine The engine to use for rendering
  25938. * @param camera The camera to use for rendering
  25939. * @param size This parameter can be set to a single number or to an object with the
  25940. * following (optional) properties: precision, width, height. If a single number is passed,
  25941. * it will be used for both width and height. If an object is passed, the screenshot size
  25942. * will be derived from the parameters. The precision property is a multiplier allowing
  25943. * rendering at a higher or lower resolution.
  25944. * @param successCallback The callback receives a single parameter which contains the
  25945. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  25946. * src parameter of an <img> to display it.
  25947. * @param mimeType The MIME type of the screenshot image (default: image/png).
  25948. * Check your browser for supported MIME types.
  25949. * @param samples Texture samples (default: 1)
  25950. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  25951. * @param fileName A name for for the downloaded file.
  25952. * @constructor
  25953. */
  25954. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  25955. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  25956. /**
  25957. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25958. * Be aware Math.random() could cause collisions, but:
  25959. * "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"
  25960. */
  25961. static RandomId(): string;
  25962. /**
  25963. * Test if the given uri is a base64 string.
  25964. * @param uri The uri to test
  25965. * @return True if the uri is a base64 string or false otherwise.
  25966. */
  25967. static IsBase64(uri: string): boolean;
  25968. /**
  25969. * Decode the given base64 uri.
  25970. * @param uri The uri to decode
  25971. * @return The decoded base64 data.
  25972. */
  25973. static DecodeBase64(uri: string): ArrayBuffer;
  25974. private static _NoneLogLevel;
  25975. private static _MessageLogLevel;
  25976. private static _WarningLogLevel;
  25977. private static _ErrorLogLevel;
  25978. private static _LogCache;
  25979. static errorsCount: number;
  25980. static OnNewCacheEntry: (entry: string) => void;
  25981. static readonly NoneLogLevel: number;
  25982. static readonly MessageLogLevel: number;
  25983. static readonly WarningLogLevel: number;
  25984. static readonly ErrorLogLevel: number;
  25985. static readonly AllLogLevel: number;
  25986. private static _AddLogEntry(entry);
  25987. private static _FormatMessage(message);
  25988. private static _LogDisabled(message);
  25989. private static _LogEnabled(message);
  25990. private static _WarnDisabled(message);
  25991. private static _WarnEnabled(message);
  25992. private static _ErrorDisabled(message);
  25993. private static _ErrorEnabled(message);
  25994. static Log: (message: string) => void;
  25995. static Warn: (message: string) => void;
  25996. static Error: (message: string) => void;
  25997. static readonly LogCache: string;
  25998. static ClearLogCache(): void;
  25999. static LogLevels: number;
  26000. static IsWindowObjectExist(): boolean;
  26001. private static _PerformanceNoneLogLevel;
  26002. private static _PerformanceUserMarkLogLevel;
  26003. private static _PerformanceConsoleLogLevel;
  26004. private static _performance;
  26005. static readonly PerformanceNoneLogLevel: number;
  26006. static readonly PerformanceUserMarkLogLevel: number;
  26007. static readonly PerformanceConsoleLogLevel: number;
  26008. static PerformanceLogLevel: number;
  26009. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  26010. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  26011. static _StartUserMark(counterName: string, condition?: boolean): void;
  26012. static _EndUserMark(counterName: string, condition?: boolean): void;
  26013. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  26014. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  26015. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  26016. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  26017. static readonly Now: number;
  26018. /**
  26019. * This method will return the name of the class used to create the instance of the given object.
  26020. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  26021. * @param object the object to get the class name from
  26022. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  26023. */
  26024. static GetClassName(object: any, isType?: boolean): string;
  26025. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  26026. /**
  26027. * This method will return the name of the full name of the class, including its owning module (if any).
  26028. * 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).
  26029. * @param object the object to get the class name from
  26030. * @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.
  26031. */
  26032. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  26033. /**
  26034. * 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.
  26035. * @param array
  26036. */
  26037. static arrayOrStringFeeder(array: any): (i: number) => number;
  26038. /**
  26039. * Compute the hashCode of a stream of number
  26040. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  26041. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  26042. * @return the hash code computed
  26043. */
  26044. static hashCodeFromStream(feeder: (index: number) => number): number;
  26045. /**
  26046. * Returns a promise that resolves after the given amount of time.
  26047. * @param delay Number of milliseconds to delay
  26048. * @returns Promise that resolves after the given amount of time
  26049. */
  26050. static DelayAsync(delay: number): Promise<void>;
  26051. }
  26052. /**
  26053. * This class is used to track a performance counter which is number based.
  26054. * The user has access to many properties which give statistics of different nature
  26055. *
  26056. * The implementer can track two kinds of Performance Counter: time and count
  26057. * 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.
  26058. * 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.
  26059. */
  26060. class PerfCounter {
  26061. static Enabled: boolean;
  26062. /**
  26063. * Returns the smallest value ever
  26064. */
  26065. readonly min: number;
  26066. /**
  26067. * Returns the biggest value ever
  26068. */
  26069. readonly max: number;
  26070. /**
  26071. * Returns the average value since the performance counter is running
  26072. */
  26073. readonly average: number;
  26074. /**
  26075. * Returns the average value of the last second the counter was monitored
  26076. */
  26077. readonly lastSecAverage: number;
  26078. /**
  26079. * Returns the current value
  26080. */
  26081. readonly current: number;
  26082. readonly total: number;
  26083. readonly count: number;
  26084. constructor();
  26085. /**
  26086. * Call this method to start monitoring a new frame.
  26087. * 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.
  26088. */
  26089. fetchNewFrame(): void;
  26090. /**
  26091. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  26092. * @param newCount the count value to add to the monitored count
  26093. * @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.
  26094. */
  26095. addCount(newCount: number, fetchResult: boolean): void;
  26096. /**
  26097. * Start monitoring this performance counter
  26098. */
  26099. beginMonitoring(): void;
  26100. /**
  26101. * Compute the time lapsed since the previous beginMonitoring() call.
  26102. * @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
  26103. */
  26104. endMonitoring(newFrame?: boolean): void;
  26105. private _fetchResult();
  26106. private _startMonitoringTime;
  26107. private _min;
  26108. private _max;
  26109. private _average;
  26110. private _current;
  26111. private _totalValueCount;
  26112. private _totalAccumulated;
  26113. private _lastSecAverage;
  26114. private _lastSecAccumulated;
  26115. private _lastSecTime;
  26116. private _lastSecValueCount;
  26117. }
  26118. /**
  26119. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  26120. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  26121. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  26122. * @param name The name of the class, case should be preserved
  26123. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  26124. */
  26125. function className(name: string, module?: string): (target: Object) => void;
  26126. /**
  26127. * An implementation of a loop for asynchronous functions.
  26128. */
  26129. class AsyncLoop {
  26130. iterations: number;
  26131. private _fn;
  26132. private _successCallback;
  26133. index: number;
  26134. private _done;
  26135. /**
  26136. * Constroctor.
  26137. * @param iterations the number of iterations.
  26138. * @param _fn the function to run each iteration
  26139. * @param _successCallback the callback that will be called upon succesful execution
  26140. * @param offset starting offset.
  26141. */
  26142. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  26143. /**
  26144. * Execute the next iteration. Must be called after the last iteration was finished.
  26145. */
  26146. executeNext(): void;
  26147. /**
  26148. * Break the loop and run the success callback.
  26149. */
  26150. breakLoop(): void;
  26151. /**
  26152. * Helper function
  26153. */
  26154. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  26155. /**
  26156. * A for-loop that will run a given number of iterations synchronous and the rest async.
  26157. * @param iterations total number of iterations
  26158. * @param syncedIterations number of synchronous iterations in each async iteration.
  26159. * @param fn the function to call each iteration.
  26160. * @param callback a success call back that will be called when iterating stops.
  26161. * @param breakFunction a break condition (optional)
  26162. * @param timeout timeout settings for the setTimeout function. default - 0.
  26163. * @constructor
  26164. */
  26165. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  26166. }
  26167. }
  26168. declare module BABYLON {
  26169. enum JoystickAxis {
  26170. X = 0,
  26171. Y = 1,
  26172. Z = 2,
  26173. }
  26174. class VirtualJoystick {
  26175. reverseLeftRight: boolean;
  26176. reverseUpDown: boolean;
  26177. deltaPosition: Vector3;
  26178. pressed: boolean;
  26179. private static _globalJoystickIndex;
  26180. private static vjCanvas;
  26181. private static vjCanvasContext;
  26182. private static vjCanvasWidth;
  26183. private static vjCanvasHeight;
  26184. private static halfWidth;
  26185. private _action;
  26186. private _axisTargetedByLeftAndRight;
  26187. private _axisTargetedByUpAndDown;
  26188. private _joystickSensibility;
  26189. private _inversedSensibility;
  26190. private _joystickPointerID;
  26191. private _joystickColor;
  26192. private _joystickPointerPos;
  26193. private _joystickPreviousPointerPos;
  26194. private _joystickPointerStartPos;
  26195. private _deltaJoystickVector;
  26196. private _leftJoystick;
  26197. private _touches;
  26198. private _onPointerDownHandlerRef;
  26199. private _onPointerMoveHandlerRef;
  26200. private _onPointerUpHandlerRef;
  26201. private _onResize;
  26202. constructor(leftJoystick?: boolean);
  26203. setJoystickSensibility(newJoystickSensibility: number): void;
  26204. private _onPointerDown(e);
  26205. private _onPointerMove(e);
  26206. private _onPointerUp(e);
  26207. /**
  26208. * Change the color of the virtual joystick
  26209. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  26210. */
  26211. setJoystickColor(newColor: string): void;
  26212. setActionOnTouch(action: () => any): void;
  26213. setAxisForLeftRight(axis: JoystickAxis): void;
  26214. setAxisForUpDown(axis: JoystickAxis): void;
  26215. private _drawVirtualJoystick();
  26216. releaseCanvas(): void;
  26217. }
  26218. }
  26219. declare module BABYLON {
  26220. /**
  26221. * Helper class to push actions to a pool of workers.
  26222. */
  26223. class WorkerPool implements IDisposable {
  26224. private _workerInfos;
  26225. private _pendingActions;
  26226. /**
  26227. * Constructor
  26228. * @param workers Array of workers to use for actions
  26229. */
  26230. constructor(workers: Array<Worker>);
  26231. /**
  26232. * Terminates all workers and clears any pending actions.
  26233. */
  26234. dispose(): void;
  26235. /**
  26236. * Pushes an action to the worker pool. If all the workers are active, the action will be
  26237. * pended until a worker has completed its action.
  26238. * @param action The action to perform. Call onComplete when the action is complete.
  26239. */
  26240. push(action: (worker: Worker, onComplete: () => void) => void): void;
  26241. private _execute(workerInfo, action);
  26242. }
  26243. }
  26244. declare module BABYLON {
  26245. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  26246. readonly name: string;
  26247. private _zoomStopsAnimation;
  26248. private _idleRotationSpeed;
  26249. private _idleRotationWaitTime;
  26250. private _idleRotationSpinupTime;
  26251. /**
  26252. * Gets the flag that indicates if user zooming should stop animation.
  26253. */
  26254. /**
  26255. * Sets the flag that indicates if user zooming should stop animation.
  26256. */
  26257. zoomStopsAnimation: boolean;
  26258. /**
  26259. * Gets the default speed at which the camera rotates around the model.
  26260. */
  26261. /**
  26262. * Sets the default speed at which the camera rotates around the model.
  26263. */
  26264. idleRotationSpeed: number;
  26265. /**
  26266. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  26267. */
  26268. /**
  26269. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  26270. */
  26271. idleRotationWaitTime: number;
  26272. /**
  26273. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  26274. */
  26275. /**
  26276. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  26277. */
  26278. idleRotationSpinupTime: number;
  26279. /**
  26280. * Gets a value indicating if the camera is currently rotating because of this behavior
  26281. */
  26282. readonly rotationInProgress: boolean;
  26283. private _onPrePointerObservableObserver;
  26284. private _onAfterCheckInputsObserver;
  26285. private _attachedCamera;
  26286. private _isPointerDown;
  26287. private _lastFrameTime;
  26288. private _lastInteractionTime;
  26289. private _cameraRotationSpeed;
  26290. init(): void;
  26291. attach(camera: ArcRotateCamera): void;
  26292. detach(): void;
  26293. /**
  26294. * Returns true if user is scrolling.
  26295. * @return true if user is scrolling.
  26296. */
  26297. private _userIsZooming();
  26298. private _lastFrameRadius;
  26299. private _shouldAnimationStopForInteraction();
  26300. /**
  26301. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  26302. */
  26303. private _applyUserInteraction();
  26304. private _userIsMoving();
  26305. }
  26306. }
  26307. declare module BABYLON {
  26308. /**
  26309. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  26310. */
  26311. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  26312. readonly name: string;
  26313. /**
  26314. * The easing function used by animations
  26315. */
  26316. static EasingFunction: BackEase;
  26317. /**
  26318. * The easing mode used by animations
  26319. */
  26320. static EasingMode: number;
  26321. /**
  26322. * The duration of the animation, in milliseconds
  26323. */
  26324. transitionDuration: number;
  26325. /**
  26326. * Length of the distance animated by the transition when lower radius is reached
  26327. */
  26328. lowerRadiusTransitionRange: number;
  26329. /**
  26330. * Length of the distance animated by the transition when upper radius is reached
  26331. */
  26332. upperRadiusTransitionRange: number;
  26333. private _autoTransitionRange;
  26334. /**
  26335. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  26336. */
  26337. /**
  26338. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  26339. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  26340. */
  26341. autoTransitionRange: boolean;
  26342. private _attachedCamera;
  26343. private _onAfterCheckInputsObserver;
  26344. private _onMeshTargetChangedObserver;
  26345. init(): void;
  26346. attach(camera: ArcRotateCamera): void;
  26347. detach(): void;
  26348. private _radiusIsAnimating;
  26349. private _radiusBounceTransition;
  26350. private _animatables;
  26351. private _cachedWheelPrecision;
  26352. /**
  26353. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  26354. * @param radiusLimit The limit to check against.
  26355. * @return Bool to indicate if at limit.
  26356. */
  26357. private _isRadiusAtLimit(radiusLimit);
  26358. /**
  26359. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  26360. * @param radiusDelta The delta by which to animate to. Can be negative.
  26361. */
  26362. private _applyBoundRadiusAnimation(radiusDelta);
  26363. /**
  26364. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  26365. */
  26366. protected _clearAnimationLocks(): void;
  26367. /**
  26368. * Stops and removes all animations that have been applied to the camera
  26369. */
  26370. stopAllAnimations(): void;
  26371. }
  26372. }
  26373. declare module BABYLON {
  26374. class FramingBehavior implements Behavior<ArcRotateCamera> {
  26375. readonly name: string;
  26376. private _mode;
  26377. private _radiusScale;
  26378. private _positionScale;
  26379. private _defaultElevation;
  26380. private _elevationReturnTime;
  26381. private _elevationReturnWaitTime;
  26382. private _zoomStopsAnimation;
  26383. private _framingTime;
  26384. /**
  26385. * The easing function used by animations
  26386. */
  26387. static EasingFunction: ExponentialEase;
  26388. /**
  26389. * The easing mode used by animations
  26390. */
  26391. static EasingMode: number;
  26392. /**
  26393. * Gets current mode used by the behavior.
  26394. */
  26395. /**
  26396. * Sets the current mode used by the behavior
  26397. */
  26398. mode: number;
  26399. /**
  26400. * Gets the scale applied to the radius
  26401. */
  26402. /**
  26403. * Sets the scale applied to the radius (1 by default)
  26404. */
  26405. radiusScale: number;
  26406. /**
  26407. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  26408. */
  26409. /**
  26410. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  26411. */
  26412. positionScale: number;
  26413. /**
  26414. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  26415. * behaviour is triggered, in radians.
  26416. */
  26417. /**
  26418. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  26419. * behaviour is triggered, in radians.
  26420. */
  26421. defaultElevation: number;
  26422. /**
  26423. * Gets the time (in milliseconds) taken to return to the default beta position.
  26424. * Negative value indicates camera should not return to default.
  26425. */
  26426. /**
  26427. * Sets the time (in milliseconds) taken to return to the default beta position.
  26428. * Negative value indicates camera should not return to default.
  26429. */
  26430. elevationReturnTime: number;
  26431. /**
  26432. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  26433. */
  26434. /**
  26435. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  26436. */
  26437. elevationReturnWaitTime: number;
  26438. /**
  26439. * Gets the flag that indicates if user zooming should stop animation.
  26440. */
  26441. /**
  26442. * Sets the flag that indicates if user zooming should stop animation.
  26443. */
  26444. zoomStopsAnimation: boolean;
  26445. /**
  26446. * Gets the transition time when framing the mesh, in milliseconds
  26447. */
  26448. /**
  26449. * Sets the transition time when framing the mesh, in milliseconds
  26450. */
  26451. framingTime: number;
  26452. private _onPrePointerObservableObserver;
  26453. private _onAfterCheckInputsObserver;
  26454. private _onMeshTargetChangedObserver;
  26455. private _attachedCamera;
  26456. private _isPointerDown;
  26457. private _lastInteractionTime;
  26458. init(): void;
  26459. attach(camera: ArcRotateCamera): void;
  26460. detach(): void;
  26461. private _animatables;
  26462. private _betaIsAnimating;
  26463. private _betaTransition;
  26464. private _radiusTransition;
  26465. private _vectorTransition;
  26466. /**
  26467. * Targets the given mesh and updates zoom level accordingly.
  26468. * @param mesh The mesh to target.
  26469. * @param radius Optional. If a cached radius position already exists, overrides default.
  26470. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  26471. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  26472. * @param onAnimationEnd Callback triggered at the end of the framing animation
  26473. */
  26474. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  26475. /**
  26476. * Targets the given mesh with its children and updates zoom level accordingly.
  26477. * @param mesh The mesh to target.
  26478. * @param radius Optional. If a cached radius position already exists, overrides default.
  26479. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  26480. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  26481. * @param onAnimationEnd Callback triggered at the end of the framing animation
  26482. */
  26483. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  26484. /**
  26485. * Targets the given meshes with their children and updates zoom level accordingly.
  26486. * @param meshes The mesh to target.
  26487. * @param radius Optional. If a cached radius position already exists, overrides default.
  26488. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  26489. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  26490. * @param onAnimationEnd Callback triggered at the end of the framing animation
  26491. */
  26492. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  26493. /**
  26494. * Targets the given mesh and updates zoom level accordingly.
  26495. * @param mesh The mesh to target.
  26496. * @param radius Optional. If a cached radius position already exists, overrides default.
  26497. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  26498. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  26499. * @param onAnimationEnd Callback triggered at the end of the framing animation
  26500. */
  26501. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  26502. /**
  26503. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  26504. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  26505. * frustum width.
  26506. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  26507. * to fully enclose the mesh in the viewing frustum.
  26508. */
  26509. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  26510. /**
  26511. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  26512. * is automatically returned to its default position (expected to be above ground plane).
  26513. */
  26514. private _maintainCameraAboveGround();
  26515. /**
  26516. * Returns the frustum slope based on the canvas ratio and camera FOV
  26517. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  26518. */
  26519. private _getFrustumSlope();
  26520. /**
  26521. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  26522. */
  26523. private _clearAnimationLocks();
  26524. /**
  26525. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  26526. */
  26527. private _applyUserInteraction();
  26528. /**
  26529. * Stops and removes all animations that have been applied to the camera
  26530. */
  26531. stopAllAnimations(): void;
  26532. /**
  26533. * Gets a value indicating if the user is moving the camera
  26534. */
  26535. readonly isUserIsMoving: boolean;
  26536. /**
  26537. * The camera can move all the way towards the mesh.
  26538. */
  26539. static IgnoreBoundsSizeMode: number;
  26540. /**
  26541. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  26542. */
  26543. static FitFrustumSidesMode: number;
  26544. }
  26545. }
  26546. declare module BABYLON {
  26547. interface IOctreeContainer<T> {
  26548. blocks: Array<OctreeBlock<T>>;
  26549. }
  26550. class Octree<T> {
  26551. maxDepth: number;
  26552. blocks: Array<OctreeBlock<T>>;
  26553. dynamicContent: T[];
  26554. private _maxBlockCapacity;
  26555. private _selectionContent;
  26556. private _creationFunc;
  26557. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  26558. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  26559. addMesh(entry: T): void;
  26560. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  26561. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  26562. intersectsRay(ray: Ray): SmartArray<T>;
  26563. 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;
  26564. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  26565. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  26566. }
  26567. }
  26568. declare module BABYLON {
  26569. class OctreeBlock<T> {
  26570. entries: T[];
  26571. blocks: Array<OctreeBlock<T>>;
  26572. private _depth;
  26573. private _maxDepth;
  26574. private _capacity;
  26575. private _minPoint;
  26576. private _maxPoint;
  26577. private _boundingVectors;
  26578. private _creationFunc;
  26579. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  26580. readonly capacity: number;
  26581. readonly minPoint: Vector3;
  26582. readonly maxPoint: Vector3;
  26583. addEntry(entry: T): void;
  26584. addEntries(entries: T[]): void;
  26585. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  26586. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  26587. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  26588. createInnerBlocks(): void;
  26589. }
  26590. }
  26591. declare module BABYLON {
  26592. class VRCameraMetrics {
  26593. hResolution: number;
  26594. vResolution: number;
  26595. hScreenSize: number;
  26596. vScreenSize: number;
  26597. vScreenCenter: number;
  26598. eyeToScreenDistance: number;
  26599. lensSeparationDistance: number;
  26600. interpupillaryDistance: number;
  26601. distortionK: number[];
  26602. chromaAbCorrection: number[];
  26603. postProcessScaleFactor: number;
  26604. lensCenterOffset: number;
  26605. compensateDistortion: boolean;
  26606. readonly aspectRatio: number;
  26607. readonly aspectRatioFov: number;
  26608. readonly leftHMatrix: Matrix;
  26609. readonly rightHMatrix: Matrix;
  26610. readonly leftPreViewMatrix: Matrix;
  26611. readonly rightPreViewMatrix: Matrix;
  26612. static GetDefault(): VRCameraMetrics;
  26613. }
  26614. }
  26615. declare module BABYLON {
  26616. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  26617. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  26618. getClassName(): string;
  26619. }
  26620. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  26621. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  26622. getClassName(): string;
  26623. }
  26624. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  26625. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  26626. getClassName(): string;
  26627. }
  26628. }
  26629. declare module BABYLON {
  26630. /**
  26631. * Options to modify the vr teleportation behavior.
  26632. */
  26633. interface VRTeleportationOptions {
  26634. /**
  26635. * The name of the mesh which should be used as the teleportation floor. (default: null)
  26636. */
  26637. floorMeshName?: string;
  26638. /**
  26639. * A list of meshes to be used as the teleportation floor. (default: empty)
  26640. */
  26641. floorMeshes?: Mesh[];
  26642. }
  26643. /**
  26644. * Options to modify the vr experience helper's behavior.
  26645. */
  26646. interface VRExperienceHelperOptions extends WebVROptions {
  26647. /**
  26648. * Create a DeviceOrientationCamera to be used as your out of vr camera.
  26649. */
  26650. createDeviceOrientationCamera?: boolean;
  26651. /**
  26652. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found.
  26653. */
  26654. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  26655. }
  26656. /**
  26657. * Helps to quickly add VR support to an existing scene.
  26658. * See http://doc.babylonjs.com/how_to/webvr_helper
  26659. */
  26660. class VRExperienceHelper {
  26661. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  26662. private _scene;
  26663. private _position;
  26664. private _btnVR;
  26665. private _btnVRDisplayed;
  26666. private _webVRsupported;
  26667. private _webVRready;
  26668. private _webVRrequesting;
  26669. private _webVRpresenting;
  26670. private _fullscreenVRpresenting;
  26671. private _canvas;
  26672. private _webVRCamera;
  26673. private _vrDeviceOrientationCamera;
  26674. private _deviceOrientationCamera;
  26675. private _existingCamera;
  26676. private _onKeyDown;
  26677. private _onVrDisplayPresentChange;
  26678. private _onVRDisplayChanged;
  26679. private _onVRRequestPresentStart;
  26680. private _onVRRequestPresentComplete;
  26681. /**
  26682. * Observable raised when entering VR.
  26683. */
  26684. onEnteringVRObservable: Observable<VRExperienceHelper>;
  26685. /**
  26686. * Observable raised when exiting VR.
  26687. */
  26688. onExitingVRObservable: Observable<VRExperienceHelper>;
  26689. /**
  26690. * Observable raised when controller mesh is loaded.
  26691. */
  26692. onControllerMeshLoadedObservable: Observable<WebVRController>;
  26693. /** Return this.onEnteringVRObservable
  26694. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  26695. */
  26696. readonly onEnteringVR: Observable<VRExperienceHelper>;
  26697. /** Return this.onExitingVRObservable
  26698. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  26699. */
  26700. readonly onExitingVR: Observable<VRExperienceHelper>;
  26701. /** Return this.onControllerMeshLoadedObservable
  26702. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  26703. */
  26704. readonly onControllerMeshLoaded: Observable<WebVRController>;
  26705. private _rayLength;
  26706. private _useCustomVRButton;
  26707. private _teleportationRequested;
  26708. private _teleportActive;
  26709. private _floorMeshName;
  26710. private _floorMeshesCollection;
  26711. private _rotationAllowed;
  26712. private _teleportBackwardsVector;
  26713. private _rotationRightAsked;
  26714. private _rotationLeftAsked;
  26715. private _teleportationTarget;
  26716. private _isDefaultTeleportationTarget;
  26717. private _postProcessMove;
  26718. private _teleportationFillColor;
  26719. private _teleportationBorderColor;
  26720. private _rotationAngle;
  26721. private _haloCenter;
  26722. private _cameraGazer;
  26723. private _padSensibilityUp;
  26724. private _padSensibilityDown;
  26725. private leftController;
  26726. private rightController;
  26727. /**
  26728. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  26729. */
  26730. onNewMeshSelected: Observable<AbstractMesh>;
  26731. /**
  26732. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  26733. */
  26734. onNewMeshPicked: Observable<PickingInfo>;
  26735. private _circleEase;
  26736. /**
  26737. * Observable raised before camera teleportation
  26738. */
  26739. onBeforeCameraTeleport: Observable<Vector3>;
  26740. /**
  26741. * Observable raised after camera teleportation
  26742. */
  26743. onAfterCameraTeleport: Observable<Vector3>;
  26744. /**
  26745. * Observable raised when current selected mesh gets unselected
  26746. */
  26747. onSelectedMeshUnselected: Observable<AbstractMesh>;
  26748. private _raySelectionPredicate;
  26749. /**
  26750. * To be optionaly changed by user to define custom ray selection
  26751. */
  26752. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  26753. /**
  26754. * To be optionaly changed by user to define custom selection logic (after ray selection)
  26755. */
  26756. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  26757. /**
  26758. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  26759. */
  26760. teleportationEnabled: boolean;
  26761. private _defaultHeight;
  26762. private _teleportationInitialized;
  26763. private _interactionsEnabled;
  26764. private _interactionsRequested;
  26765. private _displayGaze;
  26766. private _displayLaserPointer;
  26767. /**
  26768. * The mesh used to display where the user is going to teleport.
  26769. */
  26770. /**
  26771. * Sets the mesh to be used to display where the user is going to teleport.
  26772. */
  26773. teleportationTarget: Mesh;
  26774. /**
  26775. * The mesh used to display where the user is selecting,
  26776. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  26777. * See http://doc.babylonjs.com/resources/baking_transformations
  26778. */
  26779. gazeTrackerMesh: Mesh;
  26780. /**
  26781. * If the ray of the gaze should be displayed.
  26782. */
  26783. /**
  26784. * Sets if the ray of the gaze should be displayed.
  26785. */
  26786. displayGaze: boolean;
  26787. /**
  26788. * If the ray of the LaserPointer should be displayed.
  26789. */
  26790. /**
  26791. * Sets if the ray of the LaserPointer should be displayed.
  26792. */
  26793. displayLaserPointer: boolean;
  26794. /**
  26795. * The deviceOrientationCamera used as the camera when not in VR.
  26796. */
  26797. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  26798. /**
  26799. * Based on the current WebVR support, returns the current VR camera used.
  26800. */
  26801. readonly currentVRCamera: Nullable<Camera>;
  26802. /**
  26803. * The webVRCamera which is used when in VR.
  26804. */
  26805. readonly webVRCamera: WebVRFreeCamera;
  26806. /**
  26807. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  26808. */
  26809. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  26810. private readonly _teleportationRequestInitiated;
  26811. /**
  26812. * Instantiates a VRExperienceHelper.
  26813. * Helps to quickly add VR support to an existing scene.
  26814. * @param scene The scene the VRExperienceHelper belongs to.
  26815. * @param webVROptions Options to modify the vr experience helper's behavior.
  26816. */
  26817. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  26818. private _onDefaultMeshLoaded(webVRController);
  26819. private _onResize;
  26820. private _onFullscreenChange;
  26821. /**
  26822. * Gets a value indicating if we are currently in VR mode.
  26823. */
  26824. readonly isInVRMode: boolean;
  26825. private onVrDisplayPresentChange();
  26826. private onVRDisplayChanged(eventArgs);
  26827. private moveButtonToBottomRight();
  26828. private displayVRButton();
  26829. private updateButtonVisibility();
  26830. /**
  26831. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  26832. * Otherwise, will use the fullscreen API.
  26833. */
  26834. enterVR(): void;
  26835. /**
  26836. * Attempt to exit VR, or fullscreen.
  26837. */
  26838. exitVR(): void;
  26839. /**
  26840. * The position of the vr experience helper.
  26841. */
  26842. /**
  26843. * Sets the position of the vr experience helper.
  26844. */
  26845. position: Vector3;
  26846. /**
  26847. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  26848. */
  26849. enableInteractions(): void;
  26850. private beforeRender;
  26851. private _isTeleportationFloor(mesh);
  26852. /**
  26853. * Adds a floor mesh to be used for teleportation.
  26854. * @param floorMesh the mesh to be used for teleportation.
  26855. */
  26856. addFloorMesh(floorMesh: Mesh): void;
  26857. /**
  26858. * Removes a floor mesh from being used for teleportation.
  26859. * @param floorMesh the mesh to be removed.
  26860. */
  26861. removeFloorMesh(floorMesh: Mesh): void;
  26862. /**
  26863. * Enables interactions and teleportation using the VR controllers and gaze.
  26864. * @param vrTeleportationOptions options to modify teleportation behavior.
  26865. */
  26866. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  26867. private _onNewGamepadConnected;
  26868. private _tryEnableInteractionOnController;
  26869. private _onNewGamepadDisconnected;
  26870. private _enableInteractionOnController(controller);
  26871. private _checkTeleportWithRay(stateObject, gazer);
  26872. private _checkRotate(stateObject, gazer);
  26873. private _checkTeleportBackwards(stateObject, gazer);
  26874. private _enableTeleportationOnController(controller);
  26875. private _createTeleportationCircles();
  26876. private _displayTeleportationTarget();
  26877. private _hideTeleportationTarget();
  26878. private _rotateCamera(right);
  26879. private _moveTeleportationSelectorTo(hit, gazer);
  26880. private _workingVector;
  26881. private _workingQuaternion;
  26882. private _workingMatrix;
  26883. private _teleportCamera(location);
  26884. private _castRayAndSelectObject(gazer);
  26885. private _notifySelectedMeshUnselected(mesh);
  26886. /**
  26887. * Sets the color of the laser ray from the vr controllers.
  26888. * @param color new color for the ray.
  26889. */
  26890. changeLaserColor(color: Color3): void;
  26891. /**
  26892. * Sets the color of the ray from the vr headsets gaze.
  26893. * @param color new color for the ray.
  26894. */
  26895. changeGazeColor(color: Color3): void;
  26896. /**
  26897. * Exits VR and disposes of the vr experience helper
  26898. */
  26899. dispose(): void;
  26900. /**
  26901. * Gets the name of the VRExperienceHelper class
  26902. * @returns "VRExperienceHelper"
  26903. */
  26904. getClassName(): string;
  26905. }
  26906. }
  26907. declare var VRFrameData: any;
  26908. declare module BABYLON {
  26909. /**
  26910. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  26911. * IMPORTANT!! The data is right-hand data.
  26912. * @export
  26913. * @interface DevicePose
  26914. */
  26915. interface DevicePose {
  26916. /**
  26917. * The position of the device, values in array are [x,y,z].
  26918. */
  26919. readonly position?: Float32Array;
  26920. /**
  26921. * The linearVelocity of the device, values in array are [x,y,z].
  26922. */
  26923. readonly linearVelocity?: Float32Array;
  26924. /**
  26925. * The linearAcceleration of the device, values in array are [x,y,z].
  26926. */
  26927. readonly linearAcceleration?: Float32Array;
  26928. /**
  26929. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  26930. */
  26931. readonly orientation?: Float32Array;
  26932. /**
  26933. * The angularVelocity of the device, values in array are [x,y,z].
  26934. */
  26935. readonly angularVelocity?: Float32Array;
  26936. /**
  26937. * The angularAcceleration of the device, values in array are [x,y,z].
  26938. */
  26939. readonly angularAcceleration?: Float32Array;
  26940. }
  26941. /**
  26942. * Interface representing a pose controlled object in Babylon.
  26943. * A pose controlled object has both regular pose values as well as pose values
  26944. * from an external device such as a VR head mounted display
  26945. */
  26946. interface PoseControlled {
  26947. /**
  26948. * The position of the object in babylon space.
  26949. */
  26950. position: Vector3;
  26951. /**
  26952. * The rotation quaternion of the object in babylon space.
  26953. */
  26954. rotationQuaternion: Quaternion;
  26955. /**
  26956. * The position of the device in babylon space.
  26957. */
  26958. devicePosition?: Vector3;
  26959. /**
  26960. * The rotation quaternion of the device in babylon space.
  26961. */
  26962. deviceRotationQuaternion: Quaternion;
  26963. /**
  26964. * The raw pose coming from the device.
  26965. */
  26966. rawPose: Nullable<DevicePose>;
  26967. /**
  26968. * The scale of the device to be used when translating from device space to babylon space.
  26969. */
  26970. deviceScaleFactor: number;
  26971. /**
  26972. * Updates the poseControlled values based on the input device pose.
  26973. * @param poseData the pose data to update the object with
  26974. */
  26975. updateFromDevice(poseData: DevicePose): void;
  26976. }
  26977. /**
  26978. * Set of options to customize the webVRCamera
  26979. */
  26980. interface WebVROptions {
  26981. /**
  26982. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  26983. */
  26984. trackPosition?: boolean;
  26985. /**
  26986. * Sets the scale of the vrDevice in babylon space. (default: 1)
  26987. */
  26988. positionScale?: number;
  26989. /**
  26990. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  26991. */
  26992. displayName?: string;
  26993. /**
  26994. * Should the native controller meshes be initialized. (default: true)
  26995. */
  26996. controllerMeshes?: boolean;
  26997. /**
  26998. * Creating a default HemiLight only on controllers. (default: true)
  26999. */
  27000. defaultLightingOnControllers?: boolean;
  27001. /**
  27002. * If you don't want to use the default VR button of the helper. (default: false)
  27003. */
  27004. useCustomVRButton?: boolean;
  27005. /**
  27006. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27007. */
  27008. customVRButton?: HTMLButtonElement;
  27009. /**
  27010. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27011. */
  27012. rayLength?: number;
  27013. /**
  27014. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27015. */
  27016. defaultHeight?: number;
  27017. }
  27018. /**
  27019. * This represents a WebVR camera.
  27020. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27021. * @example http://doc.babylonjs.com/how_to/webvr_camera
  27022. */
  27023. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27024. private webVROptions;
  27025. /**
  27026. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27027. */
  27028. _vrDevice: any;
  27029. /**
  27030. * The rawPose of the vrDevice.
  27031. */
  27032. rawPose: Nullable<DevicePose>;
  27033. private _onVREnabled;
  27034. private _specsVersion;
  27035. private _attached;
  27036. private _frameData;
  27037. protected _descendants: Array<Node>;
  27038. private _deviceRoomPosition;
  27039. private _deviceRoomRotationQuaternion;
  27040. private _standingMatrix;
  27041. /**
  27042. * Represents device position in babylon space.
  27043. */
  27044. devicePosition: Vector3;
  27045. /**
  27046. * Represents device rotation in babylon space.
  27047. */
  27048. deviceRotationQuaternion: Quaternion;
  27049. /**
  27050. * The scale of the device to be used when translating from device space to babylon space.
  27051. */
  27052. deviceScaleFactor: number;
  27053. private _deviceToWorld;
  27054. private _worldToDevice;
  27055. /**
  27056. * References to the webVR controllers for the vrDevice.
  27057. */
  27058. controllers: Array<WebVRController>;
  27059. /**
  27060. * Emits an event when a controller is attached.
  27061. */
  27062. onControllersAttachedObservable: Observable<WebVRController[]>;
  27063. /**
  27064. * Emits an event when a controller's mesh has been loaded;
  27065. */
  27066. onControllerMeshLoadedObservable: Observable<WebVRController>;
  27067. /**
  27068. * If the rig cameras be used as parent instead of this camera.
  27069. */
  27070. rigParenting: boolean;
  27071. private _lightOnControllers;
  27072. private _defaultHeight?;
  27073. /**
  27074. * Instantiates a WebVRFreeCamera.
  27075. * @param name The name of the WebVRFreeCamera
  27076. * @param position The starting anchor position for the camera
  27077. * @param scene The scene the camera belongs to
  27078. * @param webVROptions a set of customizable options for the webVRCamera
  27079. */
  27080. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  27081. /**
  27082. * Gets the device distance from the ground in meters.
  27083. * @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.
  27084. */
  27085. deviceDistanceToRoomGround(): number;
  27086. /**
  27087. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27088. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  27089. */
  27090. useStandingMatrix(callback?: (bool: boolean) => void): void;
  27091. /**
  27092. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27093. * @returns A promise with a boolean set to if the standing matrix is supported.
  27094. */
  27095. useStandingMatrixAsync(): Promise<boolean>;
  27096. /**
  27097. * Disposes the camera
  27098. */
  27099. dispose(): void;
  27100. /**
  27101. * Gets a vrController by name.
  27102. * @param name The name of the controller to retreive
  27103. * @returns the controller matching the name specified or null if not found
  27104. */
  27105. getControllerByName(name: string): Nullable<WebVRController>;
  27106. private _leftController;
  27107. /**
  27108. * The controller corrisponding to the users left hand.
  27109. */
  27110. readonly leftController: Nullable<WebVRController>;
  27111. private _rightController;
  27112. /**
  27113. * The controller corrisponding to the users right hand.
  27114. */
  27115. readonly rightController: Nullable<WebVRController>;
  27116. /**
  27117. * Casts a ray forward from the vrCamera's gaze.
  27118. * @param length Length of the ray (default: 100)
  27119. * @returns the ray corrisponding to the gaze
  27120. */
  27121. getForwardRay(length?: number): Ray;
  27122. /**
  27123. * Updates the camera based on device's frame data
  27124. */
  27125. _checkInputs(): void;
  27126. /**
  27127. * Updates the poseControlled values based on the input device pose.
  27128. * @param poseData Pose coming from the device
  27129. */
  27130. updateFromDevice(poseData: DevicePose): void;
  27131. /**
  27132. * WebVR's attach control will start broadcasting frames to the device.
  27133. * Note that in certain browsers (chrome for example) this function must be called
  27134. * within a user-interaction callback. Example:
  27135. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27136. *
  27137. * @param element html element to attach the vrDevice to
  27138. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27139. */
  27140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27141. /**
  27142. * Detaches the camera from the html element and disables VR
  27143. *
  27144. * @param element html element to detach from
  27145. */
  27146. detachControl(element: HTMLElement): void;
  27147. /**
  27148. * @returns the name of this class
  27149. */
  27150. getClassName(): string;
  27151. /**
  27152. * Calls resetPose on the vrDisplay
  27153. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27154. */
  27155. resetToCurrentRotation(): void;
  27156. /**
  27157. * Updates the rig cameras (left and right eye)
  27158. */
  27159. _updateRigCameras(): void;
  27160. private _workingVector;
  27161. private _oneVector;
  27162. private _workingMatrix;
  27163. private updateCacheCalled;
  27164. /**
  27165. * Updates the cached values of the camera
  27166. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27167. */
  27168. _updateCache(ignoreParentClass?: boolean): void;
  27169. /**
  27170. * Updates the current device position and rotation in the babylon world
  27171. */
  27172. update(): void;
  27173. /**
  27174. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27175. * @returns an identity matrix
  27176. */
  27177. _getViewMatrix(): Matrix;
  27178. /**
  27179. * This function is called by the two RIG cameras.
  27180. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27181. */
  27182. protected _getWebVRViewMatrix(): Matrix;
  27183. protected _getWebVRProjectionMatrix(): Matrix;
  27184. private _onGamepadConnectedObserver;
  27185. private _onGamepadDisconnectedObserver;
  27186. /**
  27187. * Initializes the controllers and their meshes
  27188. */
  27189. initControllers(): void;
  27190. }
  27191. }
  27192. declare module BABYLON {
  27193. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  27194. camera: ArcRotateCamera;
  27195. gamepad: Nullable<Gamepad>;
  27196. private _onGamepadConnectedObserver;
  27197. private _onGamepadDisconnectedObserver;
  27198. gamepadRotationSensibility: number;
  27199. gamepadMoveSensibility: number;
  27200. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27201. detachControl(element: Nullable<HTMLElement>): void;
  27202. checkInputs(): void;
  27203. getClassName(): string;
  27204. getSimpleName(): string;
  27205. }
  27206. }
  27207. declare module BABYLON {
  27208. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  27209. camera: ArcRotateCamera;
  27210. private _keys;
  27211. keysUp: number[];
  27212. keysDown: number[];
  27213. keysLeft: number[];
  27214. keysRight: number[];
  27215. keysReset: number[];
  27216. panningSensibility: number;
  27217. zoomingSensibility: number;
  27218. useAltToZoom: boolean;
  27219. private _ctrlPressed;
  27220. private _altPressed;
  27221. private _onCanvasBlurObserver;
  27222. private _onKeyboardObserver;
  27223. private _engine;
  27224. private _scene;
  27225. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27226. detachControl(element: Nullable<HTMLElement>): void;
  27227. checkInputs(): void;
  27228. getClassName(): string;
  27229. getSimpleName(): string;
  27230. }
  27231. }
  27232. declare module BABYLON {
  27233. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  27234. camera: ArcRotateCamera;
  27235. private _wheel;
  27236. private _observer;
  27237. wheelPrecision: number;
  27238. /**
  27239. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  27240. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  27241. */
  27242. wheelDeltaPercentage: number;
  27243. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27244. detachControl(element: Nullable<HTMLElement>): void;
  27245. getClassName(): string;
  27246. getSimpleName(): string;
  27247. }
  27248. }
  27249. declare module BABYLON {
  27250. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  27251. camera: ArcRotateCamera;
  27252. buttons: number[];
  27253. angularSensibilityX: number;
  27254. angularSensibilityY: number;
  27255. pinchPrecision: number;
  27256. /**
  27257. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  27258. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  27259. */
  27260. pinchDeltaPercentage: number;
  27261. panningSensibility: number;
  27262. multiTouchPanning: boolean;
  27263. multiTouchPanAndZoom: boolean;
  27264. private _isPanClick;
  27265. pinchInwards: boolean;
  27266. private _pointerInput;
  27267. private _observer;
  27268. private _onMouseMove;
  27269. private _onGestureStart;
  27270. private _onGesture;
  27271. private _MSGestureHandler;
  27272. private _onLostFocus;
  27273. private _onContextMenu;
  27274. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27275. detachControl(element: Nullable<HTMLElement>): void;
  27276. getClassName(): string;
  27277. getSimpleName(): string;
  27278. }
  27279. }
  27280. declare module BABYLON {
  27281. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  27282. camera: ArcRotateCamera;
  27283. alphaCorrection: number;
  27284. betaCorrection: number;
  27285. gammaCorrection: number;
  27286. private _alpha;
  27287. private _gamma;
  27288. private _dirty;
  27289. private _deviceOrientationHandler;
  27290. constructor();
  27291. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27292. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  27293. checkInputs(): void;
  27294. detachControl(element: Nullable<HTMLElement>): void;
  27295. getClassName(): string;
  27296. getSimpleName(): string;
  27297. }
  27298. }
  27299. declare module BABYLON {
  27300. /**
  27301. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  27302. * Screen rotation is taken into account.
  27303. */
  27304. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  27305. private _camera;
  27306. private _screenOrientationAngle;
  27307. private _constantTranform;
  27308. private _screenQuaternion;
  27309. private _alpha;
  27310. private _beta;
  27311. private _gamma;
  27312. constructor();
  27313. camera: FreeCamera;
  27314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27315. private _orientationChanged;
  27316. private _deviceOrientation;
  27317. detachControl(element: Nullable<HTMLElement>): void;
  27318. checkInputs(): void;
  27319. getClassName(): string;
  27320. getSimpleName(): string;
  27321. }
  27322. }
  27323. declare module BABYLON {
  27324. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  27325. camera: FreeCamera;
  27326. gamepad: Nullable<Gamepad>;
  27327. private _onGamepadConnectedObserver;
  27328. private _onGamepadDisconnectedObserver;
  27329. gamepadAngularSensibility: number;
  27330. gamepadMoveSensibility: number;
  27331. private _cameraTransform;
  27332. private _deltaTransform;
  27333. private _vector3;
  27334. private _vector2;
  27335. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27336. detachControl(element: Nullable<HTMLElement>): void;
  27337. checkInputs(): void;
  27338. getClassName(): string;
  27339. getSimpleName(): string;
  27340. }
  27341. }
  27342. declare module BABYLON {
  27343. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  27344. camera: FreeCamera;
  27345. private _keys;
  27346. private _onCanvasBlurObserver;
  27347. private _onKeyboardObserver;
  27348. private _engine;
  27349. private _scene;
  27350. keysUp: number[];
  27351. keysDown: number[];
  27352. keysLeft: number[];
  27353. keysRight: number[];
  27354. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27355. detachControl(element: Nullable<HTMLElement>): void;
  27356. checkInputs(): void;
  27357. getClassName(): string;
  27358. _onLostFocus(e: FocusEvent): void;
  27359. getSimpleName(): string;
  27360. }
  27361. }
  27362. declare module BABYLON {
  27363. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  27364. touchEnabled: boolean;
  27365. camera: FreeCamera;
  27366. buttons: number[];
  27367. angularSensibility: number;
  27368. private _pointerInput;
  27369. private _onMouseMove;
  27370. private _observer;
  27371. private previousPosition;
  27372. constructor(touchEnabled?: boolean);
  27373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27374. detachControl(element: Nullable<HTMLElement>): void;
  27375. getClassName(): string;
  27376. getSimpleName(): string;
  27377. }
  27378. }
  27379. declare module BABYLON {
  27380. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  27381. camera: FreeCamera;
  27382. private _offsetX;
  27383. private _offsetY;
  27384. private _pointerPressed;
  27385. private _pointerInput;
  27386. private _observer;
  27387. private _onLostFocus;
  27388. touchAngularSensibility: number;
  27389. touchMoveSensibility: number;
  27390. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27391. detachControl(element: Nullable<HTMLElement>): void;
  27392. checkInputs(): void;
  27393. getClassName(): string;
  27394. getSimpleName(): string;
  27395. }
  27396. }
  27397. declare module BABYLON {
  27398. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  27399. camera: FreeCamera;
  27400. private _leftjoystick;
  27401. private _rightjoystick;
  27402. getLeftJoystick(): VirtualJoystick;
  27403. getRightJoystick(): VirtualJoystick;
  27404. checkInputs(): void;
  27405. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27406. detachControl(element: Nullable<HTMLElement>): void;
  27407. getClassName(): string;
  27408. getSimpleName(): string;
  27409. }
  27410. }
  27411. declare module BABYLON {
  27412. /**
  27413. * Google Daydream controller
  27414. */
  27415. class DaydreamController extends WebVRController {
  27416. /**
  27417. * Base Url for the controller model.
  27418. */
  27419. static MODEL_BASE_URL: string;
  27420. /**
  27421. * File name for the controller model.
  27422. */
  27423. static MODEL_FILENAME: string;
  27424. /**
  27425. * Gamepad Id prefix used to identify Daydream Controller.
  27426. */
  27427. static readonly GAMEPAD_ID_PREFIX: string;
  27428. /**
  27429. * Creates a new DaydreamController from a gamepad
  27430. * @param vrGamepad the gamepad that the controller should be created from
  27431. */
  27432. constructor(vrGamepad: any);
  27433. /**
  27434. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  27435. * @param scene scene in which to add meshes
  27436. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  27437. */
  27438. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27439. /**
  27440. * Called once for each button that changed state since the last frame
  27441. * @param buttonIdx Which button index changed
  27442. * @param state New state of the button
  27443. * @param changes Which properties on the state changed since last frame
  27444. */
  27445. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27446. }
  27447. }
  27448. declare module BABYLON {
  27449. /**
  27450. * Gear VR Controller
  27451. */
  27452. class GearVRController extends WebVRController {
  27453. /**
  27454. * Base Url for the controller model.
  27455. */
  27456. static MODEL_BASE_URL: string;
  27457. /**
  27458. * File name for the controller model.
  27459. */
  27460. static MODEL_FILENAME: string;
  27461. /**
  27462. * Gamepad Id prefix used to identify this controller.
  27463. */
  27464. static readonly GAMEPAD_ID_PREFIX: string;
  27465. private readonly _buttonIndexToObservableNameMap;
  27466. /**
  27467. * Creates a new GearVRController from a gamepad
  27468. * @param vrGamepad the gamepad that the controller should be created from
  27469. */
  27470. constructor(vrGamepad: any);
  27471. /**
  27472. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  27473. * @param scene scene in which to add meshes
  27474. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  27475. */
  27476. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27477. /**
  27478. * Called once for each button that changed state since the last frame
  27479. * @param buttonIdx Which button index changed
  27480. * @param state New state of the button
  27481. * @param changes Which properties on the state changed since last frame
  27482. */
  27483. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27484. }
  27485. }
  27486. declare module BABYLON {
  27487. /**
  27488. * Generic Controller
  27489. */
  27490. class GenericController extends WebVRController {
  27491. /**
  27492. * Base Url for the controller model.
  27493. */
  27494. static readonly MODEL_BASE_URL: string;
  27495. /**
  27496. * File name for the controller model.
  27497. */
  27498. static readonly MODEL_FILENAME: string;
  27499. /**
  27500. * Creates a new GenericController from a gamepad
  27501. * @param vrGamepad the gamepad that the controller should be created from
  27502. */
  27503. constructor(vrGamepad: any);
  27504. /**
  27505. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  27506. * @param scene scene in which to add meshes
  27507. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  27508. */
  27509. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27510. /**
  27511. * Called once for each button that changed state since the last frame
  27512. * @param buttonIdx Which button index changed
  27513. * @param state New state of the button
  27514. * @param changes Which properties on the state changed since last frame
  27515. */
  27516. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27517. }
  27518. }
  27519. declare module BABYLON {
  27520. /**
  27521. * Oculus Touch Controller
  27522. */
  27523. class OculusTouchController extends WebVRController {
  27524. /**
  27525. * Base Url for the controller model.
  27526. */
  27527. static MODEL_BASE_URL: string;
  27528. /**
  27529. * File name for the left controller model.
  27530. */
  27531. static MODEL_LEFT_FILENAME: string;
  27532. /**
  27533. * File name for the right controller model.
  27534. */
  27535. static MODEL_RIGHT_FILENAME: string;
  27536. /**
  27537. * Fired when the secondary trigger on this controller is modified
  27538. */
  27539. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27540. /**
  27541. * Fired when the thumb rest on this controller is modified
  27542. */
  27543. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  27544. /**
  27545. * Creates a new OculusTouchController from a gamepad
  27546. * @param vrGamepad the gamepad that the controller should be created from
  27547. */
  27548. constructor(vrGamepad: any);
  27549. /**
  27550. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  27551. * @param scene scene in which to add meshes
  27552. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  27553. */
  27554. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27555. /**
  27556. * Fired when the A button on this controller is modified
  27557. */
  27558. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27559. /**
  27560. * Fired when the B button on this controller is modified
  27561. */
  27562. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27563. /**
  27564. * Fired when the X button on this controller is modified
  27565. */
  27566. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27567. /**
  27568. * Fired when the Y button on this controller is modified
  27569. */
  27570. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27571. /**
  27572. * Called once for each button that changed state since the last frame
  27573. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  27574. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  27575. * 2) secondary trigger (same)
  27576. * 3) A (right) X (left), touch, pressed = value
  27577. * 4) B / Y
  27578. * 5) thumb rest
  27579. * @param buttonIdx Which button index changed
  27580. * @param state New state of the button
  27581. * @param changes Which properties on the state changed since last frame
  27582. */
  27583. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27584. }
  27585. }
  27586. declare module BABYLON {
  27587. /**
  27588. * Defines the types of pose enabled controllers that are supported
  27589. */
  27590. enum PoseEnabledControllerType {
  27591. /**
  27592. * HTC Vive
  27593. */
  27594. VIVE = 0,
  27595. /**
  27596. * Oculus Rift
  27597. */
  27598. OCULUS = 1,
  27599. /**
  27600. * Windows mixed reality
  27601. */
  27602. WINDOWS = 2,
  27603. /**
  27604. * Samsung gear VR
  27605. */
  27606. GEAR_VR = 3,
  27607. /**
  27608. * Google Daydream
  27609. */
  27610. DAYDREAM = 4,
  27611. /**
  27612. * Generic
  27613. */
  27614. GENERIC = 5,
  27615. }
  27616. /**
  27617. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27618. */
  27619. interface MutableGamepadButton {
  27620. /**
  27621. * Value of the button/trigger
  27622. */
  27623. value: number;
  27624. /**
  27625. * If the button/trigger is currently touched
  27626. */
  27627. touched: boolean;
  27628. /**
  27629. * If the button/trigger is currently pressed
  27630. */
  27631. pressed: boolean;
  27632. }
  27633. /**
  27634. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27635. * @ignore
  27636. */
  27637. interface ExtendedGamepadButton extends GamepadButton {
  27638. /**
  27639. * If the button/trigger is currently pressed
  27640. */
  27641. readonly pressed: boolean;
  27642. /**
  27643. * If the button/trigger is currently touched
  27644. */
  27645. readonly touched: boolean;
  27646. /**
  27647. * Value of the button/trigger
  27648. */
  27649. readonly value: number;
  27650. }
  27651. /**
  27652. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27653. */
  27654. class PoseEnabledControllerHelper {
  27655. /**
  27656. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27657. * @param vrGamepad the gamepad to initialized
  27658. * @returns a vr controller of the type the gamepad identified as
  27659. */
  27660. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  27661. }
  27662. /**
  27663. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27664. */
  27665. class PoseEnabledController extends Gamepad implements PoseControlled {
  27666. private _deviceRoomPosition;
  27667. private _deviceRoomRotationQuaternion;
  27668. /**
  27669. * The device position in babylon space
  27670. */
  27671. devicePosition: Vector3;
  27672. /**
  27673. * The device rotation in babylon space
  27674. */
  27675. deviceRotationQuaternion: Quaternion;
  27676. /**
  27677. * The scale factor of the device in babylon space
  27678. */
  27679. deviceScaleFactor: number;
  27680. /**
  27681. * (Likely devicePosition should be used instead) The device position in its room space
  27682. */
  27683. position: Vector3;
  27684. /**
  27685. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27686. */
  27687. rotationQuaternion: Quaternion;
  27688. /**
  27689. * The type of controller (Eg. Windows mixed reality)
  27690. */
  27691. controllerType: PoseEnabledControllerType;
  27692. private _calculatedPosition;
  27693. private _calculatedRotation;
  27694. /**
  27695. * The raw pose from the device
  27696. */
  27697. rawPose: DevicePose;
  27698. /**
  27699. * Internal, the mesh attached to the controller
  27700. */
  27701. _mesh: Nullable<AbstractMesh>;
  27702. private _poseControlledCamera;
  27703. private _leftHandSystemQuaternion;
  27704. /**
  27705. * Internal, matrix used to convert room space to babylon space
  27706. */
  27707. _deviceToWorld: Matrix;
  27708. /**
  27709. * Node to be used when casting a ray from the controller
  27710. */
  27711. _pointingPoseNode: Nullable<AbstractMesh>;
  27712. /**
  27713. * Name of the child mesh that can be used to cast a ray from the controller
  27714. */
  27715. static readonly POINTING_POSE: string;
  27716. /**
  27717. * Creates a new PoseEnabledController from a gamepad
  27718. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27719. */
  27720. constructor(browserGamepad: any);
  27721. private _workingMatrix;
  27722. /**
  27723. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27724. */
  27725. update(): void;
  27726. /**
  27727. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27728. * @param poseData raw pose fromthe device
  27729. */
  27730. updateFromDevice(poseData: DevicePose): void;
  27731. /**
  27732. * Attaches a mesh to the controller
  27733. * @param mesh the mesh to be attached
  27734. */
  27735. attachToMesh(mesh: AbstractMesh): void;
  27736. /**
  27737. * Attaches the controllers mesh to a camera
  27738. * @param camera the camera the mesh should be attached to
  27739. */
  27740. attachToPoseControlledCamera(camera: TargetCamera): void;
  27741. /**
  27742. * Disposes of the controller
  27743. */
  27744. dispose(): void;
  27745. /**
  27746. * The mesh that is attached to the controller
  27747. */
  27748. readonly mesh: Nullable<AbstractMesh>;
  27749. /**
  27750. * Gets the ray of the controller in the direction the controller is pointing
  27751. * @param length the length the resulting ray should be
  27752. * @returns a ray in the direction the controller is pointing
  27753. */
  27754. getForwardRay(length?: number): Ray;
  27755. }
  27756. }
  27757. declare module BABYLON {
  27758. /**
  27759. * Vive Controller
  27760. */
  27761. class ViveController extends WebVRController {
  27762. /**
  27763. * Base Url for the controller model.
  27764. */
  27765. static MODEL_BASE_URL: string;
  27766. /**
  27767. * File name for the controller model.
  27768. */
  27769. static MODEL_FILENAME: string;
  27770. /**
  27771. * Creates a new ViveController from a gamepad
  27772. * @param vrGamepad the gamepad that the controller should be created from
  27773. */
  27774. constructor(vrGamepad: any);
  27775. /**
  27776. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  27777. * @param scene scene in which to add meshes
  27778. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  27779. */
  27780. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27781. /**
  27782. * Fired when the left button on this controller is modified
  27783. */
  27784. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27785. /**
  27786. * Fired when the right button on this controller is modified
  27787. */
  27788. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27789. /**
  27790. * Fired when the menu button on this controller is modified
  27791. */
  27792. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27793. /**
  27794. * Called once for each button that changed state since the last frame
  27795. * Vive mapping:
  27796. * 0: touchpad
  27797. * 1: trigger
  27798. * 2: left AND right buttons
  27799. * 3: menu button
  27800. * @param buttonIdx Which button index changed
  27801. * @param state New state of the button
  27802. * @param changes Which properties on the state changed since last frame
  27803. */
  27804. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27805. }
  27806. }
  27807. declare module BABYLON {
  27808. /**
  27809. * Defines the WebVRController object that represents controllers tracked in 3D space
  27810. */
  27811. abstract class WebVRController extends PoseEnabledController {
  27812. /**
  27813. * Internal, the default controller model for the controller
  27814. */
  27815. protected _defaultModel: AbstractMesh;
  27816. /**
  27817. * Fired when the trigger state has changed
  27818. */
  27819. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27820. /**
  27821. * Fired when the main button state has changed
  27822. */
  27823. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27824. /**
  27825. * Fired when the secondary button state has changed
  27826. */
  27827. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27828. /**
  27829. * Fired when the pad state has changed
  27830. */
  27831. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27832. /**
  27833. * Fired when controllers stick values have changed
  27834. */
  27835. onPadValuesChangedObservable: Observable<StickValues>;
  27836. /**
  27837. * Array of button availible on the controller
  27838. */
  27839. protected _buttons: Array<MutableGamepadButton>;
  27840. private _onButtonStateChange;
  27841. /**
  27842. * Fired when a controller button's state has changed
  27843. * @param callback the callback containing the button that was modified
  27844. */
  27845. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27846. /**
  27847. * X and Y axis corrisponding to the controllers joystick
  27848. */
  27849. pad: StickValues;
  27850. /**
  27851. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27852. */
  27853. hand: string;
  27854. /**
  27855. * The default controller model for the controller
  27856. */
  27857. readonly defaultModel: AbstractMesh;
  27858. /**
  27859. * Creates a new WebVRController from a gamepad
  27860. * @param vrGamepad the gamepad that the WebVRController should be created from
  27861. */
  27862. constructor(vrGamepad: any);
  27863. /**
  27864. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27865. */
  27866. update(): void;
  27867. /**
  27868. * Function to be called when a button is modified
  27869. */
  27870. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27871. /**
  27872. * Loads a mesh and attaches it to the controller
  27873. * @param scene the scene the mesh should be added to
  27874. * @param meshLoaded callback for when the mesh has been loaded
  27875. */
  27876. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27877. private _setButtonValue(newState, currentState, buttonIndex);
  27878. private _changes;
  27879. private _checkChanges(newState, currentState);
  27880. /**
  27881. * Disposes of th webVRCOntroller
  27882. */
  27883. dispose(): void;
  27884. }
  27885. }
  27886. declare module BABYLON {
  27887. /**
  27888. * Defines the WindowsMotionController object that the state of the windows motion controller
  27889. */
  27890. class WindowsMotionController extends WebVRController {
  27891. /**
  27892. * The base url used to load the left and right controller models
  27893. */
  27894. static MODEL_BASE_URL: string;
  27895. /**
  27896. * The name of the left controller model file
  27897. */
  27898. static MODEL_LEFT_FILENAME: string;
  27899. /**
  27900. * The name of the right controller model file
  27901. */
  27902. static MODEL_RIGHT_FILENAME: string;
  27903. /**
  27904. * The controller name prefix for this controller type
  27905. */
  27906. static readonly GAMEPAD_ID_PREFIX: string;
  27907. /**
  27908. * The controller id pattern for this controller type
  27909. */
  27910. private static readonly GAMEPAD_ID_PATTERN;
  27911. private _loadedMeshInfo;
  27912. private readonly _mapping;
  27913. /**
  27914. * Fired when the trackpad on this controller is clicked
  27915. */
  27916. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  27917. /**
  27918. * Fired when the trackpad on this controller is modified
  27919. */
  27920. onTrackpadValuesChangedObservable: Observable<StickValues>;
  27921. /**
  27922. * The current x and y values of this controller's trackpad
  27923. */
  27924. trackpad: StickValues;
  27925. /**
  27926. * Creates a new WindowsMotionController from a gamepad
  27927. * @param vrGamepad the gamepad that the controller should be created from
  27928. */
  27929. constructor(vrGamepad: any);
  27930. /**
  27931. * Fired when the trigger on this controller is modified
  27932. */
  27933. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27934. /**
  27935. * Fired when the menu button on this controller is modified
  27936. */
  27937. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27938. /**
  27939. * Fired when the grip button on this controller is modified
  27940. */
  27941. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27942. /**
  27943. * Fired when the thumbstick button on this controller is modified
  27944. */
  27945. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27946. /**
  27947. * Fired when the touchpad button on this controller is modified
  27948. */
  27949. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27950. /**
  27951. * Fired when the touchpad values on this controller are modified
  27952. */
  27953. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  27954. /**
  27955. * Called once per frame by the engine.
  27956. */
  27957. update(): void;
  27958. /**
  27959. * Called once for each button that changed state since the last frame
  27960. * @param buttonIdx Which button index changed
  27961. * @param state New state of the button
  27962. * @param changes Which properties on the state changed since last frame
  27963. */
  27964. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27965. /**
  27966. * Moves the buttons on the controller mesh based on their current state
  27967. * @param buttonName the name of the button to move
  27968. * @param buttonValue the value of the button which determines the buttons new position
  27969. */
  27970. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  27971. /**
  27972. * Moves the axis on the controller mesh based on its current state
  27973. * @param axis the index of the axis
  27974. * @param axisValue the value of the axis which determines the meshes new position
  27975. * @ignore
  27976. */
  27977. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  27978. /**
  27979. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  27980. * @param scene scene in which to add meshes
  27981. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  27982. */
  27983. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  27984. /**
  27985. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  27986. * can be transformed by button presses and axes values, based on this._mapping.
  27987. *
  27988. * @param scene scene in which the meshes exist
  27989. * @param meshes list of meshes that make up the controller model to process
  27990. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  27991. */
  27992. private processModel(scene, meshes);
  27993. private createMeshInfo(rootNode);
  27994. /**
  27995. * Gets the ray of the controller in the direction the controller is pointing
  27996. * @param length the length the resulting ray should be
  27997. * @returns a ray in the direction the controller is pointing
  27998. */
  27999. getForwardRay(length?: number): Ray;
  28000. /**
  28001. * Disposes of the controller
  28002. */
  28003. dispose(): void;
  28004. }
  28005. }
  28006. declare module BABYLON {
  28007. }
  28008. declare module BABYLON {
  28009. /**
  28010. * Interface to implement to create a shadow generator compatible with BJS.
  28011. */
  28012. interface IShadowGenerator {
  28013. /**
  28014. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  28015. * @returns The render target texture if present otherwise, null
  28016. */
  28017. getShadowMap(): Nullable<RenderTargetTexture>;
  28018. /**
  28019. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  28020. * @returns The render target texture if the shadow map is present otherwise, null
  28021. */
  28022. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  28023. /**
  28024. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  28025. * @param subMesh The submesh we want to render in the shadow map
  28026. * @param useInstances Defines wether will draw in the map using instances
  28027. * @returns true if ready otherwise, false
  28028. */
  28029. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28030. /**
  28031. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  28032. * @param defines Defines of the material we want to update
  28033. * @param lightIndex Index of the light in the enabled light list of the material
  28034. */
  28035. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  28036. /**
  28037. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  28038. * defined in the generator but impacting the effect).
  28039. * It implies the unifroms available on the materials are the standard BJS ones.
  28040. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  28041. * @param effect The effect we are binfing the information for
  28042. */
  28043. bindShadowLight(lightIndex: string, effect: Effect): void;
  28044. /**
  28045. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  28046. * (eq to shadow prjection matrix * light transform matrix)
  28047. * @returns The transform matrix used to create the shadow map
  28048. */
  28049. getTransformMatrix(): Matrix;
  28050. /**
  28051. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  28052. * Cube and 2D textures for instance.
  28053. */
  28054. recreateShadowMap(): void;
  28055. /**
  28056. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28057. * @param onCompiled Callback triggered at the and of the effects compilation
  28058. * @param options Sets of optional options forcing the compilation with different modes
  28059. */
  28060. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  28061. useInstances: boolean;
  28062. }>): void;
  28063. /**
  28064. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28065. * @param options Sets of optional options forcing the compilation with different modes
  28066. * @returns A promise that resolves when the compilation completes
  28067. */
  28068. forceCompilationAsync(options?: Partial<{
  28069. useInstances: boolean;
  28070. }>): Promise<void>;
  28071. /**
  28072. * Serializes the shadow generator setup to a json object.
  28073. * @returns The serialized JSON object
  28074. */
  28075. serialize(): any;
  28076. /**
  28077. * Disposes the Shadow map and related Textures and effects.
  28078. */
  28079. dispose(): void;
  28080. }
  28081. /**
  28082. * Default implementation IShadowGenerator.
  28083. * This is the main object responsible of generating shadows in the framework.
  28084. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  28085. */
  28086. class ShadowGenerator implements IShadowGenerator {
  28087. /**
  28088. * Shadow generator mode None: no filtering applied.
  28089. */
  28090. static readonly FILTER_NONE: number;
  28091. /**
  28092. * Shadow generator mode ESM: Exponential Shadow Mapping.
  28093. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28094. */
  28095. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  28096. /**
  28097. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  28098. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  28099. */
  28100. static readonly FILTER_POISSONSAMPLING: number;
  28101. /**
  28102. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  28103. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28104. */
  28105. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  28106. /**
  28107. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  28108. * edge artifacts on steep falloff.
  28109. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28110. */
  28111. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  28112. /**
  28113. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  28114. * edge artifacts on steep falloff.
  28115. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28116. */
  28117. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  28118. /**
  28119. * Shadow generator mode PCF: Percentage Closer Filtering
  28120. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28121. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  28122. */
  28123. static readonly FILTER_PCF: number;
  28124. /**
  28125. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  28126. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28127. * Contact Hardening
  28128. */
  28129. static readonly FILTER_PCSS: number;
  28130. /**
  28131. * Reserved for PCF and PCSS
  28132. * Highest Quality.
  28133. *
  28134. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  28135. *
  28136. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  28137. */
  28138. static readonly QUALITY_HIGH: number;
  28139. /**
  28140. * Reserved for PCF and PCSS
  28141. * Good tradeoff for quality/perf cross devices
  28142. *
  28143. * Execute PCF on a 3*3 kernel.
  28144. *
  28145. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  28146. */
  28147. static readonly QUALITY_MEDIUM: number;
  28148. /**
  28149. * Reserved for PCF and PCSS
  28150. * The lowest quality but the fastest.
  28151. *
  28152. * Execute PCF on a 1*1 kernel.
  28153. *
  28154. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  28155. */
  28156. static readonly QUALITY_LOW: number;
  28157. private _bias;
  28158. /**
  28159. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  28160. */
  28161. /**
  28162. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  28163. */
  28164. bias: number;
  28165. private _normalBias;
  28166. /**
  28167. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28168. */
  28169. /**
  28170. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28171. */
  28172. normalBias: number;
  28173. private _blurBoxOffset;
  28174. /**
  28175. * Gets the blur box offset: offset applied during the blur pass.
  28176. * Only usefull if useKernelBlur = false
  28177. */
  28178. /**
  28179. * Sets the blur box offset: offset applied during the blur pass.
  28180. * Only usefull if useKernelBlur = false
  28181. */
  28182. blurBoxOffset: number;
  28183. private _blurScale;
  28184. /**
  28185. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  28186. * 2 means half of the size.
  28187. */
  28188. /**
  28189. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  28190. * 2 means half of the size.
  28191. */
  28192. blurScale: number;
  28193. private _blurKernel;
  28194. /**
  28195. * Gets the blur kernel: kernel size of the blur pass.
  28196. * Only usefull if useKernelBlur = true
  28197. */
  28198. /**
  28199. * Sets the blur kernel: kernel size of the blur pass.
  28200. * Only usefull if useKernelBlur = true
  28201. */
  28202. blurKernel: number;
  28203. private _useKernelBlur;
  28204. /**
  28205. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  28206. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  28207. */
  28208. /**
  28209. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  28210. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  28211. */
  28212. useKernelBlur: boolean;
  28213. private _depthScale;
  28214. /**
  28215. * Gets the depth scale used in ESM mode.
  28216. */
  28217. /**
  28218. * Sets the depth scale used in ESM mode.
  28219. * This can override the scale stored on the light.
  28220. */
  28221. depthScale: number;
  28222. private _filter;
  28223. /**
  28224. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  28225. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28226. */
  28227. /**
  28228. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  28229. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28230. */
  28231. filter: number;
  28232. /**
  28233. * Gets if the current filter is set to Poisson Sampling.
  28234. */
  28235. /**
  28236. * Sets the current filter to Poisson Sampling.
  28237. */
  28238. usePoissonSampling: boolean;
  28239. /**
  28240. * Gets if the current filter is set to VSM.
  28241. * DEPRECATED. Should use useExponentialShadowMap instead.
  28242. */
  28243. /**
  28244. * Sets the current filter is to VSM.
  28245. * DEPRECATED. Should use useExponentialShadowMap instead.
  28246. */
  28247. useVarianceShadowMap: boolean;
  28248. /**
  28249. * Gets if the current filter is set to blurred VSM.
  28250. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  28251. */
  28252. /**
  28253. * Sets the current filter is to blurred VSM.
  28254. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  28255. */
  28256. useBlurVarianceShadowMap: boolean;
  28257. /**
  28258. * Gets if the current filter is set to ESM.
  28259. */
  28260. /**
  28261. * Sets the current filter is to ESM.
  28262. */
  28263. useExponentialShadowMap: boolean;
  28264. /**
  28265. * Gets if the current filter is set to filtered ESM.
  28266. */
  28267. /**
  28268. * Gets if the current filter is set to filtered ESM.
  28269. */
  28270. useBlurExponentialShadowMap: boolean;
  28271. /**
  28272. * Gets if the current filter is set to "close ESM" (using the inverse of the
  28273. * exponential to prevent steep falloff artifacts).
  28274. */
  28275. /**
  28276. * Sets the current filter to "close ESM" (using the inverse of the
  28277. * exponential to prevent steep falloff artifacts).
  28278. */
  28279. useCloseExponentialShadowMap: boolean;
  28280. /**
  28281. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  28282. * exponential to prevent steep falloff artifacts).
  28283. */
  28284. /**
  28285. * Sets the current filter to filtered "close ESM" (using the inverse of the
  28286. * exponential to prevent steep falloff artifacts).
  28287. */
  28288. useBlurCloseExponentialShadowMap: boolean;
  28289. /**
  28290. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  28291. */
  28292. /**
  28293. * Sets the current filter to "PCF" (percentage closer filtering).
  28294. */
  28295. usePercentageCloserFiltering: boolean;
  28296. private _filteringQuality;
  28297. /**
  28298. * Gets the PCF or PCSS Quality.
  28299. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28300. */
  28301. /**
  28302. * Sets the PCF or PCSS Quality.
  28303. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28304. */
  28305. filteringQuality: number;
  28306. /**
  28307. * Gets if the current filter is set to "PCSS" (contact hardening).
  28308. */
  28309. /**
  28310. * Sets the current filter to "PCSS" (contact hardening).
  28311. */
  28312. useContactHardeningShadow: boolean;
  28313. private _contactHardeningLightSizeUVRatio;
  28314. /**
  28315. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  28316. * Using a ratio helps keeping shape stability independently of the map size.
  28317. *
  28318. * It does not account for the light projection as it was having too much
  28319. * instability during the light setup or during light position changes.
  28320. *
  28321. * Only valid if useContactHardeningShadow is true.
  28322. */
  28323. /**
  28324. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  28325. * Using a ratio helps keeping shape stability independently of the map size.
  28326. *
  28327. * It does not account for the light projection as it was having too much
  28328. * instability during the light setup or during light position changes.
  28329. *
  28330. * Only valid if useContactHardeningShadow is true.
  28331. */
  28332. contactHardeningLightSizeUVRatio: number;
  28333. private _darkness;
  28334. /**
  28335. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  28336. * 0 means strongest and 1 would means no shadow.
  28337. * @returns the darkness.
  28338. */
  28339. getDarkness(): number;
  28340. /**
  28341. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  28342. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  28343. * @returns the shadow generator allowing fluent coding.
  28344. */
  28345. setDarkness(darkness: number): ShadowGenerator;
  28346. private _transparencyShadow;
  28347. /**
  28348. * Sets the ability to have transparent shadow (boolean).
  28349. * @param transparent True if transparent else False
  28350. * @returns the shadow generator allowing fluent coding
  28351. */
  28352. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  28353. private _shadowMap;
  28354. private _shadowMap2;
  28355. /**
  28356. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  28357. * @returns The render target texture if present otherwise, null
  28358. */
  28359. getShadowMap(): Nullable<RenderTargetTexture>;
  28360. /**
  28361. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  28362. * @returns The render target texture if the shadow map is present otherwise, null
  28363. */
  28364. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  28365. /**
  28366. * Helper function to add a mesh and its descendants to the list of shadow casters.
  28367. * @param mesh Mesh to add
  28368. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  28369. * @returns the Shadow Generator itself
  28370. */
  28371. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  28372. /**
  28373. * Helper function to remove a mesh and its descendants from the list of shadow casters
  28374. * @param mesh Mesh to remove
  28375. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  28376. * @returns the Shadow Generator itself
  28377. */
  28378. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  28379. /**
  28380. * Controls the extent to which the shadows fade out at the edge of the frustum
  28381. * Used only by directionals and spots
  28382. */
  28383. frustumEdgeFalloff: number;
  28384. private _light;
  28385. /**
  28386. * Returns the associated light object.
  28387. * @returns the light generating the shadow
  28388. */
  28389. getLight(): IShadowLight;
  28390. /**
  28391. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  28392. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  28393. * It might on the other hand introduce peter panning.
  28394. */
  28395. forceBackFacesOnly: boolean;
  28396. private _scene;
  28397. private _lightDirection;
  28398. private _effect;
  28399. private _viewMatrix;
  28400. private _projectionMatrix;
  28401. private _transformMatrix;
  28402. private _cachedPosition;
  28403. private _cachedDirection;
  28404. private _cachedDefines;
  28405. private _currentRenderID;
  28406. private _boxBlurPostprocess;
  28407. private _kernelBlurXPostprocess;
  28408. private _kernelBlurYPostprocess;
  28409. private _blurPostProcesses;
  28410. private _mapSize;
  28411. private _currentFaceIndex;
  28412. private _currentFaceIndexCache;
  28413. private _textureType;
  28414. private _defaultTextureMatrix;
  28415. /**
  28416. * Creates a ShadowGenerator object.
  28417. * A ShadowGenerator is the required tool to use the shadows.
  28418. * Each light casting shadows needs to use its own ShadowGenerator.
  28419. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  28420. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  28421. * @param light The light object generating the shadows.
  28422. * @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.
  28423. */
  28424. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  28425. private _initializeGenerator();
  28426. private _initializeShadowMap();
  28427. private _initializeBlurRTTAndPostProcesses();
  28428. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  28429. private _renderSubMeshForShadowMap(subMesh);
  28430. private _applyFilterValues();
  28431. /**
  28432. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28433. * @param onCompiled Callback triggered at the and of the effects compilation
  28434. * @param options Sets of optional options forcing the compilation with different modes
  28435. */
  28436. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  28437. useInstances: boolean;
  28438. }>): void;
  28439. /**
  28440. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28441. * @param options Sets of optional options forcing the compilation with different modes
  28442. * @returns A promise that resolves when the compilation completes
  28443. */
  28444. forceCompilationAsync(options?: Partial<{
  28445. useInstances: boolean;
  28446. }>): Promise<void>;
  28447. /**
  28448. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  28449. * @param subMesh The submesh we want to render in the shadow map
  28450. * @param useInstances Defines wether will draw in the map using instances
  28451. * @returns true if ready otherwise, false
  28452. */
  28453. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28454. /**
  28455. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  28456. * @param defines Defines of the material we want to update
  28457. * @param lightIndex Index of the light in the enabled light list of the material
  28458. */
  28459. prepareDefines(defines: any, lightIndex: number): void;
  28460. /**
  28461. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  28462. * defined in the generator but impacting the effect).
  28463. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  28464. * @param effect The effect we are binfing the information for
  28465. */
  28466. bindShadowLight(lightIndex: string, effect: Effect): void;
  28467. /**
  28468. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  28469. * (eq to shadow prjection matrix * light transform matrix)
  28470. * @returns The transform matrix used to create the shadow map
  28471. */
  28472. getTransformMatrix(): Matrix;
  28473. /**
  28474. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  28475. * Cube and 2D textures for instance.
  28476. */
  28477. recreateShadowMap(): void;
  28478. private _disposeBlurPostProcesses();
  28479. private _disposeRTTandPostProcesses();
  28480. /**
  28481. * Disposes the ShadowGenerator.
  28482. * Returns nothing.
  28483. */
  28484. dispose(): void;
  28485. /**
  28486. * Serializes the shadow generator setup to a json object.
  28487. * @returns The serialized JSON object
  28488. */
  28489. serialize(): any;
  28490. /**
  28491. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  28492. * @param parsedShadowGenerator The JSON object to parse
  28493. * @param scene The scene to create the shadow map for
  28494. * @returns The parsed shadow generator
  28495. */
  28496. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  28497. }
  28498. }
  28499. declare module BABYLON {
  28500. /**
  28501. * Background material used to create an efficient environement around your scene.
  28502. */
  28503. class BackgroundMaterial extends PushMaterial {
  28504. /**
  28505. * Standard reflectance value at parallel view angle.
  28506. */
  28507. static StandardReflectance0: number;
  28508. /**
  28509. * Standard reflectance value at grazing angle.
  28510. */
  28511. static StandardReflectance90: number;
  28512. protected _primaryColor: Color3;
  28513. /**
  28514. * Key light Color (multiply against the R channel of the environement texture)
  28515. */
  28516. primaryColor: Color3;
  28517. protected _primaryLevel: float;
  28518. /**
  28519. * Key light Level (allowing HDR output of the background)
  28520. */
  28521. primaryLevel: float;
  28522. protected _secondaryColor: Color3;
  28523. /**
  28524. * Secondary light Color (multiply against the G channel of the environement texture)
  28525. */
  28526. secondaryColor: Color3;
  28527. protected _secondaryLevel: float;
  28528. /**
  28529. * Secondary light Level (allowing HDR output of the background)
  28530. */
  28531. secondaryLevel: float;
  28532. protected _tertiaryColor: Color3;
  28533. /**
  28534. * Tertiary light Color (multiply against the B channel of the environement texture)
  28535. */
  28536. tertiaryColor: Color3;
  28537. protected _tertiaryLevel: float;
  28538. /**
  28539. * Tertiary light Level (allowing HDR output of the background)
  28540. */
  28541. tertiaryLevel: float;
  28542. protected _reflectionTexture: Nullable<BaseTexture>;
  28543. /**
  28544. * Reflection Texture used in the material.
  28545. * Should be author in a specific way for the best result (refer to the documentation).
  28546. */
  28547. reflectionTexture: Nullable<BaseTexture>;
  28548. protected _reflectionBlur: float;
  28549. /**
  28550. * Reflection Texture level of blur.
  28551. *
  28552. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  28553. * texture twice.
  28554. */
  28555. reflectionBlur: float;
  28556. protected _diffuseTexture: Nullable<BaseTexture>;
  28557. /**
  28558. * Diffuse Texture used in the material.
  28559. * Should be author in a specific way for the best result (refer to the documentation).
  28560. */
  28561. diffuseTexture: Nullable<BaseTexture>;
  28562. protected _shadowLights: Nullable<IShadowLight[]>;
  28563. /**
  28564. * Specify the list of lights casting shadow on the material.
  28565. * All scene shadow lights will be included if null.
  28566. */
  28567. shadowLights: Nullable<IShadowLight[]>;
  28568. protected _shadowBlurScale: int;
  28569. /**
  28570. * For the lights having a blurred shadow generator, this can add a second blur pass in order to reach
  28571. * soft lighting on the background.
  28572. */
  28573. shadowBlurScale: int;
  28574. protected _shadowLevel: float;
  28575. /**
  28576. * Helps adjusting the shadow to a softer level if required.
  28577. * 0 means black shadows and 1 means no shadows.
  28578. */
  28579. shadowLevel: float;
  28580. protected _sceneCenter: Vector3;
  28581. /**
  28582. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  28583. * It is usually zero but might be interesting to modify according to your setup.
  28584. */
  28585. sceneCenter: Vector3;
  28586. protected _opacityFresnel: boolean;
  28587. /**
  28588. * This helps specifying that the material is falling off to the sky box at grazing angle.
  28589. * This helps ensuring a nice transition when the camera goes under the ground.
  28590. */
  28591. opacityFresnel: boolean;
  28592. protected _reflectionFresnel: boolean;
  28593. /**
  28594. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  28595. * This helps adding a mirror texture on the ground.
  28596. */
  28597. reflectionFresnel: boolean;
  28598. protected _reflectionFalloffDistance: number;
  28599. /**
  28600. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  28601. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  28602. */
  28603. reflectionFalloffDistance: number;
  28604. protected _reflectionAmount: number;
  28605. /**
  28606. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  28607. */
  28608. reflectionAmount: number;
  28609. protected _reflectionReflectance0: number;
  28610. /**
  28611. * This specifies the weight of the reflection at grazing angle.
  28612. */
  28613. reflectionReflectance0: number;
  28614. protected _reflectionReflectance90: number;
  28615. /**
  28616. * This specifies the weight of the reflection at a perpendicular point of view.
  28617. */
  28618. reflectionReflectance90: number;
  28619. /**
  28620. * Sets the reflection reflectance fresnel values according to the default standard
  28621. * empirically know to work well :-)
  28622. */
  28623. reflectionStandardFresnelWeight: number;
  28624. protected _useRGBColor: boolean;
  28625. /**
  28626. * Helps to directly use the maps channels instead of their level.
  28627. */
  28628. useRGBColor: boolean;
  28629. protected _enableNoise: boolean;
  28630. /**
  28631. * This helps reducing the banding effect that could occur on the background.
  28632. */
  28633. enableNoise: boolean;
  28634. /**
  28635. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  28636. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  28637. * Recommended to be keep at 1.0 except for special cases.
  28638. */
  28639. fovMultiplier: number;
  28640. private _fovMultiplier;
  28641. /**
  28642. * Enable the FOV adjustment feature controlled by fovMultiplier.
  28643. */
  28644. useEquirectangularFOV: boolean;
  28645. private _maxSimultaneousLights;
  28646. /**
  28647. * Number of Simultaneous lights allowed on the material.
  28648. */
  28649. maxSimultaneousLights: int;
  28650. /**
  28651. * Default configuration related to image processing available in the Background Material.
  28652. */
  28653. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  28654. /**
  28655. * Keep track of the image processing observer to allow dispose and replace.
  28656. */
  28657. private _imageProcessingObserver;
  28658. /**
  28659. * Attaches a new image processing configuration to the PBR Material.
  28660. * @param configuration (if null the scene configuration will be use)
  28661. */
  28662. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  28663. /**
  28664. * Gets the image processing configuration used either in this material.
  28665. */
  28666. /**
  28667. * Sets the Default image processing configuration used either in the this material.
  28668. *
  28669. * If sets to null, the scene one is in use.
  28670. */
  28671. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  28672. /**
  28673. * Gets wether the color curves effect is enabled.
  28674. */
  28675. /**
  28676. * Sets wether the color curves effect is enabled.
  28677. */
  28678. cameraColorCurvesEnabled: boolean;
  28679. /**
  28680. * Gets wether the color grading effect is enabled.
  28681. */
  28682. /**
  28683. * Gets wether the color grading effect is enabled.
  28684. */
  28685. cameraColorGradingEnabled: boolean;
  28686. /**
  28687. * Gets wether tonemapping is enabled or not.
  28688. */
  28689. /**
  28690. * Sets wether tonemapping is enabled or not
  28691. */
  28692. cameraToneMappingEnabled: boolean;
  28693. /**
  28694. * The camera exposure used on this material.
  28695. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28696. * This corresponds to a photographic exposure.
  28697. */
  28698. /**
  28699. * The camera exposure used on this material.
  28700. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28701. * This corresponds to a photographic exposure.
  28702. */
  28703. cameraExposure: float;
  28704. /**
  28705. * Gets The camera contrast used on this material.
  28706. */
  28707. /**
  28708. * Sets The camera contrast used on this material.
  28709. */
  28710. cameraContrast: float;
  28711. /**
  28712. * Gets the Color Grading 2D Lookup Texture.
  28713. */
  28714. /**
  28715. * Sets the Color Grading 2D Lookup Texture.
  28716. */
  28717. cameraColorGradingTexture: Nullable<BaseTexture>;
  28718. /**
  28719. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28720. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28721. * 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;
  28722. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28723. */
  28724. /**
  28725. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28726. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28727. * 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;
  28728. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28729. */
  28730. cameraColorCurves: Nullable<ColorCurves>;
  28731. /**
  28732. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  28733. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  28734. */
  28735. switchToBGR: boolean;
  28736. private _renderTargets;
  28737. private _reflectionControls;
  28738. /**
  28739. * Instantiates a Background Material in the given scene
  28740. * @param name The friendly name of the material
  28741. * @param scene The scene to add the material to
  28742. */
  28743. constructor(name: string, scene: Scene);
  28744. /**
  28745. * The entire material has been created in order to prevent overdraw.
  28746. * @returns false
  28747. */
  28748. needAlphaTesting(): boolean;
  28749. /**
  28750. * The entire material has been created in order to prevent overdraw.
  28751. * @returns true if blending is enable
  28752. */
  28753. needAlphaBlending(): boolean;
  28754. /**
  28755. * Checks wether the material is ready to be rendered for a given mesh.
  28756. * @param mesh The mesh to render
  28757. * @param subMesh The submesh to check against
  28758. * @param useInstances Specify wether or not the material is used with instances
  28759. * @returns true if all the dependencies are ready (Textures, Effects...)
  28760. */
  28761. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28762. /**
  28763. * Build the uniform buffer used in the material.
  28764. */
  28765. buildUniformLayout(): void;
  28766. /**
  28767. * Unbind the material.
  28768. */
  28769. unbind(): void;
  28770. /**
  28771. * Bind only the world matrix to the material.
  28772. * @param world The world matrix to bind.
  28773. */
  28774. bindOnlyWorldMatrix(world: Matrix): void;
  28775. /**
  28776. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  28777. * @param world The world matrix to bind.
  28778. * @param subMesh The submesh to bind for.
  28779. */
  28780. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28781. /**
  28782. * Dispose the material.
  28783. * @param forceDisposeEffect Force disposal of the associated effect.
  28784. * @param forceDisposeTextures Force disposal of the associated textures.
  28785. */
  28786. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  28787. /**
  28788. * Clones the material.
  28789. * @param name The cloned name.
  28790. * @returns The cloned material.
  28791. */
  28792. clone(name: string): BackgroundMaterial;
  28793. /**
  28794. * Serializes the current material to its JSON representation.
  28795. * @returns The JSON representation.
  28796. */
  28797. serialize(): any;
  28798. /**
  28799. * Gets the class name of the material
  28800. * @returns "BackgroundMaterial"
  28801. */
  28802. getClassName(): string;
  28803. /**
  28804. * Parse a JSON input to create back a background material.
  28805. * @param source The JSON data to parse
  28806. * @param scene The scene to create the parsed material in
  28807. * @param rootUrl The root url of the assets the material depends upon
  28808. * @returns the instantiated BackgroundMaterial.
  28809. */
  28810. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  28811. }
  28812. }
  28813. declare module BABYLON {
  28814. class BaseTexture {
  28815. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28816. name: string;
  28817. private _hasAlpha;
  28818. hasAlpha: boolean;
  28819. getAlphaFromRGB: boolean;
  28820. level: number;
  28821. coordinatesIndex: number;
  28822. private _coordinatesMode;
  28823. /**
  28824. * How a texture is mapped.
  28825. *
  28826. * | Value | Type | Description |
  28827. * | ----- | ----------------------------------- | ----------- |
  28828. * | 0 | EXPLICIT_MODE | |
  28829. * | 1 | SPHERICAL_MODE | |
  28830. * | 2 | PLANAR_MODE | |
  28831. * | 3 | CUBIC_MODE | |
  28832. * | 4 | PROJECTION_MODE | |
  28833. * | 5 | SKYBOX_MODE | |
  28834. * | 6 | INVCUBIC_MODE | |
  28835. * | 7 | EQUIRECTANGULAR_MODE | |
  28836. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28837. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28838. */
  28839. coordinatesMode: number;
  28840. /**
  28841. * | Value | Type | Description |
  28842. * | ----- | ------------------ | ----------- |
  28843. * | 0 | CLAMP_ADDRESSMODE | |
  28844. * | 1 | WRAP_ADDRESSMODE | |
  28845. * | 2 | MIRROR_ADDRESSMODE | |
  28846. */
  28847. wrapU: number;
  28848. /**
  28849. * | Value | Type | Description |
  28850. * | ----- | ------------------ | ----------- |
  28851. * | 0 | CLAMP_ADDRESSMODE | |
  28852. * | 1 | WRAP_ADDRESSMODE | |
  28853. * | 2 | MIRROR_ADDRESSMODE | |
  28854. */
  28855. wrapV: number;
  28856. /**
  28857. * | Value | Type | Description |
  28858. * | ----- | ------------------ | ----------- |
  28859. * | 0 | CLAMP_ADDRESSMODE | |
  28860. * | 1 | WRAP_ADDRESSMODE | |
  28861. * | 2 | MIRROR_ADDRESSMODE | |
  28862. */
  28863. wrapR: number;
  28864. anisotropicFilteringLevel: number;
  28865. isCube: boolean;
  28866. is3D: boolean;
  28867. gammaSpace: boolean;
  28868. invertZ: boolean;
  28869. lodLevelInAlpha: boolean;
  28870. lodGenerationOffset: number;
  28871. lodGenerationScale: number;
  28872. isRenderTarget: boolean;
  28873. readonly uid: string;
  28874. toString(): string;
  28875. getClassName(): string;
  28876. animations: Animation[];
  28877. /**
  28878. * An event triggered when the texture is disposed.
  28879. */
  28880. onDisposeObservable: Observable<BaseTexture>;
  28881. private _onDisposeObserver;
  28882. onDispose: () => void;
  28883. delayLoadState: number;
  28884. private _scene;
  28885. _texture: Nullable<InternalTexture>;
  28886. private _uid;
  28887. readonly isBlocking: boolean;
  28888. constructor(scene: Nullable<Scene>);
  28889. getScene(): Nullable<Scene>;
  28890. getTextureMatrix(): Matrix;
  28891. getReflectionTextureMatrix(): Matrix;
  28892. getInternalTexture(): Nullable<InternalTexture>;
  28893. isReadyOrNotBlocking(): boolean;
  28894. isReady(): boolean;
  28895. getSize(): ISize;
  28896. getBaseSize(): ISize;
  28897. scale(ratio: number): void;
  28898. readonly canRescale: boolean;
  28899. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  28900. _rebuild(): void;
  28901. delayLoad(): void;
  28902. clone(): Nullable<BaseTexture>;
  28903. readonly textureType: number;
  28904. readonly textureFormat: number;
  28905. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  28906. releaseInternalTexture(): void;
  28907. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28908. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28909. readonly _lodTextureMid: Nullable<BaseTexture>;
  28910. readonly _lodTextureLow: Nullable<BaseTexture>;
  28911. dispose(): void;
  28912. serialize(): any;
  28913. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28914. }
  28915. }
  28916. declare module BABYLON {
  28917. /**
  28918. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  28919. * It can help converting any input color in a desired output one. This can then be used to create effects
  28920. * from sepia, black and white to sixties or futuristic rendering...
  28921. *
  28922. * The only supported format is currently 3dl.
  28923. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  28924. */
  28925. class ColorGradingTexture extends BaseTexture {
  28926. /**
  28927. * The current texture matrix. (will always be identity in color grading texture)
  28928. */
  28929. private _textureMatrix;
  28930. /**
  28931. * The texture URL.
  28932. */
  28933. url: string;
  28934. /**
  28935. * Empty line regex stored for GC.
  28936. */
  28937. private static _noneEmptyLineRegex;
  28938. private _engine;
  28939. /**
  28940. * Instantiates a ColorGradingTexture from the following parameters.
  28941. *
  28942. * @param url The location of the color gradind data (currently only supporting 3dl)
  28943. * @param scene The scene the texture will be used in
  28944. */
  28945. constructor(url: string, scene: Scene);
  28946. /**
  28947. * Returns the texture matrix used in most of the material.
  28948. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  28949. */
  28950. getTextureMatrix(): Matrix;
  28951. /**
  28952. * Occurs when the file being loaded is a .3dl LUT file.
  28953. */
  28954. private load3dlTexture();
  28955. /**
  28956. * Starts the loading process of the texture.
  28957. */
  28958. private loadTexture();
  28959. /**
  28960. * Clones the color gradind texture.
  28961. */
  28962. clone(): ColorGradingTexture;
  28963. /**
  28964. * Called during delayed load for textures.
  28965. */
  28966. delayLoad(): void;
  28967. /**
  28968. * Parses a color grading texture serialized by Babylon.
  28969. * @param parsedTexture The texture information being parsedTexture
  28970. * @param scene The scene to load the texture in
  28971. * @param rootUrl The root url of the data assets to load
  28972. * @return A color gradind texture
  28973. */
  28974. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  28975. /**
  28976. * Serializes the LUT texture to json format.
  28977. */
  28978. serialize(): any;
  28979. }
  28980. }
  28981. declare module BABYLON {
  28982. class CubeTexture extends BaseTexture {
  28983. url: string;
  28984. coordinatesMode: number;
  28985. /**
  28986. * Gets or sets the center of the bounding box associated with the cube texture
  28987. * It must define where the camera used to render the texture was set
  28988. */
  28989. boundingBoxPosition: Vector3;
  28990. private _boundingBoxSize;
  28991. /**
  28992. * Gets or sets the size of the bounding box associated with the cube texture
  28993. * When defined, the cubemap will switch to local mode
  28994. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  28995. * @example https://www.babylonjs-playground.com/#RNASML
  28996. */
  28997. boundingBoxSize: Vector3;
  28998. private _noMipmap;
  28999. private _files;
  29000. private _extensions;
  29001. private _textureMatrix;
  29002. private _format;
  29003. private _prefiltered;
  29004. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  29005. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture;
  29006. 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);
  29007. delayLoad(): void;
  29008. getReflectionTextureMatrix(): Matrix;
  29009. setReflectionTextureMatrix(value: Matrix): void;
  29010. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  29011. clone(): CubeTexture;
  29012. }
  29013. }
  29014. declare module BABYLON {
  29015. /**
  29016. * A class extending {BABYLON.Texture} allowing drawing on a texture
  29017. * @see http://doc.babylonjs.com/how_to/dynamictexture
  29018. */
  29019. class DynamicTexture extends Texture {
  29020. private _generateMipMaps;
  29021. private _canvas;
  29022. private _context;
  29023. private _engine;
  29024. /**
  29025. * Creates a {BABYLON.DynamicTexture}
  29026. * @param name defines the name of the texture
  29027. * @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
  29028. * @param scene defines the scene where you want the texture
  29029. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  29030. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  29031. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  29032. */
  29033. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  29034. /**
  29035. * Gets the current state of canRescale
  29036. */
  29037. readonly canRescale: boolean;
  29038. private _recreate(textureSize);
  29039. /**
  29040. * Scales the texture
  29041. * @param ratio the scale factor to apply to both width and height
  29042. */
  29043. scale(ratio: number): void;
  29044. /**
  29045. * Resizes the texture
  29046. * @param width the new width
  29047. * @param height the new height
  29048. */
  29049. scaleTo(width: number, height: number): void;
  29050. /**
  29051. * Gets the context of the canvas used by the texture
  29052. * @returns the canvas context of the dynamic texture
  29053. */
  29054. getContext(): CanvasRenderingContext2D;
  29055. /**
  29056. * Clears the texture
  29057. */
  29058. clear(): void;
  29059. /**
  29060. * Updates the texture
  29061. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  29062. */
  29063. update(invertY?: boolean): void;
  29064. /**
  29065. * Draws text onto the texture
  29066. * @param text defines the text to be drawn
  29067. * @param x defines the placement of the text from the left
  29068. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  29069. * @param font defines the font to be used with font-style, font-size, font-name
  29070. * @param color defines the color used for the text
  29071. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  29072. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  29073. * @param update defines whether texture is immediately update (default is true)
  29074. */
  29075. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  29076. /**
  29077. * Clones the texture
  29078. * @returns the clone of the texture.
  29079. */
  29080. clone(): DynamicTexture;
  29081. /** @ignore */
  29082. _rebuild(): void;
  29083. }
  29084. }
  29085. declare module BABYLON {
  29086. /**
  29087. * This represents a texture coming from an HDR input.
  29088. *
  29089. * The only supported format is currently panorama picture stored in RGBE format.
  29090. * Example of such files can be found on HDRLib: http://hdrlib.com/
  29091. */
  29092. class HDRCubeTexture extends BaseTexture {
  29093. private static _facesMapping;
  29094. private _useInGammaSpace;
  29095. private _generateHarmonics;
  29096. private _noMipmap;
  29097. private _textureMatrix;
  29098. private _size;
  29099. private _usePMREMGenerator;
  29100. private _isBABYLONPreprocessed;
  29101. private _onLoad;
  29102. private _onError;
  29103. /**
  29104. * The texture URL.
  29105. */
  29106. url: string;
  29107. /**
  29108. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  29109. */
  29110. coordinatesMode: number;
  29111. /**
  29112. * Specifies wether the texture has been generated through the PMREMGenerator tool.
  29113. * This is usefull at run time to apply the good shader.
  29114. */
  29115. isPMREM: boolean;
  29116. protected _isBlocking: boolean;
  29117. /**
  29118. * Gets wether or not the texture is blocking during loading.
  29119. */
  29120. /**
  29121. * Sets wether or not the texture is blocking during loading.
  29122. */
  29123. isBlocking: boolean;
  29124. /**
  29125. * Gets or sets the center of the bounding box associated with the cube texture
  29126. * It must define where the camera used to render the texture was set
  29127. */
  29128. boundingBoxPosition: Vector3;
  29129. private _boundingBoxSize;
  29130. /**
  29131. * Gets or sets the size of the bounding box associated with the cube texture
  29132. * When defined, the cubemap will switch to local mode
  29133. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  29134. * @example https://www.babylonjs-playground.com/#RNASML
  29135. */
  29136. boundingBoxSize: Vector3;
  29137. /**
  29138. * Instantiates an HDRTexture from the following parameters.
  29139. *
  29140. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  29141. * @param scene The scene the texture will be used in
  29142. * @param size The cubemap 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.
  29143. * @param noMipmap Forces to not generate the mipmap if true
  29144. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  29145. * @param useInGammaSpace 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)
  29146. * @param usePMREMGenerator Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
  29147. */
  29148. constructor(url: string, scene: Scene, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  29149. /**
  29150. * Occurs when the file is a preprocessed .babylon.hdr file.
  29151. */
  29152. private loadBabylonTexture();
  29153. /**
  29154. * Occurs when the file is raw .hdr file.
  29155. */
  29156. private loadHDRTexture();
  29157. /**
  29158. * Starts the loading process of the texture.
  29159. */
  29160. private loadTexture();
  29161. clone(): HDRCubeTexture;
  29162. delayLoad(): void;
  29163. getReflectionTextureMatrix(): Matrix;
  29164. setReflectionTextureMatrix(value: Matrix): void;
  29165. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  29166. serialize(): any;
  29167. /**
  29168. * Saves as a file the data contained in the texture in a binary format.
  29169. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  29170. * as the spherical used in the lighting.
  29171. * @param url The HDR file url.
  29172. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  29173. * @param onError Method called if any error happens during download.
  29174. * @return The packed binary data.
  29175. */
  29176. static generateBabylonHDROnDisk(url: string, size: number, onError?: Nullable<(() => void)>): void;
  29177. /**
  29178. * Serializes the data contained in the texture in a binary format.
  29179. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  29180. * as the spherical used in the lighting.
  29181. * @param url The HDR file url.
  29182. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  29183. * @param onError Method called if any error happens during download.
  29184. * @return The packed binary data.
  29185. */
  29186. static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer: ArrayBuffer) => void), onError?: Nullable<(() => void)>): void;
  29187. }
  29188. }
  29189. declare module BABYLON {
  29190. /**
  29191. * Class used to store data associated with WebGL texture data for the engine
  29192. * This class should not be used directly
  29193. */
  29194. class InternalTexture implements IInternalTextureTracker {
  29195. /**
  29196. * The source of the texture data is unknown
  29197. */
  29198. static DATASOURCE_UNKNOWN: number;
  29199. /**
  29200. * Texture data comes from an URL
  29201. */
  29202. static DATASOURCE_URL: number;
  29203. /**
  29204. * Texture data is only used for temporary storage
  29205. */
  29206. static DATASOURCE_TEMP: number;
  29207. /**
  29208. * Texture data comes from raw data (ArrayBuffer)
  29209. */
  29210. static DATASOURCE_RAW: number;
  29211. /**
  29212. * Texture content is dynamic (video or dynamic texture)
  29213. */
  29214. static DATASOURCE_DYNAMIC: number;
  29215. /**
  29216. * Texture content is generated by rendering to it
  29217. */
  29218. static DATASOURCE_RENDERTARGET: number;
  29219. /**
  29220. * Texture content is part of a multi render target process
  29221. */
  29222. static DATASOURCE_MULTIRENDERTARGET: number;
  29223. /**
  29224. * Texture data comes from a cube data file
  29225. */
  29226. static DATASOURCE_CUBE: number;
  29227. /**
  29228. * Texture data comes from a raw cube data
  29229. */
  29230. static DATASOURCE_CUBERAW: number;
  29231. /**
  29232. * Texture data come from a prefiltered cube data file
  29233. */
  29234. static DATASOURCE_CUBEPREFILTERED: number;
  29235. /**
  29236. * Texture content is raw 3D data
  29237. */
  29238. static DATASOURCE_RAW3D: number;
  29239. /**
  29240. * Texture content is a depth texture
  29241. */
  29242. static DATASOURCE_DEPTHTEXTURE: number;
  29243. /**
  29244. * Defines if the texture is ready
  29245. */
  29246. isReady: boolean;
  29247. /**
  29248. * Defines if the texture is a cube texture
  29249. */
  29250. isCube: boolean;
  29251. /**
  29252. * Defines if the texture contains 3D data
  29253. */
  29254. is3D: boolean;
  29255. /**
  29256. * Gets the URL used to load this texture
  29257. */
  29258. url: string;
  29259. /**
  29260. * Gets the sampling mode of the texture
  29261. */
  29262. samplingMode: number;
  29263. /**
  29264. * Gets a boolean indicating if the texture needs mipmaps generation
  29265. */
  29266. generateMipMaps: boolean;
  29267. /**
  29268. * Gets the number of samples used by the texture (WebGL2+ only)
  29269. */
  29270. samples: number;
  29271. /**
  29272. * Gets the type of the texture
  29273. */
  29274. type: number;
  29275. /**
  29276. * Gets the format of the texture
  29277. */
  29278. format: number;
  29279. /**
  29280. * Observable called when the texture is loaded
  29281. */
  29282. onLoadedObservable: Observable<InternalTexture>;
  29283. /**
  29284. * Gets the width of the texture
  29285. */
  29286. width: number;
  29287. /**
  29288. * Gets the height of the texture
  29289. */
  29290. height: number;
  29291. /**
  29292. * Gets the depth of the texture
  29293. */
  29294. depth: number;
  29295. /**
  29296. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  29297. */
  29298. baseWidth: number;
  29299. /**
  29300. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  29301. */
  29302. baseHeight: number;
  29303. /**
  29304. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  29305. */
  29306. baseDepth: number;
  29307. /**
  29308. * Gets a boolean indicating if the texture is inverted on Y axis
  29309. */
  29310. invertY: boolean;
  29311. /**
  29312. * Gets or set the previous tracker in the list
  29313. */
  29314. previous: Nullable<IInternalTextureTracker>;
  29315. /**
  29316. * Gets or set the next tracker in the list
  29317. */
  29318. next: Nullable<IInternalTextureTracker>;
  29319. /** @ignore */
  29320. _initialSlot: number;
  29321. /** @ignore */
  29322. _designatedSlot: number;
  29323. /** @ignore */
  29324. _dataSource: number;
  29325. /** @ignore */
  29326. _buffer: Nullable<ArrayBuffer | HTMLImageElement>;
  29327. /** @ignore */
  29328. _bufferView: Nullable<ArrayBufferView>;
  29329. /** @ignore */
  29330. _bufferViewArray: Nullable<ArrayBufferView[]>;
  29331. /** @ignore */
  29332. _size: number;
  29333. /** @ignore */
  29334. _extension: string;
  29335. /** @ignore */
  29336. _files: Nullable<string[]>;
  29337. /** @ignore */
  29338. _workingCanvas: HTMLCanvasElement;
  29339. /** @ignore */
  29340. _workingContext: CanvasRenderingContext2D;
  29341. /** @ignore */
  29342. _framebuffer: Nullable<WebGLFramebuffer>;
  29343. /** @ignore */
  29344. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  29345. /** @ignore */
  29346. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  29347. /** @ignore */
  29348. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  29349. /** @ignore */
  29350. _attachments: Nullable<number[]>;
  29351. /** @ignore */
  29352. _cachedCoordinatesMode: Nullable<number>;
  29353. /** @ignore */
  29354. _cachedWrapU: Nullable<number>;
  29355. /** @ignore */
  29356. _cachedWrapV: Nullable<number>;
  29357. /** @ignore */
  29358. _cachedWrapR: Nullable<number>;
  29359. /** @ignore */
  29360. _cachedAnisotropicFilteringLevel: Nullable<number>;
  29361. /** @ignore */
  29362. _isDisabled: boolean;
  29363. /** @ignore */
  29364. _compression: Nullable<string>;
  29365. /** @ignore */
  29366. _generateStencilBuffer: boolean;
  29367. /** @ignore */
  29368. _generateDepthBuffer: boolean;
  29369. /** @ignore */
  29370. _comparisonFunction: number;
  29371. /** @ignore */
  29372. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  29373. /** @ignore */
  29374. _lodGenerationScale: number;
  29375. /** @ignore */
  29376. _lodGenerationOffset: number;
  29377. /** @ignore */
  29378. _lodTextureHigh: BaseTexture;
  29379. /** @ignore */
  29380. _lodTextureMid: BaseTexture;
  29381. /** @ignore */
  29382. _lodTextureLow: BaseTexture;
  29383. /** @ignore */
  29384. _webGLTexture: Nullable<WebGLTexture>;
  29385. /** @ignore */
  29386. _references: number;
  29387. private _engine;
  29388. /**
  29389. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  29390. */
  29391. readonly dataSource: number;
  29392. /**
  29393. * Creates a new InternalTexture
  29394. * @param engine defines the engine to use
  29395. * @param dataSource defines the type of data that will be used
  29396. */
  29397. constructor(engine: Engine, dataSource: number);
  29398. /**
  29399. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  29400. */
  29401. incrementReferences(): void;
  29402. /**
  29403. * Change the size of the texture (not the size of the content)
  29404. * @param width defines the new width
  29405. * @param height defines the new height
  29406. * @param depth defines the new depth (1 by default)
  29407. */
  29408. updateSize(width: int, height: int, depth?: int): void;
  29409. /** @ignore */
  29410. _rebuild(): void;
  29411. private _swapAndDie(target);
  29412. /**
  29413. * Dispose the current allocated resources
  29414. */
  29415. dispose(): void;
  29416. }
  29417. }
  29418. declare module BABYLON {
  29419. /**
  29420. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  29421. */
  29422. interface IInternalTextureTracker {
  29423. /**
  29424. * Gets or set the previous tracker in the list
  29425. */
  29426. previous: Nullable<IInternalTextureTracker>;
  29427. /**
  29428. * Gets or set the next tracker in the list
  29429. */
  29430. next: Nullable<IInternalTextureTracker>;
  29431. }
  29432. /**
  29433. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  29434. */
  29435. class DummyInternalTextureTracker {
  29436. /**
  29437. * Gets or set the previous tracker in the list
  29438. */
  29439. previous: Nullable<IInternalTextureTracker>;
  29440. /**
  29441. * Gets or set the next tracker in the list
  29442. */
  29443. next: Nullable<IInternalTextureTracker>;
  29444. }
  29445. }
  29446. declare module BABYLON {
  29447. class MirrorTexture extends RenderTargetTexture {
  29448. mirrorPlane: Plane;
  29449. private _transformMatrix;
  29450. private _mirrorMatrix;
  29451. private _savedViewMatrix;
  29452. private _blurX;
  29453. private _blurY;
  29454. private _adaptiveBlurKernel;
  29455. private _blurKernelX;
  29456. private _blurKernelY;
  29457. private _blurRatio;
  29458. blurRatio: number;
  29459. adaptiveBlurKernel: number;
  29460. blurKernel: number;
  29461. blurKernelX: number;
  29462. blurKernelY: number;
  29463. private _autoComputeBlurKernel();
  29464. protected _onRatioRescale(): void;
  29465. constructor(name: string, size: number | {
  29466. width: number;
  29467. height: number;
  29468. } | {
  29469. ratio: number;
  29470. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  29471. private _preparePostProcesses();
  29472. clone(): MirrorTexture;
  29473. serialize(): any;
  29474. }
  29475. }
  29476. declare module BABYLON {
  29477. interface IMultiRenderTargetOptions {
  29478. generateMipMaps?: boolean;
  29479. types?: number[];
  29480. samplingModes?: number[];
  29481. generateDepthBuffer?: boolean;
  29482. generateStencilBuffer?: boolean;
  29483. generateDepthTexture?: boolean;
  29484. textureCount?: number;
  29485. doNotChangeAspectRatio?: boolean;
  29486. defaultType?: number;
  29487. }
  29488. class MultiRenderTarget extends RenderTargetTexture {
  29489. private _internalTextures;
  29490. private _textures;
  29491. readonly isSupported: boolean;
  29492. private _multiRenderTargetOptions;
  29493. readonly textures: Texture[];
  29494. readonly depthTexture: Texture;
  29495. wrapU: number;
  29496. wrapV: number;
  29497. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  29498. _rebuild(): void;
  29499. private _createInternalTextures();
  29500. private _createTextures();
  29501. samples: number;
  29502. resize(size: any): void;
  29503. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  29504. dispose(): void;
  29505. releaseInternalTextures(): void;
  29506. }
  29507. }
  29508. declare module BABYLON {
  29509. class RawTexture extends Texture {
  29510. format: number;
  29511. private _engine;
  29512. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  29513. update(data: ArrayBufferView): void;
  29514. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  29515. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  29516. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  29517. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  29518. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  29519. }
  29520. }
  29521. declare module BABYLON {
  29522. /**
  29523. * Creates a refraction texture used by refraction channel of the standard material.
  29524. * @param name the texture name
  29525. * @param size size of the underlying texture
  29526. * @param scene root scene
  29527. */
  29528. class RefractionTexture extends RenderTargetTexture {
  29529. refractionPlane: Plane;
  29530. depth: number;
  29531. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  29532. clone(): RefractionTexture;
  29533. serialize(): any;
  29534. }
  29535. }
  29536. declare module BABYLON {
  29537. class RenderTargetTexture extends Texture {
  29538. isCube: boolean;
  29539. static _REFRESHRATE_RENDER_ONCE: number;
  29540. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  29541. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  29542. static readonly REFRESHRATE_RENDER_ONCE: number;
  29543. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  29544. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  29545. /**
  29546. * Use this predicate to dynamically define the list of mesh you want to render.
  29547. * If set, the renderList property will be overwritten.
  29548. */
  29549. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  29550. /**
  29551. * Use this list to define the list of mesh you want to render.
  29552. */
  29553. renderList: Nullable<Array<AbstractMesh>>;
  29554. renderParticles: boolean;
  29555. renderSprites: boolean;
  29556. coordinatesMode: number;
  29557. activeCamera: Nullable<Camera>;
  29558. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  29559. useCameraPostProcesses: boolean;
  29560. ignoreCameraViewport: boolean;
  29561. private _postProcessManager;
  29562. private _postProcesses;
  29563. private _resizeObserver;
  29564. /**
  29565. * An event triggered when the texture is unbind.
  29566. */
  29567. onBeforeBindObservable: Observable<RenderTargetTexture>;
  29568. /**
  29569. * An event triggered when the texture is unbind.
  29570. */
  29571. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  29572. private _onAfterUnbindObserver;
  29573. onAfterUnbind: () => void;
  29574. /**
  29575. * An event triggered before rendering the texture
  29576. */
  29577. onBeforeRenderObservable: Observable<number>;
  29578. private _onBeforeRenderObserver;
  29579. onBeforeRender: (faceIndex: number) => void;
  29580. /**
  29581. * An event triggered after rendering the texture
  29582. */
  29583. onAfterRenderObservable: Observable<number>;
  29584. private _onAfterRenderObserver;
  29585. onAfterRender: (faceIndex: number) => void;
  29586. /**
  29587. * An event triggered after the texture clear
  29588. */
  29589. onClearObservable: Observable<Engine>;
  29590. private _onClearObserver;
  29591. onClear: (Engine: Engine) => void;
  29592. clearColor: Color4;
  29593. protected _size: number | {
  29594. width: number;
  29595. height: number;
  29596. };
  29597. protected _initialSizeParameter: number | {
  29598. width: number;
  29599. height: number;
  29600. } | {
  29601. ratio: number;
  29602. };
  29603. protected _sizeRatio: Nullable<number>;
  29604. _generateMipMaps: boolean;
  29605. protected _renderingManager: RenderingManager;
  29606. _waitingRenderList: string[];
  29607. protected _doNotChangeAspectRatio: boolean;
  29608. protected _currentRefreshId: number;
  29609. protected _refreshRate: number;
  29610. protected _textureMatrix: Matrix;
  29611. protected _samples: number;
  29612. protected _renderTargetOptions: RenderTargetCreationOptions;
  29613. readonly renderTargetOptions: RenderTargetCreationOptions;
  29614. protected _engine: Engine;
  29615. protected _onRatioRescale(): void;
  29616. /**
  29617. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  29618. * It must define where the camera used to render the texture is set
  29619. */
  29620. boundingBoxPosition: Vector3;
  29621. private _boundingBoxSize;
  29622. /**
  29623. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  29624. * When defined, the cubemap will switch to local mode
  29625. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  29626. * @example https://www.babylonjs-playground.com/#RNASML
  29627. */
  29628. boundingBoxSize: Vector3;
  29629. /**
  29630. * In case the RTT has been created with a depth texture, get the associated
  29631. * depth texture.
  29632. * Otherwise, return null.
  29633. */
  29634. depthStencilTexture: Nullable<InternalTexture>;
  29635. /**
  29636. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  29637. * or used a shadow, depth texture...
  29638. * @param name The friendly name of the texture
  29639. * @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)
  29640. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  29641. * @param generateMipMaps True if mip maps need to be generated after render.
  29642. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  29643. * @param type The type of the buffer in the RTT (int, half float, float...)
  29644. * @param isCube True if a cube texture needs to be created
  29645. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  29646. * @param generateDepthBuffer True to generate a depth buffer
  29647. * @param generateStencilBuffer True to generate a stencil buffer
  29648. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  29649. */
  29650. constructor(name: string, size: number | {
  29651. width: number;
  29652. height: number;
  29653. } | {
  29654. ratio: number;
  29655. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  29656. /**
  29657. * Creates a depth stencil texture.
  29658. * This is only available in WebGL 2 or with the depth texture extension available.
  29659. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  29660. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  29661. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  29662. */
  29663. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  29664. private _processSizeParameter(size);
  29665. samples: number;
  29666. resetRefreshCounter(): void;
  29667. refreshRate: number;
  29668. addPostProcess(postProcess: PostProcess): void;
  29669. clearPostProcesses(dispose?: boolean): void;
  29670. removePostProcess(postProcess: PostProcess): void;
  29671. _shouldRender(): boolean;
  29672. getRenderSize(): number;
  29673. getRenderWidth(): number;
  29674. getRenderHeight(): number;
  29675. readonly canRescale: boolean;
  29676. scale(ratio: number): void;
  29677. getReflectionTextureMatrix(): Matrix;
  29678. resize(size: number | {
  29679. width: number;
  29680. height: number;
  29681. } | {
  29682. ratio: number;
  29683. }): void;
  29684. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  29685. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  29686. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  29687. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  29688. /**
  29689. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29690. * This allowed control for front to back rendering or reversly depending of the special needs.
  29691. *
  29692. * @param renderingGroupId The rendering group id corresponding to its index
  29693. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29694. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29695. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29696. */
  29697. 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;
  29698. /**
  29699. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29700. *
  29701. * @param renderingGroupId The rendering group id corresponding to its index
  29702. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29703. */
  29704. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  29705. clone(): RenderTargetTexture;
  29706. serialize(): any;
  29707. disposeFramebufferObjects(): void;
  29708. dispose(): void;
  29709. _rebuild(): void;
  29710. /**
  29711. * Clear the info related to rendering groups preventing retention point in material dispose.
  29712. */
  29713. freeRenderingGroups(): void;
  29714. }
  29715. }
  29716. declare module BABYLON {
  29717. class Texture extends BaseTexture {
  29718. static NEAREST_SAMPLINGMODE: number;
  29719. static NEAREST_NEAREST_MIPLINEAR: number;
  29720. static BILINEAR_SAMPLINGMODE: number;
  29721. static LINEAR_LINEAR_MIPNEAREST: number;
  29722. static TRILINEAR_SAMPLINGMODE: number;
  29723. static LINEAR_LINEAR_MIPLINEAR: number;
  29724. static NEAREST_NEAREST_MIPNEAREST: number;
  29725. static NEAREST_LINEAR_MIPNEAREST: number;
  29726. static NEAREST_LINEAR_MIPLINEAR: number;
  29727. static NEAREST_LINEAR: number;
  29728. static NEAREST_NEAREST: number;
  29729. static LINEAR_NEAREST_MIPNEAREST: number;
  29730. static LINEAR_NEAREST_MIPLINEAR: number;
  29731. static LINEAR_LINEAR: number;
  29732. static LINEAR_NEAREST: number;
  29733. static EXPLICIT_MODE: number;
  29734. static SPHERICAL_MODE: number;
  29735. static PLANAR_MODE: number;
  29736. static CUBIC_MODE: number;
  29737. static PROJECTION_MODE: number;
  29738. static SKYBOX_MODE: number;
  29739. static INVCUBIC_MODE: number;
  29740. static EQUIRECTANGULAR_MODE: number;
  29741. static FIXED_EQUIRECTANGULAR_MODE: number;
  29742. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29743. static CLAMP_ADDRESSMODE: number;
  29744. static WRAP_ADDRESSMODE: number;
  29745. static MIRROR_ADDRESSMODE: number;
  29746. /**
  29747. * 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
  29748. */
  29749. static UseSerializedUrlIfAny: boolean;
  29750. url: Nullable<string>;
  29751. uOffset: number;
  29752. vOffset: number;
  29753. uScale: number;
  29754. vScale: number;
  29755. uAng: number;
  29756. vAng: number;
  29757. wAng: number;
  29758. readonly noMipmap: boolean;
  29759. private _noMipmap;
  29760. _invertY: boolean;
  29761. private _rowGenerationMatrix;
  29762. private _cachedTextureMatrix;
  29763. private _projectionModeMatrix;
  29764. private _t0;
  29765. private _t1;
  29766. private _t2;
  29767. private _cachedUOffset;
  29768. private _cachedVOffset;
  29769. private _cachedUScale;
  29770. private _cachedVScale;
  29771. private _cachedUAng;
  29772. private _cachedVAng;
  29773. private _cachedWAng;
  29774. private _cachedProjectionMatrixId;
  29775. private _cachedCoordinatesMode;
  29776. _samplingMode: number;
  29777. private _buffer;
  29778. private _deleteBuffer;
  29779. protected _format: Nullable<number>;
  29780. private _delayedOnLoad;
  29781. private _delayedOnError;
  29782. protected _onLoadObservable: Nullable<Observable<Texture>>;
  29783. protected _isBlocking: boolean;
  29784. isBlocking: boolean;
  29785. readonly samplingMode: number;
  29786. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: any, deleteBuffer?: boolean, format?: number);
  29787. updateURL(url: string): void;
  29788. delayLoad(): void;
  29789. updateSamplingMode(samplingMode: number): void;
  29790. private _prepareRowForTextureGeneration(x, y, z, t);
  29791. getTextureMatrix(): Matrix;
  29792. getReflectionTextureMatrix(): Matrix;
  29793. clone(): Texture;
  29794. readonly onLoadObservable: Observable<Texture>;
  29795. serialize(): any;
  29796. getClassName(): string;
  29797. dispose(): void;
  29798. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  29799. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  29800. 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;
  29801. }
  29802. }
  29803. declare module BABYLON {
  29804. /**
  29805. * Settings for finer control over video usage
  29806. */
  29807. interface VideoTextureSettings {
  29808. /**
  29809. * Applies `autoplay` to video, if specified
  29810. */
  29811. autoPlay?: boolean;
  29812. /**
  29813. * Applies `loop` to video, if specified
  29814. */
  29815. loop?: boolean;
  29816. /**
  29817. * Automatically updates internal texture from video at every frame in the render loop
  29818. */
  29819. autoUpdateTexture: boolean;
  29820. }
  29821. class VideoTexture extends Texture {
  29822. /**
  29823. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29824. */
  29825. readonly autoUpdateTexture: boolean;
  29826. /**
  29827. * The video instance used by the texture internally
  29828. */
  29829. readonly video: HTMLVideoElement;
  29830. private _generateMipMaps;
  29831. private _engine;
  29832. /**
  29833. * Creates a video texture.
  29834. * Sample : https://doc.babylonjs.com/how_to/video_texture
  29835. * @param {string | null} name optional name, will detect from video source, if not defined
  29836. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  29837. * @param {BABYLON.Scene} scene is obviously the current scene.
  29838. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29839. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  29840. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29841. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  29842. */
  29843. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29844. private _getName(src);
  29845. private _getVideo(src);
  29846. private _createInternalTexture;
  29847. private reset;
  29848. /**
  29849. * Internal method to initiate `update`.
  29850. */
  29851. _rebuild(): void;
  29852. /**
  29853. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29854. */
  29855. update(): void;
  29856. /**
  29857. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29858. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29859. */
  29860. updateTexture(isVisible: boolean): void;
  29861. protected _updateInternalTexture: (e?: Event | undefined) => void;
  29862. /**
  29863. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29864. * @param url New url.
  29865. */
  29866. updateURL(url: string): void;
  29867. dispose(): void;
  29868. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29869. minWidth: number;
  29870. maxWidth: number;
  29871. minHeight: number;
  29872. maxHeight: number;
  29873. deviceId: string;
  29874. }): void;
  29875. }
  29876. }
  29877. declare module BABYLON {
  29878. /**
  29879. * The Physically based material base class of BJS.
  29880. *
  29881. * This offers the main features of a standard PBR material.
  29882. * For more information, please refer to the documentation :
  29883. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  29884. */
  29885. abstract class PBRBaseMaterial extends PushMaterial {
  29886. /**
  29887. * Intensity of the direct lights e.g. the four lights available in your scene.
  29888. * This impacts both the direct diffuse and specular highlights.
  29889. */
  29890. protected _directIntensity: number;
  29891. /**
  29892. * Intensity of the emissive part of the material.
  29893. * This helps controlling the emissive effect without modifying the emissive color.
  29894. */
  29895. protected _emissiveIntensity: number;
  29896. /**
  29897. * Intensity of the environment e.g. how much the environment will light the object
  29898. * either through harmonics for rough material or through the refelction for shiny ones.
  29899. */
  29900. protected _environmentIntensity: number;
  29901. /**
  29902. * This is a special control allowing the reduction of the specular highlights coming from the
  29903. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  29904. */
  29905. protected _specularIntensity: number;
  29906. /**
  29907. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  29908. */
  29909. private _lightingInfos;
  29910. /**
  29911. * Debug Control allowing disabling the bump map on this material.
  29912. */
  29913. protected _disableBumpMap: boolean;
  29914. /**
  29915. * AKA Diffuse Texture in standard nomenclature.
  29916. */
  29917. protected _albedoTexture: BaseTexture;
  29918. /**
  29919. * AKA Occlusion Texture in other nomenclature.
  29920. */
  29921. protected _ambientTexture: BaseTexture;
  29922. /**
  29923. * AKA Occlusion Texture Intensity in other nomenclature.
  29924. */
  29925. protected _ambientTextureStrength: number;
  29926. /**
  29927. * Stores the alpha values in a texture.
  29928. */
  29929. protected _opacityTexture: BaseTexture;
  29930. /**
  29931. * Stores the reflection values in a texture.
  29932. */
  29933. protected _reflectionTexture: BaseTexture;
  29934. /**
  29935. * Stores the refraction values in a texture.
  29936. */
  29937. protected _refractionTexture: BaseTexture;
  29938. /**
  29939. * Stores the emissive values in a texture.
  29940. */
  29941. protected _emissiveTexture: BaseTexture;
  29942. /**
  29943. * AKA Specular texture in other nomenclature.
  29944. */
  29945. protected _reflectivityTexture: BaseTexture;
  29946. /**
  29947. * Used to switch from specular/glossiness to metallic/roughness workflow.
  29948. */
  29949. protected _metallicTexture: BaseTexture;
  29950. /**
  29951. * Specifies the metallic scalar of the metallic/roughness workflow.
  29952. * Can also be used to scale the metalness values of the metallic texture.
  29953. */
  29954. protected _metallic: number;
  29955. /**
  29956. * Specifies the roughness scalar of the metallic/roughness workflow.
  29957. * Can also be used to scale the roughness values of the metallic texture.
  29958. */
  29959. protected _roughness: number;
  29960. /**
  29961. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  29962. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  29963. */
  29964. protected _microSurfaceTexture: BaseTexture;
  29965. /**
  29966. * Stores surface normal data used to displace a mesh in a texture.
  29967. */
  29968. protected _bumpTexture: BaseTexture;
  29969. /**
  29970. * Stores the pre-calculated light information of a mesh in a texture.
  29971. */
  29972. protected _lightmapTexture: BaseTexture;
  29973. /**
  29974. * The color of a material in ambient lighting.
  29975. */
  29976. protected _ambientColor: Color3;
  29977. /**
  29978. * AKA Diffuse Color in other nomenclature.
  29979. */
  29980. protected _albedoColor: Color3;
  29981. /**
  29982. * AKA Specular Color in other nomenclature.
  29983. */
  29984. protected _reflectivityColor: Color3;
  29985. /**
  29986. * The color applied when light is reflected from a material.
  29987. */
  29988. protected _reflectionColor: Color3;
  29989. /**
  29990. * The color applied when light is emitted from a material.
  29991. */
  29992. protected _emissiveColor: Color3;
  29993. /**
  29994. * AKA Glossiness in other nomenclature.
  29995. */
  29996. protected _microSurface: number;
  29997. /**
  29998. * source material index of refraction (IOR)' / 'destination material IOR.
  29999. */
  30000. protected _indexOfRefraction: number;
  30001. /**
  30002. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  30003. */
  30004. protected _invertRefractionY: boolean;
  30005. /**
  30006. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  30007. * Materials half opaque for instance using refraction could benefit from this control.
  30008. */
  30009. protected _linkRefractionWithTransparency: boolean;
  30010. /**
  30011. * Specifies that the material will use the light map as a show map.
  30012. */
  30013. protected _useLightmapAsShadowmap: boolean;
  30014. /**
  30015. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  30016. * makes the reflect vector face the model (under horizon).
  30017. */
  30018. protected _useHorizonOcclusion: boolean;
  30019. /**
  30020. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  30021. * too much the area relying on ambient texture to define their ambient occlusion.
  30022. */
  30023. protected _useRadianceOcclusion: boolean;
  30024. /**
  30025. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  30026. */
  30027. protected _useAlphaFromAlbedoTexture: boolean;
  30028. /**
  30029. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  30030. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30031. */
  30032. protected _useSpecularOverAlpha: boolean;
  30033. /**
  30034. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  30035. */
  30036. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  30037. /**
  30038. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  30039. */
  30040. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  30041. /**
  30042. * Specifies if the metallic texture contains the roughness information in its green channel.
  30043. */
  30044. protected _useRoughnessFromMetallicTextureGreen: boolean;
  30045. /**
  30046. * Specifies if the metallic texture contains the metallness information in its blue channel.
  30047. */
  30048. protected _useMetallnessFromMetallicTextureBlue: boolean;
  30049. /**
  30050. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  30051. */
  30052. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  30053. /**
  30054. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  30055. */
  30056. protected _useAmbientInGrayScale: boolean;
  30057. /**
  30058. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  30059. * The material will try to infer what glossiness each pixel should be.
  30060. */
  30061. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  30062. /**
  30063. * BJS is using an harcoded light falloff based on a manually sets up range.
  30064. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  30065. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  30066. */
  30067. protected _usePhysicalLightFalloff: boolean;
  30068. /**
  30069. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30070. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30071. */
  30072. protected _useRadianceOverAlpha: boolean;
  30073. /**
  30074. * Allows using an object space normal map (instead of tangent space).
  30075. */
  30076. protected _useObjectSpaceNormalMap: boolean;
  30077. /**
  30078. * Allows using the bump map in parallax mode.
  30079. */
  30080. protected _useParallax: boolean;
  30081. /**
  30082. * Allows using the bump map in parallax occlusion mode.
  30083. */
  30084. protected _useParallaxOcclusion: boolean;
  30085. /**
  30086. * Controls the scale bias of the parallax mode.
  30087. */
  30088. protected _parallaxScaleBias: number;
  30089. /**
  30090. * If sets to true, disables all the lights affecting the material.
  30091. */
  30092. protected _disableLighting: boolean;
  30093. /**
  30094. * Number of Simultaneous lights allowed on the material.
  30095. */
  30096. protected _maxSimultaneousLights: number;
  30097. /**
  30098. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  30099. */
  30100. protected _invertNormalMapX: boolean;
  30101. /**
  30102. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  30103. */
  30104. protected _invertNormalMapY: boolean;
  30105. /**
  30106. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30107. */
  30108. protected _twoSidedLighting: boolean;
  30109. /**
  30110. * Defines the alpha limits in alpha test mode.
  30111. */
  30112. protected _alphaCutOff: number;
  30113. /**
  30114. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30115. */
  30116. protected _forceAlphaTest: boolean;
  30117. /**
  30118. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  30119. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  30120. */
  30121. protected _useAlphaFresnel: boolean;
  30122. /**
  30123. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  30124. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  30125. */
  30126. protected _useLinearAlphaFresnel: boolean;
  30127. /**
  30128. * The transparency mode of the material.
  30129. */
  30130. protected _transparencyMode: Nullable<number>;
  30131. /**
  30132. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  30133. * from cos thetav and roughness:
  30134. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  30135. */
  30136. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  30137. /**
  30138. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  30139. */
  30140. protected _forceIrradianceInFragment: boolean;
  30141. /**
  30142. * Force normal to face away from face.
  30143. */
  30144. protected _forceNormalForward: boolean;
  30145. /**
  30146. * Enables specular anti aliasing in the PBR shader.
  30147. * It will both interacts on the Geometry for analytical and IBL lighting.
  30148. * It also prefilter the roughness map based on the bump values.
  30149. */
  30150. protected _enableSpecularAntiAliasing: boolean;
  30151. /**
  30152. * Default configuration related to image processing available in the PBR Material.
  30153. */
  30154. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30155. /**
  30156. * Keep track of the image processing observer to allow dispose and replace.
  30157. */
  30158. private _imageProcessingObserver;
  30159. /**
  30160. * Attaches a new image processing configuration to the PBR Material.
  30161. * @param configuration
  30162. */
  30163. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30164. /**
  30165. * Stores the available render targets.
  30166. */
  30167. private _renderTargets;
  30168. /**
  30169. * Sets the global ambient color for the material used in lighting calculations.
  30170. */
  30171. private _globalAmbientColor;
  30172. /**
  30173. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  30174. */
  30175. private _useLogarithmicDepth;
  30176. /**
  30177. * If set to true, no lighting calculations will be applied.
  30178. */
  30179. private _unlit;
  30180. /**
  30181. * Instantiates a new PBRMaterial instance.
  30182. *
  30183. * @param name The material name
  30184. * @param scene The scene the material will be use in.
  30185. */
  30186. constructor(name: string, scene: Scene);
  30187. /**
  30188. * Gets the name of the material class.
  30189. */
  30190. getClassName(): string;
  30191. /**
  30192. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  30193. */
  30194. /**
  30195. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  30196. */
  30197. useLogarithmicDepth: boolean;
  30198. /**
  30199. * Gets the current transparency mode.
  30200. */
  30201. /**
  30202. * Sets the transparency mode of the material.
  30203. */
  30204. transparencyMode: Nullable<number>;
  30205. /**
  30206. * Returns true if alpha blending should be disabled.
  30207. */
  30208. private readonly _disableAlphaBlending;
  30209. /**
  30210. * Specifies whether or not this material should be rendered in alpha blend mode.
  30211. */
  30212. needAlphaBlending(): boolean;
  30213. /**
  30214. * Specifies if the mesh will require alpha blending.
  30215. * @param mesh - BJS mesh.
  30216. */
  30217. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30218. /**
  30219. * Specifies whether or not this material should be rendered in alpha test mode.
  30220. */
  30221. needAlphaTesting(): boolean;
  30222. /**
  30223. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  30224. */
  30225. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  30226. /**
  30227. * Gets the texture used for the alpha test.
  30228. */
  30229. getAlphaTestTexture(): BaseTexture;
  30230. /**
  30231. * Stores the reflectivity values based on metallic roughness workflow.
  30232. */
  30233. private static _scaledReflectivity;
  30234. /**
  30235. * Specifies that the submesh is ready to be used.
  30236. * @param mesh - BJS mesh.
  30237. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  30238. * @param useInstances - Specifies that instances should be used.
  30239. * @returns - boolean indicating that the submesh is ready or not.
  30240. */
  30241. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30242. /**
  30243. * Specifies if the material uses metallic roughness workflow.
  30244. * @returns boolean specifiying if the material uses metallic roughness workflow.
  30245. */
  30246. isMetallicWorkflow(): boolean;
  30247. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  30248. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  30249. /**
  30250. * Force shader compilation
  30251. */
  30252. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  30253. clipPlane: boolean;
  30254. }>): void;
  30255. /**
  30256. * Initializes the uniform buffer layout for the shader.
  30257. */
  30258. buildUniformLayout(): void;
  30259. /**
  30260. * Unbinds the textures.
  30261. */
  30262. unbind(): void;
  30263. /**
  30264. * Binds the submesh data.
  30265. * @param world - The world matrix.
  30266. * @param mesh - The BJS mesh.
  30267. * @param subMesh - A submesh of the BJS mesh.
  30268. */
  30269. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30270. /**
  30271. * Returns the animatable textures.
  30272. * @returns - Array of animatable textures.
  30273. */
  30274. getAnimatables(): IAnimatable[];
  30275. /**
  30276. * Returns the texture used for reflections.
  30277. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  30278. */
  30279. private _getReflectionTexture();
  30280. /**
  30281. * Returns the texture used for refraction or null if none is used.
  30282. * @returns - Refection texture if present. If no refraction texture and refraction
  30283. * is linked with transparency, returns environment texture. Otherwise, returns null.
  30284. */
  30285. private _getRefractionTexture();
  30286. /**
  30287. * Disposes the resources of the material.
  30288. * @param forceDisposeEffect - Forces the disposal of effects.
  30289. * @param forceDisposeTextures - Forces the disposal of all textures.
  30290. */
  30291. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30292. }
  30293. }
  30294. declare module BABYLON {
  30295. /**
  30296. * The Physically based simple base material of BJS.
  30297. *
  30298. * This enables better naming and convention enforcements on top of the pbrMaterial.
  30299. * It is used as the base class for both the specGloss and metalRough conventions.
  30300. */
  30301. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  30302. /**
  30303. * Number of Simultaneous lights allowed on the material.
  30304. */
  30305. maxSimultaneousLights: number;
  30306. /**
  30307. * If sets to true, disables all the lights affecting the material.
  30308. */
  30309. disableLighting: boolean;
  30310. /**
  30311. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  30312. */
  30313. environmentTexture: BaseTexture;
  30314. /**
  30315. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30316. */
  30317. invertNormalMapX: boolean;
  30318. /**
  30319. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30320. */
  30321. invertNormalMapY: boolean;
  30322. /**
  30323. * Normal map used in the model.
  30324. */
  30325. normalTexture: BaseTexture;
  30326. /**
  30327. * Emissivie color used to self-illuminate the model.
  30328. */
  30329. emissiveColor: Color3;
  30330. /**
  30331. * Emissivie texture used to self-illuminate the model.
  30332. */
  30333. emissiveTexture: BaseTexture;
  30334. /**
  30335. * Occlusion Channel Strenght.
  30336. */
  30337. occlusionStrength: number;
  30338. /**
  30339. * Occlusion Texture of the material (adding extra occlusion effects).
  30340. */
  30341. occlusionTexture: BaseTexture;
  30342. /**
  30343. * Defines the alpha limits in alpha test mode.
  30344. */
  30345. alphaCutOff: number;
  30346. /**
  30347. * Gets the current double sided mode.
  30348. */
  30349. /**
  30350. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30351. */
  30352. doubleSided: boolean;
  30353. lightmapTexture: BaseTexture;
  30354. useLightmapAsShadowmap: boolean;
  30355. /**
  30356. * Return the active textures of the material.
  30357. */
  30358. getActiveTextures(): BaseTexture[];
  30359. hasTexture(texture: BaseTexture): boolean;
  30360. /**
  30361. * Instantiates a new PBRMaterial instance.
  30362. *
  30363. * @param name The material name
  30364. * @param scene The scene the material will be use in.
  30365. */
  30366. constructor(name: string, scene: Scene);
  30367. getClassName(): string;
  30368. }
  30369. }
  30370. declare module BABYLON {
  30371. /**
  30372. * The Physically based material of BJS.
  30373. *
  30374. * This offers the main features of a standard PBR material.
  30375. * For more information, please refer to the documentation :
  30376. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  30377. */
  30378. class PBRMaterial extends PBRBaseMaterial {
  30379. private static _PBRMATERIAL_OPAQUE;
  30380. /**
  30381. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30382. */
  30383. static readonly PBRMATERIAL_OPAQUE: number;
  30384. /**
  30385. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30386. */
  30387. private static _PBRMATERIAL_ALPHATEST;
  30388. /**
  30389. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30390. */
  30391. static readonly PBRMATERIAL_ALPHATEST: number;
  30392. /**
  30393. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30394. */
  30395. private static _PBRMATERIAL_ALPHABLEND;
  30396. /**
  30397. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30398. */
  30399. static readonly PBRMATERIAL_ALPHABLEND: number;
  30400. /**
  30401. * 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.
  30402. * They are also discarded below the alpha cutoff threshold to improve performances.
  30403. */
  30404. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  30405. /**
  30406. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30407. * They are also discarded below the alpha cutoff threshold to improve performances.
  30408. */
  30409. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  30410. /**
  30411. * Intensity of the direct lights e.g. the four lights available in your scene.
  30412. * This impacts both the direct diffuse and specular highlights.
  30413. */
  30414. directIntensity: number;
  30415. /**
  30416. * Intensity of the emissive part of the material.
  30417. * This helps controlling the emissive effect without modifying the emissive color.
  30418. */
  30419. emissiveIntensity: number;
  30420. /**
  30421. * Intensity of the environment e.g. how much the environment will light the object
  30422. * either through harmonics for rough material or through the refelction for shiny ones.
  30423. */
  30424. environmentIntensity: number;
  30425. /**
  30426. * This is a special control allowing the reduction of the specular highlights coming from the
  30427. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  30428. */
  30429. specularIntensity: number;
  30430. /**
  30431. * Debug Control allowing disabling the bump map on this material.
  30432. */
  30433. disableBumpMap: boolean;
  30434. /**
  30435. * AKA Diffuse Texture in standard nomenclature.
  30436. */
  30437. albedoTexture: BaseTexture;
  30438. /**
  30439. * AKA Occlusion Texture in other nomenclature.
  30440. */
  30441. ambientTexture: BaseTexture;
  30442. /**
  30443. * AKA Occlusion Texture Intensity in other nomenclature.
  30444. */
  30445. ambientTextureStrength: number;
  30446. /**
  30447. * Stores the alpha values in a texture.
  30448. */
  30449. opacityTexture: BaseTexture;
  30450. /**
  30451. * Stores the reflection values in a texture.
  30452. */
  30453. reflectionTexture: Nullable<BaseTexture>;
  30454. /**
  30455. * Stores the emissive values in a texture.
  30456. */
  30457. emissiveTexture: BaseTexture;
  30458. /**
  30459. * AKA Specular texture in other nomenclature.
  30460. */
  30461. reflectivityTexture: BaseTexture;
  30462. /**
  30463. * Used to switch from specular/glossiness to metallic/roughness workflow.
  30464. */
  30465. metallicTexture: BaseTexture;
  30466. /**
  30467. * Specifies the metallic scalar of the metallic/roughness workflow.
  30468. * Can also be used to scale the metalness values of the metallic texture.
  30469. */
  30470. metallic: number;
  30471. /**
  30472. * Specifies the roughness scalar of the metallic/roughness workflow.
  30473. * Can also be used to scale the roughness values of the metallic texture.
  30474. */
  30475. roughness: number;
  30476. /**
  30477. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  30478. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  30479. */
  30480. microSurfaceTexture: BaseTexture;
  30481. /**
  30482. * Stores surface normal data used to displace a mesh in a texture.
  30483. */
  30484. bumpTexture: BaseTexture;
  30485. /**
  30486. * Stores the pre-calculated light information of a mesh in a texture.
  30487. */
  30488. lightmapTexture: BaseTexture;
  30489. /**
  30490. * Stores the refracted light information in a texture.
  30491. */
  30492. refractionTexture: BaseTexture;
  30493. /**
  30494. * The color of a material in ambient lighting.
  30495. */
  30496. ambientColor: Color3;
  30497. /**
  30498. * AKA Diffuse Color in other nomenclature.
  30499. */
  30500. albedoColor: Color3;
  30501. /**
  30502. * AKA Specular Color in other nomenclature.
  30503. */
  30504. reflectivityColor: Color3;
  30505. /**
  30506. * The color reflected from the material.
  30507. */
  30508. reflectionColor: Color3;
  30509. /**
  30510. * The color emitted from the material.
  30511. */
  30512. emissiveColor: Color3;
  30513. /**
  30514. * AKA Glossiness in other nomenclature.
  30515. */
  30516. microSurface: number;
  30517. /**
  30518. * source material index of refraction (IOR)' / 'destination material IOR.
  30519. */
  30520. indexOfRefraction: number;
  30521. /**
  30522. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  30523. */
  30524. invertRefractionY: boolean;
  30525. /**
  30526. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  30527. * Materials half opaque for instance using refraction could benefit from this control.
  30528. */
  30529. linkRefractionWithTransparency: boolean;
  30530. useLightmapAsShadowmap: boolean;
  30531. /**
  30532. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  30533. */
  30534. useAlphaFromAlbedoTexture: boolean;
  30535. /**
  30536. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30537. */
  30538. forceAlphaTest: boolean;
  30539. /**
  30540. * Defines the alpha limits in alpha test mode.
  30541. */
  30542. alphaCutOff: number;
  30543. /**
  30544. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  30545. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30546. */
  30547. useSpecularOverAlpha: boolean;
  30548. /**
  30549. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  30550. */
  30551. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  30552. /**
  30553. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  30554. */
  30555. useRoughnessFromMetallicTextureAlpha: boolean;
  30556. /**
  30557. * Specifies if the metallic texture contains the roughness information in its green channel.
  30558. */
  30559. useRoughnessFromMetallicTextureGreen: boolean;
  30560. /**
  30561. * Specifies if the metallic texture contains the metallness information in its blue channel.
  30562. */
  30563. useMetallnessFromMetallicTextureBlue: boolean;
  30564. /**
  30565. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  30566. */
  30567. useAmbientOcclusionFromMetallicTextureRed: boolean;
  30568. /**
  30569. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  30570. */
  30571. useAmbientInGrayScale: boolean;
  30572. /**
  30573. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  30574. * The material will try to infer what glossiness each pixel should be.
  30575. */
  30576. useAutoMicroSurfaceFromReflectivityMap: boolean;
  30577. /**
  30578. * BJS is using an harcoded light falloff based on a manually sets up range.
  30579. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  30580. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  30581. */
  30582. usePhysicalLightFalloff: boolean;
  30583. /**
  30584. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30585. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30586. */
  30587. useRadianceOverAlpha: boolean;
  30588. /**
  30589. * Allows using an object space normal map (instead of tangent space).
  30590. */
  30591. useObjectSpaceNormalMap: boolean;
  30592. /**
  30593. * Allows using the bump map in parallax mode.
  30594. */
  30595. useParallax: boolean;
  30596. /**
  30597. * Allows using the bump map in parallax occlusion mode.
  30598. */
  30599. useParallaxOcclusion: boolean;
  30600. /**
  30601. * Controls the scale bias of the parallax mode.
  30602. */
  30603. parallaxScaleBias: number;
  30604. /**
  30605. * If sets to true, disables all the lights affecting the material.
  30606. */
  30607. disableLighting: boolean;
  30608. /**
  30609. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  30610. */
  30611. forceIrradianceInFragment: boolean;
  30612. /**
  30613. * Number of Simultaneous lights allowed on the material.
  30614. */
  30615. maxSimultaneousLights: number;
  30616. /**
  30617. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30618. */
  30619. invertNormalMapX: boolean;
  30620. /**
  30621. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30622. */
  30623. invertNormalMapY: boolean;
  30624. /**
  30625. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30626. */
  30627. twoSidedLighting: boolean;
  30628. /**
  30629. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  30630. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  30631. */
  30632. useAlphaFresnel: boolean;
  30633. /**
  30634. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  30635. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  30636. */
  30637. useLinearAlphaFresnel: boolean;
  30638. /**
  30639. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  30640. * And/Or occlude the blended part.
  30641. */
  30642. environmentBRDFTexture: Nullable<BaseTexture>;
  30643. /**
  30644. * Force normal to face away from face.
  30645. */
  30646. forceNormalForward: boolean;
  30647. /**
  30648. * Enables specular anti aliasing in the PBR shader.
  30649. * It will both interacts on the Geometry for analytical and IBL lighting.
  30650. * It also prefilter the roughness map based on the bump values.
  30651. */
  30652. enableSpecularAntiAliasing: boolean;
  30653. /**
  30654. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  30655. * makes the reflect vector face the model (under horizon).
  30656. */
  30657. useHorizonOcclusion: boolean;
  30658. /**
  30659. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  30660. * too much the area relying on ambient texture to define their ambient occlusion.
  30661. */
  30662. useRadianceOcclusion: boolean;
  30663. /**
  30664. * If set to true, no lighting calculations will be applied.
  30665. */
  30666. unlit: boolean;
  30667. /**
  30668. * Gets the image processing configuration used either in this material.
  30669. */
  30670. /**
  30671. * Sets the Default image processing configuration used either in the this material.
  30672. *
  30673. * If sets to null, the scene one is in use.
  30674. */
  30675. imageProcessingConfiguration: ImageProcessingConfiguration;
  30676. /**
  30677. * Gets wether the color curves effect is enabled.
  30678. */
  30679. /**
  30680. * Sets wether the color curves effect is enabled.
  30681. */
  30682. cameraColorCurvesEnabled: boolean;
  30683. /**
  30684. * Gets wether the color grading effect is enabled.
  30685. */
  30686. /**
  30687. * Gets wether the color grading effect is enabled.
  30688. */
  30689. cameraColorGradingEnabled: boolean;
  30690. /**
  30691. * Gets wether tonemapping is enabled or not.
  30692. */
  30693. /**
  30694. * Sets wether tonemapping is enabled or not
  30695. */
  30696. cameraToneMappingEnabled: boolean;
  30697. /**
  30698. * The camera exposure used on this material.
  30699. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30700. * This corresponds to a photographic exposure.
  30701. */
  30702. /**
  30703. * The camera exposure used on this material.
  30704. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30705. * This corresponds to a photographic exposure.
  30706. */
  30707. cameraExposure: number;
  30708. /**
  30709. * Gets The camera contrast used on this material.
  30710. */
  30711. /**
  30712. * Sets The camera contrast used on this material.
  30713. */
  30714. cameraContrast: number;
  30715. /**
  30716. * Gets the Color Grading 2D Lookup Texture.
  30717. */
  30718. /**
  30719. * Sets the Color Grading 2D Lookup Texture.
  30720. */
  30721. cameraColorGradingTexture: Nullable<BaseTexture>;
  30722. /**
  30723. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30724. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30725. * 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;
  30726. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30727. */
  30728. /**
  30729. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30730. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30731. * 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;
  30732. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30733. */
  30734. cameraColorCurves: Nullable<ColorCurves>;
  30735. /**
  30736. * Instantiates a new PBRMaterial instance.
  30737. *
  30738. * @param name The material name
  30739. * @param scene The scene the material will be use in.
  30740. */
  30741. constructor(name: string, scene: Scene);
  30742. /**
  30743. * Returns the name of this material class.
  30744. */
  30745. getClassName(): string;
  30746. /**
  30747. * Returns an array of the actively used textures.
  30748. * @returns - Array of BaseTextures
  30749. */
  30750. getActiveTextures(): BaseTexture[];
  30751. /**
  30752. * Checks to see if a texture is used in the material.
  30753. * @param texture - Base texture to use.
  30754. * @returns - Boolean specifying if a texture is used in the material.
  30755. */
  30756. hasTexture(texture: BaseTexture): boolean;
  30757. /**
  30758. * Makes a duplicate of the current material.
  30759. * @param name - name to use for the new material.
  30760. */
  30761. clone(name: string): PBRMaterial;
  30762. /**
  30763. * Serializes this PBR Material.
  30764. * @returns - An object with the serialized material.
  30765. */
  30766. serialize(): any;
  30767. /**
  30768. * Parses a PBR Material from a serialized object.
  30769. * @param source - Serialized object.
  30770. * @param scene - BJS scene instance.
  30771. * @param rootUrl - url for the scene object
  30772. * @returns - PBRMaterial
  30773. */
  30774. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  30775. }
  30776. }
  30777. declare module BABYLON {
  30778. /**
  30779. * The PBR material of BJS following the metal roughness convention.
  30780. *
  30781. * This fits to the PBR convention in the GLTF definition:
  30782. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  30783. */
  30784. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  30785. /**
  30786. * The base color has two different interpretations depending on the value of metalness.
  30787. * When the material is a metal, the base color is the specific measured reflectance value
  30788. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  30789. * of the material.
  30790. */
  30791. baseColor: Color3;
  30792. /**
  30793. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  30794. * well as opacity information in the alpha channel.
  30795. */
  30796. baseTexture: BaseTexture;
  30797. /**
  30798. * Specifies the metallic scalar value of the material.
  30799. * Can also be used to scale the metalness values of the metallic texture.
  30800. */
  30801. metallic: number;
  30802. /**
  30803. * Specifies the roughness scalar value of the material.
  30804. * Can also be used to scale the roughness values of the metallic texture.
  30805. */
  30806. roughness: number;
  30807. /**
  30808. * Texture containing both the metallic value in the B channel and the
  30809. * roughness value in the G channel to keep better precision.
  30810. */
  30811. metallicRoughnessTexture: BaseTexture;
  30812. /**
  30813. * Instantiates a new PBRMetalRoughnessMaterial instance.
  30814. *
  30815. * @param name The material name
  30816. * @param scene The scene the material will be use in.
  30817. */
  30818. constructor(name: string, scene: Scene);
  30819. /**
  30820. * Return the currrent class name of the material.
  30821. */
  30822. getClassName(): string;
  30823. /**
  30824. * Return the active textures of the material.
  30825. */
  30826. getActiveTextures(): BaseTexture[];
  30827. /**
  30828. * Checks to see if a texture is used in the material.
  30829. * @param texture - Base texture to use.
  30830. * @returns - Boolean specifying if a texture is used in the material.
  30831. */
  30832. hasTexture(texture: BaseTexture): boolean;
  30833. /**
  30834. * Makes a duplicate of the current material.
  30835. * @param name - name to use for the new material.
  30836. */
  30837. clone(name: string): PBRMetallicRoughnessMaterial;
  30838. /**
  30839. * Serialize the material to a parsable JSON object.
  30840. */
  30841. serialize(): any;
  30842. /**
  30843. * Parses a JSON object correponding to the serialize function.
  30844. */
  30845. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  30846. }
  30847. }
  30848. declare module BABYLON {
  30849. /**
  30850. * The PBR material of BJS following the specular glossiness convention.
  30851. *
  30852. * This fits to the PBR convention in the GLTF definition:
  30853. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  30854. */
  30855. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  30856. /**
  30857. * Specifies the diffuse color of the material.
  30858. */
  30859. diffuseColor: Color3;
  30860. /**
  30861. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  30862. * channel.
  30863. */
  30864. diffuseTexture: BaseTexture;
  30865. /**
  30866. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  30867. */
  30868. specularColor: Color3;
  30869. /**
  30870. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  30871. */
  30872. glossiness: number;
  30873. /**
  30874. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  30875. */
  30876. specularGlossinessTexture: BaseTexture;
  30877. /**
  30878. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  30879. *
  30880. * @param name The material name
  30881. * @param scene The scene the material will be use in.
  30882. */
  30883. constructor(name: string, scene: Scene);
  30884. /**
  30885. * Return the currrent class name of the material.
  30886. */
  30887. getClassName(): string;
  30888. /**
  30889. * Return the active textures of the material.
  30890. */
  30891. getActiveTextures(): BaseTexture[];
  30892. /**
  30893. * Checks to see if a texture is used in the material.
  30894. * @param texture - Base texture to use.
  30895. * @returns - Boolean specifying if a texture is used in the material.
  30896. */
  30897. hasTexture(texture: BaseTexture): boolean;
  30898. /**
  30899. * Makes a duplicate of the current material.
  30900. * @param name - name to use for the new material.
  30901. */
  30902. clone(name: string): PBRSpecularGlossinessMaterial;
  30903. /**
  30904. * Serialize the material to a parsable JSON object.
  30905. */
  30906. serialize(): any;
  30907. /**
  30908. * Parses a JSON object correponding to the serialize function.
  30909. */
  30910. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  30911. }
  30912. }
  30913. declare var DracoDecoderModule: any;
  30914. declare module BABYLON {
  30915. /**
  30916. * Draco compression (https://google.github.io/draco/)
  30917. */
  30918. class DracoCompression implements IDisposable {
  30919. private _workerPool;
  30920. /**
  30921. * Gets the url to the draco decoder if available.
  30922. */
  30923. static DecoderUrl: Nullable<string>;
  30924. /**
  30925. * Constructor
  30926. * @param numWorkers The number of workers for async operations
  30927. */
  30928. constructor(numWorkers?: number);
  30929. /**
  30930. * Stop all async operations and release resources.
  30931. */
  30932. dispose(): void;
  30933. /**
  30934. * Decode Draco compressed mesh data to vertex data.
  30935. * @param data The array buffer view for the Draco compression data
  30936. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  30937. * @returns A promise that resolves with the decoded vertex data
  30938. */
  30939. decodeMeshAsync(data: ArrayBufferView, attributes: {
  30940. [kind: string]: number;
  30941. }): Promise<VertexData>;
  30942. /**
  30943. * The worker function that gets converted to a blob url to pass into a worker.
  30944. */
  30945. private static _Worker();
  30946. private static _GetDefaultDecoderUrl();
  30947. }
  30948. }
  30949. declare module BABYLON {
  30950. /**
  30951. * Particle emitter emitting particles from the inside of a box.
  30952. * It emits the particles randomly between 2 given directions.
  30953. */
  30954. class BoxParticleEmitter implements IParticleEmitterType {
  30955. /**
  30956. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30957. */
  30958. direction1: Vector3;
  30959. /**
  30960. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30961. */
  30962. direction2: Vector3;
  30963. /**
  30964. * 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.
  30965. */
  30966. minEmitBox: Vector3;
  30967. /**
  30968. * 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.
  30969. */
  30970. maxEmitBox: Vector3;
  30971. /**
  30972. * Creates a new instance BoxParticleEmitter
  30973. */
  30974. constructor();
  30975. /**
  30976. * Called by the particle System when the direction is computed for the created particle.
  30977. * @param emitPower is the power of the particle (speed)
  30978. * @param worldMatrix is the world matrix of the particle system
  30979. * @param directionToUpdate is the direction vector to update with the result
  30980. * @param particle is the particle we are computed the direction for
  30981. */
  30982. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  30983. /**
  30984. * Called by the particle System when the position is computed for the created particle.
  30985. * @param worldMatrix is the world matrix of the particle system
  30986. * @param positionToUpdate is the position vector to update with the result
  30987. * @param particle is the particle we are computed the position for
  30988. */
  30989. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  30990. /**
  30991. * Clones the current emitter and returns a copy of it
  30992. * @returns the new emitter
  30993. */
  30994. clone(): BoxParticleEmitter;
  30995. /**
  30996. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  30997. * @param effect defines the update shader
  30998. */
  30999. applyToShader(effect: Effect): void;
  31000. /**
  31001. * Returns a string to use to update the GPU particles update shader
  31002. * @returns a string containng the defines string
  31003. */
  31004. getEffectDefines(): string;
  31005. /**
  31006. * Returns the string "BoxEmitter"
  31007. * @returns a string containing the class name
  31008. */
  31009. getClassName(): string;
  31010. /**
  31011. * Serializes the particle system to a JSON object.
  31012. * @returns the JSON object
  31013. */
  31014. serialize(): any;
  31015. /**
  31016. * Parse properties from a JSON object
  31017. * @param serializationObject defines the JSON object
  31018. */
  31019. parse(serializationObject: any): void;
  31020. }
  31021. }
  31022. declare module BABYLON {
  31023. /**
  31024. * Particle emitter emitting particles from the inside of a cone.
  31025. * It emits the particles alongside the cone volume from the base to the particle.
  31026. * The emission direction might be randomized.
  31027. */
  31028. class ConeParticleEmitter implements IParticleEmitterType {
  31029. /**
  31030. * The radius of the emission cone.
  31031. */
  31032. angle: number;
  31033. /**
  31034. * The cone base angle.
  31035. */
  31036. directionRandomizer: number;
  31037. private _radius;
  31038. private _height;
  31039. /**
  31040. * Gets the radius of the emission cone.
  31041. */
  31042. /**
  31043. * Sets the radius of the emission cone.
  31044. */
  31045. radius: number;
  31046. /**
  31047. * Creates a new instance ConeParticleEmitter
  31048. * @param radius the radius of the emission cone (1 by default)
  31049. * @param angles the cone base angle (PI by default)
  31050. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  31051. */
  31052. constructor(radius?: number,
  31053. /**
  31054. * The radius of the emission cone.
  31055. */
  31056. angle?: number,
  31057. /**
  31058. * The cone base angle.
  31059. */
  31060. directionRandomizer?: number);
  31061. /**
  31062. * Called by the particle System when the direction is computed for the created particle.
  31063. * @param emitPower is the power of the particle (speed)
  31064. * @param worldMatrix is the world matrix of the particle system
  31065. * @param directionToUpdate is the direction vector to update with the result
  31066. * @param particle is the particle we are computed the direction for
  31067. */
  31068. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  31069. /**
  31070. * Called by the particle System when the position is computed for the created particle.
  31071. * @param worldMatrix is the world matrix of the particle system
  31072. * @param positionToUpdate is the position vector to update with the result
  31073. * @param particle is the particle we are computed the position for
  31074. */
  31075. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  31076. /**
  31077. * Clones the current emitter and returns a copy of it
  31078. * @returns the new emitter
  31079. */
  31080. clone(): ConeParticleEmitter;
  31081. /**
  31082. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  31083. * @param effect defines the update shader
  31084. */
  31085. applyToShader(effect: Effect): void;
  31086. /**
  31087. * Returns a string to use to update the GPU particles update shader
  31088. * @returns a string containng the defines string
  31089. */
  31090. getEffectDefines(): string;
  31091. /**
  31092. * Returns the string "BoxEmitter"
  31093. * @returns a string containing the class name
  31094. */
  31095. getClassName(): string;
  31096. /**
  31097. * Serializes the particle system to a JSON object.
  31098. * @returns the JSON object
  31099. */
  31100. serialize(): any;
  31101. /**
  31102. * Parse properties from a JSON object
  31103. * @param serializationObject defines the JSON object
  31104. */
  31105. parse(serializationObject: any): void;
  31106. }
  31107. }
  31108. declare module BABYLON {
  31109. /**
  31110. * Particle emitter represents a volume emitting particles.
  31111. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  31112. */
  31113. interface IParticleEmitterType {
  31114. /**
  31115. * Called by the particle System when the direction is computed for the created particle.
  31116. * @param emitPower is the power of the particle (speed)
  31117. * @param worldMatrix is the world matrix of the particle system
  31118. * @param directionToUpdate is the direction vector to update with the result
  31119. * @param particle is the particle we are computed the direction for
  31120. */
  31121. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  31122. /**
  31123. * Called by the particle System when the position is computed for the created particle.
  31124. * @param worldMatrix is the world matrix of the particle system
  31125. * @param positionToUpdate is the position vector to update with the result
  31126. * @param particle is the particle we are computed the position for
  31127. */
  31128. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  31129. /**
  31130. * Clones the current emitter and returns a copy of it
  31131. * @returns the new emitter
  31132. */
  31133. clone(): IParticleEmitterType;
  31134. /**
  31135. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  31136. * @param effect defines the update shader
  31137. */
  31138. applyToShader(effect: Effect): void;
  31139. /**
  31140. * Returns a string to use to update the GPU particles update shader
  31141. * @returns the effect defines string
  31142. */
  31143. getEffectDefines(): string;
  31144. /**
  31145. * Returns a string representing the class name
  31146. * @returns a string containing the class name
  31147. */
  31148. getClassName(): string;
  31149. /**
  31150. * Serializes the particle system to a JSON object.
  31151. * @returns the JSON object
  31152. */
  31153. serialize(): any;
  31154. /**
  31155. * Parse properties from a JSON object
  31156. * @param serializationObject defines the JSON object
  31157. */
  31158. parse(serializationObject: any): void;
  31159. }
  31160. }
  31161. declare module BABYLON {
  31162. /**
  31163. * Particle emitter emitting particles from the inside of a sphere.
  31164. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  31165. */
  31166. class SphereParticleEmitter implements IParticleEmitterType {
  31167. /**
  31168. * The radius of the emission sphere.
  31169. */
  31170. radius: number;
  31171. /**
  31172. * How much to randomize the particle direction [0-1].
  31173. */
  31174. directionRandomizer: number;
  31175. /**
  31176. * Creates a new instance SphereParticleEmitter
  31177. * @param radius the radius of the emission sphere (1 by default)
  31178. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  31179. */
  31180. constructor(
  31181. /**
  31182. * The radius of the emission sphere.
  31183. */
  31184. radius?: number,
  31185. /**
  31186. * How much to randomize the particle direction [0-1].
  31187. */
  31188. directionRandomizer?: number);
  31189. /**
  31190. * Called by the particle System when the direction is computed for the created particle.
  31191. * @param emitPower is the power of the particle (speed)
  31192. * @param worldMatrix is the world matrix of the particle system
  31193. * @param directionToUpdate is the direction vector to update with the result
  31194. * @param particle is the particle we are computed the direction for
  31195. */
  31196. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  31197. /**
  31198. * Called by the particle System when the position is computed for the created particle.
  31199. * @param worldMatrix is the world matrix of the particle system
  31200. * @param positionToUpdate is the position vector to update with the result
  31201. * @param particle is the particle we are computed the position for
  31202. */
  31203. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  31204. /**
  31205. * Clones the current emitter and returns a copy of it
  31206. * @returns the new emitter
  31207. */
  31208. clone(): SphereParticleEmitter;
  31209. /**
  31210. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  31211. * @param effect defines the update shader
  31212. */
  31213. applyToShader(effect: Effect): void;
  31214. /**
  31215. * Returns a string to use to update the GPU particles update shader
  31216. * @returns a string containng the defines string
  31217. */
  31218. getEffectDefines(): string;
  31219. /**
  31220. * Returns the string "SphereParticleEmitter"
  31221. * @returns a string containing the class name
  31222. */
  31223. getClassName(): string;
  31224. /**
  31225. * Serializes the particle system to a JSON object.
  31226. * @returns the JSON object
  31227. */
  31228. serialize(): any;
  31229. /**
  31230. * Parse properties from a JSON object
  31231. * @param serializationObject defines the JSON object
  31232. */
  31233. parse(serializationObject: any): void;
  31234. }
  31235. /**
  31236. * Particle emitter emitting particles from the inside of a sphere.
  31237. * It emits the particles randomly between two vectors.
  31238. */
  31239. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  31240. /**
  31241. * The min limit of the emission direction.
  31242. */
  31243. direction1: Vector3;
  31244. /**
  31245. * The max limit of the emission direction.
  31246. */
  31247. direction2: Vector3;
  31248. /**
  31249. * Creates a new instance SphereDirectedParticleEmitter
  31250. * @param radius the radius of the emission sphere (1 by default)
  31251. * @param direction1 the min limit of the emission direction (up vector by default)
  31252. * @param direction2 the max limit of the emission direction (up vector by default)
  31253. */
  31254. constructor(radius?: number,
  31255. /**
  31256. * The min limit of the emission direction.
  31257. */
  31258. direction1?: Vector3,
  31259. /**
  31260. * The max limit of the emission direction.
  31261. */
  31262. direction2?: Vector3);
  31263. /**
  31264. * Called by the particle System when the direction is computed for the created particle.
  31265. * @param emitPower is the power of the particle (speed)
  31266. * @param worldMatrix is the world matrix of the particle system
  31267. * @param directionToUpdate is the direction vector to update with the result
  31268. * @param particle is the particle we are computed the direction for
  31269. */
  31270. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  31271. /**
  31272. * Clones the current emitter and returns a copy of it
  31273. * @returns the new emitter
  31274. */
  31275. clone(): SphereDirectedParticleEmitter;
  31276. /**
  31277. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  31278. * @param effect defines the update shader
  31279. */
  31280. applyToShader(effect: Effect): void;
  31281. /**
  31282. * Returns a string to use to update the GPU particles update shader
  31283. * @returns a string containng the defines string
  31284. */
  31285. getEffectDefines(): string;
  31286. /**
  31287. * Returns the string "SphereDirectedParticleEmitter"
  31288. * @returns a string containing the class name
  31289. */
  31290. getClassName(): string;
  31291. /**
  31292. * Serializes the particle system to a JSON object.
  31293. * @returns the JSON object
  31294. */
  31295. serialize(): any;
  31296. /**
  31297. * Parse properties from a JSON object
  31298. * @param serializationObject defines the JSON object
  31299. */
  31300. parse(serializationObject: any): void;
  31301. }
  31302. }
  31303. declare module BABYLON {
  31304. class CannonJSPlugin implements IPhysicsEnginePlugin {
  31305. private _useDeltaForWorldStep;
  31306. world: any;
  31307. name: string;
  31308. private _physicsMaterials;
  31309. private _fixedTimeStep;
  31310. BJSCANNON: any;
  31311. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  31312. setGravity(gravity: Vector3): void;
  31313. setTimeStep(timeStep: number): void;
  31314. getTimeStep(): number;
  31315. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31316. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31317. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31318. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31319. private _processChildMeshes(mainImpostor);
  31320. removePhysicsBody(impostor: PhysicsImpostor): void;
  31321. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  31322. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  31323. private _addMaterial(name, friction, restitution);
  31324. private _checkWithEpsilon(value);
  31325. private _createShape(impostor);
  31326. private _createHeightmap(object, pointDepth?);
  31327. private _minus90X;
  31328. private _plus90X;
  31329. private _tmpPosition;
  31330. private _tmpDeltaPosition;
  31331. private _tmpUnityRotation;
  31332. private _updatePhysicsBodyTransformation(impostor);
  31333. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31334. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31335. isSupported(): boolean;
  31336. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  31337. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  31338. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31339. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31340. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31341. getBodyMass(impostor: PhysicsImpostor): number;
  31342. getBodyFriction(impostor: PhysicsImpostor): number;
  31343. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31344. getBodyRestitution(impostor: PhysicsImpostor): number;
  31345. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31346. sleepBody(impostor: PhysicsImpostor): void;
  31347. wakeUpBody(impostor: PhysicsImpostor): void;
  31348. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31349. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  31350. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  31351. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31352. getRadius(impostor: PhysicsImpostor): number;
  31353. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31354. dispose(): void;
  31355. private _extendNamespace();
  31356. }
  31357. }
  31358. declare module BABYLON {
  31359. class OimoJSPlugin implements IPhysicsEnginePlugin {
  31360. world: any;
  31361. name: string;
  31362. BJSOIMO: any;
  31363. constructor(iterations?: number);
  31364. setGravity(gravity: Vector3): void;
  31365. setTimeStep(timeStep: number): void;
  31366. getTimeStep(): number;
  31367. private _tmpImpostorsArray;
  31368. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31369. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31370. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31371. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31372. private _tmpPositionVector;
  31373. removePhysicsBody(impostor: PhysicsImpostor): void;
  31374. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  31375. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  31376. isSupported(): boolean;
  31377. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31378. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31379. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  31380. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  31381. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31382. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31383. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31384. getBodyMass(impostor: PhysicsImpostor): number;
  31385. getBodyFriction(impostor: PhysicsImpostor): number;
  31386. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31387. getBodyRestitution(impostor: PhysicsImpostor): number;
  31388. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31389. sleepBody(impostor: PhysicsImpostor): void;
  31390. wakeUpBody(impostor: PhysicsImpostor): void;
  31391. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31392. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31393. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31394. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31395. getRadius(impostor: PhysicsImpostor): number;
  31396. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31397. dispose(): void;
  31398. }
  31399. }
  31400. declare module BABYLON {
  31401. /**
  31402. * This represents a set of one or more post processes in Babylon.
  31403. * A post process can be used to apply a shader to a texture after it is rendered.
  31404. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  31405. */
  31406. class PostProcessRenderEffect {
  31407. private _postProcesses;
  31408. private _getPostProcesses;
  31409. private _singleInstance;
  31410. private _cameras;
  31411. private _indicesForCamera;
  31412. /**
  31413. * Name of the effect
  31414. */
  31415. _name: string;
  31416. /**
  31417. * Instantiates a post process render effect.
  31418. * A post process can be used to apply a shader to a texture after it is rendered.
  31419. * @param engine The engine the effect is tied to
  31420. * @param name The name of the effect
  31421. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  31422. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  31423. */
  31424. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  31425. /**
  31426. * Checks if all the post processes in the effect are supported.
  31427. */
  31428. readonly isSupported: boolean;
  31429. /**
  31430. * Updates the current state of the effect
  31431. */
  31432. _update(): void;
  31433. /**
  31434. * Attaches the effect on cameras
  31435. * @param cameras The camera to attach to.
  31436. */
  31437. _attachCameras(cameras: Camera): void;
  31438. /**
  31439. * Attaches the effect on cameras
  31440. * @param cameras The camera to attach to.
  31441. */
  31442. _attachCameras(cameras: Camera[]): void;
  31443. /**
  31444. * Detatches the effect on cameras
  31445. * @param cameras The camera to detatch from.
  31446. */
  31447. _detachCameras(cameras: Camera): void;
  31448. /**
  31449. * Detatches the effect on cameras
  31450. * @param cameras The camera to detatch from.
  31451. */
  31452. _detachCameras(cameras: Camera[]): void;
  31453. /**
  31454. * Enables the effect on given cameras
  31455. * @param cameras The camera to enable.
  31456. */
  31457. _enable(cameras: Camera): void;
  31458. /**
  31459. * Enables the effect on given cameras
  31460. * @param cameras The camera to enable.
  31461. */
  31462. _enable(cameras: Nullable<Camera[]>): void;
  31463. /**
  31464. * Disables the effect on the given cameras
  31465. * @param cameras The camera to disable.
  31466. */
  31467. _disable(cameras: Camera): void;
  31468. /**
  31469. * Disables the effect on the given cameras
  31470. * @param cameras The camera to disable.
  31471. */
  31472. _disable(cameras: Nullable<Camera[]>): void;
  31473. /**
  31474. * Gets a list of the post processes contained in the effect.
  31475. * @param camera The camera to get the post processes on.
  31476. * @returns The list of the post processes in the effect.
  31477. */
  31478. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  31479. }
  31480. }
  31481. declare module BABYLON {
  31482. class PostProcessRenderPipeline {
  31483. private engine;
  31484. private _renderEffects;
  31485. private _renderEffectsForIsolatedPass;
  31486. protected _cameras: Camera[];
  31487. _name: string;
  31488. constructor(engine: Engine, name: string);
  31489. getClassName(): string;
  31490. readonly isSupported: boolean;
  31491. addEffect(renderEffect: PostProcessRenderEffect): void;
  31492. _rebuild(): void;
  31493. _enableEffect(renderEffectName: string, cameras: Camera): void;
  31494. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  31495. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  31496. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  31497. _attachCameras(cameras: Camera, unique: boolean): void;
  31498. _attachCameras(cameras: Camera[], unique: boolean): void;
  31499. _detachCameras(cameras: Camera): void;
  31500. _detachCameras(cameras: Nullable<Camera[]>): void;
  31501. _update(): void;
  31502. _reset(): void;
  31503. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  31504. dispose(): void;
  31505. }
  31506. }
  31507. declare module BABYLON {
  31508. class PostProcessRenderPipelineManager {
  31509. private _renderPipelines;
  31510. constructor();
  31511. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  31512. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  31513. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  31514. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  31515. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  31516. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  31517. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  31518. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  31519. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  31520. update(): void;
  31521. _rebuild(): void;
  31522. dispose(): void;
  31523. }
  31524. }
  31525. declare module BABYLON {
  31526. /**
  31527. * Helper class dealing with the extraction of spherical polynomial dataArray
  31528. * from a cube map.
  31529. */
  31530. class CubeMapToSphericalPolynomialTools {
  31531. private static FileFaces;
  31532. /**
  31533. * Converts a texture to the according Spherical Polynomial data.
  31534. * This extracts the first 3 orders only as they are the only one used in the lighting.
  31535. *
  31536. * @param texture The texture to extract the information from.
  31537. * @return The Spherical Polynomial data.
  31538. */
  31539. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  31540. /**
  31541. * Converts a cubemap to the according Spherical Polynomial data.
  31542. * This extracts the first 3 orders only as they are the only one used in the lighting.
  31543. *
  31544. * @param cubeInfo The Cube map to extract the information from.
  31545. * @return The Spherical Polynomial data.
  31546. */
  31547. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  31548. }
  31549. }
  31550. declare module BABYLON {
  31551. /**
  31552. * Header information of HDR texture files.
  31553. */
  31554. interface HDRInfo {
  31555. /**
  31556. * The height of the texture in pixels.
  31557. */
  31558. height: number;
  31559. /**
  31560. * The width of the texture in pixels.
  31561. */
  31562. width: number;
  31563. /**
  31564. * The index of the beginning of the data in the binary file.
  31565. */
  31566. dataPosition: number;
  31567. }
  31568. /**
  31569. * This groups tools to convert HDR texture to native colors array.
  31570. */
  31571. class HDRTools {
  31572. private static Ldexp(mantissa, exponent);
  31573. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  31574. private static readStringLine(uint8array, startIndex);
  31575. /**
  31576. * Reads header information from an RGBE texture stored in a native array.
  31577. * More information on this format are available here:
  31578. * https://en.wikipedia.org/wiki/RGBE_image_format
  31579. *
  31580. * @param uint8array The binary file stored in native array.
  31581. * @return The header information.
  31582. */
  31583. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  31584. /**
  31585. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  31586. * This RGBE texture needs to store the information as a panorama.
  31587. *
  31588. * More information on this format are available here:
  31589. * https://en.wikipedia.org/wiki/RGBE_image_format
  31590. *
  31591. * @param buffer The binary file stored in an array buffer.
  31592. * @param size The expected size of the extracted cubemap.
  31593. * @return The Cube Map information.
  31594. */
  31595. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  31596. /**
  31597. * Returns the pixels data extracted from an RGBE texture.
  31598. * This pixels will be stored left to right up to down in the R G B order in one array.
  31599. *
  31600. * More information on this format are available here:
  31601. * https://en.wikipedia.org/wiki/RGBE_image_format
  31602. *
  31603. * @param uint8array The binary file stored in an array buffer.
  31604. * @param hdrInfo The header information of the file.
  31605. * @return The pixels data in RGB right to left up to down order.
  31606. */
  31607. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  31608. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  31609. }
  31610. }
  31611. declare module BABYLON {
  31612. /**
  31613. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  31614. */
  31615. interface CubeMapInfo {
  31616. /**
  31617. * The pixel array for the front face.
  31618. * This is stored in format, left to right, up to down format.
  31619. */
  31620. front: Nullable<ArrayBufferView>;
  31621. /**
  31622. * The pixel array for the back face.
  31623. * This is stored in format, left to right, up to down format.
  31624. */
  31625. back: Nullable<ArrayBufferView>;
  31626. /**
  31627. * The pixel array for the left face.
  31628. * This is stored in format, left to right, up to down format.
  31629. */
  31630. left: Nullable<ArrayBufferView>;
  31631. /**
  31632. * The pixel array for the right face.
  31633. * This is stored in format, left to right, up to down format.
  31634. */
  31635. right: Nullable<ArrayBufferView>;
  31636. /**
  31637. * The pixel array for the up face.
  31638. * This is stored in format, left to right, up to down format.
  31639. */
  31640. up: Nullable<ArrayBufferView>;
  31641. /**
  31642. * The pixel array for the down face.
  31643. * This is stored in format, left to right, up to down format.
  31644. */
  31645. down: Nullable<ArrayBufferView>;
  31646. /**
  31647. * The size of the cubemap stored.
  31648. *
  31649. * Each faces will be size * size pixels.
  31650. */
  31651. size: number;
  31652. /**
  31653. * The format of the texture.
  31654. *
  31655. * RGBA, RGB.
  31656. */
  31657. format: number;
  31658. /**
  31659. * The type of the texture data.
  31660. *
  31661. * UNSIGNED_INT, FLOAT.
  31662. */
  31663. type: number;
  31664. /**
  31665. * Specifies whether the texture is in gamma space.
  31666. */
  31667. gammaSpace: boolean;
  31668. }
  31669. /**
  31670. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  31671. */
  31672. class PanoramaToCubeMapTools {
  31673. private static FACE_FRONT;
  31674. private static FACE_BACK;
  31675. private static FACE_RIGHT;
  31676. private static FACE_LEFT;
  31677. private static FACE_DOWN;
  31678. private static FACE_UP;
  31679. /**
  31680. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  31681. *
  31682. * @param float32Array The source data.
  31683. * @param inputWidth The width of the input panorama.
  31684. * @param inputhHeight The height of the input panorama.
  31685. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  31686. * @return The cubemap data
  31687. */
  31688. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  31689. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  31690. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  31691. }
  31692. }
  31693. declare module BABYLON {
  31694. class CustomProceduralTexture extends ProceduralTexture {
  31695. private _animate;
  31696. private _time;
  31697. private _config;
  31698. private _texturePath;
  31699. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  31700. private loadJson(jsonUrl);
  31701. isReady(): boolean;
  31702. render(useCameraPostProcess?: boolean): void;
  31703. updateTextures(): void;
  31704. updateShaderUniforms(): void;
  31705. animate: boolean;
  31706. }
  31707. }
  31708. declare module BABYLON {
  31709. class ProceduralTexture extends Texture {
  31710. isCube: boolean;
  31711. private _size;
  31712. _generateMipMaps: boolean;
  31713. isEnabled: boolean;
  31714. private _currentRefreshId;
  31715. private _refreshRate;
  31716. onGenerated: () => void;
  31717. private _vertexBuffers;
  31718. private _indexBuffer;
  31719. private _effect;
  31720. private _uniforms;
  31721. private _samplers;
  31722. private _fragment;
  31723. _textures: {
  31724. [key: string]: Texture;
  31725. };
  31726. private _floats;
  31727. private _floatsArrays;
  31728. private _colors3;
  31729. private _colors4;
  31730. private _vectors2;
  31731. private _vectors3;
  31732. private _matrices;
  31733. private _fallbackTexture;
  31734. private _fallbackTextureUsed;
  31735. private _engine;
  31736. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  31737. private _createIndexBuffer();
  31738. _rebuild(): void;
  31739. reset(): void;
  31740. isReady(): boolean;
  31741. resetRefreshCounter(): void;
  31742. setFragment(fragment: any): void;
  31743. refreshRate: number;
  31744. _shouldRender(): boolean;
  31745. getRenderSize(): number;
  31746. resize(size: number, generateMipMaps: boolean): void;
  31747. private _checkUniform(uniformName);
  31748. setTexture(name: string, texture: Texture): ProceduralTexture;
  31749. setFloat(name: string, value: number): ProceduralTexture;
  31750. setFloats(name: string, value: number[]): ProceduralTexture;
  31751. setColor3(name: string, value: Color3): ProceduralTexture;
  31752. setColor4(name: string, value: Color4): ProceduralTexture;
  31753. setVector2(name: string, value: Vector2): ProceduralTexture;
  31754. setVector3(name: string, value: Vector3): ProceduralTexture;
  31755. setMatrix(name: string, value: Matrix): ProceduralTexture;
  31756. render(useCameraPostProcess?: boolean): void;
  31757. clone(): ProceduralTexture;
  31758. dispose(): void;
  31759. }
  31760. }
  31761. declare module BABYLON {
  31762. /**
  31763. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  31764. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  31765. */
  31766. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  31767. private _scene;
  31768. private _originalCameras;
  31769. /**
  31770. * ID of the sharpen post process,
  31771. */
  31772. private readonly SharpenPostProcessId;
  31773. /**
  31774. * ID of the image processing post process;
  31775. */
  31776. readonly ImageProcessingPostProcessId: string;
  31777. /**
  31778. * ID of the Fast Approximate Anti-Aliasing post process;
  31779. */
  31780. readonly FxaaPostProcessId: string;
  31781. /**
  31782. * ID of the chromatic aberration post process,
  31783. */
  31784. private readonly ChromaticAberrationPostProcessId;
  31785. /**
  31786. * ID of the grain post process
  31787. */
  31788. private readonly GrainPostProcessId;
  31789. /**
  31790. * Sharpen post process which will apply a sharpen convolution to enhance edges
  31791. */
  31792. sharpen: SharpenPostProcess;
  31793. private _sharpenEffect;
  31794. private bloom;
  31795. /**
  31796. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  31797. */
  31798. depthOfField: DepthOfFieldEffect;
  31799. /**
  31800. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  31801. */
  31802. fxaa: FxaaPostProcess;
  31803. /**
  31804. * Image post processing pass used to perform operations such as tone mapping or color grading.
  31805. */
  31806. imageProcessing: ImageProcessingPostProcess;
  31807. /**
  31808. * Chromatic aberration post process which will shift rgb colors in the image
  31809. */
  31810. chromaticAberration: ChromaticAberrationPostProcess;
  31811. private _chromaticAberrationEffect;
  31812. /**
  31813. * Grain post process which add noise to the image
  31814. */
  31815. grain: GrainPostProcess;
  31816. private _grainEffect;
  31817. /**
  31818. * Animations which can be used to tweak settings over a period of time
  31819. */
  31820. animations: Animation[];
  31821. private _imageProcessingConfigurationObserver;
  31822. private _sharpenEnabled;
  31823. private _bloomEnabled;
  31824. private _depthOfFieldEnabled;
  31825. private _depthOfFieldBlurLevel;
  31826. private _fxaaEnabled;
  31827. private _imageProcessingEnabled;
  31828. private _defaultPipelineTextureType;
  31829. private _bloomScale;
  31830. private _chromaticAberrationEnabled;
  31831. private _grainEnabled;
  31832. private _buildAllowed;
  31833. /**
  31834. * Enable or disable the sharpen process from the pipeline
  31835. */
  31836. sharpenEnabled: boolean;
  31837. private _resizeObserver;
  31838. private _hardwareScaleLevel;
  31839. private _bloomKernel;
  31840. /**
  31841. * Specifies the size of the bloom blur kernel, relative to the final output size
  31842. */
  31843. bloomKernel: number;
  31844. /**
  31845. * Specifies the weight of the bloom in the final rendering
  31846. */
  31847. private _bloomWeight;
  31848. /**
  31849. * Specifies the luma threshold for the area that will be blurred by the bloom
  31850. */
  31851. private _bloomThreshold;
  31852. private _hdr;
  31853. /**
  31854. * The strength of the bloom.
  31855. */
  31856. bloomWeight: number;
  31857. /**
  31858. * The strength of the bloom.
  31859. */
  31860. bloomThreshold: number;
  31861. /**
  31862. * The scale of the bloom, lower value will provide better performance.
  31863. */
  31864. bloomScale: number;
  31865. /**
  31866. * Enable or disable the bloom from the pipeline
  31867. */
  31868. bloomEnabled: boolean;
  31869. private _rebuildBloom();
  31870. /**
  31871. * If the depth of field is enabled.
  31872. */
  31873. depthOfFieldEnabled: boolean;
  31874. /**
  31875. * Blur level of the depth of field effect. (Higher blur will effect performance)
  31876. */
  31877. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  31878. /**
  31879. * If the anti aliasing is enabled.
  31880. */
  31881. fxaaEnabled: boolean;
  31882. private _samples;
  31883. /**
  31884. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  31885. */
  31886. samples: number;
  31887. /**
  31888. * If image processing is enabled.
  31889. */
  31890. imageProcessingEnabled: boolean;
  31891. /**
  31892. * Enable or disable the chromaticAberration process from the pipeline
  31893. */
  31894. chromaticAberrationEnabled: boolean;
  31895. /**
  31896. * Enable or disable the grain process from the pipeline
  31897. */
  31898. grainEnabled: boolean;
  31899. /**
  31900. * @constructor
  31901. * @param {string} name - The rendering pipeline name
  31902. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  31903. * @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)
  31904. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  31905. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
  31906. */
  31907. constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild?: boolean);
  31908. /**
  31909. * Force the compilation of the entire pipeline.
  31910. */
  31911. prepare(): void;
  31912. private _hasCleared;
  31913. private _prevPostProcess;
  31914. private _prevPrevPostProcess;
  31915. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  31916. private _buildPipeline();
  31917. private _disposePostProcesses(disposeNonRecreated?);
  31918. /**
  31919. * Dispose of the pipeline and stop all post processes
  31920. */
  31921. dispose(): void;
  31922. /**
  31923. * Serialize the rendering pipeline (Used when exporting)
  31924. * @returns the serialized object
  31925. */
  31926. serialize(): any;
  31927. /**
  31928. * Parse the serialized pipeline
  31929. * @param source Source pipeline.
  31930. * @param scene The scene to load the pipeline to.
  31931. * @param rootUrl The URL of the serialized pipeline.
  31932. * @returns An instantiated pipeline from the serialized object.
  31933. */
  31934. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  31935. }
  31936. }
  31937. declare module BABYLON {
  31938. class LensRenderingPipeline extends PostProcessRenderPipeline {
  31939. /**
  31940. * The chromatic aberration PostProcess id in the pipeline
  31941. */
  31942. LensChromaticAberrationEffect: string;
  31943. /**
  31944. * The highlights enhancing PostProcess id in the pipeline
  31945. */
  31946. HighlightsEnhancingEffect: string;
  31947. /**
  31948. * The depth-of-field PostProcess id in the pipeline
  31949. */
  31950. LensDepthOfFieldEffect: string;
  31951. private _scene;
  31952. private _depthTexture;
  31953. private _grainTexture;
  31954. private _chromaticAberrationPostProcess;
  31955. private _highlightsPostProcess;
  31956. private _depthOfFieldPostProcess;
  31957. private _edgeBlur;
  31958. private _grainAmount;
  31959. private _chromaticAberration;
  31960. private _distortion;
  31961. private _highlightsGain;
  31962. private _highlightsThreshold;
  31963. private _dofDistance;
  31964. private _dofAperture;
  31965. private _dofDarken;
  31966. private _dofPentagon;
  31967. private _blurNoise;
  31968. /**
  31969. * @constructor
  31970. *
  31971. * Effect parameters are as follow:
  31972. * {
  31973. * chromatic_aberration: number; // from 0 to x (1 for realism)
  31974. * edge_blur: number; // from 0 to x (1 for realism)
  31975. * distortion: number; // from 0 to x (1 for realism)
  31976. * grain_amount: number; // from 0 to 1
  31977. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  31978. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  31979. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  31980. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  31981. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  31982. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  31983. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  31984. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  31985. * }
  31986. * Note: if an effect parameter is unset, effect is disabled
  31987. *
  31988. * @param {string} name - The rendering pipeline name
  31989. * @param {object} parameters - An object containing all parameters (see above)
  31990. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  31991. * @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)
  31992. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  31993. */
  31994. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  31995. setEdgeBlur(amount: number): void;
  31996. disableEdgeBlur(): void;
  31997. setGrainAmount(amount: number): void;
  31998. disableGrain(): void;
  31999. setChromaticAberration(amount: number): void;
  32000. disableChromaticAberration(): void;
  32001. setEdgeDistortion(amount: number): void;
  32002. disableEdgeDistortion(): void;
  32003. setFocusDistance(amount: number): void;
  32004. disableDepthOfField(): void;
  32005. setAperture(amount: number): void;
  32006. setDarkenOutOfFocus(amount: number): void;
  32007. enablePentagonBokeh(): void;
  32008. disablePentagonBokeh(): void;
  32009. enableNoiseBlur(): void;
  32010. disableNoiseBlur(): void;
  32011. setHighlightsGain(amount: number): void;
  32012. setHighlightsThreshold(amount: number): void;
  32013. disableHighlights(): void;
  32014. /**
  32015. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  32016. */
  32017. dispose(disableDepthRender?: boolean): void;
  32018. private _createChromaticAberrationPostProcess(ratio);
  32019. private _createHighlightsPostProcess(ratio);
  32020. private _createDepthOfFieldPostProcess(ratio);
  32021. private _createGrainTexture();
  32022. }
  32023. }
  32024. declare module BABYLON {
  32025. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  32026. /**
  32027. * The PassPostProcess id in the pipeline that contains the original scene color
  32028. */
  32029. SSAOOriginalSceneColorEffect: string;
  32030. /**
  32031. * The SSAO PostProcess id in the pipeline
  32032. */
  32033. SSAORenderEffect: string;
  32034. /**
  32035. * The horizontal blur PostProcess id in the pipeline
  32036. */
  32037. SSAOBlurHRenderEffect: string;
  32038. /**
  32039. * The vertical blur PostProcess id in the pipeline
  32040. */
  32041. SSAOBlurVRenderEffect: string;
  32042. /**
  32043. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  32044. */
  32045. SSAOCombineRenderEffect: string;
  32046. /**
  32047. * The output strength of the SSAO post-process. Default value is 1.0.
  32048. */
  32049. totalStrength: number;
  32050. /**
  32051. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  32052. */
  32053. maxZ: number;
  32054. /**
  32055. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  32056. */
  32057. minZAspect: number;
  32058. /**
  32059. * Number of samples used for the SSAO calculations. Default value is 8
  32060. */
  32061. private _samples;
  32062. /**
  32063. * Dynamically generated sphere sampler.
  32064. */
  32065. private _sampleSphere;
  32066. /**
  32067. * Blur filter offsets
  32068. */
  32069. private _samplerOffsets;
  32070. samples: number;
  32071. /**
  32072. * Are we using bilateral blur ?
  32073. */
  32074. private _expensiveBlur;
  32075. expensiveBlur: boolean;
  32076. /**
  32077. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  32078. */
  32079. radius: number;
  32080. /**
  32081. * The base color of the SSAO post-process
  32082. * The final result is "base + ssao" between [0, 1]
  32083. */
  32084. base: number;
  32085. /**
  32086. * Support test.
  32087. */
  32088. static readonly IsSupported: boolean;
  32089. private _scene;
  32090. private _depthTexture;
  32091. private _normalTexture;
  32092. private _randomTexture;
  32093. private _originalColorPostProcess;
  32094. private _ssaoPostProcess;
  32095. private _blurHPostProcess;
  32096. private _blurVPostProcess;
  32097. private _ssaoCombinePostProcess;
  32098. private _firstUpdate;
  32099. /**
  32100. * @constructor
  32101. * @param {string} name - The rendering pipeline name
  32102. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  32103. * @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 }
  32104. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  32105. */
  32106. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  32107. /**
  32108. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  32109. */
  32110. dispose(disableGeometryBufferRenderer?: boolean): void;
  32111. private _createBlurPostProcess(ssaoRatio, blurRatio);
  32112. _rebuild(): void;
  32113. private _generateHemisphere();
  32114. private _createSSAOPostProcess(ratio);
  32115. private _createSSAOCombinePostProcess(ratio);
  32116. private _createRandomTexture();
  32117. }
  32118. }
  32119. declare module BABYLON {
  32120. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  32121. /**
  32122. * The PassPostProcess id in the pipeline that contains the original scene color
  32123. */
  32124. SSAOOriginalSceneColorEffect: string;
  32125. /**
  32126. * The SSAO PostProcess id in the pipeline
  32127. */
  32128. SSAORenderEffect: string;
  32129. /**
  32130. * The horizontal blur PostProcess id in the pipeline
  32131. */
  32132. SSAOBlurHRenderEffect: string;
  32133. /**
  32134. * The vertical blur PostProcess id in the pipeline
  32135. */
  32136. SSAOBlurVRenderEffect: string;
  32137. /**
  32138. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  32139. */
  32140. SSAOCombineRenderEffect: string;
  32141. /**
  32142. * The output strength of the SSAO post-process. Default value is 1.0.
  32143. */
  32144. totalStrength: number;
  32145. /**
  32146. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  32147. */
  32148. radius: number;
  32149. /**
  32150. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  32151. * Must not be equal to fallOff and superior to fallOff.
  32152. * Default value is 0.975
  32153. */
  32154. area: number;
  32155. /**
  32156. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  32157. * Must not be equal to area and inferior to area.
  32158. * Default value is 0.0
  32159. */
  32160. fallOff: number;
  32161. /**
  32162. * The base color of the SSAO post-process
  32163. * The final result is "base + ssao" between [0, 1]
  32164. */
  32165. base: number;
  32166. private _scene;
  32167. private _depthTexture;
  32168. private _randomTexture;
  32169. private _originalColorPostProcess;
  32170. private _ssaoPostProcess;
  32171. private _blurHPostProcess;
  32172. private _blurVPostProcess;
  32173. private _ssaoCombinePostProcess;
  32174. private _firstUpdate;
  32175. /**
  32176. * @constructor
  32177. * @param {string} name - The rendering pipeline name
  32178. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  32179. * @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 }
  32180. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  32181. */
  32182. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  32183. /**
  32184. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  32185. */
  32186. dispose(disableDepthRender?: boolean): void;
  32187. private _createBlurPostProcess(ratio);
  32188. _rebuild(): void;
  32189. private _createSSAOPostProcess(ratio);
  32190. private _createSSAOCombinePostProcess(ratio);
  32191. private _createRandomTexture();
  32192. }
  32193. }
  32194. declare module BABYLON {
  32195. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  32196. /**
  32197. * Public members
  32198. */
  32199. originalPostProcess: Nullable<PostProcess>;
  32200. downSampleX4PostProcess: Nullable<PostProcess>;
  32201. brightPassPostProcess: Nullable<PostProcess>;
  32202. blurHPostProcesses: PostProcess[];
  32203. blurVPostProcesses: PostProcess[];
  32204. textureAdderPostProcess: Nullable<PostProcess>;
  32205. volumetricLightPostProcess: Nullable<PostProcess>;
  32206. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  32207. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  32208. volumetricLightMergePostProces: Nullable<PostProcess>;
  32209. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  32210. luminancePostProcess: Nullable<PostProcess>;
  32211. luminanceDownSamplePostProcesses: PostProcess[];
  32212. hdrPostProcess: Nullable<PostProcess>;
  32213. textureAdderFinalPostProcess: Nullable<PostProcess>;
  32214. lensFlareFinalPostProcess: Nullable<PostProcess>;
  32215. hdrFinalPostProcess: Nullable<PostProcess>;
  32216. lensFlarePostProcess: Nullable<PostProcess>;
  32217. lensFlareComposePostProcess: Nullable<PostProcess>;
  32218. motionBlurPostProcess: Nullable<PostProcess>;
  32219. depthOfFieldPostProcess: Nullable<PostProcess>;
  32220. brightThreshold: number;
  32221. blurWidth: number;
  32222. horizontalBlur: boolean;
  32223. exposure: number;
  32224. lensTexture: Nullable<Texture>;
  32225. volumetricLightCoefficient: number;
  32226. volumetricLightPower: number;
  32227. volumetricLightBlurScale: number;
  32228. sourceLight: Nullable<SpotLight | DirectionalLight>;
  32229. hdrMinimumLuminance: number;
  32230. hdrDecreaseRate: number;
  32231. hdrIncreaseRate: number;
  32232. lensColorTexture: Nullable<Texture>;
  32233. lensFlareStrength: number;
  32234. lensFlareGhostDispersal: number;
  32235. lensFlareHaloWidth: number;
  32236. lensFlareDistortionStrength: number;
  32237. lensStarTexture: Nullable<Texture>;
  32238. lensFlareDirtTexture: Nullable<Texture>;
  32239. depthOfFieldDistance: number;
  32240. depthOfFieldBlurWidth: number;
  32241. motionStrength: number;
  32242. animations: Animation[];
  32243. /**
  32244. * Private members
  32245. */
  32246. private _scene;
  32247. private _currentDepthOfFieldSource;
  32248. private _basePostProcess;
  32249. private _hdrCurrentLuminance;
  32250. private _floatTextureType;
  32251. private _ratio;
  32252. private _bloomEnabled;
  32253. private _depthOfFieldEnabled;
  32254. private _vlsEnabled;
  32255. private _lensFlareEnabled;
  32256. private _hdrEnabled;
  32257. private _motionBlurEnabled;
  32258. private _motionBlurSamples;
  32259. private _volumetricLightStepsCount;
  32260. BloomEnabled: boolean;
  32261. DepthOfFieldEnabled: boolean;
  32262. LensFlareEnabled: boolean;
  32263. HDREnabled: boolean;
  32264. VLSEnabled: boolean;
  32265. MotionBlurEnabled: boolean;
  32266. volumetricLightStepsCount: number;
  32267. motionBlurSamples: number;
  32268. /**
  32269. * @constructor
  32270. * @param {string} name - The rendering pipeline name
  32271. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  32272. * @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)
  32273. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  32274. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  32275. */
  32276. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  32277. private _buildPipeline();
  32278. private _createDownSampleX4PostProcess(scene, ratio);
  32279. private _createBrightPassPostProcess(scene, ratio);
  32280. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  32281. private _createTextureAdderPostProcess(scene, ratio);
  32282. private _createVolumetricLightPostProcess(scene, ratio);
  32283. private _createLuminancePostProcesses(scene, textureType);
  32284. private _createHdrPostProcess(scene, ratio);
  32285. private _createLensFlarePostProcess(scene, ratio);
  32286. private _createDepthOfFieldPostProcess(scene, ratio);
  32287. private _createMotionBlurPostProcess(scene, ratio);
  32288. private _getDepthTexture();
  32289. private _disposePostProcesses();
  32290. dispose(): void;
  32291. serialize(): any;
  32292. /**
  32293. * Static members
  32294. */
  32295. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  32296. static LuminanceSteps: number;
  32297. }
  32298. }