babylon.d.ts 1.6 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /** All of the cameras added to this scene
  62. * @see http://doc.babylonjs.com/babylon101/cameras
  63. */
  64. cameras: Camera[];
  65. /**
  66. * All of the lights added to this scene
  67. * @see http://doc.babylonjs.com/babylon101/lights
  68. */
  69. lights: Light[];
  70. /**
  71. * All of the (abstract) meshes added to this scene
  72. */
  73. meshes: AbstractMesh[];
  74. /**
  75. * The list of skeletons added to the scene
  76. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77. */
  78. skeletons: Skeleton[];
  79. /**
  80. * All of the particle systems added to this scene
  81. * @see http://doc.babylonjs.com/babylon101/particles
  82. */
  83. particleSystems: IParticleSystem[];
  84. /**
  85. * Gets a list of Animations associated with the scene
  86. */
  87. animations: Animation[];
  88. /**
  89. * All of the animation groups added to this scene
  90. * @see http://doc.babylonjs.com/how_to/group
  91. */
  92. animationGroups: AnimationGroup[];
  93. /**
  94. * All of the multi-materials added to this scene
  95. * @see http://doc.babylonjs.com/how_to/multi_materials
  96. */
  97. multiMaterials: MultiMaterial[];
  98. /**
  99. * All of the materials added to this scene
  100. * @see http://doc.babylonjs.com/babylon101/materials
  101. */
  102. materials: Material[];
  103. /**
  104. * The list of morph target managers added to the scene
  105. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  106. */
  107. morphTargetManagers: MorphTargetManager[];
  108. /**
  109. * The list of geometries used in the scene.
  110. */
  111. geometries: Geometry[];
  112. /**
  113. * All of the tranform nodes added to this scene
  114. * @see http://doc.babylonjs.com/how_to/transformnode
  115. */
  116. transformNodes: TransformNode[];
  117. /**
  118. * ActionManagers available on the scene.
  119. */
  120. actionManagers: ActionManager[];
  121. /**
  122. * Sounds to keep.
  123. */
  124. sounds: Sound[];
  125. /**
  126. * Textures to keep.
  127. */
  128. textures: BaseTexture[];
  129. }
  130. }
  131. declare module BABYLON {
  132. /**
  133. * Set of assets to keep when moving a scene into an asset container.
  134. */
  135. class KeepAssets extends AbstractScene {
  136. }
  137. /**
  138. * Container with a set of assets that can be added or removed from a scene.
  139. */
  140. class AssetContainer extends AbstractScene {
  141. /**
  142. * The scene the AssetContainer belongs to.
  143. */
  144. scene: Scene;
  145. /**
  146. * Instantiates an AssetContainer.
  147. * @param scene The scene the AssetContainer belongs to.
  148. */
  149. constructor(scene: Scene);
  150. /**
  151. * Adds all the assets from the container to the scene.
  152. */
  153. addAllToScene(): void;
  154. /**
  155. * Removes all the assets in the container from the scene
  156. */
  157. removeAllFromScene(): void;
  158. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  159. /**
  160. * Removes all the assets contained in the scene and adds them to the container.
  161. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  162. */
  163. moveAllFromScene(keepAssets?: KeepAssets): void;
  164. /**
  165. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  166. * @returns the root mesh
  167. */
  168. createRootMesh(): Mesh;
  169. }
  170. }
  171. interface Window {
  172. mozIndexedDB: IDBFactory;
  173. webkitIndexedDB: IDBFactory;
  174. msIndexedDB: IDBFactory;
  175. webkitURL: typeof URL;
  176. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  177. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  178. WebGLRenderingContext: WebGLRenderingContext;
  179. MSGesture: MSGesture;
  180. CANNON: any;
  181. AudioContext: AudioContext;
  182. webkitAudioContext: AudioContext;
  183. PointerEvent: any;
  184. Math: Math;
  185. Uint8Array: Uint8ArrayConstructor;
  186. Float32Array: Float32ArrayConstructor;
  187. mozURL: typeof URL;
  188. msURL: typeof URL;
  189. VRFrameData: any;
  190. DracoDecoderModule: any;
  191. }
  192. interface WebGLRenderingContext {
  193. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  194. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  195. vertexAttribDivisor(index: number, divisor: number): void;
  196. createVertexArray(): any;
  197. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  198. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  199. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  200. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  201. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  202. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  203. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  204. createQuery(): WebGLQuery;
  205. deleteQuery(query: WebGLQuery): void;
  206. beginQuery(target: number, query: WebGLQuery): void;
  207. endQuery(target: number): void;
  208. getQueryParameter(query: WebGLQuery, pname: number): any;
  209. getQuery(target: number, pname: number): any;
  210. MAX_SAMPLES: number;
  211. RGBA8: number;
  212. READ_FRAMEBUFFER: number;
  213. DRAW_FRAMEBUFFER: number;
  214. UNIFORM_BUFFER: number;
  215. HALF_FLOAT_OES: number;
  216. RGBA16F: number;
  217. RGBA32F: number;
  218. R32F: number;
  219. RG32F: number;
  220. RGB32F: number;
  221. R16F: number;
  222. RG16F: number;
  223. RGB16F: number;
  224. RED: number;
  225. RG: number;
  226. R8: number;
  227. RG8: number;
  228. UNSIGNED_INT_24_8: number;
  229. DEPTH24_STENCIL8: number;
  230. drawBuffers(buffers: number[]): void;
  231. readBuffer(src: number): void;
  232. readonly COLOR_ATTACHMENT0: number;
  233. readonly COLOR_ATTACHMENT1: number;
  234. readonly COLOR_ATTACHMENT2: number;
  235. readonly COLOR_ATTACHMENT3: number;
  236. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  237. ANY_SAMPLES_PASSED: number;
  238. QUERY_RESULT_AVAILABLE: number;
  239. QUERY_RESULT: number;
  240. }
  241. interface Document {
  242. mozCancelFullScreen(): void;
  243. msCancelFullScreen(): void;
  244. mozFullScreen: boolean;
  245. msIsFullScreen: boolean;
  246. fullscreen: boolean;
  247. mozPointerLockElement: HTMLElement;
  248. msPointerLockElement: HTMLElement;
  249. webkitPointerLockElement: HTMLElement;
  250. }
  251. interface HTMLCanvasElement {
  252. msRequestPointerLock?(): void;
  253. mozRequestPointerLock?(): void;
  254. webkitRequestPointerLock?(): void;
  255. }
  256. interface CanvasRenderingContext2D {
  257. msImageSmoothingEnabled: boolean;
  258. }
  259. interface WebGLBuffer {
  260. references: number;
  261. capacity: number;
  262. is32Bits: boolean;
  263. }
  264. interface WebGLProgram {
  265. transformFeedback?: WebGLTransformFeedback | null;
  266. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  267. }
  268. interface MouseEvent {
  269. mozMovementX: number;
  270. mozMovementY: number;
  271. webkitMovementX: number;
  272. webkitMovementY: number;
  273. msMovementX: number;
  274. msMovementY: number;
  275. }
  276. interface Navigator {
  277. mozGetVRDevices: (any: any) => any;
  278. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  279. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  280. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  281. webkitGetGamepads(): Gamepad[];
  282. msGetGamepads(): Gamepad[];
  283. webkitGamepads(): Gamepad[];
  284. }
  285. interface HTMLVideoElement {
  286. mozSrcObject: any;
  287. }
  288. interface Screen {
  289. orientation: string;
  290. mozOrientation: string;
  291. }
  292. interface Math {
  293. fround(x: number): number;
  294. imul(a: number, b: number): number;
  295. }
  296. interface EXT_disjoint_timer_query {
  297. QUERY_COUNTER_BITS_EXT: number;
  298. TIME_ELAPSED_EXT: number;
  299. TIMESTAMP_EXT: number;
  300. GPU_DISJOINT_EXT: number;
  301. QUERY_RESULT_EXT: number;
  302. QUERY_RESULT_AVAILABLE_EXT: number;
  303. queryCounterEXT(query: WebGLQuery, target: number): void;
  304. createQueryEXT(): WebGLQuery;
  305. beginQueryEXT(target: number, query: WebGLQuery): void;
  306. endQueryEXT(target: number): void;
  307. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  308. deleteQueryEXT(query: WebGLQuery): void;
  309. }
  310. interface WebGLUniformLocation {
  311. _currentState: any;
  312. }
  313. declare module BABYLON {
  314. /**
  315. * Defines how a node can be built from a string name.
  316. */
  317. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  318. /**
  319. * Node is the basic class for all scene objects (Mesh, Light Camera).
  320. */
  321. class Node implements IBehaviorAware<Node> {
  322. private static _NodeConstructors;
  323. /**
  324. * Add a new node constructor
  325. * @param type defines the type name of the node to construct
  326. * @param constructorFunc defines the constructor function
  327. */
  328. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  329. /**
  330. * Returns a node constructor based on type name
  331. * @param type defines the type name
  332. * @param name defines the new node name
  333. * @param scene defines the hosting scene
  334. * @param options defines optional options to transmit to constructors
  335. * @returns the new constructor or null
  336. */
  337. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  338. /**
  339. * Gets or sets the name of the node
  340. */
  341. name: string;
  342. /**
  343. * Gets or sets the id of the node
  344. */
  345. id: string;
  346. /**
  347. * Gets or sets the unique id of the node
  348. */
  349. uniqueId: number;
  350. /**
  351. * Gets or sets a string used to store user defined state for the node
  352. */
  353. state: string;
  354. /**
  355. * Gets or sets an object used to store user defined information for the node
  356. */
  357. metadata: any;
  358. /**
  359. * Gets or sets a boolean used to define if the node must be serialized
  360. */
  361. doNotSerialize: boolean;
  362. /** @hidden */
  363. _isDisposed: boolean;
  364. /**
  365. * Gets a list of Animations associated with the node
  366. */
  367. animations: Animation[];
  368. private _ranges;
  369. /**
  370. * Callback raised when the node is ready to be used
  371. */
  372. onReady: (node: Node) => void;
  373. private _isEnabled;
  374. private _isReady;
  375. /** @hidden */
  376. _currentRenderId: number;
  377. private _parentRenderId;
  378. protected _childRenderId: number;
  379. /** @hidden */
  380. _waitingParentId: Nullable<string>;
  381. private _scene;
  382. /** @hidden */
  383. _cache: any;
  384. private _parentNode;
  385. private _children;
  386. /**
  387. * Gets a boolean indicating if the node has been disposed
  388. * @returns true if the node was disposed
  389. */
  390. isDisposed(): boolean;
  391. /**
  392. * Gets or sets the parent of the node
  393. */
  394. parent: Nullable<Node>;
  395. private _animationPropertiesOverride;
  396. /**
  397. * Gets or sets the animation properties override
  398. */
  399. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  400. /**
  401. * Gets a string idenfifying the name of the class
  402. * @returns "Node" string
  403. */
  404. getClassName(): string;
  405. /**
  406. * An event triggered when the mesh is disposed
  407. */
  408. onDisposeObservable: Observable<Node>;
  409. private _onDisposeObserver;
  410. /**
  411. * Sets a callback that will be raised when the node will be disposed
  412. */
  413. onDispose: () => void;
  414. /**
  415. * Creates a new Node
  416. * @param {string} name - the name and id to be given to this node
  417. * @param {BABYLON.Scene} the scene this node will be added to
  418. */
  419. constructor(name: string, scene?: Nullable<Scene>);
  420. /**
  421. * Gets the scene of the node
  422. * @returns a {BABYLON.Scene}
  423. */
  424. getScene(): Scene;
  425. /**
  426. * Gets the engine of the node
  427. * @returns a {BABYLON.Engine}
  428. */
  429. getEngine(): Engine;
  430. private _behaviors;
  431. /**
  432. * Attach a behavior to the node
  433. * @see http://doc.babylonjs.com/features/behaviour
  434. * @param behavior defines the behavior to attach
  435. * @returns the current Node
  436. */
  437. addBehavior(behavior: Behavior<Node>): Node;
  438. /**
  439. * Remove an attached behavior
  440. * @see http://doc.babylonjs.com/features/behaviour
  441. * @param behavior defines the behavior to attach
  442. * @returns the current Node
  443. */
  444. removeBehavior(behavior: Behavior<Node>): Node;
  445. /**
  446. * Gets the list of attached behaviors
  447. * @see http://doc.babylonjs.com/features/behaviour
  448. */
  449. readonly behaviors: Behavior<Node>[];
  450. /**
  451. * Gets an attached behavior by name
  452. * @param name defines the name of the behavior to look for
  453. * @see http://doc.babylonjs.com/features/behaviour
  454. * @returns null if behavior was not found else the requested behavior
  455. */
  456. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  457. /**
  458. * Returns the world matrix of the node
  459. * @returns a matrix containing the node's world matrix
  460. */
  461. getWorldMatrix(): Matrix;
  462. /** @hidden */
  463. _getWorldMatrixDeterminant(): number;
  464. /** @hidden */
  465. _initCache(): void;
  466. /** @hidden */
  467. updateCache(force?: boolean): void;
  468. /** @hidden */
  469. _updateCache(ignoreParentClass?: boolean): void;
  470. /** @hidden */
  471. _isSynchronized(): boolean;
  472. /** @hidden */
  473. _markSyncedWithParent(): void;
  474. /** @hidden */
  475. isSynchronizedWithParent(): boolean;
  476. /** @hidden */
  477. isSynchronized(updateCache?: boolean): boolean;
  478. /** @hidden */
  479. hasNewParent(update?: boolean): boolean;
  480. /**
  481. * Is this node ready to be used/rendered
  482. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  483. * @return true if the node is ready
  484. */
  485. isReady(completeCheck?: boolean): boolean;
  486. /**
  487. * Is this node enabled?
  488. * 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
  489. * @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
  490. * @return whether this node (and its parent) is enabled
  491. */
  492. isEnabled(checkAncestors?: boolean): boolean;
  493. /**
  494. * Set the enabled state of this node
  495. * @param value defines the new enabled state
  496. */
  497. setEnabled(value: boolean): void;
  498. /**
  499. * Is this node a descendant of the given node?
  500. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  501. * @param ancestor defines the parent node to inspect
  502. * @returns a boolean indicating if this node is a descendant of the given node
  503. */
  504. isDescendantOf(ancestor: Node): boolean;
  505. /** @hidden */
  506. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  507. /**
  508. * Will return all nodes that have this node as ascendant
  509. * @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
  510. * @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
  511. * @return all children nodes of all types
  512. */
  513. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  514. /**
  515. * Get all child-meshes of this node
  516. * @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
  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.AbstractMesh}
  519. */
  520. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  521. /**
  522. * Get all child-transformNodes of this node
  523. * @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
  524. * @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
  525. * @returns an array of {BABYLON.TransformNode}
  526. */
  527. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  528. /**
  529. * Get all direct children of this node
  530. * @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
  531. * @returns an array of {BABYLON.Node}
  532. */
  533. getChildren(predicate?: (node: Node) => boolean): Node[];
  534. /** @hidden */
  535. _setReady(state: boolean): void;
  536. /**
  537. * Get an animation by name
  538. * @param name defines the name of the animation to look for
  539. * @returns null if not found else the requested animation
  540. */
  541. getAnimationByName(name: string): Nullable<Animation>;
  542. /**
  543. * Creates an animation range for this node
  544. * @param name defines the name of the range
  545. * @param from defines the starting key
  546. * @param to defines the end key
  547. */
  548. createAnimationRange(name: string, from: number, to: number): void;
  549. /**
  550. * Delete a specific animation range
  551. * @param name defines the name of the range to delete
  552. * @param deleteFrames defines if animation frames from the range must be deleted as well
  553. */
  554. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  555. /**
  556. * Get an animation range by name
  557. * @param name defines the name of the animation range to look for
  558. * @returns null if not found else the requested animation range
  559. */
  560. getAnimationRange(name: string): Nullable<AnimationRange>;
  561. /**
  562. * Will start the animation sequence
  563. * @param name defines the range frames for animation sequence
  564. * @param loop defines if the animation should loop (false by default)
  565. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  566. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  567. * @returns the object created for this animation. If range does not exist, it will return null
  568. */
  569. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  570. /**
  571. * Serialize animation ranges into a JSON compatible object
  572. * @returns serialization object
  573. */
  574. serializeAnimationRanges(): any;
  575. /**
  576. * Computes the world matrix of the node
  577. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  578. * @returns the world matrix
  579. */
  580. computeWorldMatrix(force?: boolean): Matrix;
  581. /**
  582. * Releases resources associated with this node.
  583. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  584. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  585. */
  586. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  587. /**
  588. * Parse animation range data from a serialization object and store them into a given node
  589. * @param node defines where to store the animation ranges
  590. * @param parsedNode defines the serialization object to read data from
  591. * @param scene defines the hosting scene
  592. */
  593. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  594. }
  595. }
  596. declare module BABYLON {
  597. /**
  598. * Define an interface for all classes that will hold resources
  599. */
  600. interface IDisposable {
  601. /**
  602. * Releases all held resources
  603. */
  604. dispose(): void;
  605. }
  606. /**
  607. * Interface used to let developers provide their own mesh selection mechanism
  608. */
  609. interface IActiveMeshCandidateProvider {
  610. /**
  611. * Return the list of active meshes
  612. * @param scene defines the current scene
  613. * @returns the list of active meshes
  614. */
  615. getMeshes(scene: Scene): AbstractMesh[];
  616. /**
  617. * Indicates if the meshes have been checked to make sure they are isEnabled()
  618. */
  619. readonly checksIsEnabled: boolean;
  620. }
  621. /**
  622. * This class is used by the onRenderingGroupObservable
  623. */
  624. class RenderingGroupInfo {
  625. /**
  626. * The Scene that being rendered
  627. */
  628. scene: Scene;
  629. /**
  630. * The camera currently used for the rendering pass
  631. */
  632. camera: Nullable<Camera>;
  633. /**
  634. * The ID of the renderingGroup being processed
  635. */
  636. renderingGroupId: number;
  637. /**
  638. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  639. */
  640. renderStage: number;
  641. /**
  642. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  643. * This stage will be fired no matter what
  644. */
  645. static STAGE_PRECLEAR: number;
  646. /**
  647. * Called before opaque object are rendered.
  648. * This stage will be fired only if there's 3D Opaque content to render
  649. */
  650. static STAGE_PREOPAQUE: number;
  651. /**
  652. * Called after the opaque objects are rendered and before the transparent ones
  653. * This stage will be fired only if there's 3D transparent content to render
  654. */
  655. static STAGE_PRETRANSPARENT: number;
  656. /**
  657. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  658. * This stage will be fired no matter what
  659. */
  660. static STAGE_POSTTRANSPARENT: number;
  661. }
  662. /**
  663. * Represents a scene to be rendered by the engine.
  664. * @see http://doc.babylonjs.com/features/scene
  665. */
  666. class Scene extends AbstractScene implements IAnimatable {
  667. private static _FOGMODE_NONE;
  668. private static _FOGMODE_EXP;
  669. private static _FOGMODE_EXP2;
  670. private static _FOGMODE_LINEAR;
  671. private static _uniqueIdCounter;
  672. /**
  673. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  674. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  675. */
  676. static MinDeltaTime: number;
  677. /**
  678. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  679. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  680. */
  681. static MaxDeltaTime: number;
  682. /** The fog is deactivated */
  683. static readonly FOGMODE_NONE: number;
  684. /** The fog density is following an exponential function */
  685. static readonly FOGMODE_EXP: number;
  686. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  687. static readonly FOGMODE_EXP2: number;
  688. /** The fog density is following a linear function. */
  689. static readonly FOGMODE_LINEAR: number;
  690. /**
  691. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  692. */
  693. autoClear: boolean;
  694. /**
  695. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  696. */
  697. autoClearDepthAndStencil: boolean;
  698. /**
  699. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  700. */
  701. clearColor: Color4;
  702. /**
  703. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  704. */
  705. ambientColor: Color3;
  706. /** @hidden */
  707. _environmentBRDFTexture: BaseTexture;
  708. /** @hidden */
  709. protected _environmentTexture: BaseTexture;
  710. /**
  711. * Texture used in all pbr material as the reflection texture.
  712. * As in the majority of the scene they are the same (exception for multi room and so on),
  713. * this is easier to reference from here than from all the materials.
  714. */
  715. /**
  716. * Texture used in all pbr material as the reflection texture.
  717. * As in the majority of the scene they are the same (exception for multi room and so on),
  718. * this is easier to set here than in all the materials.
  719. */
  720. environmentTexture: BaseTexture;
  721. /** @hidden */
  722. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  723. /**
  724. * Default image processing configuration used either in the rendering
  725. * Forward main pass or through the imageProcessingPostProcess if present.
  726. * As in the majority of the scene they are the same (exception for multi camera),
  727. * this is easier to reference from here than from all the materials and post process.
  728. *
  729. * No setter as we it is a shared configuration, you can set the values instead.
  730. */
  731. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  732. private _forceWireframe;
  733. /**
  734. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  735. */
  736. forceWireframe: boolean;
  737. private _forcePointsCloud;
  738. /**
  739. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  740. */
  741. forcePointsCloud: boolean;
  742. /**
  743. * Gets or sets the active clipplane
  744. */
  745. clipPlane: Nullable<Plane>;
  746. /**
  747. * Gets or sets a boolean indicating if animations are enabled
  748. */
  749. animationsEnabled: boolean;
  750. private _animationPropertiesOverride;
  751. /**
  752. * Gets or sets the animation properties override
  753. */
  754. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  755. /**
  756. * Gets or sets a boolean indicating if a constant deltatime has to be used
  757. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  758. */
  759. useConstantAnimationDeltaTime: boolean;
  760. /**
  761. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  762. * Please note that it requires to run a ray cast through the scene on every frame
  763. */
  764. constantlyUpdateMeshUnderPointer: boolean;
  765. /**
  766. * Defines the HTML cursor to use when hovering over interactive elements
  767. */
  768. hoverCursor: string;
  769. /**
  770. * Defines the HTML default cursor to use (empty by default)
  771. */
  772. defaultCursor: string;
  773. /**
  774. * This is used to call preventDefault() on pointer down
  775. * in order to block unwanted artifacts like system double clicks
  776. */
  777. preventDefaultOnPointerDown: boolean;
  778. /**
  779. * Gets or sets user defined metadata
  780. */
  781. metadata: any;
  782. /**
  783. * Gets the name of the plugin used to load this scene (null by default)
  784. */
  785. loadingPluginName: string;
  786. /**
  787. * Use this array to add regular expressions used to disable offline support for specific urls
  788. */
  789. disableOfflineSupportExceptionRules: RegExp[];
  790. private _spritePredicate;
  791. /**
  792. * An event triggered when the scene is disposed.
  793. */
  794. onDisposeObservable: Observable<Scene>;
  795. private _onDisposeObserver;
  796. /** Sets a function to be executed when this scene is disposed. */
  797. onDispose: () => void;
  798. /**
  799. * An event triggered before rendering the scene (right after animations and physics)
  800. */
  801. onBeforeRenderObservable: Observable<Scene>;
  802. private _onBeforeRenderObserver;
  803. /** Sets a function to be executed before rendering this scene */
  804. beforeRender: Nullable<() => void>;
  805. /**
  806. * An event triggered after rendering the scene
  807. */
  808. onAfterRenderObservable: Observable<Scene>;
  809. private _onAfterRenderObserver;
  810. /** Sets a function to be executed after rendering this scene */
  811. afterRender: Nullable<() => void>;
  812. /**
  813. * An event triggered before animating the scene
  814. */
  815. onBeforeAnimationsObservable: Observable<Scene>;
  816. /**
  817. * An event triggered after animations processing
  818. */
  819. onAfterAnimationsObservable: Observable<Scene>;
  820. /**
  821. * An event triggered before draw calls are ready to be sent
  822. */
  823. onBeforeDrawPhaseObservable: Observable<Scene>;
  824. /**
  825. * An event triggered after draw calls have been sent
  826. */
  827. onAfterDrawPhaseObservable: Observable<Scene>;
  828. /**
  829. * An event triggered when physic simulation is about to be run
  830. */
  831. onBeforePhysicsObservable: Observable<Scene>;
  832. /**
  833. * An event triggered when physic simulation has been done
  834. */
  835. onAfterPhysicsObservable: Observable<Scene>;
  836. /**
  837. * An event triggered when the scene is ready
  838. */
  839. onReadyObservable: Observable<Scene>;
  840. /**
  841. * An event triggered before rendering a camera
  842. */
  843. onBeforeCameraRenderObservable: Observable<Camera>;
  844. private _onBeforeCameraRenderObserver;
  845. /** Sets a function to be executed before rendering a camera*/
  846. beforeCameraRender: () => void;
  847. /**
  848. * An event triggered after rendering a camera
  849. */
  850. onAfterCameraRenderObservable: Observable<Camera>;
  851. private _onAfterCameraRenderObserver;
  852. /** Sets a function to be executed after rendering a camera*/
  853. afterCameraRender: () => void;
  854. /**
  855. * An event triggered when active meshes evaluation is about to start
  856. */
  857. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  858. /**
  859. * An event triggered when active meshes evaluation is done
  860. */
  861. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  862. /**
  863. * An event triggered when particles rendering is about to start
  864. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  865. */
  866. onBeforeParticlesRenderingObservable: Observable<Scene>;
  867. /**
  868. * An event triggered when particles rendering is done
  869. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  870. */
  871. onAfterParticlesRenderingObservable: Observable<Scene>;
  872. /**
  873. * An event triggered when sprites rendering is about to start
  874. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  875. */
  876. onBeforeSpritesRenderingObservable: Observable<Scene>;
  877. /**
  878. * An event triggered when sprites rendering is done
  879. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  880. */
  881. onAfterSpritesRenderingObservable: Observable<Scene>;
  882. /**
  883. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  884. */
  885. onDataLoadedObservable: Observable<Scene>;
  886. /**
  887. * An event triggered when a camera is created
  888. */
  889. onNewCameraAddedObservable: Observable<Camera>;
  890. /**
  891. * An event triggered when a camera is removed
  892. */
  893. onCameraRemovedObservable: Observable<Camera>;
  894. /**
  895. * An event triggered when a light is created
  896. */
  897. onNewLightAddedObservable: Observable<Light>;
  898. /**
  899. * An event triggered when a light is removed
  900. */
  901. onLightRemovedObservable: Observable<Light>;
  902. /**
  903. * An event triggered when a geometry is created
  904. */
  905. onNewGeometryAddedObservable: Observable<Geometry>;
  906. /**
  907. * An event triggered when a geometry is removed
  908. */
  909. onGeometryRemovedObservable: Observable<Geometry>;
  910. /**
  911. * An event triggered when a transform node is created
  912. */
  913. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  914. /**
  915. * An event triggered when a transform node is removed
  916. */
  917. onTransformNodeRemovedObservable: Observable<TransformNode>;
  918. /**
  919. * An event triggered when a mesh is created
  920. */
  921. onNewMeshAddedObservable: Observable<AbstractMesh>;
  922. /**
  923. * An event triggered when a mesh is removed
  924. */
  925. onMeshRemovedObservable: Observable<AbstractMesh>;
  926. /**
  927. * An event triggered when render targets are about to be rendered
  928. * Can happen multiple times per frame.
  929. */
  930. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  931. /**
  932. * An event triggered when render targets were rendered.
  933. * Can happen multiple times per frame.
  934. */
  935. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  936. /**
  937. * An event triggered before calculating deterministic simulation step
  938. */
  939. onBeforeStepObservable: Observable<Scene>;
  940. /**
  941. * An event triggered after calculating deterministic simulation step
  942. */
  943. onAfterStepObservable: Observable<Scene>;
  944. /**
  945. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  946. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  947. * 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)
  948. */
  949. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  950. private _registeredForLateAnimationBindings;
  951. /**
  952. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  953. */
  954. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  955. /**
  956. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  957. */
  958. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  959. /**
  960. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  961. */
  962. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  963. private _onPointerMove;
  964. private _onPointerDown;
  965. private _onPointerUp;
  966. /** Deprecated. Use onPointerObservable instead */
  967. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  968. /** Deprecated. Use onPointerObservable instead */
  969. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  970. /** Deprecated. Use onPointerObservable instead */
  971. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  972. /** Deprecated. Use onPointerObservable instead */
  973. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  974. /**
  975. * 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).
  976. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  977. */
  978. onPrePointerObservable: Observable<PointerInfoPre>;
  979. /**
  980. * Observable event triggered each time an input event is received from the rendering canvas
  981. */
  982. onPointerObservable: Observable<PointerInfo>;
  983. /**
  984. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  985. */
  986. readonly unTranslatedPointer: Vector2;
  987. /** The distance in pixel that you have to move to prevent some events */
  988. static DragMovementThreshold: number;
  989. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  990. static LongPressDelay: number;
  991. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  992. static DoubleClickDelay: number;
  993. /** If you need to check double click without raising a single click at first click, enable this flag */
  994. static ExclusiveDoubleClickMode: boolean;
  995. private _initClickEvent;
  996. private _initActionManager;
  997. private _delayedSimpleClick;
  998. private _delayedSimpleClickTimeout;
  999. private _previousDelayedSimpleClickTimeout;
  1000. private _meshPickProceed;
  1001. private _previousButtonPressed;
  1002. private _currentPickResult;
  1003. private _previousPickResult;
  1004. private _totalPointersPressed;
  1005. private _doubleClickOccured;
  1006. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1007. cameraToUseForPointers: Nullable<Camera>;
  1008. private _pointerX;
  1009. private _pointerY;
  1010. private _unTranslatedPointerX;
  1011. private _unTranslatedPointerY;
  1012. private _startingPointerPosition;
  1013. private _previousStartingPointerPosition;
  1014. private _startingPointerTime;
  1015. private _previousStartingPointerTime;
  1016. private _pointerCaptures;
  1017. private _timeAccumulator;
  1018. private _currentStepId;
  1019. private _currentInternalStep;
  1020. /** @hidden */
  1021. _mirroredCameraPosition: Nullable<Vector3>;
  1022. /**
  1023. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1024. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1025. */
  1026. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1027. /**
  1028. * Observable event triggered each time an keyboard event is received from the hosting window
  1029. */
  1030. onKeyboardObservable: Observable<KeyboardInfo>;
  1031. private _onKeyDown;
  1032. private _onKeyUp;
  1033. private _onCanvasFocusObserver;
  1034. private _onCanvasBlurObserver;
  1035. private _useRightHandedSystem;
  1036. /**
  1037. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1038. */
  1039. useRightHandedSystem: boolean;
  1040. /**
  1041. * Sets the step Id used by deterministic lock step
  1042. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1043. * @param newStepId defines the step Id
  1044. */
  1045. setStepId(newStepId: number): void;
  1046. /**
  1047. * Gets the step Id used by deterministic lock step
  1048. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1049. * @returns the step Id
  1050. */
  1051. getStepId(): number;
  1052. /**
  1053. * Gets the internal step used by deterministic lock step
  1054. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1055. * @returns the internal step
  1056. */
  1057. getInternalStep(): number;
  1058. private _fogEnabled;
  1059. /**
  1060. * Gets or sets a boolean indicating if fog is enabled on this scene
  1061. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1062. */
  1063. fogEnabled: boolean;
  1064. private _fogMode;
  1065. /**
  1066. * Gets or sets the fog mode to use
  1067. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1068. */
  1069. fogMode: number;
  1070. /**
  1071. * Gets or sets the fog color to use
  1072. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1073. */
  1074. fogColor: Color3;
  1075. /**
  1076. * Gets or sets the fog density to use
  1077. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1078. */
  1079. fogDensity: number;
  1080. /**
  1081. * Gets or sets the fog start distance to use
  1082. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1083. */
  1084. fogStart: number;
  1085. /**
  1086. * Gets or sets the fog end distance to use
  1087. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1088. */
  1089. fogEnd: number;
  1090. private _shadowsEnabled;
  1091. /**
  1092. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1093. */
  1094. shadowsEnabled: boolean;
  1095. private _lightsEnabled;
  1096. /**
  1097. * Gets or sets a boolean indicating if lights are enabled on this scene
  1098. */
  1099. lightsEnabled: boolean;
  1100. /** All of the active cameras added to this scene. */
  1101. activeCameras: Camera[];
  1102. /** The current active camera */
  1103. activeCamera: Nullable<Camera>;
  1104. private _defaultMaterial;
  1105. /** The default material used on meshes when no material is affected */
  1106. /** The default material used on meshes when no material is affected */
  1107. defaultMaterial: Material;
  1108. private _texturesEnabled;
  1109. /**
  1110. * Gets or sets a boolean indicating if textures are enabled on this scene
  1111. */
  1112. texturesEnabled: boolean;
  1113. /**
  1114. * Gets or sets a boolean indicating if particles are enabled on this scene
  1115. */
  1116. particlesEnabled: boolean;
  1117. /**
  1118. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1119. */
  1120. spritesEnabled: boolean;
  1121. /**
  1122. * All of the sprite managers added to this scene
  1123. * @see http://doc.babylonjs.com/babylon101/sprites
  1124. */
  1125. spriteManagers: SpriteManager[];
  1126. private _skeletonsEnabled;
  1127. /**
  1128. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1129. */
  1130. skeletonsEnabled: boolean;
  1131. /**
  1132. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1133. */
  1134. lensFlaresEnabled: boolean;
  1135. /**
  1136. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1137. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1138. */
  1139. collisionsEnabled: boolean;
  1140. private _workerCollisions;
  1141. /** @hidden */
  1142. collisionCoordinator: ICollisionCoordinator;
  1143. /**
  1144. * Defines the gravity applied to this scene (used only for collisions)
  1145. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1146. */
  1147. gravity: Vector3;
  1148. /**
  1149. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1150. */
  1151. postProcessesEnabled: boolean;
  1152. /**
  1153. * The list of postprocesses added to the scene
  1154. */
  1155. postProcesses: PostProcess[];
  1156. /**
  1157. * Gets the current postprocess manager
  1158. */
  1159. postProcessManager: PostProcessManager;
  1160. private _postProcessRenderPipelineManager;
  1161. /**
  1162. * Gets the postprocess render pipeline manager
  1163. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1164. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1165. */
  1166. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1167. /**
  1168. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1169. */
  1170. renderTargetsEnabled: boolean;
  1171. /**
  1172. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1173. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1174. */
  1175. dumpNextRenderTargets: boolean;
  1176. /**
  1177. * The list of user defined render targets added to the scene
  1178. */
  1179. customRenderTargets: RenderTargetTexture[];
  1180. /**
  1181. * Defines if texture loading must be delayed
  1182. * If true, textures will only be loaded when they need to be rendered
  1183. */
  1184. useDelayedTextureLoading: boolean;
  1185. /**
  1186. * Gets the list of meshes imported to the scene through SceneLoader
  1187. */
  1188. importedMeshesFiles: String[];
  1189. /**
  1190. * Gets or sets a boolean indicating if probes are enabled on this scene
  1191. */
  1192. probesEnabled: boolean;
  1193. /**
  1194. * The list of reflection probes added to the scene
  1195. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1196. */
  1197. reflectionProbes: ReflectionProbe[];
  1198. /**
  1199. * @hidden
  1200. */
  1201. database: Database;
  1202. /**
  1203. * Gets or sets the action manager associated with the scene
  1204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1205. */
  1206. actionManager: ActionManager;
  1207. private _meshesForIntersections;
  1208. /**
  1209. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1210. */
  1211. proceduralTexturesEnabled: boolean;
  1212. /**
  1213. * The list of procedural textures added to the scene
  1214. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1215. */
  1216. proceduralTextures: ProceduralTexture[];
  1217. private _mainSoundTrack;
  1218. /**
  1219. * The list of sound tracks added to the scene
  1220. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1221. */
  1222. soundTracks: SoundTrack[];
  1223. private _audioEnabled;
  1224. private _headphone;
  1225. /**
  1226. * Gets the main soundtrack associated with the scene
  1227. */
  1228. readonly mainSoundTrack: SoundTrack;
  1229. /**
  1230. * Gets or sets the VRExperienceHelper attached to the scene
  1231. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1232. * @ignorenaming
  1233. */
  1234. VRHelper: VRExperienceHelper;
  1235. /**
  1236. * Gets or sets the simplification queue attached to the scene
  1237. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1238. */
  1239. simplificationQueue: SimplificationQueue;
  1240. private _engine;
  1241. private _totalVertices;
  1242. /** @hidden */
  1243. _activeIndices: PerfCounter;
  1244. /** @hidden */
  1245. _activeParticles: PerfCounter;
  1246. /** @hidden */
  1247. _activeBones: PerfCounter;
  1248. private _animationRatio;
  1249. private _animationTimeLast;
  1250. private _animationTime;
  1251. /**
  1252. * Gets or sets a general scale for animation speed
  1253. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1254. */
  1255. animationTimeScale: number;
  1256. /** @hidden */
  1257. _cachedMaterial: Nullable<Material>;
  1258. /** @hidden */
  1259. _cachedEffect: Nullable<Effect>;
  1260. /** @hidden */
  1261. _cachedVisibility: Nullable<number>;
  1262. private _renderId;
  1263. private _executeWhenReadyTimeoutId;
  1264. private _intermediateRendering;
  1265. private _viewUpdateFlag;
  1266. private _projectionUpdateFlag;
  1267. private _alternateViewUpdateFlag;
  1268. private _alternateProjectionUpdateFlag;
  1269. /** @hidden */
  1270. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1271. private _activeRequests;
  1272. private _pendingData;
  1273. private _isDisposed;
  1274. /**
  1275. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1276. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1277. */
  1278. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1279. private _activeMeshes;
  1280. private _processedMaterials;
  1281. private _renderTargets;
  1282. /** @hidden */
  1283. _activeParticleSystems: SmartArray<IParticleSystem>;
  1284. private _activeSkeletons;
  1285. private _softwareSkinnedMeshes;
  1286. private _renderingManager;
  1287. private _physicsEngine;
  1288. /** @hidden */
  1289. _activeAnimatables: Animatable[];
  1290. private _transformMatrix;
  1291. private _sceneUbo;
  1292. private _alternateSceneUbo;
  1293. private _pickWithRayInverseMatrix;
  1294. private _outlineRenderer;
  1295. private _viewMatrix;
  1296. private _projectionMatrix;
  1297. private _alternateViewMatrix;
  1298. private _alternateProjectionMatrix;
  1299. private _alternateTransformMatrix;
  1300. private _useAlternateCameraConfiguration;
  1301. private _alternateRendering;
  1302. /** @hidden */
  1303. _forcedViewPosition: Nullable<Vector3>;
  1304. /** @hidden */
  1305. readonly _isAlternateRenderingEnabled: boolean;
  1306. private _frustumPlanes;
  1307. /**
  1308. * Gets the list of frustum planes (built from the active camera)
  1309. */
  1310. readonly frustumPlanes: Plane[];
  1311. /**
  1312. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1313. * This is useful if there are more lights that the maximum simulteanous authorized
  1314. */
  1315. requireLightSorting: boolean;
  1316. private _selectionOctree;
  1317. private _pointerOverMesh;
  1318. private _pointerOverSprite;
  1319. private _debugLayer;
  1320. private _depthRenderer;
  1321. private _geometryBufferRenderer;
  1322. /**
  1323. * Gets the current geometry buffer associated to the scene.
  1324. */
  1325. /**
  1326. * Sets the current geometry buffer for the scene.
  1327. */
  1328. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1329. private _pickedDownMesh;
  1330. private _pickedUpMesh;
  1331. private _pickedDownSprite;
  1332. private _externalData;
  1333. private _uid;
  1334. /**
  1335. * Backing store of defined scene components.
  1336. */
  1337. _components: ISceneComponent[];
  1338. /**
  1339. * Backing store of defined scene components.
  1340. */
  1341. _serializableComponents: ISceneSerializableComponent[];
  1342. /**
  1343. * List of components to register on the next registration step.
  1344. */
  1345. private _transientComponents;
  1346. /**
  1347. * Registers the transient components if needed.
  1348. */
  1349. private _registerTransientComponents();
  1350. /**
  1351. * Add a component to the scene.
  1352. * Note that the ccomponent could be registered on th next frame if this is called after
  1353. * the register component stage.
  1354. * @param component Defines the component to add to the scene
  1355. */
  1356. _addComponent(component: ISceneComponent): void;
  1357. /**
  1358. * Gets a component from the scene.
  1359. * @param name defines the name of the component to retrieve
  1360. * @returns the component or null if not present
  1361. */
  1362. _getComponent(name: string): Nullable<ISceneComponent>;
  1363. /**
  1364. * Defines the actions happening before camera updates.
  1365. */
  1366. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1367. /**
  1368. * Defines the actions happening during the per mesh ready checks.
  1369. */
  1370. _isReadyForMeshStage: Stage<MeshStageAction>;
  1371. /**
  1372. * Defines the actions happening before evaluate active mesh checks.
  1373. */
  1374. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1375. /**
  1376. * Defines the actions happening during the evaluate sub mesh checks.
  1377. */
  1378. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1379. /**
  1380. * Defines the actions happening during the active mesh stage.
  1381. */
  1382. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1383. /**
  1384. * Defines the actions happening during the per camera render target step.
  1385. */
  1386. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1387. /**
  1388. * Defines the actions happening just before the active camera is drawing.
  1389. */
  1390. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1391. /**
  1392. * Defines the actions happening just before a rendering group is drawing.
  1393. */
  1394. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1395. /**
  1396. * Defines the actions happening just after a rendering group has been drawn.
  1397. */
  1398. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1399. /**
  1400. * Defines the actions happening just after the active camera has been drawn.
  1401. */
  1402. _afterCameraDrawStage: Stage<CameraStageAction>;
  1403. /**
  1404. * Creates a new Scene
  1405. * @param engine defines the engine to use to render this scene
  1406. */
  1407. constructor(engine: Engine);
  1408. /**
  1409. * Gets the debug layer (aka Inspector) associated with the scene
  1410. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1411. */
  1412. readonly debugLayer: DebugLayer;
  1413. /**
  1414. * Gets a boolean indicating if collisions are processed on a web worker
  1415. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1416. */
  1417. workerCollisions: boolean;
  1418. /**
  1419. * Gets the octree used to boost mesh selection (picking)
  1420. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1421. */
  1422. readonly selectionOctree: Octree<AbstractMesh>;
  1423. /**
  1424. * Gets the mesh that is currently under the pointer
  1425. */
  1426. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1427. /**
  1428. * Gets the current on-screen X position of the pointer
  1429. */
  1430. readonly pointerX: number;
  1431. /**
  1432. * Gets the current on-screen Y position of the pointer
  1433. */
  1434. readonly pointerY: number;
  1435. /**
  1436. * Gets the cached material (ie. the latest rendered one)
  1437. * @returns the cached material
  1438. */
  1439. getCachedMaterial(): Nullable<Material>;
  1440. /**
  1441. * Gets the cached effect (ie. the latest rendered one)
  1442. * @returns the cached effect
  1443. */
  1444. getCachedEffect(): Nullable<Effect>;
  1445. /**
  1446. * Gets the cached visibility state (ie. the latest rendered one)
  1447. * @returns the cached visibility state
  1448. */
  1449. getCachedVisibility(): Nullable<number>;
  1450. /**
  1451. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1452. * @param material defines the current material
  1453. * @param effect defines the current effect
  1454. * @param visibility defines the current visibility state
  1455. * @returns true if one parameter is not cached
  1456. */
  1457. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1458. /**
  1459. * Gets the outline renderer associated with the scene
  1460. * @returns a OutlineRenderer
  1461. */
  1462. getOutlineRenderer(): OutlineRenderer;
  1463. /**
  1464. * Gets the engine associated with the scene
  1465. * @returns an Engine
  1466. */
  1467. getEngine(): Engine;
  1468. /**
  1469. * Gets the total number of vertices rendered per frame
  1470. * @returns the total number of vertices rendered per frame
  1471. */
  1472. getTotalVertices(): number;
  1473. /**
  1474. * Gets the performance counter for total vertices
  1475. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1476. */
  1477. readonly totalVerticesPerfCounter: PerfCounter;
  1478. /**
  1479. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1480. * @returns the total number of active indices rendered per frame
  1481. */
  1482. getActiveIndices(): number;
  1483. /**
  1484. * Gets the performance counter for active indices
  1485. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1486. */
  1487. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1488. /**
  1489. * Gets the total number of active particles rendered per frame
  1490. * @returns the total number of active particles rendered per frame
  1491. */
  1492. getActiveParticles(): number;
  1493. /**
  1494. * Gets the performance counter for active particles
  1495. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1496. */
  1497. readonly activeParticlesPerfCounter: PerfCounter;
  1498. /**
  1499. * Gets the total number of active bones rendered per frame
  1500. * @returns the total number of active bones rendered per frame
  1501. */
  1502. getActiveBones(): number;
  1503. /**
  1504. * Gets the performance counter for active bones
  1505. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1506. */
  1507. readonly activeBonesPerfCounter: PerfCounter;
  1508. /** @hidden */
  1509. getInterFramePerfCounter(): number;
  1510. /** @hidden */
  1511. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1512. /** @hidden */
  1513. getLastFrameDuration(): number;
  1514. /** @hidden */
  1515. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1516. /** @hidden */
  1517. getEvaluateActiveMeshesDuration(): number;
  1518. /** @hidden */
  1519. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1520. /**
  1521. * Gets the array of active meshes
  1522. * @returns an array of AbstractMesh
  1523. */
  1524. getActiveMeshes(): SmartArray<AbstractMesh>;
  1525. /** @hidden */
  1526. getRenderTargetsDuration(): number;
  1527. /** @hidden */
  1528. getRenderDuration(): number;
  1529. /** @hidden */
  1530. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1531. /** @hidden */
  1532. getParticlesDuration(): number;
  1533. /** @hidden */
  1534. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1535. /** @hidden */
  1536. getSpritesDuration(): number;
  1537. /** @hidden */
  1538. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1539. /**
  1540. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1541. * @returns a number
  1542. */
  1543. getAnimationRatio(): number;
  1544. /**
  1545. * Gets an unique Id for the current frame
  1546. * @returns a number
  1547. */
  1548. getRenderId(): number;
  1549. /** Call this function if you want to manually increment the render Id*/
  1550. incrementRenderId(): void;
  1551. private _updatePointerPosition(evt);
  1552. private _createUbo();
  1553. private _createAlternateUbo();
  1554. private _pickSpriteButKeepRay(originalPointerInfo, x, y, predicate?, fastCheck?, camera?);
  1555. private _setRayOnPointerInfo(pointerInfo);
  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. private _checkPrePointerObservable(pickResult, evt, type);
  1566. /**
  1567. * Use this method to simulate a pointer down on a mesh
  1568. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1569. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1570. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1571. * @returns the current scene
  1572. */
  1573. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1574. private _processPointerDown(pickResult, evt);
  1575. /**
  1576. * Use this method to simulate a pointer up on a mesh
  1577. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1578. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1579. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1580. * @returns the current scene
  1581. */
  1582. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1583. private _processPointerUp(pickResult, evt, clickInfo);
  1584. /**
  1585. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1586. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1587. * @returns true if the pointer was captured
  1588. */
  1589. isPointerCaptured(pointerId?: number): boolean;
  1590. /**
  1591. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1592. * @param attachUp defines if you want to attach events to pointerup
  1593. * @param attachDown defines if you want to attach events to pointerdown
  1594. * @param attachMove defines if you want to attach events to pointermove
  1595. */
  1596. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1597. /** Detaches all event handlers*/
  1598. detachControl(): void;
  1599. /**
  1600. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1601. * Delay loaded resources are not taking in account
  1602. * @return true if all required resources are ready
  1603. */
  1604. isReady(): boolean;
  1605. /** Resets all cached information relative to material (including effect and visibility) */
  1606. resetCachedMaterial(): void;
  1607. /**
  1608. * Registers a function to be called before every frame render
  1609. * @param func defines the function to register
  1610. */
  1611. registerBeforeRender(func: () => void): void;
  1612. /**
  1613. * Unregisters a function called before every frame render
  1614. * @param func defines the function to unregister
  1615. */
  1616. unregisterBeforeRender(func: () => void): void;
  1617. /**
  1618. * Registers a function to be called after every frame render
  1619. * @param func defines the function to register
  1620. */
  1621. registerAfterRender(func: () => void): void;
  1622. /**
  1623. * Unregisters a function called after every frame render
  1624. * @param func defines the function to unregister
  1625. */
  1626. unregisterAfterRender(func: () => void): void;
  1627. private _executeOnceBeforeRender(func);
  1628. /**
  1629. * The provided function will run before render once and will be disposed afterwards.
  1630. * A timeout delay can be provided so that the function will be executed in N ms.
  1631. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1632. * @param func The function to be executed.
  1633. * @param timeout optional delay in ms
  1634. */
  1635. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1636. /** @hidden */
  1637. _addPendingData(data: any): void;
  1638. /** @hidden */
  1639. _removePendingData(data: any): void;
  1640. /**
  1641. * Returns the number of items waiting to be loaded
  1642. * @returns the number of items waiting to be loaded
  1643. */
  1644. getWaitingItemsCount(): number;
  1645. /**
  1646. * Returns a boolean indicating if the scene is still loading data
  1647. */
  1648. readonly isLoading: boolean;
  1649. /**
  1650. * Registers a function to be executed when the scene is ready
  1651. * @param {Function} func - the function to be executed
  1652. */
  1653. executeWhenReady(func: () => void): void;
  1654. /**
  1655. * Returns a promise that resolves when the scene is ready
  1656. * @returns A promise that resolves when the scene is ready
  1657. */
  1658. whenReadyAsync(): Promise<void>;
  1659. /** @hidden */
  1660. _checkIsReady(): void;
  1661. /**
  1662. * Will start the animation sequence of a given target
  1663. * @param target defines the target
  1664. * @param from defines from which frame should animation start
  1665. * @param to defines until which frame should animation run.
  1666. * @param weight defines the weight to apply to the animation (1.0 by default)
  1667. * @param loop defines if the animation loops
  1668. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1669. * @param onAnimationEnd defines the function to be executed when the animation ends
  1670. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1671. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1672. * @returns the animatable object created for this animation
  1673. */
  1674. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1675. /**
  1676. * Will start the animation sequence of a given target
  1677. * @param target defines the target
  1678. * @param from defines from which frame should animation start
  1679. * @param to defines until which frame should animation run.
  1680. * @param loop defines if the animation loops
  1681. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1682. * @param onAnimationEnd defines the function to be executed when the animation ends
  1683. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1684. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1685. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1686. * @returns the animatable object created for this animation
  1687. */
  1688. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1689. /**
  1690. * Begin a new animation on a given node
  1691. * @param target defines the target where the animation will take place
  1692. * @param animations defines the list of animations to start
  1693. * @param from defines the initial value
  1694. * @param to defines the final value
  1695. * @param loop defines if you want animation to loop (off by default)
  1696. * @param speedRatio defines the speed ratio to apply to all animations
  1697. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1698. * @returns the list of created animatables
  1699. */
  1700. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1701. /**
  1702. * Begin a new animation on a given node and its hierarchy
  1703. * @param target defines the root node where the animation will take place
  1704. * @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.
  1705. * @param animations defines the list of animations to start
  1706. * @param from defines the initial value
  1707. * @param to defines the final value
  1708. * @param loop defines if you want animation to loop (off by default)
  1709. * @param speedRatio defines the speed ratio to apply to all animations
  1710. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1711. * @returns the list of animatables created for all nodes
  1712. */
  1713. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1714. /**
  1715. * Gets the animatable associated with a specific target
  1716. * @param target defines the target of the animatable
  1717. * @returns the required animatable if found
  1718. */
  1719. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1720. /**
  1721. * Gets all animatables associated with a given target
  1722. * @param target defines the target to look animatables for
  1723. * @returns an array of Animatables
  1724. */
  1725. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1726. /**
  1727. * Gets all animatable attached to the scene
  1728. */
  1729. readonly animatables: Animatable[];
  1730. /**
  1731. * Will stop the animation of the given target
  1732. * @param target - the target
  1733. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1734. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  1735. */
  1736. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1737. /**
  1738. * Stops and removes all animations that have been applied to the scene
  1739. */
  1740. stopAllAnimations(): void;
  1741. private _animate();
  1742. /** @hidden */
  1743. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1744. private _processLateAnimationBindingsForMatrices(holder);
  1745. private _processLateAnimationBindingsForQuaternions(holder);
  1746. private _processLateAnimationBindings();
  1747. /** @hidden */
  1748. _switchToAlternateCameraConfiguration(active: boolean): void;
  1749. /**
  1750. * Gets the current view matrix
  1751. * @returns a Matrix
  1752. */
  1753. getViewMatrix(): Matrix;
  1754. /**
  1755. * Gets the current projection matrix
  1756. * @returns a Matrix
  1757. */
  1758. getProjectionMatrix(): Matrix;
  1759. /**
  1760. * Gets the current transform matrix
  1761. * @returns a Matrix made of View * Projection
  1762. */
  1763. getTransformMatrix(): Matrix;
  1764. /**
  1765. * Sets the current transform matrix
  1766. * @param view defines the View matrix to use
  1767. * @param projection defines the Projection matrix to use
  1768. */
  1769. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1770. /** @hidden */
  1771. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1772. /**
  1773. * Gets the uniform buffer used to store scene data
  1774. * @returns a UniformBuffer
  1775. */
  1776. getSceneUniformBuffer(): UniformBuffer;
  1777. /**
  1778. * Gets an unique (relatively to the current scene) Id
  1779. * @returns an unique number for the scene
  1780. */
  1781. getUniqueId(): number;
  1782. /**
  1783. * Add a mesh to the list of scene's meshes
  1784. * @param newMesh defines the mesh to add
  1785. * @param recursive if all child meshes should also be added to the scene
  1786. */
  1787. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1788. /**
  1789. * Remove a mesh for the list of scene's meshes
  1790. * @param toRemove defines the mesh to remove
  1791. * @param recursive if all child meshes should also be removed from the scene
  1792. * @returns the index where the mesh was in the mesh list
  1793. */
  1794. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1795. /**
  1796. * Add a transform node to the list of scene's transform nodes
  1797. * @param newTransformNode defines the transform node to add
  1798. */
  1799. addTransformNode(newTransformNode: TransformNode): void;
  1800. /**
  1801. * Remove a transform node for the list of scene's transform nodes
  1802. * @param toRemove defines the transform node to remove
  1803. * @returns the index where the transform node was in the transform node list
  1804. */
  1805. removeTransformNode(toRemove: TransformNode): number;
  1806. /**
  1807. * Remove a skeleton for the list of scene's skeletons
  1808. * @param toRemove defines the skeleton to remove
  1809. * @returns the index where the skeleton was in the skeleton list
  1810. */
  1811. removeSkeleton(toRemove: Skeleton): number;
  1812. /**
  1813. * Remove a morph target for the list of scene's morph targets
  1814. * @param toRemove defines the morph target to remove
  1815. * @returns the index where the morph target was in the morph target list
  1816. */
  1817. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1818. /**
  1819. * Remove a light for the list of scene's lights
  1820. * @param toRemove defines the light to remove
  1821. * @returns the index where the light was in the light list
  1822. */
  1823. removeLight(toRemove: Light): number;
  1824. /**
  1825. * Remove a camera for the list of scene's cameras
  1826. * @param toRemove defines the camera to remove
  1827. * @returns the index where the camera was in the camera list
  1828. */
  1829. removeCamera(toRemove: Camera): number;
  1830. /**
  1831. * Remove a particle system for the list of scene's particle systems
  1832. * @param toRemove defines the particle system to remove
  1833. * @returns the index where the particle system was in the particle system list
  1834. */
  1835. removeParticleSystem(toRemove: IParticleSystem): number;
  1836. /**
  1837. * Remove a animation for the list of scene's animations
  1838. * @param toRemove defines the animation to remove
  1839. * @returns the index where the animation was in the animation list
  1840. */
  1841. removeAnimation(toRemove: Animation): number;
  1842. /**
  1843. * Removes the given animation group from this scene.
  1844. * @param toRemove The animation group to remove
  1845. * @returns The index of the removed animation group
  1846. */
  1847. removeAnimationGroup(toRemove: AnimationGroup): number;
  1848. /**
  1849. * Removes the given multi-material from this scene.
  1850. * @param toRemove The multi-material to remove
  1851. * @returns The index of the removed multi-material
  1852. */
  1853. removeMultiMaterial(toRemove: MultiMaterial): number;
  1854. /**
  1855. * Removes the given material from this scene.
  1856. * @param toRemove The material to remove
  1857. * @returns The index of the removed material
  1858. */
  1859. removeMaterial(toRemove: Material): number;
  1860. /**
  1861. * Removes the given action manager from this scene.
  1862. * @param toRemove The action manager to remove
  1863. * @returns The index of the removed action manager
  1864. */
  1865. removeActionManager(toRemove: ActionManager): number;
  1866. /**
  1867. * Removes the given texture from this scene.
  1868. * @param toRemove The texture to remove
  1869. * @returns The index of the removed texture
  1870. */
  1871. removeTexture(toRemove: BaseTexture): number;
  1872. /**
  1873. * Adds the given light to this scene
  1874. * @param newLight The light to add
  1875. */
  1876. addLight(newLight: Light): void;
  1877. /**
  1878. * Sorts the list list based on light priorities
  1879. */
  1880. sortLightsByPriority(): void;
  1881. /**
  1882. * Adds the given camera to this scene
  1883. * @param newCamera The camera to add
  1884. */
  1885. addCamera(newCamera: Camera): void;
  1886. /**
  1887. * Adds the given skeleton to this scene
  1888. * @param newSkeleton The skeleton to add
  1889. */
  1890. addSkeleton(newSkeleton: Skeleton): void;
  1891. /**
  1892. * Adds the given particle system to this scene
  1893. * @param newParticleSystem The particle system to add
  1894. */
  1895. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1896. /**
  1897. * Adds the given animation to this scene
  1898. * @param newAnimation The animation to add
  1899. */
  1900. addAnimation(newAnimation: Animation): void;
  1901. /**
  1902. * Adds the given animation group to this scene.
  1903. * @param newAnimationGroup The animation group to add
  1904. */
  1905. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1906. /**
  1907. * Adds the given multi-material to this scene
  1908. * @param newMultiMaterial The multi-material to add
  1909. */
  1910. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1911. /**
  1912. * Adds the given material to this scene
  1913. * @param newMaterial The material to add
  1914. */
  1915. addMaterial(newMaterial: Material): void;
  1916. /**
  1917. * Adds the given morph target to this scene
  1918. * @param newMorphTargetManager The morph target to add
  1919. */
  1920. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1921. /**
  1922. * Adds the given geometry to this scene
  1923. * @param newGeometry The geometry to add
  1924. */
  1925. addGeometry(newGeometry: Geometry): void;
  1926. /**
  1927. * Adds the given action manager to this scene
  1928. * @param newActionManager The action manager to add
  1929. */
  1930. addActionManager(newActionManager: ActionManager): void;
  1931. /**
  1932. * Adds the given texture to this scene.
  1933. * @param newTexture The texture to add
  1934. */
  1935. addTexture(newTexture: BaseTexture): void;
  1936. /**
  1937. * Switch active camera
  1938. * @param newCamera defines the new active camera
  1939. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1940. */
  1941. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1942. /**
  1943. * sets the active camera of the scene using its ID
  1944. * @param id defines the camera's ID
  1945. * @return the new active camera or null if none found.
  1946. */
  1947. setActiveCameraByID(id: string): Nullable<Camera>;
  1948. /**
  1949. * sets the active camera of the scene using its name
  1950. * @param name defines the camera's name
  1951. * @returns the new active camera or null if none found.
  1952. */
  1953. setActiveCameraByName(name: string): Nullable<Camera>;
  1954. /**
  1955. * get an animation group using its name
  1956. * @param name defines the material's name
  1957. * @return the animation group or null if none found.
  1958. */
  1959. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1960. /**
  1961. * get a material using its id
  1962. * @param id defines the material's ID
  1963. * @return the material or null if none found.
  1964. */
  1965. getMaterialByID(id: string): Nullable<Material>;
  1966. /**
  1967. * Gets a material using its name
  1968. * @param name defines the material's name
  1969. * @return the material or null if none found.
  1970. */
  1971. getMaterialByName(name: string): Nullable<Material>;
  1972. /**
  1973. * Gets a camera using its id
  1974. * @param id defines the id to look for
  1975. * @returns the camera or null if not found
  1976. */
  1977. getCameraByID(id: string): Nullable<Camera>;
  1978. /**
  1979. * Gets a camera using its unique id
  1980. * @param uniqueId defines the unique id to look for
  1981. * @returns the camera or null if not found
  1982. */
  1983. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1984. /**
  1985. * Gets a camera using its name
  1986. * @param name defines the camera's name
  1987. * @return the camera or null if none found.
  1988. */
  1989. getCameraByName(name: string): Nullable<Camera>;
  1990. /**
  1991. * Gets a bone using its id
  1992. * @param id defines the bone's id
  1993. * @return the bone or null if not found
  1994. */
  1995. getBoneByID(id: string): Nullable<Bone>;
  1996. /**
  1997. * Gets a bone using its id
  1998. * @param name defines the bone's name
  1999. * @return the bone or null if not found
  2000. */
  2001. getBoneByName(name: string): Nullable<Bone>;
  2002. /**
  2003. * Gets a light node using its name
  2004. * @param name defines the the light's name
  2005. * @return the light or null if none found.
  2006. */
  2007. getLightByName(name: string): Nullable<Light>;
  2008. /**
  2009. * Gets a light node using its id
  2010. * @param id defines the light's id
  2011. * @return the light or null if none found.
  2012. */
  2013. getLightByID(id: string): Nullable<Light>;
  2014. /**
  2015. * Gets a light node using its scene-generated unique ID
  2016. * @param uniqueId defines the light's unique id
  2017. * @return the light or null if none found.
  2018. */
  2019. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2020. /**
  2021. * Gets a particle system by id
  2022. * @param id defines the particle system id
  2023. * @return the corresponding system or null if none found
  2024. */
  2025. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2026. /**
  2027. * Gets a geometry using its ID
  2028. * @param id defines the geometry's id
  2029. * @return the geometry or null if none found.
  2030. */
  2031. getGeometryByID(id: string): Nullable<Geometry>;
  2032. /**
  2033. * Add a new geometry to this scene
  2034. * @param geometry defines the geometry to be added to the scene.
  2035. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2036. * @return a boolean defining if the geometry was added or not
  2037. */
  2038. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2039. /**
  2040. * Removes an existing geometry
  2041. * @param geometry defines the geometry to be removed from the scene
  2042. * @return a boolean defining if the geometry was removed or not
  2043. */
  2044. removeGeometry(geometry: Geometry): boolean;
  2045. /**
  2046. * Gets the list of geometries attached to the scene
  2047. * @returns an array of Geometry
  2048. */
  2049. getGeometries(): Geometry[];
  2050. /**
  2051. * Gets the first added mesh found of a given ID
  2052. * @param id defines the id to search for
  2053. * @return the mesh found or null if not found at all
  2054. */
  2055. getMeshByID(id: string): Nullable<AbstractMesh>;
  2056. /**
  2057. * Gets a list of meshes using their id
  2058. * @param id defines the id to search for
  2059. * @returns a list of meshes
  2060. */
  2061. getMeshesByID(id: string): Array<AbstractMesh>;
  2062. /**
  2063. * Gets the first added transform node found of a given ID
  2064. * @param id defines the id to search for
  2065. * @return the found transform node or null if not found at all.
  2066. */
  2067. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2068. /**
  2069. * Gets a list of transform nodes using their id
  2070. * @param id defines the id to search for
  2071. * @returns a list of transform nodes
  2072. */
  2073. getTransformNodesByID(id: string): Array<TransformNode>;
  2074. /**
  2075. * Gets a mesh with its auto-generated unique id
  2076. * @param uniqueId defines the unique id to search for
  2077. * @return the found mesh or null if not found at all.
  2078. */
  2079. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2080. /**
  2081. * Gets a the last added mesh using a given id
  2082. * @param id defines the id to search for
  2083. * @return the found mesh or null if not found at all.
  2084. */
  2085. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2086. /**
  2087. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2088. * @param id defines the id to search for
  2089. * @return the found node or null if not found at all
  2090. */
  2091. getLastEntryByID(id: string): Nullable<Node>;
  2092. /**
  2093. * Gets a node (Mesh, Camera, Light) using a given id
  2094. * @param id defines the id to search for
  2095. * @return the found node or null if not found at all
  2096. */
  2097. getNodeByID(id: string): Nullable<Node>;
  2098. /**
  2099. * Gets a node (Mesh, Camera, Light) using a given name
  2100. * @param name defines the name to search for
  2101. * @return the found node or null if not found at all.
  2102. */
  2103. getNodeByName(name: string): Nullable<Node>;
  2104. /**
  2105. * Gets a mesh using a given name
  2106. * @param name defines the name to search for
  2107. * @return the found mesh or null if not found at all.
  2108. */
  2109. getMeshByName(name: string): Nullable<AbstractMesh>;
  2110. /**
  2111. * Gets a transform node using a given name
  2112. * @param name defines the name to search for
  2113. * @return the found transform node or null if not found at all.
  2114. */
  2115. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2116. /**
  2117. * Gets a sound using a given name
  2118. * @param name defines the name to search for
  2119. * @return the found sound or null if not found at all.
  2120. */
  2121. getSoundByName(name: string): Nullable<Sound>;
  2122. /**
  2123. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2124. * @param id defines the id to search for
  2125. * @return the found skeleton or null if not found at all.
  2126. */
  2127. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2128. /**
  2129. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2130. * @param id defines the id to search for
  2131. * @return the found skeleton or null if not found at all.
  2132. */
  2133. getSkeletonById(id: string): Nullable<Skeleton>;
  2134. /**
  2135. * Gets a skeleton using a given name
  2136. * @param name defines the name to search for
  2137. * @return the found skeleton or null if not found at all.
  2138. */
  2139. getSkeletonByName(name: string): Nullable<Skeleton>;
  2140. /**
  2141. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2142. * @param id defines the id to search for
  2143. * @return the found morph target manager or null if not found at all.
  2144. */
  2145. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2146. /**
  2147. * Gets a boolean indicating if the given mesh is active
  2148. * @param mesh defines the mesh to look for
  2149. * @returns true if the mesh is in the active list
  2150. */
  2151. isActiveMesh(mesh: AbstractMesh): boolean;
  2152. /**
  2153. * Return a unique id as a string which can serve as an identifier for the scene
  2154. */
  2155. readonly uid: string;
  2156. /**
  2157. * Add an externaly attached data from its key.
  2158. * This method call will fail and return false, if such key already exists.
  2159. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2160. * @param key the unique key that identifies the data
  2161. * @param data the data object to associate to the key for this Engine instance
  2162. * @return true if no such key were already present and the data was added successfully, false otherwise
  2163. */
  2164. addExternalData<T>(key: string, data: T): boolean;
  2165. /**
  2166. * Get an externaly attached data from its key
  2167. * @param key the unique key that identifies the data
  2168. * @return the associated data, if present (can be null), or undefined if not present
  2169. */
  2170. getExternalData<T>(key: string): Nullable<T>;
  2171. /**
  2172. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2173. * @param key the unique key that identifies the data
  2174. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2175. * @return the associated data, can be null if the factory returned null.
  2176. */
  2177. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2178. /**
  2179. * Remove an externaly attached data from the Engine instance
  2180. * @param key the unique key that identifies the data
  2181. * @return true if the data was successfully removed, false if it doesn't exist
  2182. */
  2183. removeExternalData(key: string): boolean;
  2184. private _evaluateSubMesh(subMesh, mesh);
  2185. /**
  2186. * Clear the processed materials smart array preventing retention point in material dispose.
  2187. */
  2188. freeProcessedMaterials(): void;
  2189. /**
  2190. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2191. */
  2192. freeActiveMeshes(): void;
  2193. /**
  2194. * Clear the info related to rendering groups preventing retention points during dispose.
  2195. */
  2196. freeRenderingGroups(): void;
  2197. /** @hidden */
  2198. _isInIntermediateRendering(): boolean;
  2199. private _activeMeshCandidateProvider;
  2200. /**
  2201. * Defines the current active mesh candidate provider
  2202. * @param provider defines the provider to use
  2203. */
  2204. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2205. /**
  2206. * Gets the current active mesh candidate provider
  2207. * @returns the current active mesh candidate provider
  2208. */
  2209. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2210. private _activeMeshesFrozen;
  2211. /**
  2212. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2213. * @returns the current scene
  2214. */
  2215. freezeActiveMeshes(): Scene;
  2216. /**
  2217. * Use this function to restart evaluating active meshes on every frame
  2218. * @returns the current scene
  2219. */
  2220. unfreezeActiveMeshes(): Scene;
  2221. private _evaluateActiveMeshes();
  2222. private _activeMesh(sourceMesh, mesh);
  2223. /**
  2224. * Update the transform matrix to update from the current active camera
  2225. * @param force defines a boolean used to force the update even if cache is up to date
  2226. */
  2227. updateTransformMatrix(force?: boolean): void;
  2228. /**
  2229. * 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)
  2230. * @param alternateCamera defines the camera to use
  2231. */
  2232. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2233. private _renderForCamera(camera, rigParent?);
  2234. private _processSubCameras(camera);
  2235. private _checkIntersections();
  2236. /**
  2237. * Render the scene
  2238. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2239. */
  2240. render(updateCameras?: boolean): void;
  2241. private _updateAudioParameters();
  2242. /**
  2243. * Gets or sets if audio support is enabled
  2244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2245. */
  2246. audioEnabled: boolean;
  2247. private _disableAudio();
  2248. private _enableAudio();
  2249. /**
  2250. * Gets or sets if audio will be output to headphones
  2251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2252. */
  2253. headphone: boolean;
  2254. private _switchAudioModeForHeadphones();
  2255. private _switchAudioModeForNormalSpeakers();
  2256. /**
  2257. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2258. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2259. * @returns the created depth renderer
  2260. */
  2261. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2262. /**
  2263. * Disables a depth renderer for a given camera
  2264. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2265. */
  2266. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2267. /**
  2268. * Enables a GeometryBufferRender and associates it with the scene
  2269. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2270. * @returns the GeometryBufferRenderer
  2271. */
  2272. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2273. /**
  2274. * Disables the GeometryBufferRender associated with the scene
  2275. */
  2276. disableGeometryBufferRenderer(): void;
  2277. /**
  2278. * Freeze all materials
  2279. * A frozen material will not be updatable but should be faster to render
  2280. */
  2281. freezeMaterials(): void;
  2282. /**
  2283. * Unfreeze all materials
  2284. * A frozen material will not be updatable but should be faster to render
  2285. */
  2286. unfreezeMaterials(): void;
  2287. /**
  2288. * Releases all held ressources
  2289. */
  2290. dispose(): void;
  2291. /**
  2292. * Gets if the scene is already disposed
  2293. */
  2294. readonly isDisposed: boolean;
  2295. /**
  2296. * Releases sounds & soundtracks
  2297. */
  2298. disposeSounds(): void;
  2299. /**
  2300. * Call this function to reduce memory footprint of the scene.
  2301. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2302. */
  2303. clearCachedVertexData(): void;
  2304. /**
  2305. * This function will remove the local cached buffer data from texture.
  2306. * It will save memory but will prevent the texture from being rebuilt
  2307. */
  2308. cleanCachedTextureBuffer(): void;
  2309. /**
  2310. * Get the world extend vectors with an optional filter
  2311. *
  2312. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2313. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2314. */
  2315. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2316. min: Vector3;
  2317. max: Vector3;
  2318. };
  2319. /**
  2320. * Creates or updates the octree used to boost selection (picking)
  2321. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2322. * @param maxCapacity defines the maximum capacity per leaf
  2323. * @param maxDepth defines the maximum depth of the octree
  2324. * @returns an octree of AbstractMesh
  2325. */
  2326. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2327. /**
  2328. * Creates a ray that can be used to pick in the scene
  2329. * @param x defines the x coordinate of the origin (on-screen)
  2330. * @param y defines the y coordinate of the origin (on-screen)
  2331. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2332. * @param camera defines the camera to use for the picking
  2333. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2334. * @returns a Ray
  2335. */
  2336. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  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 result defines the ray where to store the picking ray
  2343. * @param camera defines the camera to use for the picking
  2344. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2345. * @returns the current scene
  2346. */
  2347. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2348. /**
  2349. * Creates a ray that can be used to pick in the scene
  2350. * @param x defines the x coordinate of the origin (on-screen)
  2351. * @param y defines the y coordinate of the origin (on-screen)
  2352. * @param camera defines the camera to use for the picking
  2353. * @returns a Ray
  2354. */
  2355. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2356. /**
  2357. * Creates a ray that can be used to pick in the scene
  2358. * @param x defines the x coordinate of the origin (on-screen)
  2359. * @param y defines the y coordinate of the origin (on-screen)
  2360. * @param result defines the ray where to store the picking ray
  2361. * @param camera defines the camera to use for the picking
  2362. * @returns the current scene
  2363. */
  2364. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2365. private _internalPick(rayFunction, predicate?, fastCheck?);
  2366. private _internalMultiPick(rayFunction, predicate?);
  2367. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2368. private _tempPickingRay;
  2369. /** Launch a ray to try to pick a mesh in the scene
  2370. * @param x position on screen
  2371. * @param y position on screen
  2372. * @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
  2373. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2374. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2375. * @returns a PickingInfo
  2376. */
  2377. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2378. /** Launch a ray to try to pick a sprite in the scene
  2379. * @param x position on screen
  2380. * @param y position on screen
  2381. * @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
  2382. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2383. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2384. * @returns a PickingInfo
  2385. */
  2386. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2387. private _cachedRayForTransform;
  2388. /** Use the given ray to pick a mesh in the scene
  2389. * @param ray The ray to use to pick meshes
  2390. * @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
  2391. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2392. * @returns a PickingInfo
  2393. */
  2394. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2395. /**
  2396. * Launch a ray to try to pick a mesh in the scene
  2397. * @param x X position on screen
  2398. * @param y Y position on screen
  2399. * @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
  2400. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2401. * @returns an array of PickingInfo
  2402. */
  2403. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2404. /**
  2405. * Launch a ray to try to pick a mesh in the scene
  2406. * @param ray Ray to use
  2407. * @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
  2408. * @returns an array of PickingInfo
  2409. */
  2410. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2411. /**
  2412. * Force the value of meshUnderPointer
  2413. * @param mesh defines the mesh to use
  2414. */
  2415. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2416. /**
  2417. * Gets the mesh under the pointer
  2418. * @returns a Mesh or null if no mesh is under the pointer
  2419. */
  2420. getPointerOverMesh(): Nullable<AbstractMesh>;
  2421. /**
  2422. * Force the sprite under the pointer
  2423. * @param sprite defines the sprite to use
  2424. */
  2425. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2426. /**
  2427. * Gets the sprite under the pointer
  2428. * @returns a Sprite or null if no sprite is under the pointer
  2429. */
  2430. getPointerOverSprite(): Nullable<Sprite>;
  2431. /**
  2432. * Gets the current physics engine
  2433. * @returns a PhysicsEngine or null if none attached
  2434. */
  2435. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2436. /**
  2437. * Enables physics to the current scene
  2438. * @param gravity defines the scene's gravity for the physics engine
  2439. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2440. * @return a boolean indicating if the physics engine was initialized
  2441. */
  2442. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2443. /**
  2444. * Disables and disposes the physics engine associated with the scene
  2445. */
  2446. disablePhysicsEngine(): void;
  2447. /**
  2448. * Gets a boolean indicating if there is an active physics engine
  2449. * @returns a boolean indicating if there is an active physics engine
  2450. */
  2451. isPhysicsEnabled(): boolean;
  2452. /**
  2453. * Deletes a physics compound impostor
  2454. * @param compound defines the compound to delete
  2455. */
  2456. deleteCompoundImpostor(compound: any): void;
  2457. /** @hidden */
  2458. _rebuildGeometries(): void;
  2459. /** @hidden */
  2460. _rebuildTextures(): void;
  2461. /**
  2462. * Creates a default light for the scene.
  2463. * @param replace Whether to replace the existing lights in the scene.
  2464. */
  2465. createDefaultLight(replace?: boolean): void;
  2466. /**
  2467. * Creates a default camera for the scene.
  2468. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2469. * @param replace Whether to replace the existing active camera in the scene.
  2470. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2471. */
  2472. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2473. /**
  2474. * Creates a default camera and a default light
  2475. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2476. * @param replace defines if the camera and/or light will replace the existing ones
  2477. * @param attachCameraControls defines if attachControl will be called on the new camera
  2478. */
  2479. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2480. /**
  2481. * Creates a new sky box
  2482. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2483. * @param environmentTexture defines the texture to use as environment texture
  2484. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2485. * @param scale defines the overall scale of the skybox
  2486. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2487. * @param setGlobalEnvTexture defines a boolean indicating that scene.environmentTexture must match the current skybox texture (true by default)
  2488. * @returns a new mesh holding the sky box
  2489. */
  2490. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2491. /**
  2492. * Creates a new environment
  2493. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2494. * @param options defines the options you can use to configure the environment
  2495. * @returns the new EnvironmentHelper
  2496. */
  2497. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2498. /**
  2499. * Creates a new VREXperienceHelper
  2500. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2501. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2502. * @returns a new VREXperienceHelper
  2503. */
  2504. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2505. private _getByTags(list, tagsQuery, forEach?);
  2506. /**
  2507. * Get a list of meshes by tags
  2508. * @param tagsQuery defines the tags query to use
  2509. * @param forEach defines a predicate used to filter results
  2510. * @returns an array of Mesh
  2511. */
  2512. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2513. /**
  2514. * Get a list of cameras by tags
  2515. * @param tagsQuery defines the tags query to use
  2516. * @param forEach defines a predicate used to filter results
  2517. * @returns an array of Camera
  2518. */
  2519. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2520. /**
  2521. * Get a list of lights by tags
  2522. * @param tagsQuery defines the tags query to use
  2523. * @param forEach defines a predicate used to filter results
  2524. * @returns an array of Light
  2525. */
  2526. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2527. /**
  2528. * Get a list of materials by tags
  2529. * @param tagsQuery defines the tags query to use
  2530. * @param forEach defines a predicate used to filter results
  2531. * @returns an array of Material
  2532. */
  2533. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2534. /**
  2535. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2536. * This allowed control for front to back rendering or reversly depending of the special needs.
  2537. *
  2538. * @param renderingGroupId The rendering group id corresponding to its index
  2539. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2540. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2541. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2542. */
  2543. 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;
  2544. /**
  2545. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2546. *
  2547. * @param renderingGroupId The rendering group id corresponding to its index
  2548. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2549. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2550. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2551. */
  2552. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2553. /**
  2554. * Will flag all materials as dirty to trigger new shader compilation
  2555. * @param flag defines the flag used to specify which material part must be marked as dirty
  2556. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2557. */
  2558. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2559. /** @hidden */
  2560. _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;
  2561. /** @hidden */
  2562. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2563. }
  2564. }
  2565. declare module BABYLON {
  2566. /**
  2567. * Groups all the scene component constants in one place to ease maintenance.
  2568. * @hidden
  2569. */
  2570. class SceneComponentConstants {
  2571. static readonly NAME_EFFECTLAYER: string;
  2572. static readonly NAME_LAYER: string;
  2573. static readonly NAME_LENSFLARESYSTEM: string;
  2574. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2575. static readonly NAME_PARTICLESYSTEM: string;
  2576. static readonly NAME_GAMEPAD: string;
  2577. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2578. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2579. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2580. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2581. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2582. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2583. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2584. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2585. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2586. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2587. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2588. static readonly STEP_AFTERCAMERADRAW_BOUNDINGBOXRENDERER: number;
  2589. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2590. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2591. }
  2592. /**
  2593. * This represents a scene component.
  2594. *
  2595. * This is used to decouple the dependency the scene is having on the different workloads like
  2596. * layers, post processes...
  2597. */
  2598. interface ISceneComponent {
  2599. /**
  2600. * The name of the component. Each component must have a unique name.
  2601. */
  2602. name: string;
  2603. /**
  2604. * The scene the component belongs to.
  2605. */
  2606. scene: Scene;
  2607. /**
  2608. * Register the component to one instance of a scene.
  2609. */
  2610. register(): void;
  2611. /**
  2612. * Rebuilds the elements related to this component in case of
  2613. * context lost for instance.
  2614. */
  2615. rebuild(): void;
  2616. /**
  2617. * Disposes the component and the associated ressources.
  2618. */
  2619. dispose(): void;
  2620. }
  2621. /**
  2622. * This represents a SERIALIZABLE scene component.
  2623. *
  2624. * This extends Scene Component to add Serialization methods on top.
  2625. */
  2626. interface ISceneSerializableComponent extends ISceneComponent {
  2627. /**
  2628. * Adds all the element from the container to the scene
  2629. * @param container the container holding the elements
  2630. */
  2631. addFromContainer(container: AbstractScene): void;
  2632. /**
  2633. * Removes all the elements in the container from the scene
  2634. * @param container contains the elements to remove
  2635. */
  2636. removeFromContainer(container: AbstractScene): void;
  2637. /**
  2638. * Serializes the component data to the specified json object
  2639. * @param serializationObject The object to serialize to
  2640. */
  2641. serialize(serializationObject: any): void;
  2642. }
  2643. /**
  2644. * Strong typing of a Mesh related stage step action
  2645. */
  2646. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2647. /**
  2648. * Strong typing of a Evaluate Sub Mesh related stage step action
  2649. */
  2650. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2651. /**
  2652. * Strong typing of a Active Mesh related stage step action
  2653. */
  2654. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2655. /**
  2656. * Strong typing of a Camera related stage step action
  2657. */
  2658. type CameraStageAction = (camera: Camera) => void;
  2659. /**
  2660. * Strong typing of a RenderingGroup related stage step action
  2661. */
  2662. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2663. /**
  2664. * Strong typing of a simple stage step action
  2665. */
  2666. type SimpleStageAction = () => void;
  2667. /**
  2668. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2669. * @hidden
  2670. */
  2671. class Stage<T extends Function> extends Array<{
  2672. index: number;
  2673. component: ISceneComponent;
  2674. action: T;
  2675. }> {
  2676. /**
  2677. * Hide ctor from the rest of the world.
  2678. * @param items The items to add.
  2679. */
  2680. private constructor();
  2681. /**
  2682. * Creates a new Stage.
  2683. * @returns A new instance of a Stage
  2684. */
  2685. static Create<T extends Function>(): Stage<T>;
  2686. /**
  2687. * Registers a step in an ordered way in the targeted stage.
  2688. * @param index Defines the position to register the step in
  2689. * @param component Defines the component attached to the step
  2690. * @param action Defines the action to launch during the step
  2691. */
  2692. registerStep(index: number, component: ISceneComponent, action: T): void;
  2693. /**
  2694. * Clears all the steps from the stage.
  2695. */
  2696. clear(): void;
  2697. }
  2698. }
  2699. declare module BABYLON {
  2700. type Nullable<T> = T | null;
  2701. type float = number;
  2702. type double = number;
  2703. type int = number;
  2704. type FloatArray = number[] | Float32Array;
  2705. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2706. /**
  2707. * Alias for types that can be used by a Buffer or VertexBuffer.
  2708. */
  2709. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2710. }
  2711. declare module BABYLON {
  2712. /**
  2713. * The action to be carried out following a trigger
  2714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2715. */
  2716. class Action {
  2717. /** the trigger, with or without parameters, for the action */
  2718. triggerOptions: any;
  2719. /**
  2720. * Trigger for the action
  2721. */
  2722. trigger: number;
  2723. /**
  2724. * Internal only - manager for action
  2725. * @hidden
  2726. */
  2727. _actionManager: ActionManager;
  2728. private _nextActiveAction;
  2729. private _child;
  2730. private _condition?;
  2731. private _triggerParameter;
  2732. /**
  2733. * An event triggered prior to action being executed.
  2734. */
  2735. onBeforeExecuteObservable: Observable<Action>;
  2736. /**
  2737. * Creates a new Action
  2738. * @param triggerOptions the trigger, with or without parameters, for the action
  2739. * @param condition an optional determinant of action
  2740. */
  2741. constructor(
  2742. /** the trigger, with or without parameters, for the action */
  2743. triggerOptions: any, condition?: Condition);
  2744. /**
  2745. * Internal only
  2746. * @hidden
  2747. */
  2748. _prepare(): void;
  2749. /**
  2750. * Gets the trigger parameters
  2751. * @returns the trigger parameters
  2752. */
  2753. getTriggerParameter(): any;
  2754. /**
  2755. * Internal only - executes current action event
  2756. * @hidden
  2757. */
  2758. _executeCurrent(evt?: ActionEvent): void;
  2759. /**
  2760. * Execute placeholder for child classes
  2761. * @param evt optional action event
  2762. */
  2763. execute(evt?: ActionEvent): void;
  2764. /**
  2765. * Skips to next active action
  2766. */
  2767. skipToNextActiveAction(): void;
  2768. /**
  2769. * Adds action to chain of actions, may be a DoNothingAction
  2770. * @param action defines the next action to execute
  2771. * @returns The action passed in
  2772. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2773. */
  2774. then(action: Action): Action;
  2775. /**
  2776. * Internal only
  2777. * @hidden
  2778. */
  2779. _getProperty(propertyPath: string): string;
  2780. /**
  2781. * Internal only
  2782. * @hidden
  2783. */
  2784. _getEffectiveTarget(target: any, propertyPath: string): any;
  2785. /**
  2786. * Serialize placeholder for child classes
  2787. * @param parent of child
  2788. * @returns the serialized object
  2789. */
  2790. serialize(parent: any): any;
  2791. /**
  2792. * Internal only called by serialize
  2793. * @hidden
  2794. */
  2795. protected _serialize(serializedAction: any, parent?: any): any;
  2796. /**
  2797. * Internal only
  2798. * @hidden
  2799. */
  2800. static _SerializeValueAsString: (value: any) => string;
  2801. /**
  2802. * Internal only
  2803. * @hidden
  2804. */
  2805. static _GetTargetProperty: (target: Scene | Node) => {
  2806. name: string;
  2807. targetType: string;
  2808. value: string;
  2809. };
  2810. }
  2811. }
  2812. declare module BABYLON {
  2813. /**
  2814. * ActionEvent is the event being sent when an action is triggered.
  2815. */
  2816. class ActionEvent {
  2817. /** The mesh or sprite that triggered the action */
  2818. source: any;
  2819. /** The X mouse cursor position at the time of the event */
  2820. pointerX: number;
  2821. /** The Y mouse cursor position at the time of the event */
  2822. pointerY: number;
  2823. /** The mesh that is currently pointed at (can be null) */
  2824. meshUnderPointer: Nullable<AbstractMesh>;
  2825. /** the original (browser) event that triggered the ActionEvent */
  2826. sourceEvent: any;
  2827. /** additional data for the event */
  2828. additionalData: any;
  2829. /**
  2830. * Creates a new ActionEvent
  2831. * @param source The mesh or sprite that triggered the action
  2832. * @param pointerX The X mouse cursor position at the time of the event
  2833. * @param pointerY The Y mouse cursor position at the time of the event
  2834. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2835. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2836. * @param additionalData additional data for the event
  2837. */
  2838. constructor(
  2839. /** The mesh or sprite that triggered the action */
  2840. source: any,
  2841. /** The X mouse cursor position at the time of the event */
  2842. pointerX: number,
  2843. /** The Y mouse cursor position at the time of the event */
  2844. pointerY: number,
  2845. /** The mesh that is currently pointed at (can be null) */
  2846. meshUnderPointer: Nullable<AbstractMesh>,
  2847. /** the original (browser) event that triggered the ActionEvent */
  2848. sourceEvent?: any,
  2849. /** additional data for the event */
  2850. additionalData?: any);
  2851. /**
  2852. * Helper function to auto-create an ActionEvent from a source mesh.
  2853. * @param source The source mesh that triggered the event
  2854. * @param evt The original (browser) event
  2855. * @param additionalData additional data for the event
  2856. * @returns the new ActionEvent
  2857. */
  2858. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2859. /**
  2860. * Helper function to auto-create an ActionEvent from a source sprite
  2861. * @param source The source sprite that triggered the event
  2862. * @param scene Scene associated with the sprite
  2863. * @param evt The original (browser) event
  2864. * @param additionalData additional data for the event
  2865. * @returns the new ActionEvent
  2866. */
  2867. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2868. /**
  2869. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2870. * @param scene the scene where the event occurred
  2871. * @param evt The original (browser) event
  2872. * @returns the new ActionEvent
  2873. */
  2874. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2875. /**
  2876. * Helper function to auto-create an ActionEvent from a primitive
  2877. * @param prim defines the target primitive
  2878. * @param pointerPos defines the pointer position
  2879. * @param evt The original (browser) event
  2880. * @param additionalData additional data for the event
  2881. * @returns the new ActionEvent
  2882. */
  2883. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2884. }
  2885. /**
  2886. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2887. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2889. */
  2890. class ActionManager {
  2891. private static _NothingTrigger;
  2892. private static _OnPickTrigger;
  2893. private static _OnLeftPickTrigger;
  2894. private static _OnRightPickTrigger;
  2895. private static _OnCenterPickTrigger;
  2896. private static _OnPickDownTrigger;
  2897. private static _OnDoublePickTrigger;
  2898. private static _OnPickUpTrigger;
  2899. private static _OnLongPressTrigger;
  2900. private static _OnPointerOverTrigger;
  2901. private static _OnPointerOutTrigger;
  2902. private static _OnEveryFrameTrigger;
  2903. private static _OnIntersectionEnterTrigger;
  2904. private static _OnIntersectionExitTrigger;
  2905. private static _OnKeyDownTrigger;
  2906. private static _OnKeyUpTrigger;
  2907. private static _OnPickOutTrigger;
  2908. /**
  2909. * Nothing
  2910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2911. */
  2912. static readonly NothingTrigger: number;
  2913. /**
  2914. * On pick
  2915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2916. */
  2917. static readonly OnPickTrigger: number;
  2918. /**
  2919. * On left pick
  2920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2921. */
  2922. static readonly OnLeftPickTrigger: number;
  2923. /**
  2924. * On right pick
  2925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2926. */
  2927. static readonly OnRightPickTrigger: number;
  2928. /**
  2929. * On center pick
  2930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2931. */
  2932. static readonly OnCenterPickTrigger: number;
  2933. /**
  2934. * On pick down
  2935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2936. */
  2937. static readonly OnPickDownTrigger: number;
  2938. /**
  2939. * On double pick
  2940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2941. */
  2942. static readonly OnDoublePickTrigger: number;
  2943. /**
  2944. * On pick up
  2945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2946. */
  2947. static readonly OnPickUpTrigger: number;
  2948. /**
  2949. * On pick out.
  2950. * This trigger will only be raised if you also declared a OnPickDown
  2951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2952. */
  2953. static readonly OnPickOutTrigger: number;
  2954. /**
  2955. * On long press
  2956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2957. */
  2958. static readonly OnLongPressTrigger: number;
  2959. /**
  2960. * On pointer over
  2961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2962. */
  2963. static readonly OnPointerOverTrigger: number;
  2964. /**
  2965. * On pointer out
  2966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2967. */
  2968. static readonly OnPointerOutTrigger: number;
  2969. /**
  2970. * On every frame
  2971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2972. */
  2973. static readonly OnEveryFrameTrigger: number;
  2974. /**
  2975. * On intersection enter
  2976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2977. */
  2978. static readonly OnIntersectionEnterTrigger: number;
  2979. /**
  2980. * On intersection exit
  2981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2982. */
  2983. static readonly OnIntersectionExitTrigger: number;
  2984. /**
  2985. * On key down
  2986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2987. */
  2988. static readonly OnKeyDownTrigger: number;
  2989. /**
  2990. * On key up
  2991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2992. */
  2993. static readonly OnKeyUpTrigger: number;
  2994. /** Gets the list of active triggers */
  2995. static Triggers: {
  2996. [key: string]: number;
  2997. };
  2998. /** Gets the list of actions */
  2999. actions: Action[];
  3000. /** Gets the cursor to use when hovering items */
  3001. hoverCursor: string;
  3002. private _scene;
  3003. /**
  3004. * Creates a new action manager
  3005. * @param scene defines the hosting scene
  3006. */
  3007. constructor(scene: Scene);
  3008. /**
  3009. * Releases all associated resources
  3010. */
  3011. dispose(): void;
  3012. /**
  3013. * Gets hosting scene
  3014. * @returns the hosting scene
  3015. */
  3016. getScene(): Scene;
  3017. /**
  3018. * Does this action manager handles actions of any of the given triggers
  3019. * @param triggers defines the triggers to be tested
  3020. * @return a boolean indicating whether one (or more) of the triggers is handled
  3021. */
  3022. hasSpecificTriggers(triggers: number[]): boolean;
  3023. /**
  3024. * Does this action manager handles actions of a given trigger
  3025. * @param trigger defines the trigger to be tested
  3026. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3027. * @return whether the trigger is handled
  3028. */
  3029. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3030. /**
  3031. * Does this action manager has pointer triggers
  3032. */
  3033. readonly hasPointerTriggers: boolean;
  3034. /**
  3035. * Does this action manager has pick triggers
  3036. */
  3037. readonly hasPickTriggers: boolean;
  3038. /**
  3039. * Does exist one action manager with at least one trigger
  3040. **/
  3041. static readonly HasTriggers: boolean;
  3042. /**
  3043. * Does exist one action manager with at least one pick trigger
  3044. **/
  3045. static readonly HasPickTriggers: boolean;
  3046. /**
  3047. * Does exist one action manager that handles actions of a given trigger
  3048. * @param trigger defines the trigger to be tested
  3049. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3050. **/
  3051. static HasSpecificTrigger(trigger: number): boolean;
  3052. /**
  3053. * Registers an action to this action manager
  3054. * @param action defines the action to be registered
  3055. * @return the action amended (prepared) after registration
  3056. */
  3057. registerAction(action: Action): Nullable<Action>;
  3058. /**
  3059. * Unregisters an action to this action manager
  3060. * @param action defines the action to be unregistered
  3061. * @return a boolean indicating whether the action has been unregistered
  3062. */
  3063. unregisterAction(action: Action): Boolean;
  3064. /**
  3065. * Process a specific trigger
  3066. * @param trigger defines the trigger to process
  3067. * @param evt defines the event details to be processed
  3068. */
  3069. processTrigger(trigger: number, evt?: ActionEvent): void;
  3070. /** @hidden */
  3071. _getEffectiveTarget(target: any, propertyPath: string): any;
  3072. /** @hidden */
  3073. _getProperty(propertyPath: string): string;
  3074. /**
  3075. * Serialize this manager to a JSON object
  3076. * @param name defines the property name to store this manager
  3077. * @returns a JSON representation of this manager
  3078. */
  3079. serialize(name: string): any;
  3080. /**
  3081. * Creates a new ActionManager from a JSON data
  3082. * @param parsedActions defines the JSON data to read from
  3083. * @param object defines the hosting mesh
  3084. * @param scene defines the hosting scene
  3085. */
  3086. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3087. /**
  3088. * Get a trigger name by index
  3089. * @param trigger defines the trigger index
  3090. * @returns a trigger name
  3091. */
  3092. static GetTriggerName(trigger: number): string;
  3093. }
  3094. }
  3095. declare module BABYLON {
  3096. /**
  3097. * A Condition applied to an Action
  3098. */
  3099. class Condition {
  3100. /**
  3101. * Internal only - manager for action
  3102. * @hidden
  3103. */
  3104. _actionManager: ActionManager;
  3105. /**
  3106. * Internal only
  3107. * @hidden
  3108. */
  3109. _evaluationId: number;
  3110. /**
  3111. * Internal only
  3112. * @hidden
  3113. */
  3114. _currentResult: boolean;
  3115. /**
  3116. * Creates a new Condition
  3117. * @param actionManager the manager of the action the condition is applied to
  3118. */
  3119. constructor(actionManager: ActionManager);
  3120. /**
  3121. * Check if the current condition is valid
  3122. * @returns a boolean
  3123. */
  3124. isValid(): boolean;
  3125. /**
  3126. * Internal only
  3127. * @hidden
  3128. */
  3129. _getProperty(propertyPath: string): string;
  3130. /**
  3131. * Internal only
  3132. * @hidden
  3133. */
  3134. _getEffectiveTarget(target: any, propertyPath: string): any;
  3135. /**
  3136. * Serialize placeholder for child classes
  3137. * @returns the serialized object
  3138. */
  3139. serialize(): any;
  3140. /**
  3141. * Internal only
  3142. * @hidden
  3143. */
  3144. protected _serialize(serializedCondition: any): any;
  3145. }
  3146. /**
  3147. * Defines specific conditional operators as extensions of Condition
  3148. */
  3149. class ValueCondition extends Condition {
  3150. /** path to specify the property of the target the conditional operator uses */
  3151. propertyPath: string;
  3152. /** the value compared by the conditional operator against the current value of the property */
  3153. value: any;
  3154. /** the conditional operator, default ValueCondition.IsEqual */
  3155. operator: number;
  3156. /**
  3157. * Internal only
  3158. * @hidden
  3159. */
  3160. private static _IsEqual;
  3161. /**
  3162. * Internal only
  3163. * @hidden
  3164. */
  3165. private static _IsDifferent;
  3166. /**
  3167. * Internal only
  3168. * @hidden
  3169. */
  3170. private static _IsGreater;
  3171. /**
  3172. * Internal only
  3173. * @hidden
  3174. */
  3175. private static _IsLesser;
  3176. /**
  3177. * returns the number for IsEqual
  3178. */
  3179. static readonly IsEqual: number;
  3180. /**
  3181. * Returns the number for IsDifferent
  3182. */
  3183. static readonly IsDifferent: number;
  3184. /**
  3185. * Returns the number for IsGreater
  3186. */
  3187. static readonly IsGreater: number;
  3188. /**
  3189. * Returns the number for IsLesser
  3190. */
  3191. static readonly IsLesser: number;
  3192. /**
  3193. * Internal only The action manager for the condition
  3194. * @hidden
  3195. */
  3196. _actionManager: ActionManager;
  3197. /**
  3198. * Internal only
  3199. * @hidden
  3200. */
  3201. private _target;
  3202. /**
  3203. * Internal only
  3204. * @hidden
  3205. */
  3206. private _effectiveTarget;
  3207. /**
  3208. * Internal only
  3209. * @hidden
  3210. */
  3211. private _property;
  3212. /**
  3213. * Creates a new ValueCondition
  3214. * @param actionManager manager for the action the condition applies to
  3215. * @param target for the action
  3216. * @param propertyPath path to specify the property of the target the conditional operator uses
  3217. * @param value the value compared by the conditional operator against the current value of the property
  3218. * @param operator the conditional operator, default ValueCondition.IsEqual
  3219. */
  3220. constructor(actionManager: ActionManager, target: any,
  3221. /** path to specify the property of the target the conditional operator uses */
  3222. propertyPath: string,
  3223. /** the value compared by the conditional operator against the current value of the property */
  3224. value: any,
  3225. /** the conditional operator, default ValueCondition.IsEqual */
  3226. operator?: number);
  3227. /**
  3228. * Compares the given value with the property value for the specified conditional operator
  3229. * @returns the result of the comparison
  3230. */
  3231. isValid(): boolean;
  3232. /**
  3233. * Serialize the ValueCondition into a JSON compatible object
  3234. * @returns serialization object
  3235. */
  3236. serialize(): any;
  3237. /**
  3238. * Gets the name of the conditional operator for the ValueCondition
  3239. * @param operator the conditional operator
  3240. * @returns the name
  3241. */
  3242. static GetOperatorName(operator: number): string;
  3243. }
  3244. /**
  3245. * Defines a predicate condition as an extension of Condition
  3246. */
  3247. class PredicateCondition extends Condition {
  3248. /** defines the predicate function used to validate the condition */
  3249. predicate: () => boolean;
  3250. /**
  3251. * Internal only - manager for action
  3252. * @hidden
  3253. */
  3254. _actionManager: ActionManager;
  3255. /**
  3256. * Creates a new PredicateCondition
  3257. * @param actionManager manager for the action the condition applies to
  3258. * @param predicate defines the predicate function used to validate the condition
  3259. */
  3260. constructor(actionManager: ActionManager,
  3261. /** defines the predicate function used to validate the condition */
  3262. predicate: () => boolean);
  3263. /**
  3264. * @returns the validity of the predicate condition
  3265. */
  3266. isValid(): boolean;
  3267. }
  3268. /**
  3269. * Defines a state condition as an extension of Condition
  3270. */
  3271. class StateCondition extends Condition {
  3272. value: string;
  3273. /**
  3274. * Internal only - manager for action
  3275. * @hidden
  3276. */
  3277. _actionManager: ActionManager;
  3278. /**
  3279. * Internal only
  3280. * @hidden
  3281. */
  3282. private _target;
  3283. /**
  3284. * Creates a new StateCondition
  3285. * @param actionManager manager for the action the condition applies to
  3286. * @param target of the condition
  3287. * @param value to compare with target state
  3288. */
  3289. constructor(actionManager: ActionManager, target: any, value: string);
  3290. /**
  3291. * @returns the validity of the state
  3292. */
  3293. isValid(): boolean;
  3294. /**
  3295. * Serialize the StateCondition into a JSON compatible object
  3296. * @returns serialization object
  3297. */
  3298. serialize(): any;
  3299. }
  3300. }
  3301. declare module BABYLON {
  3302. class SwitchBooleanAction extends Action {
  3303. propertyPath: string;
  3304. private _target;
  3305. private _effectiveTarget;
  3306. private _property;
  3307. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3308. _prepare(): void;
  3309. execute(): void;
  3310. serialize(parent: any): any;
  3311. }
  3312. class SetStateAction extends Action {
  3313. value: string;
  3314. private _target;
  3315. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3316. execute(): void;
  3317. serialize(parent: any): any;
  3318. }
  3319. class SetValueAction extends Action {
  3320. propertyPath: string;
  3321. value: any;
  3322. private _target;
  3323. private _effectiveTarget;
  3324. private _property;
  3325. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3326. _prepare(): void;
  3327. execute(): void;
  3328. serialize(parent: any): any;
  3329. }
  3330. class IncrementValueAction extends Action {
  3331. propertyPath: string;
  3332. value: any;
  3333. private _target;
  3334. private _effectiveTarget;
  3335. private _property;
  3336. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3337. _prepare(): void;
  3338. execute(): void;
  3339. serialize(parent: any): any;
  3340. }
  3341. class PlayAnimationAction extends Action {
  3342. from: number;
  3343. to: number;
  3344. loop: boolean | undefined;
  3345. private _target;
  3346. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3347. _prepare(): void;
  3348. execute(): void;
  3349. serialize(parent: any): any;
  3350. }
  3351. class StopAnimationAction extends Action {
  3352. private _target;
  3353. constructor(triggerOptions: any, target: any, condition?: Condition);
  3354. _prepare(): void;
  3355. execute(): void;
  3356. serialize(parent: any): any;
  3357. }
  3358. class DoNothingAction extends Action {
  3359. constructor(triggerOptions?: any, condition?: Condition);
  3360. execute(): void;
  3361. serialize(parent: any): any;
  3362. }
  3363. class CombineAction extends Action {
  3364. children: Action[];
  3365. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3366. _prepare(): void;
  3367. execute(evt: ActionEvent): void;
  3368. serialize(parent: any): any;
  3369. }
  3370. class ExecuteCodeAction extends Action {
  3371. func: (evt: ActionEvent) => void;
  3372. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3373. execute(evt: ActionEvent): void;
  3374. }
  3375. class SetParentAction extends Action {
  3376. private _parent;
  3377. private _target;
  3378. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3379. _prepare(): void;
  3380. execute(): void;
  3381. serialize(parent: any): any;
  3382. }
  3383. class PlaySoundAction extends Action {
  3384. private _sound;
  3385. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3386. _prepare(): void;
  3387. execute(): void;
  3388. serialize(parent: any): any;
  3389. }
  3390. class StopSoundAction extends Action {
  3391. private _sound;
  3392. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3393. _prepare(): void;
  3394. execute(): void;
  3395. serialize(parent: any): any;
  3396. }
  3397. }
  3398. declare module BABYLON {
  3399. class InterpolateValueAction extends Action {
  3400. propertyPath: string;
  3401. value: any;
  3402. duration: number;
  3403. stopOtherAnimations: boolean | undefined;
  3404. onInterpolationDone: (() => void) | undefined;
  3405. private _target;
  3406. private _effectiveTarget;
  3407. private _property;
  3408. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3409. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3410. _prepare(): void;
  3411. execute(): void;
  3412. serialize(parent: any): any;
  3413. }
  3414. }
  3415. declare module BABYLON {
  3416. /**
  3417. * Class used to store an actual running animation
  3418. */
  3419. class Animatable {
  3420. /** defines the target object */
  3421. target: any;
  3422. /** defines the starting frame number (default is 0) */
  3423. fromFrame: number;
  3424. /** defines the ending frame number (default is 100) */
  3425. toFrame: number;
  3426. /** defines if the animation must loop (default is false) */
  3427. loopAnimation: boolean;
  3428. /** defines a callback to call when animation ends if it is not looping */
  3429. onAnimationEnd: (() => void) | null | undefined;
  3430. private _localDelayOffset;
  3431. private _pausedDelay;
  3432. private _runtimeAnimations;
  3433. private _paused;
  3434. private _scene;
  3435. private _speedRatio;
  3436. private _weight;
  3437. private _syncRoot;
  3438. /**
  3439. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3440. * This will only apply for non looping animation (default is true)
  3441. */
  3442. disposeOnEnd: boolean;
  3443. /**
  3444. * Gets a boolean indicating if the animation has started
  3445. */
  3446. animationStarted: boolean;
  3447. /**
  3448. * Observer raised when the animation ends
  3449. */
  3450. onAnimationEndObservable: Observable<Animatable>;
  3451. /**
  3452. * Gets the root Animatable used to synchronize and normalize animations
  3453. */
  3454. readonly syncRoot: Animatable;
  3455. /**
  3456. * Gets the current frame of the first RuntimeAnimation
  3457. * Used to synchronize Animatables
  3458. */
  3459. readonly masterFrame: number;
  3460. /**
  3461. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3462. */
  3463. weight: number;
  3464. /**
  3465. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3466. */
  3467. speedRatio: number;
  3468. /**
  3469. * Creates a new Animatable
  3470. * @param scene defines the hosting scene
  3471. * @param target defines the target object
  3472. * @param fromFrame defines the starting frame number (default is 0)
  3473. * @param toFrame defines the ending frame number (default is 100)
  3474. * @param loopAnimation defines if the animation must loop (default is false)
  3475. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3476. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3477. * @param animations defines a group of animation to add to the new Animatable
  3478. */
  3479. constructor(scene: Scene,
  3480. /** defines the target object */
  3481. target: any,
  3482. /** defines the starting frame number (default is 0) */
  3483. fromFrame?: number,
  3484. /** defines the ending frame number (default is 100) */
  3485. toFrame?: number,
  3486. /** defines if the animation must loop (default is false) */
  3487. loopAnimation?: boolean, speedRatio?: number,
  3488. /** defines a callback to call when animation ends if it is not looping */
  3489. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3490. /**
  3491. * Synchronize and normalize current Animatable with a source Animatable
  3492. * This is useful when using animation weights and when animations are not of the same length
  3493. * @param root defines the root Animatable to synchronize with
  3494. * @returns the current Animatable
  3495. */
  3496. syncWith(root: Animatable): Animatable;
  3497. /**
  3498. * Gets the list of runtime animations
  3499. * @returns an array of RuntimeAnimation
  3500. */
  3501. getAnimations(): RuntimeAnimation[];
  3502. /**
  3503. * Adds more animations to the current animatable
  3504. * @param target defines the target of the animations
  3505. * @param animations defines the new animations to add
  3506. */
  3507. appendAnimations(target: any, animations: Animation[]): void;
  3508. /**
  3509. * Gets the source animation for a specific property
  3510. * @param property defines the propertyu to look for
  3511. * @returns null or the source animation for the given property
  3512. */
  3513. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3514. /**
  3515. * Gets the runtime animation for a specific property
  3516. * @param property defines the propertyu to look for
  3517. * @returns null or the runtime animation for the given property
  3518. */
  3519. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3520. /**
  3521. * Resets the animatable to its original state
  3522. */
  3523. reset(): void;
  3524. /**
  3525. * Allows the animatable to blend with current running animations
  3526. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3527. * @param blendingSpeed defines the blending speed to use
  3528. */
  3529. enableBlending(blendingSpeed: number): void;
  3530. /**
  3531. * Disable animation blending
  3532. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3533. */
  3534. disableBlending(): void;
  3535. /**
  3536. * Jump directly to a given frame
  3537. * @param frame defines the frame to jump to
  3538. */
  3539. goToFrame(frame: number): void;
  3540. /**
  3541. * Pause the animation
  3542. */
  3543. pause(): void;
  3544. /**
  3545. * Restart the animation
  3546. */
  3547. restart(): void;
  3548. private _raiseOnAnimationEnd();
  3549. /**
  3550. * Stop and delete the current animation
  3551. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3552. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  3553. */
  3554. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3555. /**
  3556. * Wait asynchronously for the animation to end
  3557. * @returns a promise which will be fullfilled when the animation ends
  3558. */
  3559. waitAsync(): Promise<Animatable>;
  3560. /** @hidden */
  3561. _animate(delay: number): boolean;
  3562. }
  3563. }
  3564. declare module BABYLON {
  3565. /**
  3566. * Represents the range of an animation
  3567. */
  3568. class AnimationRange {
  3569. /**The name of the animation range**/
  3570. name: string;
  3571. /**The starting frame of the animation */
  3572. from: number;
  3573. /**The ending frame of the animation*/
  3574. to: number;
  3575. /**
  3576. * Initializes the range of an animation
  3577. * @param name The name of the animation range
  3578. * @param from The starting frame of the animation
  3579. * @param to The ending frame of the animation
  3580. */
  3581. constructor(
  3582. /**The name of the animation range**/
  3583. name: string,
  3584. /**The starting frame of the animation */
  3585. from: number,
  3586. /**The ending frame of the animation*/
  3587. to: number);
  3588. /**
  3589. * Makes a copy of the animation range
  3590. * @returns A copy of the animation range
  3591. */
  3592. clone(): AnimationRange;
  3593. }
  3594. /**
  3595. * Composed of a frame, and an action function
  3596. */
  3597. class AnimationEvent {
  3598. /** The frame for which the event is triggered **/
  3599. frame: number;
  3600. /** The event to perform when triggered **/
  3601. action: () => void;
  3602. /** Specifies if the event should be triggered only once**/
  3603. onlyOnce: boolean | undefined;
  3604. /**
  3605. * Specifies if the animation event is done
  3606. */
  3607. isDone: boolean;
  3608. /**
  3609. * Initializes the animation event
  3610. * @param frame The frame for which the event is triggered
  3611. * @param action The event to perform when triggered
  3612. * @param onlyOnce Specifies if the event should be triggered only once
  3613. */
  3614. constructor(
  3615. /** The frame for which the event is triggered **/
  3616. frame: number,
  3617. /** The event to perform when triggered **/
  3618. action: () => void,
  3619. /** Specifies if the event should be triggered only once**/
  3620. onlyOnce?: boolean | undefined);
  3621. /** @hidden */
  3622. _clone(): AnimationEvent;
  3623. }
  3624. /**
  3625. * A cursor which tracks a point on a path
  3626. */
  3627. class PathCursor {
  3628. private path;
  3629. /**
  3630. * Stores path cursor callbacks for when an onchange event is triggered
  3631. */
  3632. private _onchange;
  3633. /**
  3634. * The value of the path cursor
  3635. */
  3636. value: number;
  3637. /**
  3638. * The animation array of the path cursor
  3639. */
  3640. animations: Animation[];
  3641. /**
  3642. * Initializes the path cursor
  3643. * @param path The path to track
  3644. */
  3645. constructor(path: Path2);
  3646. /**
  3647. * Gets the cursor point on the path
  3648. * @returns A point on the path cursor at the cursor location
  3649. */
  3650. getPoint(): Vector3;
  3651. /**
  3652. * Moves the cursor ahead by the step amount
  3653. * @param step The amount to move the cursor forward
  3654. * @returns This path cursor
  3655. */
  3656. moveAhead(step?: number): PathCursor;
  3657. /**
  3658. * Moves the cursor behind by the step amount
  3659. * @param step The amount to move the cursor back
  3660. * @returns This path cursor
  3661. */
  3662. moveBack(step?: number): PathCursor;
  3663. /**
  3664. * Moves the cursor by the step amount
  3665. * If the step amount is greater than one, an exception is thrown
  3666. * @param step The amount to move the cursor
  3667. * @returns This path cursor
  3668. */
  3669. move(step: number): PathCursor;
  3670. /**
  3671. * Ensures that the value is limited between zero and one
  3672. * @returns This path cursor
  3673. */
  3674. private ensureLimits();
  3675. /**
  3676. * Runs onchange callbacks on change (used by the animation engine)
  3677. * @returns This path cursor
  3678. */
  3679. private raiseOnChange();
  3680. /**
  3681. * Executes a function on change
  3682. * @param f A path cursor onchange callback
  3683. * @returns This path cursor
  3684. */
  3685. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3686. }
  3687. /**
  3688. * Defines an interface which represents an animation key frame
  3689. */
  3690. interface IAnimationKey {
  3691. /**
  3692. * Frame of the key frame
  3693. */
  3694. frame: number;
  3695. /**
  3696. * Value at the specifies key frame
  3697. */
  3698. value: any;
  3699. /**
  3700. * The input tangent for the cubic hermite spline
  3701. */
  3702. inTangent?: any;
  3703. /**
  3704. * The output tangent for the cubic hermite spline
  3705. */
  3706. outTangent?: any;
  3707. /**
  3708. * The animation interpolation type
  3709. */
  3710. interpolation?: AnimationKeyInterpolation;
  3711. }
  3712. /**
  3713. * Enum for the animation key frame interpolation type
  3714. */
  3715. enum AnimationKeyInterpolation {
  3716. /**
  3717. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3718. */
  3719. STEP = 1,
  3720. }
  3721. /**
  3722. * Class used to store any kind of animation
  3723. */
  3724. class Animation {
  3725. /**Name of the animation */
  3726. name: string;
  3727. /**Property to animate */
  3728. targetProperty: string;
  3729. /**The frames per second of the animation */
  3730. framePerSecond: number;
  3731. /**The data type of the animation */
  3732. dataType: number;
  3733. /**The loop mode of the animation */
  3734. loopMode: number | undefined;
  3735. /**Specifies if blending should be enabled */
  3736. enableBlending: boolean | undefined;
  3737. /**
  3738. * Use matrix interpolation instead of using direct key value when animating matrices
  3739. */
  3740. static AllowMatricesInterpolation: boolean;
  3741. /**
  3742. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3743. */
  3744. static AllowMatrixDecomposeForInterpolation: boolean;
  3745. /**
  3746. * Stores the key frames of the animation
  3747. */
  3748. private _keys;
  3749. /**
  3750. * Stores the easing function of the animation
  3751. */
  3752. private _easingFunction;
  3753. /**
  3754. * @hidden Internal use only
  3755. */
  3756. _runtimeAnimations: RuntimeAnimation[];
  3757. /**
  3758. * The set of event that will be linked to this animation
  3759. */
  3760. private _events;
  3761. /**
  3762. * Stores an array of target property paths
  3763. */
  3764. targetPropertyPath: string[];
  3765. /**
  3766. * Stores the blending speed of the animation
  3767. */
  3768. blendingSpeed: number;
  3769. /**
  3770. * Stores the animation ranges for the animation
  3771. */
  3772. private _ranges;
  3773. /**
  3774. * @hidden Internal use
  3775. */
  3776. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3777. /**
  3778. * Sets up an animation
  3779. * @param property The property to animate
  3780. * @param animationType The animation type to apply
  3781. * @param framePerSecond The frames per second of the animation
  3782. * @param easingFunction The easing function used in the animation
  3783. * @returns The created animation
  3784. */
  3785. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3786. /**
  3787. * Create and start an animation on a node
  3788. * @param name defines the name of the global animation that will be run on all nodes
  3789. * @param node defines the root node where the animation will take place
  3790. * @param targetProperty defines property to animate
  3791. * @param framePerSecond defines the number of frame per second yo use
  3792. * @param totalFrame defines the number of frames in total
  3793. * @param from defines the initial value
  3794. * @param to defines the final value
  3795. * @param loopMode defines which loop mode you want to use (off by default)
  3796. * @param easingFunction defines the easing function to use (linear by default)
  3797. * @param onAnimationEnd defines the callback to call when animation end
  3798. * @returns the animatable created for this animation
  3799. */
  3800. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3801. /**
  3802. * Create and start an animation on a node and its descendants
  3803. * @param name defines the name of the global animation that will be run on all nodes
  3804. * @param node defines the root node where the animation will take place
  3805. * @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
  3806. * @param targetProperty defines property to animate
  3807. * @param framePerSecond defines the number of frame per second to use
  3808. * @param totalFrame defines the number of frames in total
  3809. * @param from defines the initial value
  3810. * @param to defines the final value
  3811. * @param loopMode defines which loop mode you want to use (off by default)
  3812. * @param easingFunction defines the easing function to use (linear by default)
  3813. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3814. * @returns the list of animatables created for all nodes
  3815. * @example https://www.babylonjs-playground.com/#MH0VLI
  3816. */
  3817. 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[]>;
  3818. /**
  3819. * Creates a new animation, merges it with the existing animations and starts it
  3820. * @param name Name of the animation
  3821. * @param node Node which contains the scene that begins the animations
  3822. * @param targetProperty Specifies which property to animate
  3823. * @param framePerSecond The frames per second of the animation
  3824. * @param totalFrame The total number of frames
  3825. * @param from The frame at the beginning of the animation
  3826. * @param to The frame at the end of the animation
  3827. * @param loopMode Specifies the loop mode of the animation
  3828. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3829. * @param onAnimationEnd Callback to run once the animation is complete
  3830. * @returns Nullable animation
  3831. */
  3832. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3833. /**
  3834. * Transition property of an host to the target Value
  3835. * @param property The property to transition
  3836. * @param targetValue The target Value of the property
  3837. * @param host The object where the property to animate belongs
  3838. * @param scene Scene used to run the animation
  3839. * @param frameRate Framerate (in frame/s) to use
  3840. * @param transition The transition type we want to use
  3841. * @param duration The duration of the animation, in milliseconds
  3842. * @param onAnimationEnd Callback trigger at the end of the animation
  3843. * @returns Nullable animation
  3844. */
  3845. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3846. /**
  3847. * Return the array of runtime animations currently using this animation
  3848. */
  3849. readonly runtimeAnimations: RuntimeAnimation[];
  3850. /**
  3851. * Specifies if any of the runtime animations are currently running
  3852. */
  3853. readonly hasRunningRuntimeAnimations: boolean;
  3854. /**
  3855. * Initializes the animation
  3856. * @param name Name of the animation
  3857. * @param targetProperty Property to animate
  3858. * @param framePerSecond The frames per second of the animation
  3859. * @param dataType The data type of the animation
  3860. * @param loopMode The loop mode of the animation
  3861. * @param enableBlendings Specifies if blending should be enabled
  3862. */
  3863. constructor(
  3864. /**Name of the animation */
  3865. name: string,
  3866. /**Property to animate */
  3867. targetProperty: string,
  3868. /**The frames per second of the animation */
  3869. framePerSecond: number,
  3870. /**The data type of the animation */
  3871. dataType: number,
  3872. /**The loop mode of the animation */
  3873. loopMode?: number | undefined,
  3874. /**Specifies if blending should be enabled */
  3875. enableBlending?: boolean | undefined);
  3876. /**
  3877. * Converts the animation to a string
  3878. * @param fullDetails support for multiple levels of logging within scene loading
  3879. * @returns String form of the animation
  3880. */
  3881. toString(fullDetails?: boolean): string;
  3882. /**
  3883. * Add an event to this animation
  3884. * @param event Event to add
  3885. */
  3886. addEvent(event: AnimationEvent): void;
  3887. /**
  3888. * Remove all events found at the given frame
  3889. * @param frame The frame to remove events from
  3890. */
  3891. removeEvents(frame: number): void;
  3892. /**
  3893. * Retrieves all the events from the animation
  3894. * @returns Events from the animation
  3895. */
  3896. getEvents(): AnimationEvent[];
  3897. /**
  3898. * Creates an animation range
  3899. * @param name Name of the animation range
  3900. * @param from Starting frame of the animation range
  3901. * @param to Ending frame of the animation
  3902. */
  3903. createRange(name: string, from: number, to: number): void;
  3904. /**
  3905. * Deletes an animation range by name
  3906. * @param name Name of the animation range to delete
  3907. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3908. */
  3909. deleteRange(name: string, deleteFrames?: boolean): void;
  3910. /**
  3911. * Gets the animation range by name, or null if not defined
  3912. * @param name Name of the animation range
  3913. * @returns Nullable animation range
  3914. */
  3915. getRange(name: string): Nullable<AnimationRange>;
  3916. /**
  3917. * Gets the key frames from the animation
  3918. * @returns The key frames of the animation
  3919. */
  3920. getKeys(): Array<IAnimationKey>;
  3921. /**
  3922. * Gets the highest frame rate of the animation
  3923. * @returns Highest frame rate of the animation
  3924. */
  3925. getHighestFrame(): number;
  3926. /**
  3927. * Gets the easing function of the animation
  3928. * @returns Easing function of the animation
  3929. */
  3930. getEasingFunction(): IEasingFunction;
  3931. /**
  3932. * Sets the easing function of the animation
  3933. * @param easingFunction A custom mathematical formula for animation
  3934. */
  3935. setEasingFunction(easingFunction: EasingFunction): void;
  3936. /**
  3937. * Interpolates a scalar linearly
  3938. * @param startValue Start value of the animation curve
  3939. * @param endValue End value of the animation curve
  3940. * @param gradient Scalar amount to interpolate
  3941. * @returns Interpolated scalar value
  3942. */
  3943. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3944. /**
  3945. * Interpolates a scalar cubically
  3946. * @param startValue Start value of the animation curve
  3947. * @param outTangent End tangent of the animation
  3948. * @param endValue End value of the animation curve
  3949. * @param inTangent Start tangent of the animation curve
  3950. * @param gradient Scalar amount to interpolate
  3951. * @returns Interpolated scalar value
  3952. */
  3953. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3954. /**
  3955. * Interpolates a quaternion using a spherical linear interpolation
  3956. * @param startValue Start value of the animation curve
  3957. * @param endValue End value of the animation curve
  3958. * @param gradient Scalar amount to interpolate
  3959. * @returns Interpolated quaternion value
  3960. */
  3961. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3962. /**
  3963. * Interpolates a quaternion cubically
  3964. * @param startValue Start value of the animation curve
  3965. * @param outTangent End tangent of the animation curve
  3966. * @param endValue End value of the animation curve
  3967. * @param inTangent Start tangent of the animation curve
  3968. * @param gradient Scalar amount to interpolate
  3969. * @returns Interpolated quaternion value
  3970. */
  3971. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3972. /**
  3973. * Interpolates a Vector3 linearl
  3974. * @param startValue Start value of the animation curve
  3975. * @param endValue End value of the animation curve
  3976. * @param gradient Scalar amount to interpolate
  3977. * @returns Interpolated scalar value
  3978. */
  3979. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3980. /**
  3981. * Interpolates a Vector3 cubically
  3982. * @param startValue Start value of the animation curve
  3983. * @param outTangent End tangent of the animation
  3984. * @param endValue End value of the animation curve
  3985. * @param inTangent Start tangent of the animation curve
  3986. * @param gradient Scalar amount to interpolate
  3987. * @returns InterpolatedVector3 value
  3988. */
  3989. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3990. /**
  3991. * Interpolates a Vector2 linearly
  3992. * @param startValue Start value of the animation curve
  3993. * @param endValue End value of the animation curve
  3994. * @param gradient Scalar amount to interpolate
  3995. * @returns Interpolated Vector2 value
  3996. */
  3997. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3998. /**
  3999. * Interpolates a Vector2 cubically
  4000. * @param startValue Start value of the animation curve
  4001. * @param outTangent End tangent of the animation
  4002. * @param endValue End value of the animation curve
  4003. * @param inTangent Start tangent of the animation curve
  4004. * @param gradient Scalar amount to interpolate
  4005. * @returns Interpolated Vector2 value
  4006. */
  4007. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4008. /**
  4009. * Interpolates a size linearly
  4010. * @param startValue Start value of the animation curve
  4011. * @param endValue End value of the animation curve
  4012. * @param gradient Scalar amount to interpolate
  4013. * @returns Interpolated Size value
  4014. */
  4015. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4016. /**
  4017. * Interpolates a Color3 linearly
  4018. * @param startValue Start value of the animation curve
  4019. * @param endValue End value of the animation curve
  4020. * @param gradient Scalar amount to interpolate
  4021. * @returns Interpolated Color3 value
  4022. */
  4023. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4024. /**
  4025. * @hidden Internal use only
  4026. */
  4027. _getKeyValue(value: any): any;
  4028. /**
  4029. * @hidden Internal use only
  4030. */
  4031. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4032. /**
  4033. * Defines the function to use to interpolate matrices
  4034. * @param startValue defines the start matrix
  4035. * @param endValue defines the end matrix
  4036. * @param gradient defines the gradient between both matrices
  4037. * @param result defines an optional target matrix where to store the interpolation
  4038. * @returns the interpolated matrix
  4039. */
  4040. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4041. /**
  4042. * Makes a copy of the animation
  4043. * @returns Cloned animation
  4044. */
  4045. clone(): Animation;
  4046. /**
  4047. * Sets the key frames of the animation
  4048. * @param values The animation key frames to set
  4049. */
  4050. setKeys(values: Array<IAnimationKey>): void;
  4051. /**
  4052. * Serializes the animation to an object
  4053. * @returns Serialized object
  4054. */
  4055. serialize(): any;
  4056. /**
  4057. * Float animation type
  4058. */
  4059. private static _ANIMATIONTYPE_FLOAT;
  4060. /**
  4061. * Vector3 animation type
  4062. */
  4063. private static _ANIMATIONTYPE_VECTOR3;
  4064. /**
  4065. * Quaternion animation type
  4066. */
  4067. private static _ANIMATIONTYPE_QUATERNION;
  4068. /**
  4069. * Matrix animation type
  4070. */
  4071. private static _ANIMATIONTYPE_MATRIX;
  4072. /**
  4073. * Color3 animation type
  4074. */
  4075. private static _ANIMATIONTYPE_COLOR3;
  4076. /**
  4077. * Vector2 animation type
  4078. */
  4079. private static _ANIMATIONTYPE_VECTOR2;
  4080. /**
  4081. * Size animation type
  4082. */
  4083. private static _ANIMATIONTYPE_SIZE;
  4084. /**
  4085. * Relative Loop Mode
  4086. */
  4087. private static _ANIMATIONLOOPMODE_RELATIVE;
  4088. /**
  4089. * Cycle Loop Mode
  4090. */
  4091. private static _ANIMATIONLOOPMODE_CYCLE;
  4092. /**
  4093. * Constant Loop Mode
  4094. */
  4095. private static _ANIMATIONLOOPMODE_CONSTANT;
  4096. /**
  4097. * Get the float animation type
  4098. */
  4099. static readonly ANIMATIONTYPE_FLOAT: number;
  4100. /**
  4101. * Get the Vector3 animation type
  4102. */
  4103. static readonly ANIMATIONTYPE_VECTOR3: number;
  4104. /**
  4105. * Get the Vectpr2 animation type
  4106. */
  4107. static readonly ANIMATIONTYPE_VECTOR2: number;
  4108. /**
  4109. * Get the Size animation type
  4110. */
  4111. static readonly ANIMATIONTYPE_SIZE: number;
  4112. /**
  4113. * Get the Quaternion animation type
  4114. */
  4115. static readonly ANIMATIONTYPE_QUATERNION: number;
  4116. /**
  4117. * Get the Matrix animation type
  4118. */
  4119. static readonly ANIMATIONTYPE_MATRIX: number;
  4120. /**
  4121. * Get the Color3 animation type
  4122. */
  4123. static readonly ANIMATIONTYPE_COLOR3: number;
  4124. /**
  4125. * Get the Relative Loop Mode
  4126. */
  4127. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4128. /**
  4129. * Get the Cycle Loop Mode
  4130. */
  4131. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4132. /**
  4133. * Get the Constant Loop Mode
  4134. */
  4135. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4136. /** @hidden */
  4137. static _UniversalLerp(left: any, right: any, amount: number): any;
  4138. /**
  4139. * Parses an animation object and creates an animation
  4140. * @param parsedAnimation Parsed animation object
  4141. * @returns Animation object
  4142. */
  4143. static Parse(parsedAnimation: any): Animation;
  4144. /**
  4145. * Appends the serialized animations from the source animations
  4146. * @param source Source containing the animations
  4147. * @param destination Target to store the animations
  4148. */
  4149. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4150. }
  4151. }
  4152. declare module BABYLON {
  4153. /**
  4154. * This class defines the direct association between an animation and a target
  4155. */
  4156. class TargetedAnimation {
  4157. animation: Animation;
  4158. target: any;
  4159. }
  4160. /**
  4161. * Use this class to create coordinated animations on multiple targets
  4162. */
  4163. class AnimationGroup implements IDisposable {
  4164. name: string;
  4165. private _scene;
  4166. private _targetedAnimations;
  4167. private _animatables;
  4168. private _from;
  4169. private _to;
  4170. private _isStarted;
  4171. private _speedRatio;
  4172. onAnimationEndObservable: Observable<TargetedAnimation>;
  4173. /**
  4174. * This observable will notify when all animations have ended.
  4175. */
  4176. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4177. /**
  4178. * Gets the first frame
  4179. */
  4180. readonly from: number;
  4181. /**
  4182. * Gets the last frame
  4183. */
  4184. readonly to: number;
  4185. /**
  4186. * Define if the animations are started
  4187. */
  4188. readonly isStarted: boolean;
  4189. /**
  4190. * Gets or sets the speed ratio to use for all animations
  4191. */
  4192. /**
  4193. * Gets or sets the speed ratio to use for all animations
  4194. */
  4195. speedRatio: number;
  4196. /**
  4197. * Gets the targeted animations for this animation group
  4198. */
  4199. readonly targetedAnimations: Array<TargetedAnimation>;
  4200. /**
  4201. * returning the list of animatables controlled by this animation group.
  4202. */
  4203. readonly animatables: Array<Animatable>;
  4204. constructor(name: string, scene?: Nullable<Scene>);
  4205. /**
  4206. * Add an animation (with its target) in the group
  4207. * @param animation defines the animation we want to add
  4208. * @param target defines the target of the animation
  4209. * @returns the {BABYLON.TargetedAnimation} object
  4210. */
  4211. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4212. /**
  4213. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4214. * It can add constant keys at begin or end
  4215. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4216. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4217. */
  4218. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4219. /**
  4220. * Start all animations on given targets
  4221. * @param loop defines if animations must loop
  4222. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4223. * @param from defines the from key (optional)
  4224. * @param to defines the to key (optional)
  4225. * @returns the current animation group
  4226. */
  4227. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4228. /**
  4229. * Pause all animations
  4230. */
  4231. pause(): AnimationGroup;
  4232. /**
  4233. * Play all animations to initial state
  4234. * This function will start() the animations if they were not started or will restart() them if they were paused
  4235. * @param loop defines if animations must loop
  4236. */
  4237. play(loop?: boolean): AnimationGroup;
  4238. /**
  4239. * Reset all animations to initial state
  4240. */
  4241. reset(): AnimationGroup;
  4242. /**
  4243. * Restart animations from key 0
  4244. */
  4245. restart(): AnimationGroup;
  4246. /**
  4247. * Stop all animations
  4248. */
  4249. stop(): AnimationGroup;
  4250. /**
  4251. * Set animation weight for all animatables
  4252. * @param weight defines the weight to use
  4253. * @return the animationGroup
  4254. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4255. */
  4256. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4257. /**
  4258. * Synchronize and normalize all animatables with a source animatable
  4259. * @param root defines the root animatable to synchronize with
  4260. * @return the animationGroup
  4261. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4262. */
  4263. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4264. /**
  4265. * Goes to a specific frame in this animation group
  4266. * @param frame the frame number to go to
  4267. * @return the animationGroup
  4268. */
  4269. goToFrame(frame: number): AnimationGroup;
  4270. /**
  4271. * Dispose all associated resources
  4272. */
  4273. dispose(): void;
  4274. private _checkAnimationGroupEnded(animatable);
  4275. }
  4276. }
  4277. declare module BABYLON {
  4278. /**
  4279. * Class used to override all child animations of a given target
  4280. */
  4281. class AnimationPropertiesOverride {
  4282. /**
  4283. * Gets or sets a value indicating if animation blending must be used
  4284. */
  4285. enableBlending: boolean;
  4286. /**
  4287. * Gets or sets the blending speed to use when enableBlending is true
  4288. */
  4289. blendingSpeed: number;
  4290. /**
  4291. * Gets or sets the default loop mode to use
  4292. */
  4293. loopMode: number;
  4294. }
  4295. }
  4296. declare module BABYLON {
  4297. interface IEasingFunction {
  4298. ease(gradient: number): number;
  4299. }
  4300. class EasingFunction implements IEasingFunction {
  4301. private static _EASINGMODE_EASEIN;
  4302. private static _EASINGMODE_EASEOUT;
  4303. private static _EASINGMODE_EASEINOUT;
  4304. static readonly EASINGMODE_EASEIN: number;
  4305. static readonly EASINGMODE_EASEOUT: number;
  4306. static readonly EASINGMODE_EASEINOUT: number;
  4307. private _easingMode;
  4308. setEasingMode(easingMode: number): void;
  4309. getEasingMode(): number;
  4310. easeInCore(gradient: number): number;
  4311. ease(gradient: number): number;
  4312. }
  4313. class CircleEase extends EasingFunction implements IEasingFunction {
  4314. easeInCore(gradient: number): number;
  4315. }
  4316. class BackEase extends EasingFunction implements IEasingFunction {
  4317. amplitude: number;
  4318. constructor(amplitude?: number);
  4319. easeInCore(gradient: number): number;
  4320. }
  4321. class BounceEase extends EasingFunction implements IEasingFunction {
  4322. bounces: number;
  4323. bounciness: number;
  4324. constructor(bounces?: number, bounciness?: number);
  4325. easeInCore(gradient: number): number;
  4326. }
  4327. class CubicEase extends EasingFunction implements IEasingFunction {
  4328. easeInCore(gradient: number): number;
  4329. }
  4330. class ElasticEase extends EasingFunction implements IEasingFunction {
  4331. oscillations: number;
  4332. springiness: number;
  4333. constructor(oscillations?: number, springiness?: number);
  4334. easeInCore(gradient: number): number;
  4335. }
  4336. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4337. exponent: number;
  4338. constructor(exponent?: number);
  4339. easeInCore(gradient: number): number;
  4340. }
  4341. class PowerEase extends EasingFunction implements IEasingFunction {
  4342. power: number;
  4343. constructor(power?: number);
  4344. easeInCore(gradient: number): number;
  4345. }
  4346. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4347. easeInCore(gradient: number): number;
  4348. }
  4349. class QuarticEase extends EasingFunction implements IEasingFunction {
  4350. easeInCore(gradient: number): number;
  4351. }
  4352. class QuinticEase extends EasingFunction implements IEasingFunction {
  4353. easeInCore(gradient: number): number;
  4354. }
  4355. class SineEase extends EasingFunction implements IEasingFunction {
  4356. easeInCore(gradient: number): number;
  4357. }
  4358. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4359. x1: number;
  4360. y1: number;
  4361. x2: number;
  4362. y2: number;
  4363. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4364. easeInCore(gradient: number): number;
  4365. }
  4366. }
  4367. declare module BABYLON {
  4368. /**
  4369. * Defines a runtime animation
  4370. */
  4371. class RuntimeAnimation {
  4372. private _events;
  4373. /**
  4374. * The current frame of the runtime animation
  4375. */
  4376. private _currentFrame;
  4377. /**
  4378. * The animation used by the runtime animation
  4379. */
  4380. private _animation;
  4381. /**
  4382. * The target of the runtime animation
  4383. */
  4384. private _target;
  4385. /**
  4386. * The initiating animatable
  4387. */
  4388. private _host;
  4389. /**
  4390. * The original value of the runtime animation
  4391. */
  4392. private _originalValue;
  4393. /**
  4394. * The original blend value of the runtime animation
  4395. */
  4396. private _originalBlendValue;
  4397. /**
  4398. * The offsets cache of the runtime animation
  4399. */
  4400. private _offsetsCache;
  4401. /**
  4402. * The high limits cache of the runtime animation
  4403. */
  4404. private _highLimitsCache;
  4405. /**
  4406. * Specifies if the runtime animation has been stopped
  4407. */
  4408. private _stopped;
  4409. /**
  4410. * The blending factor of the runtime animation
  4411. */
  4412. private _blendingFactor;
  4413. /**
  4414. * The BabylonJS scene
  4415. */
  4416. private _scene;
  4417. /**
  4418. * The current value of the runtime animation
  4419. */
  4420. private _currentValue;
  4421. /** @hidden */
  4422. _workValue: any;
  4423. /**
  4424. * The active target of the runtime animation
  4425. */
  4426. private _activeTarget;
  4427. /**
  4428. * The target path of the runtime animation
  4429. */
  4430. private _targetPath;
  4431. /**
  4432. * The weight of the runtime animation
  4433. */
  4434. private _weight;
  4435. /**
  4436. * The ratio offset of the runtime animation
  4437. */
  4438. private _ratioOffset;
  4439. /**
  4440. * The previous delay of the runtime animation
  4441. */
  4442. private _previousDelay;
  4443. /**
  4444. * The previous ratio of the runtime animation
  4445. */
  4446. private _previousRatio;
  4447. /**
  4448. * Gets the current frame of the runtime animation
  4449. */
  4450. readonly currentFrame: number;
  4451. /**
  4452. * Gets the weight of the runtime animation
  4453. */
  4454. readonly weight: number;
  4455. /**
  4456. * Gets the current value of the runtime animation
  4457. */
  4458. readonly currentValue: any;
  4459. /**
  4460. * Gets the target path of the runtime animation
  4461. */
  4462. readonly targetPath: string;
  4463. /**
  4464. * Gets the actual target of the runtime animation
  4465. */
  4466. readonly target: any;
  4467. /**
  4468. * Create a new RuntimeAnimation object
  4469. * @param target defines the target of the animation
  4470. * @param animation defines the source animation object
  4471. * @param scene defines the hosting scene
  4472. * @param host defines the initiating Animatable
  4473. */
  4474. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4475. /**
  4476. * Gets the animation from the runtime animation
  4477. */
  4478. readonly animation: Animation;
  4479. /**
  4480. * Resets the runtime animation to the beginning
  4481. * @param restoreOriginal defines whether to restore the target property to the original value
  4482. */
  4483. reset(restoreOriginal?: boolean): void;
  4484. /**
  4485. * Specifies if the runtime animation is stopped
  4486. * @returns Boolean specifying if the runtime animation is stopped
  4487. */
  4488. isStopped(): boolean;
  4489. /**
  4490. * Disposes of the runtime animation
  4491. */
  4492. dispose(): void;
  4493. /**
  4494. * Interpolates the animation from the current frame
  4495. * @param currentFrame The frame to interpolate the animation to
  4496. * @param repeatCount The number of times that the animation should loop
  4497. * @param loopMode The type of looping mode to use
  4498. * @param offsetValue Animation offset value
  4499. * @param highLimitValue The high limit value
  4500. * @returns The interpolated value
  4501. */
  4502. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4503. /**
  4504. * Apply the interpolated value to the target
  4505. * @param currentValue defines the value computed by the animation
  4506. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4507. */
  4508. setValue(currentValue: any, weight?: number): void;
  4509. private _setValue(target, currentValue, weight, targetIndex?);
  4510. /**
  4511. * Gets the loop pmode of the runtime animation
  4512. * @returns Loop Mode
  4513. */
  4514. private _getCorrectLoopMode();
  4515. /**
  4516. * Move the current animation to a given frame
  4517. * @param frame defines the frame to move to
  4518. */
  4519. goToFrame(frame: number): void;
  4520. /**
  4521. * @hidden Internal use only
  4522. */
  4523. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4524. /**
  4525. * Execute the current animation
  4526. * @param delay defines the delay to add to the current frame
  4527. * @param from defines the lower bound of the animation range
  4528. * @param to defines the upper bound of the animation range
  4529. * @param loop defines if the current animation must loop
  4530. * @param speedRatio defines the current speed ratio
  4531. * @param weight defines the weight of the animation (default is -1 so no weight)
  4532. * @returns a boolean indicating if the animation has ended
  4533. */
  4534. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4535. }
  4536. }
  4537. declare module BABYLON {
  4538. /**
  4539. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4541. */
  4542. class Analyser {
  4543. /**
  4544. * Gets or sets the smoothing
  4545. * @ignorenaming
  4546. */
  4547. SMOOTHING: number;
  4548. /**
  4549. * Gets or sets the FFT table size
  4550. * @ignorenaming
  4551. */
  4552. FFT_SIZE: number;
  4553. /**
  4554. * Gets or sets the bar graph amplitude
  4555. * @ignorenaming
  4556. */
  4557. BARGRAPHAMPLITUDE: number;
  4558. /**
  4559. * Gets or sets the position of the debug canvas
  4560. * @ignorenaming
  4561. */
  4562. DEBUGCANVASPOS: {
  4563. x: number;
  4564. y: number;
  4565. };
  4566. /**
  4567. * Gets or sets the debug canvas size
  4568. * @ignorenaming
  4569. */
  4570. DEBUGCANVASSIZE: {
  4571. width: number;
  4572. height: number;
  4573. };
  4574. private _byteFreqs;
  4575. private _byteTime;
  4576. private _floatFreqs;
  4577. private _webAudioAnalyser;
  4578. private _debugCanvas;
  4579. private _debugCanvasContext;
  4580. private _scene;
  4581. private _registerFunc;
  4582. private _audioEngine;
  4583. /**
  4584. * Creates a new analyser
  4585. * @param scene defines hosting scene
  4586. */
  4587. constructor(scene: Scene);
  4588. /**
  4589. * Get the number of data values you will have to play with for the visualization
  4590. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4591. * @returns a number
  4592. */
  4593. getFrequencyBinCount(): number;
  4594. /**
  4595. * Gets the current frequency data as a byte array
  4596. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4597. * @returns a Uint8Array
  4598. */
  4599. getByteFrequencyData(): Uint8Array;
  4600. /**
  4601. * Gets the current waveform as a byte array
  4602. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4603. * @returns a Uint8Array
  4604. */
  4605. getByteTimeDomainData(): Uint8Array;
  4606. /**
  4607. * Gets the current frequency data as a float array
  4608. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4609. * @returns a Float32Array
  4610. */
  4611. getFloatFrequencyData(): Float32Array;
  4612. /**
  4613. * Renders the debug canvas
  4614. */
  4615. drawDebugCanvas(): void;
  4616. /**
  4617. * Stops rendering the debug canvas and removes it
  4618. */
  4619. stopDebugCanvas(): void;
  4620. /**
  4621. * Connects two audio nodes
  4622. * @param inputAudioNode defines first node to connect
  4623. * @param outputAudioNode defines second node to connect
  4624. */
  4625. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4626. /**
  4627. * Releases all associated resources
  4628. */
  4629. dispose(): void;
  4630. }
  4631. }
  4632. declare module BABYLON {
  4633. class AudioEngine {
  4634. private _audioContext;
  4635. private _audioContextInitialized;
  4636. canUseWebAudio: boolean;
  4637. masterGain: GainNode;
  4638. private _connectedAnalyser;
  4639. WarnedWebAudioUnsupported: boolean;
  4640. unlocked: boolean;
  4641. onAudioUnlocked: () => any;
  4642. isMP3supported: boolean;
  4643. isOGGsupported: boolean;
  4644. readonly audioContext: Nullable<AudioContext>;
  4645. constructor();
  4646. private _unlockiOSaudio();
  4647. private _initializeAudioContext();
  4648. dispose(): void;
  4649. getGlobalVolume(): number;
  4650. setGlobalVolume(newVolume: number): void;
  4651. connectToAnalyser(analyser: Analyser): void;
  4652. }
  4653. }
  4654. declare module BABYLON {
  4655. class Sound {
  4656. name: string;
  4657. autoplay: boolean;
  4658. loop: boolean;
  4659. useCustomAttenuation: boolean;
  4660. soundTrackId: number;
  4661. spatialSound: boolean;
  4662. refDistance: number;
  4663. rolloffFactor: number;
  4664. maxDistance: number;
  4665. distanceModel: string;
  4666. private _panningModel;
  4667. onended: () => any;
  4668. private _playbackRate;
  4669. private _streaming;
  4670. private _startTime;
  4671. private _startOffset;
  4672. private _position;
  4673. private _localDirection;
  4674. private _volume;
  4675. private _isReadyToPlay;
  4676. isPlaying: boolean;
  4677. isPaused: boolean;
  4678. private _isDirectional;
  4679. private _readyToPlayCallback;
  4680. private _audioBuffer;
  4681. private _soundSource;
  4682. private _streamingSource;
  4683. private _soundPanner;
  4684. private _soundGain;
  4685. private _inputAudioNode;
  4686. private _ouputAudioNode;
  4687. private _coneInnerAngle;
  4688. private _coneOuterAngle;
  4689. private _coneOuterGain;
  4690. private _scene;
  4691. private _connectedMesh;
  4692. private _customAttenuationFunction;
  4693. private _registerFunc;
  4694. private _isOutputConnected;
  4695. private _htmlAudioElement;
  4696. private _urlType;
  4697. /**
  4698. * Create a sound and attach it to a scene
  4699. * @param name Name of your sound
  4700. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4701. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4702. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4703. */
  4704. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4705. dispose(): void;
  4706. isReady(): boolean;
  4707. private _soundLoaded(audioData);
  4708. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4709. updateOptions(options: any): void;
  4710. private _createSpatialParameters();
  4711. private _updateSpatialParameters();
  4712. switchPanningModelToHRTF(): void;
  4713. switchPanningModelToEqualPower(): void;
  4714. private _switchPanningModel();
  4715. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4716. /**
  4717. * Transform this sound into a directional source
  4718. * @param coneInnerAngle Size of the inner cone in degree
  4719. * @param coneOuterAngle Size of the outer cone in degree
  4720. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4721. */
  4722. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4723. setPosition(newPosition: Vector3): void;
  4724. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4725. private _updateDirection();
  4726. updateDistanceFromListener(): void;
  4727. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4728. /**
  4729. * Play the sound
  4730. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4731. * @param offset (optional) Start the sound setting it at a specific time
  4732. */
  4733. play(time?: number, offset?: number): void;
  4734. private _onended();
  4735. /**
  4736. * Stop the sound
  4737. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4738. */
  4739. stop(time?: number): void;
  4740. pause(): void;
  4741. setVolume(newVolume: number, time?: number): void;
  4742. setPlaybackRate(newPlaybackRate: number): void;
  4743. getVolume(): number;
  4744. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4745. detachFromMesh(): void;
  4746. private _onRegisterAfterWorldMatrixUpdate(node);
  4747. clone(): Nullable<Sound>;
  4748. getAudioBuffer(): AudioBuffer | null;
  4749. serialize(): any;
  4750. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4751. }
  4752. }
  4753. declare module BABYLON {
  4754. class SoundTrack {
  4755. private _outputAudioNode;
  4756. private _scene;
  4757. id: number;
  4758. soundCollection: Array<Sound>;
  4759. private _isMainTrack;
  4760. private _connectedAnalyser;
  4761. private _options;
  4762. private _isInitialized;
  4763. constructor(scene: Scene, options?: any);
  4764. private _initializeSoundTrackAudioGraph();
  4765. dispose(): void;
  4766. AddSound(sound: Sound): void;
  4767. RemoveSound(sound: Sound): void;
  4768. setVolume(newVolume: number): void;
  4769. switchPanningModelToHRTF(): void;
  4770. switchPanningModelToEqualPower(): void;
  4771. connectToAnalyser(analyser: Analyser): void;
  4772. }
  4773. }
  4774. declare module BABYLON {
  4775. /**
  4776. * Interface used to define a behavior
  4777. */
  4778. interface Behavior<T> {
  4779. /** gets or sets behavior's name */
  4780. name: string;
  4781. /**
  4782. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4783. */
  4784. init(): void;
  4785. /**
  4786. * Called when the behavior is attached to a target
  4787. * @param target defines the target where the behavior is attached to
  4788. */
  4789. attach(target: T): void;
  4790. /**
  4791. * Called when the behavior is detached from its target
  4792. */
  4793. detach(): void;
  4794. }
  4795. /**
  4796. * Interface implemented by classes supporting behaviors
  4797. */
  4798. interface IBehaviorAware<T> {
  4799. /**
  4800. * Attach a behavior
  4801. * @param behavior defines the behavior to attach
  4802. * @returns the current host
  4803. */
  4804. addBehavior(behavior: Behavior<T>): T;
  4805. /**
  4806. * Remove a behavior from the current object
  4807. * @param behavior defines the behavior to detach
  4808. * @returns the current host
  4809. */
  4810. removeBehavior(behavior: Behavior<T>): T;
  4811. /**
  4812. * Gets a behavior using its name to search
  4813. * @param name defines the name to search
  4814. * @returns the behavior or null if not found
  4815. */
  4816. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4817. }
  4818. }
  4819. declare module BABYLON {
  4820. /**
  4821. * Class used to store bone information
  4822. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4823. */
  4824. class Bone extends Node {
  4825. /**
  4826. * defines the bone name
  4827. */
  4828. name: string;
  4829. private static _tmpVecs;
  4830. private static _tmpQuat;
  4831. private static _tmpMats;
  4832. /**
  4833. * Gets the list of child bones
  4834. */
  4835. children: Bone[];
  4836. /** Gets the animations associated with this bone */
  4837. animations: Animation[];
  4838. /**
  4839. * Gets or sets bone length
  4840. */
  4841. length: number;
  4842. /**
  4843. * @hidden Internal only
  4844. * Set this value to map this bone to a different index in the transform matrices
  4845. * Set this value to -1 to exclude the bone from the transform matrices
  4846. */
  4847. _index: Nullable<number>;
  4848. private _skeleton;
  4849. private _localMatrix;
  4850. private _restPose;
  4851. private _baseMatrix;
  4852. private _absoluteTransform;
  4853. private _invertedAbsoluteTransform;
  4854. private _parent;
  4855. private _scalingDeterminant;
  4856. private _worldTransform;
  4857. private _localScaling;
  4858. private _localRotation;
  4859. private _localPosition;
  4860. private _needToDecompose;
  4861. private _needToCompose;
  4862. /** @hidden */
  4863. /** @hidden */
  4864. _matrix: Matrix;
  4865. /**
  4866. * Create a new bone
  4867. * @param name defines the bone name
  4868. * @param skeleton defines the parent skeleton
  4869. * @param parentBone defines the parent (can be null if the bone is the root)
  4870. * @param localMatrix defines the local matrix
  4871. * @param restPose defines the rest pose matrix
  4872. * @param baseMatrix defines the base matrix
  4873. * @param index defines index of the bone in the hiearchy
  4874. */
  4875. constructor(
  4876. /**
  4877. * defines the bone name
  4878. */
  4879. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4880. /**
  4881. * Gets the parent skeleton
  4882. * @returns a skeleton
  4883. */
  4884. getSkeleton(): Skeleton;
  4885. /**
  4886. * Gets parent bone
  4887. * @returns a bone or null if the bone is the root of the bone hierarchy
  4888. */
  4889. getParent(): Nullable<Bone>;
  4890. /**
  4891. * Sets the parent bone
  4892. * @param parent defines the parent (can be null if the bone is the root)
  4893. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4894. */
  4895. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4896. /**
  4897. * Gets the local matrix
  4898. * @returns a matrix
  4899. */
  4900. getLocalMatrix(): Matrix;
  4901. /**
  4902. * Gets the base matrix (initial matrix which remains unchanged)
  4903. * @returns a matrix
  4904. */
  4905. getBaseMatrix(): Matrix;
  4906. /**
  4907. * Gets the rest pose matrix
  4908. * @returns a matrix
  4909. */
  4910. getRestPose(): Matrix;
  4911. /**
  4912. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4913. */
  4914. getWorldMatrix(): Matrix;
  4915. /**
  4916. * Sets the local matrix to rest pose matrix
  4917. */
  4918. returnToRest(): void;
  4919. /**
  4920. * Gets the inverse of the absolute transform matrix.
  4921. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4922. * @returns a matrix
  4923. */
  4924. getInvertedAbsoluteTransform(): Matrix;
  4925. /**
  4926. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4927. * @returns a matrix
  4928. */
  4929. getAbsoluteTransform(): Matrix;
  4930. /** Gets or sets current position (in local space) */
  4931. position: Vector3;
  4932. /** Gets or sets current rotation (in local space) */
  4933. rotation: Vector3;
  4934. /** Gets or sets current rotation quaternion (in local space) */
  4935. rotationQuaternion: Quaternion;
  4936. /** Gets or sets current scaling (in local space) */
  4937. scaling: Vector3;
  4938. /**
  4939. * Gets the animation properties override
  4940. */
  4941. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4942. private _decompose();
  4943. private _compose();
  4944. /**
  4945. * Update the base and local matrices
  4946. * @param matrix defines the new base or local matrix
  4947. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4948. * @param updateLocalMatrix defines if the local matrix should be updated
  4949. */
  4950. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4951. /** @hidden */
  4952. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  4953. /**
  4954. * Flag the bone as dirty (Forcing it to update everything)
  4955. */
  4956. markAsDirty(): void;
  4957. private _markAsDirtyAndCompose();
  4958. private _markAsDirtyAndDecompose();
  4959. /**
  4960. * Copy an animation range from another bone
  4961. * @param source defines the source bone
  4962. * @param rangeName defines the range name to copy
  4963. * @param frameOffset defines the frame offset
  4964. * @param rescaleAsRequired defines if rescaling must be applied if required
  4965. * @param skelDimensionsRatio defines the scaling ratio
  4966. * @returns true if operation was successful
  4967. */
  4968. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4969. /**
  4970. * Translate the bone in local or world space
  4971. * @param vec The amount to translate the bone
  4972. * @param space The space that the translation is in
  4973. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4974. */
  4975. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4976. /**
  4977. * Set the postion of the bone in local or world space
  4978. * @param position The position to set the bone
  4979. * @param space The space that the position is in
  4980. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4981. */
  4982. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4983. /**
  4984. * Set the absolute position of the bone (world space)
  4985. * @param position The position to set the bone
  4986. * @param mesh The mesh that this bone is attached to
  4987. */
  4988. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4989. /**
  4990. * Scale the bone on the x, y and z axes (in local space)
  4991. * @param x The amount to scale the bone on the x axis
  4992. * @param y The amount to scale the bone on the y axis
  4993. * @param z The amount to scale the bone on the z axis
  4994. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4995. */
  4996. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4997. /**
  4998. * Set the bone scaling in local space
  4999. * @param scale defines the scaling vector
  5000. */
  5001. setScale(scale: Vector3): void;
  5002. /**
  5003. * Gets the current scaling in local space
  5004. * @returns the current scaling vector
  5005. */
  5006. getScale(): Vector3;
  5007. /**
  5008. * Gets the current scaling in local space and stores it in a target vector
  5009. * @param result defines the target vector
  5010. */
  5011. getScaleToRef(result: Vector3): void;
  5012. /**
  5013. * Set the yaw, pitch, and roll of the bone in local or world space
  5014. * @param yaw The rotation of the bone on the y axis
  5015. * @param pitch The rotation of the bone on the x axis
  5016. * @param roll The rotation of the bone on the z axis
  5017. * @param space The space that the axes of rotation are in
  5018. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5019. */
  5020. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  5021. /**
  5022. * Add a rotation to the bone on an axis in local or world space
  5023. * @param axis The axis to rotate the bone on
  5024. * @param amount The amount to rotate the bone
  5025. * @param space The space that the axis is in
  5026. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5027. */
  5028. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  5029. /**
  5030. * Set the rotation of the bone to a particular axis angle in local or world space
  5031. * @param axis The axis to rotate the bone on
  5032. * @param angle The angle that the bone should be rotated to
  5033. * @param space The space that the axis is in
  5034. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5035. */
  5036. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  5037. /**
  5038. * Set the euler rotation of the bone in local of world space
  5039. * @param rotation The euler rotation that the bone should be set to
  5040. * @param space The space that the rotation is in
  5041. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5042. */
  5043. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5044. /**
  5045. * Set the quaternion rotation of the bone in local of world space
  5046. * @param quat The quaternion rotation that the bone should be set to
  5047. * @param space The space that the rotation is in
  5048. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5049. */
  5050. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  5051. /**
  5052. * Set the rotation matrix of the bone in local of world space
  5053. * @param rotMat The rotation matrix that the bone should be set to
  5054. * @param space The space that the rotation is in
  5055. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5056. */
  5057. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  5058. private _rotateWithMatrix(rmat, space?, mesh?);
  5059. private _getNegativeRotationToRef(rotMatInv, mesh?);
  5060. /**
  5061. * Get the position of the bone in local or world space
  5062. * @param space The space that the returned position is in
  5063. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5064. * @returns The position of the bone
  5065. */
  5066. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5067. /**
  5068. * Copy the position of the bone to a vector3 in local or world space
  5069. * @param space The space that the returned position is in
  5070. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5071. * @param result The vector3 to copy the position to
  5072. */
  5073. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  5074. /**
  5075. * Get the absolute position of the bone (world space)
  5076. * @param mesh The mesh that this bone is attached to
  5077. * @returns The absolute position of the bone
  5078. */
  5079. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  5080. /**
  5081. * Copy the absolute position of the bone (world space) to the result param
  5082. * @param mesh The mesh that this bone is attached to
  5083. * @param result The vector3 to copy the absolute position to
  5084. */
  5085. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  5086. /**
  5087. * Compute the absolute transforms of this bone and its children
  5088. */
  5089. computeAbsoluteTransforms(): void;
  5090. /**
  5091. * Get the world direction from an axis that is in the local space of the bone
  5092. * @param localAxis The local direction that is used to compute the world direction
  5093. * @param mesh The mesh that this bone is attached to
  5094. * @returns The world direction
  5095. */
  5096. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5097. /**
  5098. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  5099. * @param localAxis The local direction that is used to compute the world direction
  5100. * @param mesh The mesh that this bone is attached to
  5101. * @param result The vector3 that the world direction will be copied to
  5102. */
  5103. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5104. /**
  5105. * Get the euler rotation of the bone in local or world space
  5106. * @param space The space that the rotation should be in
  5107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5108. * @returns The euler rotation
  5109. */
  5110. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5111. /**
  5112. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  5113. * @param space The space that the rotation should be in
  5114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5115. * @param result The vector3 that the rotation should be copied to
  5116. */
  5117. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5118. /**
  5119. * Get the quaternion rotation of the bone in either local or world space
  5120. * @param space The space that the rotation should be in
  5121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5122. * @returns The quaternion rotation
  5123. */
  5124. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  5125. /**
  5126. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  5127. * @param space The space that the rotation should be in
  5128. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5129. * @param result The quaternion that the rotation should be copied to
  5130. */
  5131. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  5132. /**
  5133. * Get the rotation matrix of the bone in local or world space
  5134. * @param space The space that the rotation should be in
  5135. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5136. * @returns The rotation matrix
  5137. */
  5138. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  5139. /**
  5140. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  5141. * @param space The space that the rotation should be in
  5142. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5143. * @param result The quaternion that the rotation should be copied to
  5144. */
  5145. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  5146. /**
  5147. * Get the world position of a point that is in the local space of the bone
  5148. * @param position The local position
  5149. * @param mesh The mesh that this bone is attached to
  5150. * @returns The world position
  5151. */
  5152. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5153. /**
  5154. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  5155. * @param position The local position
  5156. * @param mesh The mesh that this bone is attached to
  5157. * @param result The vector3 that the world position should be copied to
  5158. */
  5159. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5160. /**
  5161. * Get the local position of a point that is in world space
  5162. * @param position The world position
  5163. * @param mesh The mesh that this bone is attached to
  5164. * @returns The local position
  5165. */
  5166. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5167. /**
  5168. * Get the local position of a point that is in world space and copy it to the result param
  5169. * @param position The world position
  5170. * @param mesh The mesh that this bone is attached to
  5171. * @param result The vector3 that the local position should be copied to
  5172. */
  5173. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5174. }
  5175. }
  5176. declare module BABYLON {
  5177. /**
  5178. * Class used to apply inverse kinematics to bones
  5179. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5180. */
  5181. class BoneIKController {
  5182. private static _tmpVecs;
  5183. private static _tmpQuat;
  5184. private static _tmpMats;
  5185. /**
  5186. * Gets or sets the target mesh
  5187. */
  5188. targetMesh: AbstractMesh;
  5189. /** Gets or sets the mesh used as pole */
  5190. poleTargetMesh: AbstractMesh;
  5191. /**
  5192. * Gets or sets the bone used as pole
  5193. */
  5194. poleTargetBone: Nullable<Bone>;
  5195. /**
  5196. * Gets or sets the target position
  5197. */
  5198. targetPosition: Vector3;
  5199. /**
  5200. * Gets or sets the pole target position
  5201. */
  5202. poleTargetPosition: Vector3;
  5203. /**
  5204. * Gets or sets the pole target local offset
  5205. */
  5206. poleTargetLocalOffset: Vector3;
  5207. /**
  5208. * Gets or sets the pole angle
  5209. */
  5210. poleAngle: number;
  5211. /**
  5212. * Gets or sets the mesh associated with the controller
  5213. */
  5214. mesh: AbstractMesh;
  5215. /**
  5216. * 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)
  5217. */
  5218. slerpAmount: number;
  5219. private _bone1Quat;
  5220. private _bone1Mat;
  5221. private _bone2Ang;
  5222. private _bone1;
  5223. private _bone2;
  5224. private _bone1Length;
  5225. private _bone2Length;
  5226. private _maxAngle;
  5227. private _maxReach;
  5228. private _rightHandedSystem;
  5229. private _bendAxis;
  5230. private _slerping;
  5231. private _adjustRoll;
  5232. /**
  5233. * Gets or sets maximum allowed angle
  5234. */
  5235. maxAngle: number;
  5236. /**
  5237. * Creates a new BoneIKController
  5238. * @param mesh defines the mesh to control
  5239. * @param bone defines the bone to control
  5240. * @param options defines options to set up the controller
  5241. */
  5242. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5243. targetMesh?: AbstractMesh;
  5244. poleTargetMesh?: AbstractMesh;
  5245. poleTargetBone?: Bone;
  5246. poleTargetLocalOffset?: Vector3;
  5247. poleAngle?: number;
  5248. bendAxis?: Vector3;
  5249. maxAngle?: number;
  5250. slerpAmount?: number;
  5251. });
  5252. private _setMaxAngle(ang);
  5253. /**
  5254. * Force the controller to update the bones
  5255. */
  5256. update(): void;
  5257. }
  5258. }
  5259. declare module BABYLON {
  5260. /**
  5261. * Class used to make a bone look toward a point in space
  5262. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5263. */
  5264. class BoneLookController {
  5265. private static _tmpVecs;
  5266. private static _tmpQuat;
  5267. private static _tmpMats;
  5268. /**
  5269. * The target Vector3 that the bone will look at
  5270. */
  5271. target: Vector3;
  5272. /**
  5273. * The mesh that the bone is attached to
  5274. */
  5275. mesh: AbstractMesh;
  5276. /**
  5277. * The bone that will be looking to the target
  5278. */
  5279. bone: Bone;
  5280. /**
  5281. * The up axis of the coordinate system that is used when the bone is rotated
  5282. */
  5283. upAxis: Vector3;
  5284. /**
  5285. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5286. */
  5287. upAxisSpace: Space;
  5288. /**
  5289. * Used to make an adjustment to the yaw of the bone
  5290. */
  5291. adjustYaw: number;
  5292. /**
  5293. * Used to make an adjustment to the pitch of the bone
  5294. */
  5295. adjustPitch: number;
  5296. /**
  5297. * Used to make an adjustment to the roll of the bone
  5298. */
  5299. adjustRoll: number;
  5300. /**
  5301. * 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)
  5302. */
  5303. slerpAmount: number;
  5304. private _minYaw;
  5305. private _maxYaw;
  5306. private _minPitch;
  5307. private _maxPitch;
  5308. private _minYawSin;
  5309. private _minYawCos;
  5310. private _maxYawSin;
  5311. private _maxYawCos;
  5312. private _midYawConstraint;
  5313. private _minPitchTan;
  5314. private _maxPitchTan;
  5315. private _boneQuat;
  5316. private _slerping;
  5317. private _transformYawPitch;
  5318. private _transformYawPitchInv;
  5319. private _firstFrameSkipped;
  5320. private _yawRange;
  5321. private _fowardAxis;
  5322. /**
  5323. * Gets or sets the minimum yaw angle that the bone can look to
  5324. */
  5325. minYaw: number;
  5326. /**
  5327. * Gets or sets the maximum yaw angle that the bone can look to
  5328. */
  5329. maxYaw: number;
  5330. /**
  5331. * Gets or sets the minimum pitch angle that the bone can look to
  5332. */
  5333. minPitch: number;
  5334. /**
  5335. * Gets or sets the maximum pitch angle that the bone can look to
  5336. */
  5337. maxPitch: number;
  5338. /**
  5339. * Create a BoneLookController
  5340. * @param mesh the mesh that the bone belongs to
  5341. * @param bone the bone that will be looking to the target
  5342. * @param target the target Vector3 to look at
  5343. * @param settings optional settings:
  5344. * * maxYaw: the maximum angle the bone will yaw to
  5345. * * minYaw: the minimum angle the bone will yaw to
  5346. * * maxPitch: the maximum angle the bone will pitch to
  5347. * * minPitch: the minimum angle the bone will yaw to
  5348. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5349. * * upAxis: the up axis of the coordinate system
  5350. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5351. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5352. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5353. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5354. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5355. * * adjustRoll: used to make an adjustment to the roll of the bone
  5356. **/
  5357. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5358. maxYaw?: number;
  5359. minYaw?: number;
  5360. maxPitch?: number;
  5361. minPitch?: number;
  5362. slerpAmount?: number;
  5363. upAxis?: Vector3;
  5364. upAxisSpace?: Space;
  5365. yawAxis?: Vector3;
  5366. pitchAxis?: Vector3;
  5367. adjustYaw?: number;
  5368. adjustPitch?: number;
  5369. adjustRoll?: number;
  5370. });
  5371. /**
  5372. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5373. */
  5374. update(): void;
  5375. private _getAngleDiff(ang1, ang2);
  5376. private _getAngleBetween(ang1, ang2);
  5377. private _isAngleBetween(ang, ang1, ang2);
  5378. }
  5379. }
  5380. declare module BABYLON {
  5381. /**
  5382. * Class used to handle skinning animations
  5383. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5384. */
  5385. class Skeleton implements IAnimatable {
  5386. /** defines the skeleton name */
  5387. name: string;
  5388. /** defines the skeleton Id */
  5389. id: string;
  5390. /**
  5391. * Gets the list of child bones
  5392. */
  5393. bones: Bone[];
  5394. /**
  5395. * Gets an estimate of the dimension of the skeleton at rest
  5396. */
  5397. dimensionsAtRest: Vector3;
  5398. /**
  5399. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5400. */
  5401. needInitialSkinMatrix: boolean;
  5402. /**
  5403. * Gets the list of animations attached to this skeleton
  5404. */
  5405. animations: Array<Animation>;
  5406. private _scene;
  5407. private _isDirty;
  5408. private _transformMatrices;
  5409. private _meshesWithPoseMatrix;
  5410. private _animatables;
  5411. private _identity;
  5412. private _synchronizedWithMesh;
  5413. private _ranges;
  5414. private _lastAbsoluteTransformsUpdateId;
  5415. /**
  5416. * Specifies if the skeleton should be serialized
  5417. */
  5418. doNotSerialize: boolean;
  5419. private _animationPropertiesOverride;
  5420. /**
  5421. * Gets or sets the animation properties override
  5422. */
  5423. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5424. /**
  5425. * An observable triggered before computing the skeleton's matrices
  5426. */
  5427. onBeforeComputeObservable: Observable<Skeleton>;
  5428. /**
  5429. * Creates a new skeleton
  5430. * @param name defines the skeleton name
  5431. * @param id defines the skeleton Id
  5432. * @param scene defines the hosting scene
  5433. */
  5434. constructor(
  5435. /** defines the skeleton name */
  5436. name: string,
  5437. /** defines the skeleton Id */
  5438. id: string, scene: Scene);
  5439. /**
  5440. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5441. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5442. * @returns a Float32Array containing matrices data
  5443. */
  5444. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5445. /**
  5446. * Gets the current hosting scene
  5447. * @returns a scene object
  5448. */
  5449. getScene(): Scene;
  5450. /**
  5451. * Gets a string representing the current skeleton data
  5452. * @param fullDetails defines a boolean indicating if we want a verbose version
  5453. * @returns a string representing the current skeleton data
  5454. */
  5455. toString(fullDetails?: boolean): string;
  5456. /**
  5457. * Get bone's index searching by name
  5458. * @param name defines bone's name to search for
  5459. * @return the indice of the bone. Returns -1 if not found
  5460. */
  5461. getBoneIndexByName(name: string): number;
  5462. /**
  5463. * Creater a new animation range
  5464. * @param name defines the name of the range
  5465. * @param from defines the start key
  5466. * @param to defines the end key
  5467. */
  5468. createAnimationRange(name: string, from: number, to: number): void;
  5469. /**
  5470. * Delete a specific animation range
  5471. * @param name defines the name of the range
  5472. * @param deleteFrames defines if frames must be removed as well
  5473. */
  5474. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5475. /**
  5476. * Gets a specific animation range
  5477. * @param name defines the name of the range to look for
  5478. * @returns the requested animation range or null if not found
  5479. */
  5480. getAnimationRange(name: string): Nullable<AnimationRange>;
  5481. /**
  5482. * Gets the list of all animation ranges defined on this skeleton
  5483. * @returns an array
  5484. */
  5485. getAnimationRanges(): Nullable<AnimationRange>[];
  5486. /**
  5487. * Copy animation range from a source skeleton.
  5488. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5489. * @param source defines the source skeleton
  5490. * @param name defines the name of the range to copy
  5491. * @param rescaleAsRequired defines if rescaling must be applied if required
  5492. * @returns true if operation was successful
  5493. */
  5494. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5495. /**
  5496. * Forces the skeleton to go to rest pose
  5497. */
  5498. returnToRest(): void;
  5499. private _getHighestAnimationFrame();
  5500. /**
  5501. * Begin a specific animation range
  5502. * @param name defines the name of the range to start
  5503. * @param loop defines if looping must be turned on (false by default)
  5504. * @param speedRatio defines the speed ratio to apply (1 by default)
  5505. * @param onAnimationEnd defines a callback which will be called when animation will end
  5506. * @returns a new animatable
  5507. */
  5508. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5509. /** @hidden */
  5510. _markAsDirty(): void;
  5511. /** @hidden */
  5512. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5513. /** @hidden */
  5514. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5515. /** @hidden */
  5516. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5517. /**
  5518. * Build all resources required to render a skeleton
  5519. */
  5520. prepare(): void;
  5521. /**
  5522. * Gets the list of animatables currently running for this skeleton
  5523. * @returns an array of animatables
  5524. */
  5525. getAnimatables(): IAnimatable[];
  5526. /**
  5527. * Clone the current skeleton
  5528. * @param name defines the name of the new skeleton
  5529. * @param id defines the id of the enw skeleton
  5530. * @returns the new skeleton
  5531. */
  5532. clone(name: string, id: string): Skeleton;
  5533. /**
  5534. * Enable animation blending for this skeleton
  5535. * @param blendingSpeed defines the blending speed to apply
  5536. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5537. */
  5538. enableBlending(blendingSpeed?: number): void;
  5539. /**
  5540. * Releases all resources associated with the current skeleton
  5541. */
  5542. dispose(): void;
  5543. /**
  5544. * Serialize the skeleton in a JSON object
  5545. * @returns a JSON object
  5546. */
  5547. serialize(): any;
  5548. /**
  5549. * Creates a new skeleton from serialized data
  5550. * @param parsedSkeleton defines the serialized data
  5551. * @param scene defines the hosting scene
  5552. * @returns a new skeleton
  5553. */
  5554. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5555. /**
  5556. * Compute all node absolute transforms
  5557. * @param forceUpdate defines if computation must be done even if cache is up to date
  5558. */
  5559. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5560. /**
  5561. * Gets the root pose matrix
  5562. * @returns a matrix
  5563. */
  5564. getPoseMatrix(): Nullable<Matrix>;
  5565. /**
  5566. * Sorts bones per internal index
  5567. */
  5568. sortBones(): void;
  5569. private _sortBones(index, bones, visited);
  5570. }
  5571. }
  5572. declare module BABYLON {
  5573. class ArcRotateCamera extends TargetCamera {
  5574. alpha: number;
  5575. beta: number;
  5576. radius: number;
  5577. protected _target: Vector3;
  5578. protected _targetHost: Nullable<AbstractMesh>;
  5579. target: Vector3;
  5580. inertialAlphaOffset: number;
  5581. inertialBetaOffset: number;
  5582. inertialRadiusOffset: number;
  5583. lowerAlphaLimit: Nullable<number>;
  5584. upperAlphaLimit: Nullable<number>;
  5585. lowerBetaLimit: number;
  5586. upperBetaLimit: number;
  5587. lowerRadiusLimit: Nullable<number>;
  5588. upperRadiusLimit: Nullable<number>;
  5589. inertialPanningX: number;
  5590. inertialPanningY: number;
  5591. pinchToPanMaxDistance: number;
  5592. panningDistanceLimit: Nullable<number>;
  5593. panningOriginTarget: Vector3;
  5594. panningInertia: number;
  5595. angularSensibilityX: number;
  5596. angularSensibilityY: number;
  5597. pinchPrecision: number;
  5598. pinchDeltaPercentage: number;
  5599. panningSensibility: number;
  5600. keysUp: number[];
  5601. keysDown: number[];
  5602. keysLeft: number[];
  5603. keysRight: number[];
  5604. wheelPrecision: number;
  5605. wheelDeltaPercentage: number;
  5606. zoomOnFactor: number;
  5607. targetScreenOffset: Vector2;
  5608. allowUpsideDown: boolean;
  5609. _viewMatrix: Matrix;
  5610. _useCtrlForPanning: boolean;
  5611. _panningMouseButton: number;
  5612. inputs: ArcRotateCameraInputsManager;
  5613. _reset: () => void;
  5614. panningAxis: Vector3;
  5615. protected _localDirection: Vector3;
  5616. protected _transformedDirection: Vector3;
  5617. private _bouncingBehavior;
  5618. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5619. useBouncingBehavior: boolean;
  5620. private _framingBehavior;
  5621. readonly framingBehavior: Nullable<FramingBehavior>;
  5622. useFramingBehavior: boolean;
  5623. private _autoRotationBehavior;
  5624. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5625. useAutoRotationBehavior: boolean;
  5626. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5627. onCollide: (collidedMesh: AbstractMesh) => void;
  5628. checkCollisions: boolean;
  5629. collisionRadius: Vector3;
  5630. protected _collider: Collider;
  5631. protected _previousPosition: Vector3;
  5632. protected _collisionVelocity: Vector3;
  5633. protected _newPosition: Vector3;
  5634. protected _previousAlpha: number;
  5635. protected _previousBeta: number;
  5636. protected _previousRadius: number;
  5637. protected _collisionTriggered: boolean;
  5638. protected _targetBoundingCenter: Nullable<Vector3>;
  5639. private _computationVector;
  5640. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5641. _initCache(): void;
  5642. _updateCache(ignoreParentClass?: boolean): void;
  5643. protected _getTargetPosition(): Vector3;
  5644. /**
  5645. * Store current camera state (fov, position, etc..)
  5646. */
  5647. private _storedAlpha;
  5648. private _storedBeta;
  5649. private _storedRadius;
  5650. private _storedTarget;
  5651. storeState(): Camera;
  5652. /**
  5653. * Restored camera state. You must call storeState() first
  5654. */
  5655. _restoreStateValues(): boolean;
  5656. _isSynchronizedViewMatrix(): boolean;
  5657. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5658. detachControl(element: HTMLElement): void;
  5659. _checkInputs(): void;
  5660. protected _checkLimits(): void;
  5661. rebuildAnglesAndRadius(): void;
  5662. setPosition(position: Vector3): void;
  5663. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5664. _getViewMatrix(): Matrix;
  5665. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5666. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5667. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5668. min: Vector3;
  5669. max: Vector3;
  5670. distance: number;
  5671. }, doNotUpdateMaxZ?: boolean): void;
  5672. /**
  5673. * @override
  5674. * Override Camera.createRigCamera
  5675. */
  5676. createRigCamera(name: string, cameraIndex: number): Camera;
  5677. /**
  5678. * @override
  5679. * Override Camera._updateRigCameras
  5680. */
  5681. _updateRigCameras(): void;
  5682. dispose(): void;
  5683. getClassName(): string;
  5684. }
  5685. }
  5686. declare module BABYLON {
  5687. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5688. constructor(camera: ArcRotateCamera);
  5689. addMouseWheel(): ArcRotateCameraInputsManager;
  5690. addPointers(): ArcRotateCameraInputsManager;
  5691. addKeyboard(): ArcRotateCameraInputsManager;
  5692. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5693. }
  5694. }
  5695. declare module BABYLON {
  5696. class Camera extends Node {
  5697. inputs: CameraInputsManager<Camera>;
  5698. private static _PERSPECTIVE_CAMERA;
  5699. private static _ORTHOGRAPHIC_CAMERA;
  5700. private static _FOVMODE_VERTICAL_FIXED;
  5701. private static _FOVMODE_HORIZONTAL_FIXED;
  5702. private static _RIG_MODE_NONE;
  5703. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5704. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5705. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5706. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5707. private static _RIG_MODE_VR;
  5708. private static _RIG_MODE_WEBVR;
  5709. static readonly PERSPECTIVE_CAMERA: number;
  5710. static readonly ORTHOGRAPHIC_CAMERA: number;
  5711. /**
  5712. * This is the default FOV mode for perspective cameras.
  5713. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5714. *
  5715. */
  5716. static readonly FOVMODE_VERTICAL_FIXED: number;
  5717. /**
  5718. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5719. *
  5720. */
  5721. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5722. static readonly RIG_MODE_NONE: number;
  5723. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5724. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5725. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5726. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5727. static readonly RIG_MODE_VR: number;
  5728. static readonly RIG_MODE_WEBVR: number;
  5729. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5730. static UseAlternateWebVRRendering: boolean;
  5731. position: Vector3;
  5732. /**
  5733. * The vector the camera should consider as up.
  5734. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5735. */
  5736. upVector: Vector3;
  5737. orthoLeft: Nullable<number>;
  5738. orthoRight: Nullable<number>;
  5739. orthoBottom: Nullable<number>;
  5740. orthoTop: Nullable<number>;
  5741. /**
  5742. * FOV is set in Radians. (default is 0.8)
  5743. */
  5744. fov: number;
  5745. minZ: number;
  5746. maxZ: number;
  5747. inertia: number;
  5748. mode: number;
  5749. isIntermediate: boolean;
  5750. viewport: Viewport;
  5751. /**
  5752. * Restricts the camera to viewing objects with the same layerMask.
  5753. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5754. */
  5755. layerMask: number;
  5756. /**
  5757. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5758. */
  5759. fovMode: number;
  5760. cameraRigMode: number;
  5761. interaxialDistance: number;
  5762. isStereoscopicSideBySide: boolean;
  5763. _cameraRigParams: any;
  5764. _rigCameras: Camera[];
  5765. _rigPostProcess: Nullable<PostProcess>;
  5766. protected _webvrViewMatrix: Matrix;
  5767. _skipRendering: boolean;
  5768. _alternateCamera: Camera;
  5769. customRenderTargets: RenderTargetTexture[];
  5770. onViewMatrixChangedObservable: Observable<Camera>;
  5771. onProjectionMatrixChangedObservable: Observable<Camera>;
  5772. onAfterCheckInputsObservable: Observable<Camera>;
  5773. onRestoreStateObservable: Observable<Camera>;
  5774. private _computedViewMatrix;
  5775. _projectionMatrix: Matrix;
  5776. private _doNotComputeProjectionMatrix;
  5777. private _worldMatrix;
  5778. _postProcesses: Nullable<PostProcess>[];
  5779. private _transformMatrix;
  5780. _activeMeshes: SmartArray<AbstractMesh>;
  5781. protected _globalPosition: Vector3;
  5782. private _frustumPlanes;
  5783. private _refreshFrustumPlanes;
  5784. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5785. private _storedFov;
  5786. private _stateStored;
  5787. /**
  5788. * Store current camera state (fov, position, etc..)
  5789. */
  5790. storeState(): Camera;
  5791. /**
  5792. * Restores the camera state values if it has been stored. You must call storeState() first
  5793. */
  5794. protected _restoreStateValues(): boolean;
  5795. /**
  5796. * Restored camera state. You must call storeState() first
  5797. */
  5798. restoreState(): boolean;
  5799. getClassName(): string;
  5800. /**
  5801. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5802. */
  5803. toString(fullDetails?: boolean): string;
  5804. readonly globalPosition: Vector3;
  5805. getActiveMeshes(): SmartArray<AbstractMesh>;
  5806. isActiveMesh(mesh: Mesh): boolean;
  5807. /**
  5808. * Is this camera ready to be used/rendered
  5809. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  5810. * @return true if the camera is ready
  5811. */
  5812. isReady(completeCheck?: boolean): boolean;
  5813. _initCache(): void;
  5814. _updateCache(ignoreParentClass?: boolean): void;
  5815. _isSynchronized(): boolean;
  5816. _isSynchronizedViewMatrix(): boolean;
  5817. _isSynchronizedProjectionMatrix(): boolean;
  5818. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5819. detachControl(element: HTMLElement): void;
  5820. update(): void;
  5821. _checkInputs(): void;
  5822. readonly rigCameras: Camera[];
  5823. readonly rigPostProcess: Nullable<PostProcess>;
  5824. /**
  5825. * Internal, gets the first post proces.
  5826. * @returns the first post process to be run on this camera.
  5827. */
  5828. _getFirstPostProcess(): Nullable<PostProcess>;
  5829. private _cascadePostProcessesToRigCams();
  5830. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  5831. detachPostProcess(postProcess: PostProcess): void;
  5832. getWorldMatrix(): Matrix;
  5833. _getViewMatrix(): Matrix;
  5834. getViewMatrix(force?: boolean): Matrix;
  5835. freezeProjectionMatrix(projection?: Matrix): void;
  5836. unfreezeProjectionMatrix(): void;
  5837. getProjectionMatrix(force?: boolean): Matrix;
  5838. getTranformationMatrix(): Matrix;
  5839. private updateFrustumPlanes();
  5840. isInFrustum(target: ICullable): boolean;
  5841. isCompletelyInFrustum(target: ICullable): boolean;
  5842. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  5843. /**
  5844. * Releases resources associated with this node.
  5845. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  5846. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  5847. */
  5848. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  5849. readonly leftCamera: Nullable<FreeCamera>;
  5850. readonly rightCamera: Nullable<FreeCamera>;
  5851. getLeftTarget(): Nullable<Vector3>;
  5852. getRightTarget(): Nullable<Vector3>;
  5853. setCameraRigMode(mode: number, rigParams: any): void;
  5854. private _getVRProjectionMatrix();
  5855. protected _updateCameraRotationMatrix(): void;
  5856. protected _updateWebVRCameraRotationMatrix(): void;
  5857. /**
  5858. * This function MUST be overwritten by the different WebVR cameras available.
  5859. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5860. */
  5861. protected _getWebVRProjectionMatrix(): Matrix;
  5862. /**
  5863. * This function MUST be overwritten by the different WebVR cameras available.
  5864. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5865. */
  5866. protected _getWebVRViewMatrix(): Matrix;
  5867. setCameraRigParameter(name: string, value: any): void;
  5868. /**
  5869. * needs to be overridden by children so sub has required properties to be copied
  5870. */
  5871. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5872. /**
  5873. * May need to be overridden by children
  5874. */
  5875. _updateRigCameras(): void;
  5876. _setupInputs(): void;
  5877. serialize(): any;
  5878. clone(name: string): Camera;
  5879. getDirection(localAxis: Vector3): Vector3;
  5880. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  5881. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  5882. computeWorldMatrix(): Matrix;
  5883. static Parse(parsedCamera: any, scene: Scene): Camera;
  5884. }
  5885. }
  5886. declare module BABYLON {
  5887. var CameraInputTypes: {};
  5888. interface ICameraInput<TCamera extends Camera> {
  5889. camera: Nullable<TCamera>;
  5890. getClassName(): string;
  5891. getSimpleName(): string;
  5892. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  5893. detachControl: (element: Nullable<HTMLElement>) => void;
  5894. checkInputs?: () => void;
  5895. }
  5896. interface CameraInputsMap<TCamera extends Camera> {
  5897. [name: string]: ICameraInput<TCamera>;
  5898. [idx: number]: ICameraInput<TCamera>;
  5899. }
  5900. class CameraInputsManager<TCamera extends Camera> {
  5901. attached: CameraInputsMap<TCamera>;
  5902. attachedElement: Nullable<HTMLElement>;
  5903. noPreventDefault: boolean;
  5904. camera: TCamera;
  5905. checkInputs: () => void;
  5906. constructor(camera: TCamera);
  5907. /**
  5908. * Add an input method to a camera
  5909. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  5910. * @param input camera input method
  5911. */
  5912. add(input: ICameraInput<TCamera>): void;
  5913. /**
  5914. * Remove a specific input method from a camera
  5915. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  5916. * @param inputToRemove camera input method
  5917. */
  5918. remove(inputToRemove: ICameraInput<TCamera>): void;
  5919. removeByType(inputType: string): void;
  5920. private _addCheckInputs(fn);
  5921. attachInput(input: ICameraInput<TCamera>): void;
  5922. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  5923. detachElement(element: HTMLElement, disconnect?: boolean): void;
  5924. rebuildInputCheck(): void;
  5925. /**
  5926. * Remove all attached input methods from a camera
  5927. */
  5928. clear(): void;
  5929. serialize(serializedCamera: any): void;
  5930. parse(parsedCamera: any): void;
  5931. }
  5932. }
  5933. declare module BABYLON {
  5934. /**
  5935. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  5936. * being tilted forward or back and left or right.
  5937. */
  5938. class DeviceOrientationCamera extends FreeCamera {
  5939. private _initialQuaternion;
  5940. private _quaternionCache;
  5941. /**
  5942. * Creates a new device orientation camera
  5943. * @param name The name of the camera
  5944. * @param position The start position camera
  5945. * @param scene The scene the camera belongs to
  5946. */
  5947. constructor(name: string, position: Vector3, scene: Scene);
  5948. /**
  5949. * Gets the current instance class name ("DeviceOrientationCamera").
  5950. * This helps avoiding instanceof at run time.
  5951. * @returns the class name
  5952. */
  5953. getClassName(): string;
  5954. /**
  5955. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  5956. */
  5957. _checkInputs(): void;
  5958. /**
  5959. * Reset the camera to its default orientation on the specified axis only.
  5960. * @param axis The axis to reset
  5961. */
  5962. resetToCurrentRotation(axis?: Axis): void;
  5963. }
  5964. }
  5965. declare module BABYLON {
  5966. class FollowCamera extends TargetCamera {
  5967. radius: number;
  5968. rotationOffset: number;
  5969. heightOffset: number;
  5970. cameraAcceleration: number;
  5971. maxCameraSpeed: number;
  5972. lockedTarget: Nullable<AbstractMesh>;
  5973. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  5974. private getRadians(degrees);
  5975. private follow(cameraTarget);
  5976. _checkInputs(): void;
  5977. getClassName(): string;
  5978. }
  5979. class ArcFollowCamera extends TargetCamera {
  5980. alpha: number;
  5981. beta: number;
  5982. radius: number;
  5983. target: Nullable<AbstractMesh>;
  5984. private _cartesianCoordinates;
  5985. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  5986. private follow();
  5987. _checkInputs(): void;
  5988. getClassName(): string;
  5989. }
  5990. }
  5991. declare module BABYLON {
  5992. class FreeCamera extends TargetCamera {
  5993. ellipsoid: Vector3;
  5994. ellipsoidOffset: Vector3;
  5995. checkCollisions: boolean;
  5996. applyGravity: boolean;
  5997. inputs: FreeCameraInputsManager;
  5998. /**
  5999. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6000. * Higher values reduce sensitivity.
  6001. */
  6002. /**
  6003. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6004. * Higher values reduce sensitivity.
  6005. */
  6006. angularSensibility: number;
  6007. keysUp: number[];
  6008. keysDown: number[];
  6009. keysLeft: number[];
  6010. keysRight: number[];
  6011. onCollide: (collidedMesh: AbstractMesh) => void;
  6012. private _collider;
  6013. private _needMoveForGravity;
  6014. private _oldPosition;
  6015. private _diffPosition;
  6016. private _newPosition;
  6017. _localDirection: Vector3;
  6018. _transformedDirection: Vector3;
  6019. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6021. detachControl(element: HTMLElement): void;
  6022. private _collisionMask;
  6023. collisionMask: number;
  6024. _collideWithWorld(displacement: Vector3): void;
  6025. private _onCollisionPositionChange;
  6026. _checkInputs(): void;
  6027. _decideIfNeedsToMove(): boolean;
  6028. _updatePosition(): void;
  6029. dispose(): void;
  6030. getClassName(): string;
  6031. }
  6032. }
  6033. declare module BABYLON {
  6034. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6035. constructor(camera: FreeCamera);
  6036. addKeyboard(): FreeCameraInputsManager;
  6037. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6038. addDeviceOrientation(): FreeCameraInputsManager;
  6039. addTouch(): FreeCameraInputsManager;
  6040. addVirtualJoystick(): FreeCameraInputsManager;
  6041. }
  6042. }
  6043. declare module BABYLON {
  6044. class GamepadCamera extends UniversalCamera {
  6045. gamepadAngularSensibility: number;
  6046. gamepadMoveSensibility: number;
  6047. constructor(name: string, position: Vector3, scene: Scene);
  6048. getClassName(): string;
  6049. }
  6050. }
  6051. declare module BABYLON {
  6052. class TargetCamera extends Camera {
  6053. cameraDirection: Vector3;
  6054. cameraRotation: Vector2;
  6055. rotation: Vector3;
  6056. rotationQuaternion: Quaternion;
  6057. speed: number;
  6058. noRotationConstraint: boolean;
  6059. lockedTarget: any;
  6060. _currentTarget: Vector3;
  6061. _viewMatrix: Matrix;
  6062. _camMatrix: Matrix;
  6063. _cameraTransformMatrix: Matrix;
  6064. _cameraRotationMatrix: Matrix;
  6065. private _rigCamTransformMatrix;
  6066. _referencePoint: Vector3;
  6067. private _currentUpVector;
  6068. _transformedReferencePoint: Vector3;
  6069. protected _globalCurrentTarget: Vector3;
  6070. protected _globalCurrentUpVector: Vector3;
  6071. _reset: () => void;
  6072. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6073. getFrontPosition(distance: number): Vector3;
  6074. _getLockedTargetPosition(): Nullable<Vector3>;
  6075. /**
  6076. * Store current camera state (fov, position, etc..)
  6077. */
  6078. private _storedPosition;
  6079. private _storedRotation;
  6080. private _storedRotationQuaternion;
  6081. storeState(): Camera;
  6082. /**
  6083. * Restored camera state. You must call storeState() first
  6084. */
  6085. _restoreStateValues(): boolean;
  6086. _initCache(): void;
  6087. _updateCache(ignoreParentClass?: boolean): void;
  6088. _isSynchronizedViewMatrix(): boolean;
  6089. _computeLocalCameraSpeed(): number;
  6090. setTarget(target: Vector3): void;
  6091. /**
  6092. * Return the current target position of the camera. This value is expressed in local space.
  6093. */
  6094. getTarget(): Vector3;
  6095. _decideIfNeedsToMove(): boolean;
  6096. _updatePosition(): void;
  6097. _checkInputs(): void;
  6098. protected _updateCameraRotationMatrix(): void;
  6099. _getViewMatrix(): Matrix;
  6100. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6101. /**
  6102. * @override
  6103. * Override Camera.createRigCamera
  6104. */
  6105. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6106. /**
  6107. * @override
  6108. * Override Camera._updateRigCameras
  6109. */
  6110. _updateRigCameras(): void;
  6111. private _getRigCamPosition(halfSpace, result);
  6112. getClassName(): string;
  6113. }
  6114. }
  6115. declare module BABYLON {
  6116. class TouchCamera extends FreeCamera {
  6117. touchAngularSensibility: number;
  6118. touchMoveSensibility: number;
  6119. constructor(name: string, position: Vector3, scene: Scene);
  6120. getClassName(): string;
  6121. _setupInputs(): void;
  6122. }
  6123. }
  6124. declare module BABYLON {
  6125. class UniversalCamera extends TouchCamera {
  6126. gamepadAngularSensibility: number;
  6127. gamepadMoveSensibility: number;
  6128. constructor(name: string, position: Vector3, scene: Scene);
  6129. getClassName(): string;
  6130. }
  6131. }
  6132. declare module BABYLON {
  6133. class VirtualJoysticksCamera extends FreeCamera {
  6134. constructor(name: string, position: Vector3, scene: Scene);
  6135. getClassName(): string;
  6136. }
  6137. }
  6138. interface VRDisplay extends EventTarget {
  6139. /**
  6140. * Dictionary of capabilities describing the VRDisplay.
  6141. */
  6142. readonly capabilities: VRDisplayCapabilities;
  6143. /**
  6144. * z-depth defining the far plane of the eye view frustum
  6145. * enables mapping of values in the render target depth
  6146. * attachment to scene coordinates. Initially set to 10000.0.
  6147. */
  6148. depthFar: number;
  6149. /**
  6150. * z-depth defining the near plane of the eye view frustum
  6151. * enables mapping of values in the render target depth
  6152. * attachment to scene coordinates. Initially set to 0.01.
  6153. */
  6154. depthNear: number;
  6155. /**
  6156. * An identifier for this distinct VRDisplay. Used as an
  6157. * association point in the Gamepad API.
  6158. */
  6159. readonly displayId: number;
  6160. /**
  6161. * A display name, a user-readable name identifying it.
  6162. */
  6163. readonly displayName: string;
  6164. readonly isConnected: boolean;
  6165. readonly isPresenting: boolean;
  6166. /**
  6167. * If this VRDisplay supports room-scale experiences, the optional
  6168. * stage attribute contains details on the room-scale parameters.
  6169. */
  6170. readonly stageParameters: VRStageParameters | null;
  6171. /**
  6172. * Passing the value returned by `requestAnimationFrame` to
  6173. * `cancelAnimationFrame` will unregister the callback.
  6174. */
  6175. cancelAnimationFrame(handle: number): void;
  6176. /**
  6177. * Stops presenting to the VRDisplay.
  6178. */
  6179. exitPresent(): Promise<void>;
  6180. getEyeParameters(whichEye: string): VREyeParameters;
  6181. /**
  6182. * Populates the passed VRFrameData with the information required to render
  6183. * the current frame.
  6184. */
  6185. getFrameData(frameData: VRFrameData): boolean;
  6186. /**
  6187. * Get the layers currently being presented.
  6188. */
  6189. getLayers(): VRLayer[];
  6190. /**
  6191. * Return a VRPose containing the future predicted pose of the VRDisplay
  6192. * when the current frame will be presented. The value returned will not
  6193. * change until JavaScript has returned control to the browser.
  6194. *
  6195. * The VRPose will contain the position, orientation, velocity,
  6196. * and acceleration of each of these properties.
  6197. */
  6198. getPose(): VRPose;
  6199. /**
  6200. * Return the current instantaneous pose of the VRDisplay, with no
  6201. * prediction applied.
  6202. */
  6203. getImmediatePose(): VRPose;
  6204. /**
  6205. * The callback passed to `requestAnimationFrame` will be called
  6206. * any time a new frame should be rendered. When the VRDisplay is
  6207. * presenting the callback will be called at the native refresh
  6208. * rate of the HMD. When not presenting this function acts
  6209. * identically to how window.requestAnimationFrame acts. Content should
  6210. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6211. * asynchronously from other displays and at differing refresh rates.
  6212. */
  6213. requestAnimationFrame(callback: FrameRequestCallback): number;
  6214. /**
  6215. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6216. * Repeat calls while already presenting will update the VRLayers being displayed.
  6217. */
  6218. requestPresent(layers: VRLayer[]): Promise<void>;
  6219. /**
  6220. * Reset the pose for this display, treating its current position and
  6221. * orientation as the "origin/zero" values. VRPose.position,
  6222. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6223. * updated when calling resetPose(). This should be called in only
  6224. * sitting-space experiences.
  6225. */
  6226. resetPose(): void;
  6227. /**
  6228. * The VRLayer provided to the VRDisplay will be captured and presented
  6229. * in the HMD. Calling this function has the same effect on the source
  6230. * canvas as any other operation that uses its source image, and canvases
  6231. * created without preserveDrawingBuffer set to true will be cleared.
  6232. */
  6233. submitFrame(pose?: VRPose): void;
  6234. }
  6235. declare var VRDisplay: {
  6236. prototype: VRDisplay;
  6237. new (): VRDisplay;
  6238. };
  6239. interface VRLayer {
  6240. leftBounds?: number[] | null;
  6241. rightBounds?: number[] | null;
  6242. source?: HTMLCanvasElement | null;
  6243. }
  6244. interface VRDisplayCapabilities {
  6245. readonly canPresent: boolean;
  6246. readonly hasExternalDisplay: boolean;
  6247. readonly hasOrientation: boolean;
  6248. readonly hasPosition: boolean;
  6249. readonly maxLayers: number;
  6250. }
  6251. interface VREyeParameters {
  6252. /** @deprecated */
  6253. readonly fieldOfView: VRFieldOfView;
  6254. readonly offset: Float32Array;
  6255. readonly renderHeight: number;
  6256. readonly renderWidth: number;
  6257. }
  6258. interface VRFieldOfView {
  6259. readonly downDegrees: number;
  6260. readonly leftDegrees: number;
  6261. readonly rightDegrees: number;
  6262. readonly upDegrees: number;
  6263. }
  6264. interface VRFrameData {
  6265. readonly leftProjectionMatrix: Float32Array;
  6266. readonly leftViewMatrix: Float32Array;
  6267. readonly pose: VRPose;
  6268. readonly rightProjectionMatrix: Float32Array;
  6269. readonly rightViewMatrix: Float32Array;
  6270. readonly timestamp: number;
  6271. }
  6272. interface VRPose {
  6273. readonly angularAcceleration: Float32Array | null;
  6274. readonly angularVelocity: Float32Array | null;
  6275. readonly linearAcceleration: Float32Array | null;
  6276. readonly linearVelocity: Float32Array | null;
  6277. readonly orientation: Float32Array | null;
  6278. readonly position: Float32Array | null;
  6279. readonly timestamp: number;
  6280. }
  6281. interface VRStageParameters {
  6282. sittingToStandingTransform?: Float32Array;
  6283. sizeX?: number;
  6284. sizeY?: number;
  6285. }
  6286. interface Navigator {
  6287. getVRDisplays(): Promise<VRDisplay[]>;
  6288. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6289. }
  6290. interface Window {
  6291. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6292. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6293. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6294. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6295. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6296. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6297. }
  6298. interface Gamepad {
  6299. readonly displayId: number;
  6300. }
  6301. declare module BABYLON {
  6302. class BoundingBox implements ICullable {
  6303. vectors: Vector3[];
  6304. center: Vector3;
  6305. centerWorld: Vector3;
  6306. extendSize: Vector3;
  6307. extendSizeWorld: Vector3;
  6308. directions: Vector3[];
  6309. vectorsWorld: Vector3[];
  6310. minimumWorld: Vector3;
  6311. maximumWorld: Vector3;
  6312. minimum: Vector3;
  6313. maximum: Vector3;
  6314. private _worldMatrix;
  6315. /**
  6316. * Creates a new bounding box
  6317. * @param min defines the minimum vector (in local space)
  6318. * @param max defines the maximum vector (in local space)
  6319. */
  6320. constructor(min: Vector3, max: Vector3);
  6321. /**
  6322. * Recreates the entire bounding box from scratch
  6323. * @param min defines the new minimum vector (in local space)
  6324. * @param max defines the new maximum vector (in local space)
  6325. */
  6326. reConstruct(min: Vector3, max: Vector3): void;
  6327. getWorldMatrix(): Matrix;
  6328. setWorldMatrix(matrix: Matrix): BoundingBox;
  6329. _update(world: Matrix): void;
  6330. isInFrustum(frustumPlanes: Plane[]): boolean;
  6331. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6332. intersectsPoint(point: Vector3): boolean;
  6333. intersectsSphere(sphere: BoundingSphere): boolean;
  6334. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  6335. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  6336. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  6337. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6338. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6339. }
  6340. }
  6341. declare module BABYLON {
  6342. interface ICullable {
  6343. isInFrustum(frustumPlanes: Plane[]): boolean;
  6344. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6345. }
  6346. class BoundingInfo implements ICullable {
  6347. minimum: Vector3;
  6348. maximum: Vector3;
  6349. boundingBox: BoundingBox;
  6350. boundingSphere: BoundingSphere;
  6351. private _isLocked;
  6352. constructor(minimum: Vector3, maximum: Vector3);
  6353. isLocked: boolean;
  6354. update(world: Matrix): void;
  6355. /**
  6356. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6357. * @param center New center of the bounding info
  6358. * @param extend New extend of the bounding info
  6359. */
  6360. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  6361. isInFrustum(frustumPlanes: Plane[]): boolean;
  6362. /**
  6363. * Gets the world distance between the min and max points of the bounding box
  6364. */
  6365. readonly diagonalLength: number;
  6366. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6367. _checkCollision(collider: Collider): boolean;
  6368. intersectsPoint(point: Vector3): boolean;
  6369. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  6370. }
  6371. }
  6372. declare module BABYLON {
  6373. class BoundingSphere {
  6374. center: Vector3;
  6375. radius: number;
  6376. centerWorld: Vector3;
  6377. radiusWorld: number;
  6378. minimum: Vector3;
  6379. maximum: Vector3;
  6380. private _tempRadiusVector;
  6381. /**
  6382. * Creates a new bounding sphere
  6383. * @param min defines the minimum vector (in local space)
  6384. * @param max defines the maximum vector (in local space)
  6385. */
  6386. constructor(min: Vector3, max: Vector3);
  6387. /**
  6388. * Recreates the entire bounding sphere from scratch
  6389. * @param min defines the new minimum vector (in local space)
  6390. * @param max defines the new maximum vector (in local space)
  6391. */
  6392. reConstruct(min: Vector3, max: Vector3): void;
  6393. _update(world: Matrix): void;
  6394. isInFrustum(frustumPlanes: Plane[]): boolean;
  6395. intersectsPoint(point: Vector3): boolean;
  6396. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  6397. }
  6398. }
  6399. declare module BABYLON {
  6400. class Ray {
  6401. origin: Vector3;
  6402. direction: Vector3;
  6403. length: number;
  6404. private _edge1;
  6405. private _edge2;
  6406. private _pvec;
  6407. private _tvec;
  6408. private _qvec;
  6409. private _tmpRay;
  6410. constructor(origin: Vector3, direction: Vector3, length?: number);
  6411. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  6412. intersectsBox(box: BoundingBox): boolean;
  6413. intersectsSphere(sphere: BoundingSphere): boolean;
  6414. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  6415. intersectsPlane(plane: Plane): Nullable<number>;
  6416. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  6417. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  6418. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  6419. private static smallnum;
  6420. private static rayl;
  6421. /**
  6422. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  6423. * @param sega the first point of the segment to test the intersection against
  6424. * @param segb the second point of the segment to test the intersection against
  6425. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  6426. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  6427. */
  6428. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  6429. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6430. static Zero(): Ray;
  6431. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6432. /**
  6433. * 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
  6434. * transformed to the given world matrix.
  6435. * @param origin The origin point
  6436. * @param end The end point
  6437. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6438. */
  6439. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6440. static Transform(ray: Ray, matrix: Matrix): Ray;
  6441. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6442. }
  6443. }
  6444. declare module BABYLON {
  6445. class Collider {
  6446. /** Define if a collision was found */
  6447. collisionFound: boolean;
  6448. /**
  6449. * Define last intersection point in local space
  6450. */
  6451. intersectionPoint: Vector3;
  6452. /**
  6453. * Define last collided mesh
  6454. */
  6455. collidedMesh: Nullable<AbstractMesh>;
  6456. private _collisionPoint;
  6457. private _planeIntersectionPoint;
  6458. private _tempVector;
  6459. private _tempVector2;
  6460. private _tempVector3;
  6461. private _tempVector4;
  6462. private _edge;
  6463. private _baseToVertex;
  6464. private _destinationPoint;
  6465. private _slidePlaneNormal;
  6466. private _displacementVector;
  6467. _radius: Vector3;
  6468. _retry: number;
  6469. private _velocity;
  6470. private _basePoint;
  6471. private _epsilon;
  6472. _velocityWorldLength: number;
  6473. _basePointWorld: Vector3;
  6474. private _velocityWorld;
  6475. private _normalizedVelocity;
  6476. _initialVelocity: Vector3;
  6477. _initialPosition: Vector3;
  6478. private _nearestDistance;
  6479. private _collisionMask;
  6480. collisionMask: number;
  6481. /**
  6482. * Gets the plane normal used to compute the sliding response (in local space)
  6483. */
  6484. readonly slidePlaneNormal: Vector3;
  6485. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6486. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6487. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6488. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6489. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6490. _getResponse(pos: Vector3, vel: Vector3): void;
  6491. }
  6492. }
  6493. declare module BABYLON {
  6494. var CollisionWorker: string;
  6495. interface ICollisionCoordinator {
  6496. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6497. init(scene: Scene): void;
  6498. destroy(): void;
  6499. onMeshAdded(mesh: AbstractMesh): void;
  6500. onMeshUpdated(mesh: AbstractMesh): void;
  6501. onMeshRemoved(mesh: AbstractMesh): void;
  6502. onGeometryAdded(geometry: Geometry): void;
  6503. onGeometryUpdated(geometry: Geometry): void;
  6504. onGeometryDeleted(geometry: Geometry): void;
  6505. }
  6506. interface SerializedMesh {
  6507. id: string;
  6508. name: string;
  6509. uniqueId: number;
  6510. geometryId: Nullable<string>;
  6511. sphereCenter: Array<number>;
  6512. sphereRadius: number;
  6513. boxMinimum: Array<number>;
  6514. boxMaximum: Array<number>;
  6515. worldMatrixFromCache: any;
  6516. subMeshes: Array<SerializedSubMesh>;
  6517. checkCollisions: boolean;
  6518. }
  6519. interface SerializedSubMesh {
  6520. position: number;
  6521. verticesStart: number;
  6522. verticesCount: number;
  6523. indexStart: number;
  6524. indexCount: number;
  6525. hasMaterial: boolean;
  6526. sphereCenter: Array<number>;
  6527. sphereRadius: number;
  6528. boxMinimum: Array<number>;
  6529. boxMaximum: Array<number>;
  6530. }
  6531. /**
  6532. * Interface describing the value associated with a geometry
  6533. */
  6534. interface SerializedGeometry {
  6535. /**
  6536. * Defines the unique ID of the geometry
  6537. */
  6538. id: string;
  6539. /**
  6540. * Defines the array containing the positions
  6541. */
  6542. positions: Float32Array;
  6543. /**
  6544. * Defines the array containing the indices
  6545. */
  6546. indices: Uint32Array;
  6547. /**
  6548. * Defines the array containing the normals
  6549. */
  6550. normals: Float32Array;
  6551. }
  6552. interface BabylonMessage {
  6553. taskType: WorkerTaskType;
  6554. payload: InitPayload | CollidePayload | UpdatePayload;
  6555. }
  6556. interface SerializedColliderToWorker {
  6557. position: Array<number>;
  6558. velocity: Array<number>;
  6559. radius: Array<number>;
  6560. }
  6561. /** Defines supported task for worker process */
  6562. enum WorkerTaskType {
  6563. /** Initialization */
  6564. INIT = 0,
  6565. /** Update of geometry */
  6566. UPDATE = 1,
  6567. /** Evaluate collision */
  6568. COLLIDE = 2,
  6569. }
  6570. interface WorkerReply {
  6571. error: WorkerReplyType;
  6572. taskType: WorkerTaskType;
  6573. payload?: any;
  6574. }
  6575. interface CollisionReplyPayload {
  6576. newPosition: Array<number>;
  6577. collisionId: number;
  6578. collidedMeshUniqueId: number;
  6579. }
  6580. interface InitPayload {
  6581. }
  6582. interface CollidePayload {
  6583. collisionId: number;
  6584. collider: SerializedColliderToWorker;
  6585. maximumRetry: number;
  6586. excludedMeshUniqueId: Nullable<number>;
  6587. }
  6588. interface UpdatePayload {
  6589. updatedMeshes: {
  6590. [n: number]: SerializedMesh;
  6591. };
  6592. updatedGeometries: {
  6593. [s: string]: SerializedGeometry;
  6594. };
  6595. removedMeshes: Array<number>;
  6596. removedGeometries: Array<string>;
  6597. }
  6598. /** Defines kind of replies returned by worker */
  6599. enum WorkerReplyType {
  6600. /** Success */
  6601. SUCCESS = 0,
  6602. /** Unkown error */
  6603. UNKNOWN_ERROR = 1,
  6604. }
  6605. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6606. private _scene;
  6607. private _scaledPosition;
  6608. private _scaledVelocity;
  6609. private _collisionsCallbackArray;
  6610. private _init;
  6611. private _runningUpdated;
  6612. private _worker;
  6613. private _addUpdateMeshesList;
  6614. private _addUpdateGeometriesList;
  6615. private _toRemoveMeshesArray;
  6616. private _toRemoveGeometryArray;
  6617. constructor();
  6618. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6619. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6620. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6621. init(scene: Scene): void;
  6622. destroy(): void;
  6623. onMeshAdded(mesh: AbstractMesh): void;
  6624. onMeshUpdated: (transformNode: TransformNode) => void;
  6625. onMeshRemoved(mesh: AbstractMesh): void;
  6626. onGeometryAdded(geometry: Geometry): void;
  6627. onGeometryUpdated: (geometry: Geometry) => void;
  6628. onGeometryDeleted(geometry: Geometry): void;
  6629. private _afterRender;
  6630. private _onMessageFromWorker;
  6631. }
  6632. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6633. private _scene;
  6634. private _scaledPosition;
  6635. private _scaledVelocity;
  6636. private _finalPosition;
  6637. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6638. init(scene: Scene): void;
  6639. destroy(): void;
  6640. onMeshAdded(mesh: AbstractMesh): void;
  6641. onMeshUpdated(mesh: AbstractMesh): void;
  6642. onMeshRemoved(mesh: AbstractMesh): void;
  6643. onGeometryAdded(geometry: Geometry): void;
  6644. onGeometryUpdated(geometry: Geometry): void;
  6645. onGeometryDeleted(geometry: Geometry): void;
  6646. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  6647. }
  6648. }
  6649. declare function importScripts(...urls: string[]): void;
  6650. declare const safePostMessage: any;
  6651. declare module BABYLON {
  6652. var WorkerIncluded: boolean;
  6653. class CollisionCache {
  6654. private _meshes;
  6655. private _geometries;
  6656. getMeshes(): {
  6657. [n: number]: SerializedMesh;
  6658. };
  6659. getGeometries(): {
  6660. [s: number]: SerializedGeometry;
  6661. };
  6662. getMesh(id: any): SerializedMesh;
  6663. addMesh(mesh: SerializedMesh): void;
  6664. removeMesh(uniqueId: number): void;
  6665. getGeometry(id: string): SerializedGeometry;
  6666. addGeometry(geometry: SerializedGeometry): void;
  6667. removeGeometry(id: string): void;
  6668. }
  6669. class CollideWorker {
  6670. collider: Collider;
  6671. private _collisionCache;
  6672. private finalPosition;
  6673. private collisionsScalingMatrix;
  6674. private collisionTranformationMatrix;
  6675. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  6676. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  6677. private checkCollision(mesh);
  6678. private processCollisionsForSubMeshes(transformMatrix, mesh);
  6679. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  6680. private checkSubmeshCollision(subMesh);
  6681. }
  6682. interface ICollisionDetector {
  6683. onInit(payload: InitPayload): void;
  6684. onUpdate(payload: UpdatePayload): void;
  6685. onCollision(payload: CollidePayload): void;
  6686. }
  6687. class CollisionDetectorTransferable implements ICollisionDetector {
  6688. private _collisionCache;
  6689. onInit(payload: InitPayload): void;
  6690. onUpdate(payload: UpdatePayload): void;
  6691. onCollision(payload: CollidePayload): void;
  6692. }
  6693. }
  6694. declare module BABYLON {
  6695. class IntersectionInfo {
  6696. bu: Nullable<number>;
  6697. bv: Nullable<number>;
  6698. distance: number;
  6699. faceId: number;
  6700. subMeshId: number;
  6701. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6702. }
  6703. /**
  6704. * Information about the result of picking within a scene
  6705. * See https://doc.babylonjs.com/babylon101/picking_collisions
  6706. */
  6707. class PickingInfo {
  6708. /**
  6709. * If the pick collided with an object
  6710. */
  6711. hit: boolean;
  6712. /**
  6713. * Distance away where the pick collided
  6714. */
  6715. distance: number;
  6716. /**
  6717. * The location of pick collision
  6718. */
  6719. pickedPoint: Nullable<Vector3>;
  6720. /**
  6721. * The mesh corrisponding the the pick collision
  6722. */
  6723. pickedMesh: Nullable<AbstractMesh>;
  6724. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  6725. bu: number;
  6726. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  6727. bv: number;
  6728. /** The id of the face on the mesh that was picked */
  6729. faceId: number;
  6730. /** Id of the the submesh that was picked */
  6731. subMeshId: number;
  6732. /** If a sprite was picked, this will be the sprite the pick collided with */
  6733. pickedSprite: Nullable<Sprite>;
  6734. /**
  6735. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  6736. */
  6737. originMesh: Nullable<AbstractMesh>;
  6738. /**
  6739. * The ray that was used to perform the picking.
  6740. */
  6741. ray: Nullable<Ray>;
  6742. /**
  6743. * Gets the normal corrispodning to the face the pick collided with
  6744. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  6745. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  6746. * @returns The normal corrispodning to the face the pick collided with
  6747. */
  6748. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  6749. /**
  6750. * Gets the texture coordinates of where the pick occured
  6751. * @returns the vector containing the coordnates of the texture
  6752. */
  6753. getTextureCoordinates(): Nullable<Vector2>;
  6754. }
  6755. }
  6756. declare module BABYLON {
  6757. /**
  6758. * Interface for attribute information associated with buffer instanciation
  6759. */
  6760. class InstancingAttributeInfo {
  6761. /**
  6762. * Index/offset of the attribute in the vertex shader
  6763. */
  6764. index: number;
  6765. /**
  6766. * size of the attribute, 1, 2, 3 or 4
  6767. */
  6768. attributeSize: number;
  6769. /**
  6770. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  6771. * default is FLOAT
  6772. */
  6773. attribyteType: number;
  6774. /**
  6775. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  6776. */
  6777. normalized: boolean;
  6778. /**
  6779. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  6780. */
  6781. offset: number;
  6782. /**
  6783. * Name of the GLSL attribute, for debugging purpose only
  6784. */
  6785. attributeName: string;
  6786. }
  6787. /**
  6788. * Define options used to create a render target texture
  6789. */
  6790. class RenderTargetCreationOptions {
  6791. /**
  6792. * Specifies is mipmaps must be generated
  6793. */
  6794. generateMipMaps?: boolean;
  6795. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6796. generateDepthBuffer?: boolean;
  6797. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6798. generateStencilBuffer?: boolean;
  6799. /** Defines texture type (int by default) */
  6800. type?: number;
  6801. /** Defines sampling mode (trilinear by default) */
  6802. samplingMode?: number;
  6803. /** Defines format (RGBA by default) */
  6804. format?: number;
  6805. }
  6806. /**
  6807. * Define options used to create a depth texture
  6808. */
  6809. class DepthTextureCreationOptions {
  6810. /** Specifies whether or not a stencil should be allocated in the texture */
  6811. generateStencil?: boolean;
  6812. /** Specifies whether or not bilinear filtering is enable on the texture */
  6813. bilinearFiltering?: boolean;
  6814. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  6815. comparisonFunction?: number;
  6816. /** Specifies if the created texture is a cube texture */
  6817. isCube?: boolean;
  6818. }
  6819. /**
  6820. * Class used to describe the capabilities of the engine relatively to the current browser
  6821. */
  6822. class EngineCapabilities {
  6823. /** Maximum textures units per fragment shader */
  6824. maxTexturesImageUnits: number;
  6825. /** Maximum texture units per vertex shader */
  6826. maxVertexTextureImageUnits: number;
  6827. /** Maximum textures units in the entire pipeline */
  6828. maxCombinedTexturesImageUnits: number;
  6829. /** Maximum texture size */
  6830. maxTextureSize: number;
  6831. /** Maximum cube texture size */
  6832. maxCubemapTextureSize: number;
  6833. /** Maximum render texture size */
  6834. maxRenderTextureSize: number;
  6835. /** Maximum number of vertex attributes */
  6836. maxVertexAttribs: number;
  6837. /** Maximum number of varyings */
  6838. maxVaryingVectors: number;
  6839. /** Maximum number of uniforms per vertex shader */
  6840. maxVertexUniformVectors: number;
  6841. /** Maximum number of uniforms per fragment shader */
  6842. maxFragmentUniformVectors: number;
  6843. /** Defines if standard derivates (dx/dy) are supported */
  6844. standardDerivatives: boolean;
  6845. /** Defines if s3tc texture compression is supported */
  6846. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  6847. /** Defines if pvrtc texture compression is supported */
  6848. pvrtc: any;
  6849. /** Defines if etc1 texture compression is supported */
  6850. etc1: any;
  6851. /** Defines if etc2 texture compression is supported */
  6852. etc2: any;
  6853. /** Defines if astc texture compression is supported */
  6854. astc: any;
  6855. /** Defines if float textures are supported */
  6856. textureFloat: boolean;
  6857. /** Defines if vertex array objects are supported */
  6858. vertexArrayObject: boolean;
  6859. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  6860. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  6861. /** Gets the maximum level of anisotropy supported */
  6862. maxAnisotropy: number;
  6863. /** Defines if instancing is supported */
  6864. instancedArrays: boolean;
  6865. /** Defines if 32 bits indices are supported */
  6866. uintIndices: boolean;
  6867. /** Defines if high precision shaders are supported */
  6868. highPrecisionShaderSupported: boolean;
  6869. /** Defines if depth reading in the fragment shader is supported */
  6870. fragmentDepthSupported: boolean;
  6871. /** Defines if float texture linear filtering is supported*/
  6872. textureFloatLinearFiltering: boolean;
  6873. /** Defines if rendering to float textures is supported */
  6874. textureFloatRender: boolean;
  6875. /** Defines if half float textures are supported*/
  6876. textureHalfFloat: boolean;
  6877. /** Defines if half float texture linear filtering is supported*/
  6878. textureHalfFloatLinearFiltering: boolean;
  6879. /** Defines if rendering to half float textures is supported */
  6880. textureHalfFloatRender: boolean;
  6881. /** Defines if textureLOD shader command is supported */
  6882. textureLOD: boolean;
  6883. /** Defines if draw buffers extension is supported */
  6884. drawBuffersExtension: boolean;
  6885. /** Defines if depth textures are supported */
  6886. depthTextureExtension: boolean;
  6887. /** Defines if float color buffer are supported */
  6888. colorBufferFloat: boolean;
  6889. /** Gets disjoint timer query extension (null if not supported) */
  6890. timerQuery: EXT_disjoint_timer_query;
  6891. /** Defines if timestamp can be used with timer query */
  6892. canUseTimestampForTimerQuery: boolean;
  6893. }
  6894. /** Interface defining initialization parameters for Engine class */
  6895. interface EngineOptions extends WebGLContextAttributes {
  6896. /**
  6897. * Defines if the engine should no exceed a specified device ratio
  6898. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  6899. */
  6900. limitDeviceRatio?: number;
  6901. /**
  6902. * Defines if webvr should be enabled automatically
  6903. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6904. */
  6905. autoEnableWebVR?: boolean;
  6906. /**
  6907. * Defines if webgl2 should be turned off even if supported
  6908. * @see http://doc.babylonjs.com/features/webgl2
  6909. */
  6910. disableWebGL2Support?: boolean;
  6911. /**
  6912. * Defines if webaudio should be initialized as well
  6913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6914. */
  6915. audioEngine?: boolean;
  6916. /**
  6917. * Defines if animations should run using a deterministic lock step
  6918. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6919. */
  6920. deterministicLockstep?: boolean;
  6921. /** Defines the maximum steps to use with deterministic lock step mode */
  6922. lockstepMaxSteps?: number;
  6923. /**
  6924. * Defines that engine should ignore context lost events
  6925. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  6926. */
  6927. doNotHandleContextLost?: boolean;
  6928. }
  6929. /**
  6930. * Defines the interface used by display changed events
  6931. */
  6932. interface IDisplayChangedEventArgs {
  6933. /** Gets the vrDisplay object (if any) */
  6934. vrDisplay: Nullable<any>;
  6935. /** Gets a boolean indicating if webVR is supported */
  6936. vrSupported: boolean;
  6937. }
  6938. /**
  6939. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  6940. */
  6941. class Engine {
  6942. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  6943. static ExceptionList: ({
  6944. key: string;
  6945. capture: string;
  6946. captureConstraint: number;
  6947. targets: string[];
  6948. } | {
  6949. key: string;
  6950. capture: null;
  6951. captureConstraint: null;
  6952. targets: string[];
  6953. })[];
  6954. /** Gets the list of created engines */
  6955. static Instances: Engine[];
  6956. /**
  6957. * Gets the latest created engine
  6958. */
  6959. static readonly LastCreatedEngine: Nullable<Engine>;
  6960. /**
  6961. * Gets the latest created scene
  6962. */
  6963. static readonly LastCreatedScene: Nullable<Scene>;
  6964. /**
  6965. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  6966. * @param flag defines which part of the materials must be marked as dirty
  6967. * @param predicate defines a predicate used to filter which materials should be affected
  6968. */
  6969. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  6970. /** Defines that alpha blending is disabled */
  6971. static readonly ALPHA_DISABLE: number;
  6972. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  6973. static readonly ALPHA_ADD: number;
  6974. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  6975. static readonly ALPHA_COMBINE: number;
  6976. /** Defines that alpha blending to DEST - SRC * DEST */
  6977. static readonly ALPHA_SUBTRACT: number;
  6978. /** Defines that alpha blending to SRC * DEST */
  6979. static readonly ALPHA_MULTIPLY: number;
  6980. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  6981. static readonly ALPHA_MAXIMIZED: number;
  6982. /** Defines that alpha blending to SRC + DEST */
  6983. static readonly ALPHA_ONEONE: number;
  6984. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  6985. static readonly ALPHA_PREMULTIPLIED: number;
  6986. /**
  6987. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  6988. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  6989. */
  6990. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  6991. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  6992. static readonly ALPHA_INTERPOLATE: number;
  6993. /**
  6994. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  6995. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  6996. */
  6997. static readonly ALPHA_SCREENMODE: number;
  6998. /** Defines that the ressource is not delayed*/
  6999. static readonly DELAYLOADSTATE_NONE: number;
  7000. /** Defines that the ressource was successfully delay loaded */
  7001. static readonly DELAYLOADSTATE_LOADED: number;
  7002. /** Defines that the ressource is currently delay loading */
  7003. static readonly DELAYLOADSTATE_LOADING: number;
  7004. /** Defines that the ressource is delayed and has not started loading */
  7005. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7006. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7007. static readonly NEVER: number;
  7008. /** 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 */
  7009. static readonly ALWAYS: number;
  7010. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7011. static readonly LESS: number;
  7012. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7013. static readonly EQUAL: number;
  7014. /** 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 */
  7015. static readonly LEQUAL: number;
  7016. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7017. static readonly GREATER: number;
  7018. /** 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 */
  7019. static readonly GEQUAL: number;
  7020. /** 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 */
  7021. static readonly NOTEQUAL: number;
  7022. /** Passed to stencilOperation to specify that stencil value must be kept */
  7023. static readonly KEEP: number;
  7024. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7025. static readonly REPLACE: number;
  7026. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7027. static readonly INCR: number;
  7028. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7029. static readonly DECR: number;
  7030. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7031. static readonly INVERT: number;
  7032. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7033. static readonly INCR_WRAP: number;
  7034. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7035. static readonly DECR_WRAP: number;
  7036. /** Texture is not repeating outside of 0..1 UVs */
  7037. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  7038. /** Texture is repeating outside of 0..1 UVs */
  7039. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  7040. /** Texture is repeating and mirrored */
  7041. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  7042. /** ALPHA */
  7043. static readonly TEXTUREFORMAT_ALPHA: number;
  7044. /** LUMINANCE */
  7045. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7046. /** LUMINANCE_ALPHA */
  7047. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7048. /** RGB */
  7049. static readonly TEXTUREFORMAT_RGB: number;
  7050. /** RGBA */
  7051. static readonly TEXTUREFORMAT_RGBA: number;
  7052. /** R */
  7053. static readonly TEXTUREFORMAT_R: number;
  7054. /** RG */
  7055. static readonly TEXTUREFORMAT_RG: number;
  7056. /** UNSIGNED_INT */
  7057. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7058. /** FLOAT */
  7059. static readonly TEXTURETYPE_FLOAT: number;
  7060. /** HALF_FLOAT */
  7061. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7062. /** nearest is mag = nearest and min = nearest and mip = linear */
  7063. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  7064. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7065. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  7066. /** Trilinear is mag = linear and min = linear and mip = linear */
  7067. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  7068. /** nearest is mag = nearest and min = nearest and mip = linear */
  7069. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  7070. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7071. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  7072. /** Trilinear is mag = linear and min = linear and mip = linear */
  7073. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  7074. /** mag = nearest and min = nearest and mip = nearest */
  7075. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  7076. /** mag = nearest and min = linear and mip = nearest */
  7077. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  7078. /** mag = nearest and min = linear and mip = linear */
  7079. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  7080. /** mag = nearest and min = linear and mip = none */
  7081. static readonly TEXTURE_NEAREST_LINEAR: number;
  7082. /** mag = nearest and min = nearest and mip = none */
  7083. static readonly TEXTURE_NEAREST_NEAREST: number;
  7084. /** mag = linear and min = nearest and mip = nearest */
  7085. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  7086. /** mag = linear and min = nearest and mip = linear */
  7087. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  7088. /** mag = linear and min = linear and mip = none */
  7089. static readonly TEXTURE_LINEAR_LINEAR: number;
  7090. /** mag = linear and min = nearest and mip = none */
  7091. static readonly TEXTURE_LINEAR_NEAREST: number;
  7092. /** Explicit coordinates mode */
  7093. static readonly TEXTURE_EXPLICIT_MODE: number;
  7094. /** Spherical coordinates mode */
  7095. static readonly TEXTURE_SPHERICAL_MODE: number;
  7096. /** Planar coordinates mode */
  7097. static readonly TEXTURE_PLANAR_MODE: number;
  7098. /** Cubic coordinates mode */
  7099. static readonly TEXTURE_CUBIC_MODE: number;
  7100. /** Projection coordinates mode */
  7101. static readonly TEXTURE_PROJECTION_MODE: number;
  7102. /** Skybox coordinates mode */
  7103. static readonly TEXTURE_SKYBOX_MODE: number;
  7104. /** Inverse Cubic coordinates mode */
  7105. static readonly TEXTURE_INVCUBIC_MODE: number;
  7106. /** Equirectangular coordinates mode */
  7107. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  7108. /** Equirectangular Fixed coordinates mode */
  7109. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  7110. /** Equirectangular Fixed Mirrored coordinates mode */
  7111. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  7112. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7113. static readonly SCALEMODE_FLOOR: number;
  7114. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7115. static readonly SCALEMODE_NEAREST: number;
  7116. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7117. static readonly SCALEMODE_CEILING: number;
  7118. /**
  7119. * Returns the current version of the framework
  7120. */
  7121. static readonly Version: string;
  7122. /**
  7123. * Gets or sets the epsilon value used by collision engine
  7124. */
  7125. static CollisionsEpsilon: number;
  7126. /**
  7127. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7128. */
  7129. static CodeRepository: string;
  7130. /**
  7131. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7132. */
  7133. static ShadersRepository: string;
  7134. /**
  7135. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7136. */
  7137. forcePOTTextures: boolean;
  7138. /**
  7139. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7140. */
  7141. isFullscreen: boolean;
  7142. /**
  7143. * Gets a boolean indicating if the pointer is currently locked
  7144. */
  7145. isPointerLock: boolean;
  7146. /**
  7147. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7148. */
  7149. cullBackFaces: boolean;
  7150. /**
  7151. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7152. */
  7153. renderEvenInBackground: boolean;
  7154. /**
  7155. * Gets or sets a boolean indicating that cache can be kept between frames
  7156. */
  7157. preventCacheWipeBetweenFrames: boolean;
  7158. /**
  7159. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7160. **/
  7161. enableOfflineSupport: boolean;
  7162. /**
  7163. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date)
  7164. **/
  7165. disableManifestCheck: boolean;
  7166. /**
  7167. * Gets the list of created scenes
  7168. */
  7169. scenes: Scene[];
  7170. /**
  7171. * Gets the list of created postprocesses
  7172. */
  7173. postProcesses: PostProcess[];
  7174. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  7175. validateShaderPrograms: boolean;
  7176. /**
  7177. * Observable event triggered each time the rendering canvas is resized
  7178. */
  7179. onResizeObservable: Observable<Engine>;
  7180. /**
  7181. * Observable event triggered each time the canvas loses focus
  7182. */
  7183. onCanvasBlurObservable: Observable<Engine>;
  7184. /**
  7185. * Observable event triggered each time the canvas gains focus
  7186. */
  7187. onCanvasFocusObservable: Observable<Engine>;
  7188. /**
  7189. * Observable event triggered each time the canvas receives pointerout event
  7190. */
  7191. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7192. /**
  7193. * Observable event triggered before each texture is initialized
  7194. */
  7195. onBeforeTextureInitObservable: Observable<Texture>;
  7196. private _vrDisplay;
  7197. private _vrSupported;
  7198. private _oldSize;
  7199. private _oldHardwareScaleFactor;
  7200. private _vrExclusivePointerMode;
  7201. private _webVRInitPromise;
  7202. /**
  7203. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7204. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7205. */
  7206. readonly isInVRExclusivePointerMode: boolean;
  7207. /**
  7208. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7209. */
  7210. disableUniformBuffers: boolean;
  7211. /** @hidden */
  7212. _uniformBuffers: UniformBuffer[];
  7213. /**
  7214. * Gets a boolean indicating that the engine supports uniform buffers
  7215. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7216. */
  7217. readonly supportsUniformBuffers: boolean;
  7218. /**
  7219. * Observable raised when the engine begins a new frame
  7220. */
  7221. onBeginFrameObservable: Observable<Engine>;
  7222. /**
  7223. * Observable raised when the engine ends the current frame
  7224. */
  7225. onEndFrameObservable: Observable<Engine>;
  7226. /**
  7227. * Observable raised when the engine is about to compile a shader
  7228. */
  7229. onBeforeShaderCompilationObservable: Observable<Engine>;
  7230. /**
  7231. * Observable raised when the engine has jsut compiled a shader
  7232. */
  7233. onAfterShaderCompilationObservable: Observable<Engine>;
  7234. private _gl;
  7235. private _renderingCanvas;
  7236. private _windowIsBackground;
  7237. private _webGLVersion;
  7238. /**
  7239. * Gets a boolean indicating that only power of 2 textures are supported
  7240. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7241. */
  7242. readonly needPOTTextures: boolean;
  7243. /** @hidden */
  7244. _badOS: boolean;
  7245. /** @hidden */
  7246. _badDesktopOS: boolean;
  7247. /**
  7248. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7249. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7250. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7251. */
  7252. disableTextureBindingOptimization: boolean;
  7253. /**
  7254. * Gets the audio engine
  7255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7256. * @ignorenaming
  7257. */
  7258. static audioEngine: AudioEngine;
  7259. private _onFocus;
  7260. private _onBlur;
  7261. private _onCanvasPointerOut;
  7262. private _onCanvasBlur;
  7263. private _onCanvasFocus;
  7264. private _onFullscreenChange;
  7265. private _onPointerLockChange;
  7266. private _onVRDisplayPointerRestricted;
  7267. private _onVRDisplayPointerUnrestricted;
  7268. private _onVrDisplayConnect;
  7269. private _onVrDisplayDisconnect;
  7270. private _onVrDisplayPresentChange;
  7271. /**
  7272. * Observable signaled when VR display mode changes
  7273. */
  7274. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7275. /**
  7276. * Observable signaled when VR request present is complete
  7277. */
  7278. onVRRequestPresentComplete: Observable<boolean>;
  7279. /**
  7280. * Observable signaled when VR request present starts
  7281. */
  7282. onVRRequestPresentStart: Observable<Engine>;
  7283. private _hardwareScalingLevel;
  7284. /** @hidden */
  7285. protected _caps: EngineCapabilities;
  7286. private _pointerLockRequested;
  7287. private _isStencilEnable;
  7288. private _colorWrite;
  7289. private _loadingScreen;
  7290. /** @hidden */
  7291. _drawCalls: PerfCounter;
  7292. /** @hidden */
  7293. _textureCollisions: PerfCounter;
  7294. private _glVersion;
  7295. private _glRenderer;
  7296. private _glVendor;
  7297. private _videoTextureSupported;
  7298. private _renderingQueueLaunched;
  7299. private _activeRenderLoops;
  7300. private _deterministicLockstep;
  7301. private _lockstepMaxSteps;
  7302. /**
  7303. * Observable signaled when a context lost event is raised
  7304. */
  7305. onContextLostObservable: Observable<Engine>;
  7306. /**
  7307. * Observable signaled when a context restored event is raised
  7308. */
  7309. onContextRestoredObservable: Observable<Engine>;
  7310. private _onContextLost;
  7311. private _onContextRestored;
  7312. private _contextWasLost;
  7313. private _doNotHandleContextLost;
  7314. /**
  7315. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7316. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7317. */
  7318. doNotHandleContextLost: boolean;
  7319. private _performanceMonitor;
  7320. private _fps;
  7321. private _deltaTime;
  7322. /**
  7323. * Turn this value on if you want to pause FPS computation when in background
  7324. */
  7325. disablePerformanceMonitorInBackground: boolean;
  7326. /**
  7327. * Gets the performance monitor attached to this engine
  7328. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7329. */
  7330. readonly performanceMonitor: PerformanceMonitor;
  7331. /** @hidden */
  7332. protected _depthCullingState: _DepthCullingState;
  7333. /** @hidden */
  7334. protected _stencilState: _StencilState;
  7335. /** @hidden */
  7336. protected _alphaState: _AlphaState;
  7337. /** @hidden */
  7338. protected _alphaMode: number;
  7339. protected _internalTexturesCache: InternalTexture[];
  7340. /** @hidden */
  7341. protected _activeChannel: number;
  7342. private _currentTextureChannel;
  7343. /** @hidden */
  7344. protected _boundTexturesCache: {
  7345. [key: string]: Nullable<InternalTexture>;
  7346. };
  7347. /** @hidden */
  7348. protected _currentEffect: Nullable<Effect>;
  7349. /** @hidden */
  7350. protected _currentProgram: Nullable<WebGLProgram>;
  7351. private _compiledEffects;
  7352. private _vertexAttribArraysEnabled;
  7353. /** @hidden */
  7354. protected _cachedViewport: Nullable<Viewport>;
  7355. private _cachedVertexArrayObject;
  7356. /** @hidden */
  7357. protected _cachedVertexBuffers: any;
  7358. /** @hidden */
  7359. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7360. /** @hidden */
  7361. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7362. /** @hidden */
  7363. protected _currentRenderTarget: Nullable<InternalTexture>;
  7364. private _uintIndicesCurrentlySet;
  7365. private _currentBoundBuffer;
  7366. /** @hidden */
  7367. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7368. private _currentBufferPointers;
  7369. private _currentInstanceLocations;
  7370. private _currentInstanceBuffers;
  7371. private _textureUnits;
  7372. private _firstBoundInternalTextureTracker;
  7373. private _lastBoundInternalTextureTracker;
  7374. private _workingCanvas;
  7375. private _workingContext;
  7376. private _rescalePostProcess;
  7377. private _dummyFramebuffer;
  7378. private _externalData;
  7379. private _bindedRenderFunction;
  7380. private _vaoRecordInProgress;
  7381. private _mustWipeVertexAttributes;
  7382. private _emptyTexture;
  7383. private _emptyCubeTexture;
  7384. private _emptyTexture3D;
  7385. private _frameHandler;
  7386. private _nextFreeTextureSlots;
  7387. private _maxSimultaneousTextures;
  7388. private _activeRequests;
  7389. private _texturesSupported;
  7390. private _textureFormatInUse;
  7391. /**
  7392. * Gets the list of texture formats supported
  7393. */
  7394. readonly texturesSupported: Array<string>;
  7395. /**
  7396. * Gets the list of texture formats in use
  7397. */
  7398. readonly textureFormatInUse: Nullable<string>;
  7399. /**
  7400. * Gets the current viewport
  7401. */
  7402. readonly currentViewport: Nullable<Viewport>;
  7403. /**
  7404. * Gets the default empty texture
  7405. */
  7406. readonly emptyTexture: InternalTexture;
  7407. /**
  7408. * Gets the default empty 3D texture
  7409. */
  7410. readonly emptyTexture3D: InternalTexture;
  7411. /**
  7412. * Gets the default empty cube texture
  7413. */
  7414. readonly emptyCubeTexture: InternalTexture;
  7415. /**
  7416. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  7417. */
  7418. readonly premultipliedAlpha: boolean;
  7419. /**
  7420. * Creates a new engine
  7421. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  7422. * @param antialias defines enable antialiasing (default: false)
  7423. * @param options defines further options to be sent to the getContext() function
  7424. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7425. */
  7426. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7427. private _rebuildInternalTextures();
  7428. private _rebuildEffects();
  7429. private _rebuildBuffers();
  7430. private _initGLContext();
  7431. /**
  7432. * Gets version of the current webGL context
  7433. */
  7434. readonly webGLVersion: number;
  7435. /**
  7436. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7437. */
  7438. readonly isStencilEnable: boolean;
  7439. private _prepareWorkingCanvas();
  7440. /**
  7441. * Reset the texture cache to empty state
  7442. */
  7443. resetTextureCache(): void;
  7444. /**
  7445. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7446. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7447. * @returns true if engine is in deterministic lock step mode
  7448. */
  7449. isDeterministicLockStep(): boolean;
  7450. /**
  7451. * Gets the max steps when engine is running in deterministic lock step
  7452. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7453. * @returns the max steps
  7454. */
  7455. getLockstepMaxSteps(): number;
  7456. /**
  7457. * Gets an object containing information about the current webGL context
  7458. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7459. */
  7460. getGlInfo(): {
  7461. vendor: string;
  7462. renderer: string;
  7463. version: string;
  7464. };
  7465. /**
  7466. * Gets current aspect ratio
  7467. * @param camera defines the camera to use to get the aspect ratio
  7468. * @param useScreen defines if screen size must be used (or the current render target if any)
  7469. * @returns a number defining the aspect ratio
  7470. */
  7471. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7472. /**
  7473. * Gets current screen aspect ratio
  7474. * @returns a number defining the aspect ratio
  7475. */
  7476. getScreenAspectRatio(): number;
  7477. /**
  7478. * Gets the current render width
  7479. * @param useScreen defines if screen size must be used (or the current render target if any)
  7480. * @returns a number defining the current render width
  7481. */
  7482. getRenderWidth(useScreen?: boolean): number;
  7483. /**
  7484. * Gets the current render height
  7485. * @param useScreen defines if screen size must be used (or the current render target if any)
  7486. * @returns a number defining the current render height
  7487. */
  7488. getRenderHeight(useScreen?: boolean): number;
  7489. /**
  7490. * Gets the HTML canvas attached with the current webGL context
  7491. * @returns a HTML canvas
  7492. */
  7493. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7494. /**
  7495. * Gets the client rect of the HTML canvas attached with the current webGL context
  7496. * @returns a client rectanglee
  7497. */
  7498. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7499. /**
  7500. * Defines the hardware scaling level.
  7501. * By default the hardware scaling level is computed from the window device ratio.
  7502. * 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.
  7503. * @param level defines the level to use
  7504. */
  7505. setHardwareScalingLevel(level: number): void;
  7506. /**
  7507. * Gets the current hardware scaling level.
  7508. * By default the hardware scaling level is computed from the window device ratio.
  7509. * 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.
  7510. * @returns a number indicating the current hardware scaling level
  7511. */
  7512. getHardwareScalingLevel(): number;
  7513. /**
  7514. * Gets the list of loaded textures
  7515. * @returns an array containing all loaded textures
  7516. */
  7517. getLoadedTexturesCache(): InternalTexture[];
  7518. /**
  7519. * Gets the object containing all engine capabilities
  7520. * @returns the EngineCapabilities object
  7521. */
  7522. getCaps(): EngineCapabilities;
  7523. /** @hidden */
  7524. readonly drawCalls: number;
  7525. /** @hidden */
  7526. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7527. /**
  7528. * Gets the current depth function
  7529. * @returns a number defining the depth function
  7530. */
  7531. getDepthFunction(): Nullable<number>;
  7532. /**
  7533. * Sets the current depth function
  7534. * @param depthFunc defines the function to use
  7535. */
  7536. setDepthFunction(depthFunc: number): void;
  7537. /**
  7538. * Sets the current depth function to GREATER
  7539. */
  7540. setDepthFunctionToGreater(): void;
  7541. /**
  7542. * Sets the current depth function to GEQUAL
  7543. */
  7544. setDepthFunctionToGreaterOrEqual(): void;
  7545. /**
  7546. * Sets the current depth function to LESS
  7547. */
  7548. setDepthFunctionToLess(): void;
  7549. /**
  7550. * Sets the current depth function to LEQUAL
  7551. */
  7552. setDepthFunctionToLessOrEqual(): void;
  7553. /**
  7554. * Gets a boolean indicating if stencil buffer is enabled
  7555. * @returns the current stencil buffer state
  7556. */
  7557. getStencilBuffer(): boolean;
  7558. /**
  7559. * Enable or disable the stencil buffer
  7560. * @param enable defines if the stencil buffer must be enabled or disabled
  7561. */
  7562. setStencilBuffer(enable: boolean): void;
  7563. /**
  7564. * Gets the current stencil mask
  7565. * @returns a number defining the new stencil mask to use
  7566. */
  7567. getStencilMask(): number;
  7568. /**
  7569. * Sets the current stencil mask
  7570. * @param mask defines the new stencil mask to use
  7571. */
  7572. setStencilMask(mask: number): void;
  7573. /**
  7574. * Gets the current stencil function
  7575. * @returns a number defining the stencil function to use
  7576. */
  7577. getStencilFunction(): number;
  7578. /**
  7579. * Gets the current stencil reference value
  7580. * @returns a number defining the stencil reference value to use
  7581. */
  7582. getStencilFunctionReference(): number;
  7583. /**
  7584. * Gets the current stencil mask
  7585. * @returns a number defining the stencil mask to use
  7586. */
  7587. getStencilFunctionMask(): number;
  7588. /**
  7589. * Sets the current stencil function
  7590. * @param stencilFunc defines the new stencil function to use
  7591. */
  7592. setStencilFunction(stencilFunc: number): void;
  7593. /**
  7594. * Sets the current stencil reference
  7595. * @param reference defines the new stencil reference to use
  7596. */
  7597. setStencilFunctionReference(reference: number): void;
  7598. /**
  7599. * Sets the current stencil mask
  7600. * @param mask defines the new stencil mask to use
  7601. */
  7602. setStencilFunctionMask(mask: number): void;
  7603. /**
  7604. * Gets the current stencil operation when stencil fails
  7605. * @returns a number defining stencil operation to use when stencil fails
  7606. */
  7607. getStencilOperationFail(): number;
  7608. /**
  7609. * Gets the current stencil operation when depth fails
  7610. * @returns a number defining stencil operation to use when depth fails
  7611. */
  7612. getStencilOperationDepthFail(): number;
  7613. /**
  7614. * Gets the current stencil operation when stencil passes
  7615. * @returns a number defining stencil operation to use when stencil passes
  7616. */
  7617. getStencilOperationPass(): number;
  7618. /**
  7619. * Sets the stencil operation to use when stencil fails
  7620. * @param operation defines the stencil operation to use when stencil fails
  7621. */
  7622. setStencilOperationFail(operation: number): void;
  7623. /**
  7624. * Sets the stencil operation to use when depth fails
  7625. * @param operation defines the stencil operation to use when depth fails
  7626. */
  7627. setStencilOperationDepthFail(operation: number): void;
  7628. /**
  7629. * Sets the stencil operation to use when stencil passes
  7630. * @param operation defines the stencil operation to use when stencil passes
  7631. */
  7632. setStencilOperationPass(operation: number): void;
  7633. /**
  7634. * Sets a boolean indicating if the dithering state is enabled or disabled
  7635. * @param value defines the dithering state
  7636. */
  7637. setDitheringState(value: boolean): void;
  7638. /**
  7639. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7640. * @param value defines the rasterizer state
  7641. */
  7642. setRasterizerState(value: boolean): void;
  7643. /**
  7644. * stop executing a render loop function and remove it from the execution array
  7645. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7646. */
  7647. stopRenderLoop(renderFunction?: () => void): void;
  7648. /** @hidden */
  7649. _renderLoop(): void;
  7650. /**
  7651. * Register and execute a render loop. The engine can have more than one render function
  7652. * @param renderFunction defines the function to continuously execute
  7653. */
  7654. runRenderLoop(renderFunction: () => void): void;
  7655. /**
  7656. * Toggle full screen mode
  7657. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7658. * @param options defines an option object to be sent to the requestFullscreen function
  7659. */
  7660. switchFullscreen(requestPointerLock: boolean): void;
  7661. /**
  7662. * Clear the current render buffer or the current render target (if any is set up)
  7663. * @param color defines the color to use
  7664. * @param backBuffer defines if the back buffer must be cleared
  7665. * @param depth defines if the depth buffer must be cleared
  7666. * @param stencil defines if the stencil buffer must be cleared
  7667. */
  7668. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7669. /**
  7670. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7671. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7672. * @param y defines the y-coordinate of the corner of the clear rectangle
  7673. * @param width defines the width of the clear rectangle
  7674. * @param height defines the height of the clear rectangle
  7675. * @param clearColor defines the clear color
  7676. */
  7677. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7678. private _viewportCached;
  7679. /** @hidden */
  7680. _viewport(x: number, y: number, width: number, height: number): void;
  7681. /**
  7682. * Set the WebGL's viewport
  7683. * @param viewport defines the viewport element to be used
  7684. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7685. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7686. */
  7687. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7688. /**
  7689. * Directly set the WebGL Viewport
  7690. * @param x defines the x coordinate of the viewport (in screen space)
  7691. * @param y defines the y coordinate of the viewport (in screen space)
  7692. * @param width defines the width of the viewport (in screen space)
  7693. * @param height defines the height of the viewport (in screen space)
  7694. * @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
  7695. */
  7696. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  7697. /**
  7698. * Begin a new frame
  7699. */
  7700. beginFrame(): void;
  7701. /**
  7702. * Enf the current frame
  7703. */
  7704. endFrame(): void;
  7705. /**
  7706. * Resize the view according to the canvas' size
  7707. */
  7708. resize(): void;
  7709. /**
  7710. * Force a specific size of the canvas
  7711. * @param width defines the new canvas' width
  7712. * @param height defines the new canvas' height
  7713. */
  7714. setSize(width: number, height: number): void;
  7715. /**
  7716. * Gets a boolean indicating if a webVR device was detected
  7717. * @returns true if a webVR device was detected
  7718. */
  7719. isVRDevicePresent(): boolean;
  7720. /**
  7721. * Gets the current webVR device
  7722. * @returns the current webVR device (or null)
  7723. */
  7724. getVRDevice(): any;
  7725. /**
  7726. * Initializes a webVR display and starts listening to display change events
  7727. * The onVRDisplayChangedObservable will be notified upon these changes
  7728. * @returns The onVRDisplayChangedObservable
  7729. */
  7730. initWebVR(): Observable<IDisplayChangedEventArgs>;
  7731. /**
  7732. * Initializes a webVR display and starts listening to display change events
  7733. * The onVRDisplayChangedObservable will be notified upon these changes
  7734. * @returns A promise containing a VRDisplay and if vr is supported
  7735. */
  7736. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  7737. /**
  7738. * Call this function to switch to webVR mode
  7739. * Will do nothing if webVR is not supported or if there is no webVR device
  7740. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7741. */
  7742. enableVR(): void;
  7743. /**
  7744. * Call this function to leave webVR mode
  7745. * Will do nothing if webVR is not supported or if there is no webVR device
  7746. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7747. */
  7748. disableVR(): void;
  7749. private _onVRFullScreenTriggered;
  7750. private _getVRDisplaysAsync();
  7751. /**
  7752. * Binds the frame buffer to the specified texture.
  7753. * @param texture The texture to render to or null for the default canvas
  7754. * @param faceIndex The face of the texture to render to in case of cube texture
  7755. * @param requiredWidth The width of the target to render to
  7756. * @param requiredHeight The height of the target to render to
  7757. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  7758. * @param depthStencilTexture The depth stencil texture to use to render
  7759. * @param lodLevel defines le lod level to bind to the frame buffer
  7760. */
  7761. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  7762. private bindUnboundFramebuffer(framebuffer);
  7763. /**
  7764. * Unbind the current render target texture from the webGL context
  7765. * @param texture defines the render target texture to unbind
  7766. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7767. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7768. */
  7769. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7770. /**
  7771. * Unbind a list of render target textures from the webGL context
  7772. * This is used only when drawBuffer extension or webGL2 are active
  7773. * @param textures defines the render target textures to unbind
  7774. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7775. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7776. */
  7777. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7778. /**
  7779. * Force the mipmap generation for the given render target texture
  7780. * @param texture defines the render target texture to use
  7781. */
  7782. generateMipMapsForCubemap(texture: InternalTexture): void;
  7783. /**
  7784. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  7785. */
  7786. flushFramebuffer(): void;
  7787. /**
  7788. * Unbind the current render target and bind the default framebuffer
  7789. */
  7790. restoreDefaultFramebuffer(): void;
  7791. /**
  7792. * Create an uniform buffer
  7793. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7794. * @param elements defines the content of the uniform buffer
  7795. * @returns the webGL uniform buffer
  7796. */
  7797. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  7798. /**
  7799. * Create a dynamic uniform buffer
  7800. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7801. * @param elements defines the content of the uniform buffer
  7802. * @returns the webGL uniform buffer
  7803. */
  7804. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  7805. /**
  7806. * Update an existing uniform buffer
  7807. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7808. * @param uniformBuffer defines the target uniform buffer
  7809. * @param elements defines the content to update
  7810. * @param offset defines the offset in the uniform buffer where update should start
  7811. * @param count defines the size of the data to update
  7812. */
  7813. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7814. private _resetVertexBufferBinding();
  7815. /**
  7816. * Creates a vertex buffer
  7817. * @param data the data for the vertex buffer
  7818. * @returns the new WebGL static buffer
  7819. */
  7820. createVertexBuffer(data: DataArray): WebGLBuffer;
  7821. /**
  7822. * Creates a dynamic vertex buffer
  7823. * @param data the data for the dynamic vertex buffer
  7824. * @returns the new WebGL dynamic buffer
  7825. */
  7826. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  7827. /**
  7828. * Update a dynamic index buffer
  7829. * @param indexBuffer defines the target index buffer
  7830. * @param indices defines the data to update
  7831. * @param offset defines the offset in the target index buffer where update should start
  7832. */
  7833. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7834. /**
  7835. * Updates a dynamic vertex buffer.
  7836. * @param vertexBuffer the vertex buffer to update
  7837. * @param data the data used to update the vertex buffer
  7838. * @param byteOffset the byte offset of the data
  7839. * @param byteLength the byte length of the data
  7840. */
  7841. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  7842. private _resetIndexBufferBinding();
  7843. /**
  7844. * Creates a new index buffer
  7845. * @param indices defines the content of the index buffer
  7846. * @param updatable defines if the index buffer must be updatable
  7847. * @returns a new webGL buffer
  7848. */
  7849. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  7850. /**
  7851. * Bind a webGL buffer to the webGL context
  7852. * @param buffer defines the buffer to bind
  7853. */
  7854. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  7855. /**
  7856. * Bind an uniform buffer to the current webGL context
  7857. * @param buffer defines the buffer to bind
  7858. */
  7859. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  7860. /**
  7861. * Bind a buffer to the current webGL context at a given location
  7862. * @param buffer defines the buffer to bind
  7863. * @param location defines the index where to bind the buffer
  7864. */
  7865. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  7866. /**
  7867. * Bind a specific block at a given index in a specific shader program
  7868. * @param shaderProgram defines the shader program
  7869. * @param blockName defines the block name
  7870. * @param index defines the index where to bind the block
  7871. */
  7872. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  7873. private bindIndexBuffer(buffer);
  7874. private bindBuffer(buffer, target);
  7875. /**
  7876. * update the bound buffer with the given data
  7877. * @param data defines the data to update
  7878. */
  7879. updateArrayBuffer(data: Float32Array): void;
  7880. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  7881. private _bindIndexBufferWithCache(indexBuffer);
  7882. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  7883. /**
  7884. * Records a vertex array object
  7885. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7886. * @param vertexBuffers defines the list of vertex buffers to store
  7887. * @param indexBuffer defines the index buffer to store
  7888. * @param effect defines the effect to store
  7889. * @returns the new vertex array object
  7890. */
  7891. recordVertexArrayObject(vertexBuffers: {
  7892. [key: string]: VertexBuffer;
  7893. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  7894. /**
  7895. * Bind a specific vertex array object
  7896. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7897. * @param vertexArrayObject defines the vertex array object to bind
  7898. * @param indexBuffer defines the index buffer to bind
  7899. */
  7900. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  7901. /**
  7902. * Bind webGl buffers directly to the webGL context
  7903. * @param vertexBuffer defines the vertex buffer to bind
  7904. * @param indexBuffer defines the index buffer to bind
  7905. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  7906. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  7907. * @param effect defines the effect associated with the vertex buffer
  7908. */
  7909. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  7910. private _unbindVertexArrayObject();
  7911. /**
  7912. * Bind a list of vertex buffers to the webGL context
  7913. * @param vertexBuffers defines the list of vertex buffers to bind
  7914. * @param indexBuffer defines the index buffer to bind
  7915. * @param effect defines the effect associated with the vertex buffers
  7916. */
  7917. bindBuffers(vertexBuffers: {
  7918. [key: string]: Nullable<VertexBuffer>;
  7919. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  7920. /**
  7921. * Unbind all instance attributes
  7922. */
  7923. unbindInstanceAttributes(): void;
  7924. /**
  7925. * Release and free the memory of a vertex array object
  7926. * @param vao defines the vertex array object to delete
  7927. */
  7928. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  7929. /** @hidden */
  7930. _releaseBuffer(buffer: WebGLBuffer): boolean;
  7931. /**
  7932. * Creates a webGL buffer to use with instanciation
  7933. * @param capacity defines the size of the buffer
  7934. * @returns the webGL buffer
  7935. */
  7936. createInstancesBuffer(capacity: number): WebGLBuffer;
  7937. /**
  7938. * Delete a webGL buffer used with instanciation
  7939. * @param buffer defines the webGL buffer to delete
  7940. */
  7941. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  7942. /**
  7943. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  7944. * @param instancesBuffer defines the webGL buffer to update and bind
  7945. * @param data defines the data to store in the buffer
  7946. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  7947. */
  7948. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  7949. /**
  7950. * Apply all cached states (depth, culling, stencil and alpha)
  7951. */
  7952. applyStates(): void;
  7953. /**
  7954. * Send a draw order
  7955. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7956. * @param indexStart defines the starting index
  7957. * @param indexCount defines the number of index to draw
  7958. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7959. */
  7960. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7961. /**
  7962. * Draw a list of points
  7963. * @param verticesStart defines the index of first vertex to draw
  7964. * @param verticesCount defines the count of vertices to draw
  7965. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7966. */
  7967. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7968. /**
  7969. * Draw a list of unindexed primitives
  7970. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7971. * @param verticesStart defines the index of first vertex to draw
  7972. * @param verticesCount defines the count of vertices to draw
  7973. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7974. */
  7975. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7976. /**
  7977. * Draw a list of indexed primitives
  7978. * @param fillMode defines the primitive to use
  7979. * @param indexStart defines the starting index
  7980. * @param indexCount defines the number of index to draw
  7981. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7982. */
  7983. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  7984. /**
  7985. * Draw a list of unindexed primitives
  7986. * @param fillMode defines the primitive to use
  7987. * @param verticesStart defines the index of first vertex to draw
  7988. * @param verticesCount defines the count of vertices to draw
  7989. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7990. */
  7991. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7992. private _drawMode(fillMode);
  7993. /** @hidden */
  7994. _releaseEffect(effect: Effect): void;
  7995. /** @hidden */
  7996. _deleteProgram(program: WebGLProgram): void;
  7997. /**
  7998. * Create a new effect (used to store vertex/fragment shaders)
  7999. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8000. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8001. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8002. * @param samplers defines an array of string used to represent textures
  8003. * @param defines defines the string containing the defines to use to compile the shaders
  8004. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8005. * @param onCompiled defines a function to call when the effect creation is successful
  8006. * @param onError defines a function to call when the effect creation has failed
  8007. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8008. * @returns the new Effect
  8009. */
  8010. 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;
  8011. private _compileShader(source, type, defines, shaderVersion);
  8012. private _compileRawShader(source, type);
  8013. /**
  8014. * Directly creates a webGL program
  8015. * @param vertexCode defines the vertex shader code to use
  8016. * @param fragmentCode defines the fragment shader code to use
  8017. * @param context defines the webGL context to use (if not set, the current one will be used)
  8018. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8019. * @returns the new webGL program
  8020. */
  8021. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8022. /**
  8023. * Creates a webGL program
  8024. * @param vertexCode defines the vertex shader code to use
  8025. * @param fragmentCode defines the fragment shader code to use
  8026. * @param defines defines the string containing the defines to use to compile the shaders
  8027. * @param context defines the webGL context to use (if not set, the current one will be used)
  8028. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8029. * @returns the new webGL program
  8030. */
  8031. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8032. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  8033. /**
  8034. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8035. * @param shaderProgram defines the webGL program to use
  8036. * @param uniformsNames defines the list of uniform names
  8037. * @returns an array of webGL uniform locations
  8038. */
  8039. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8040. /**
  8041. * Gets the lsit of active attributes for a given webGL program
  8042. * @param shaderProgram defines the webGL program to use
  8043. * @param attributesNames defines the list of attribute names to get
  8044. * @returns an array of indices indicating the offset of each attribute
  8045. */
  8046. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8047. /**
  8048. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8049. * @param effect defines the effect to activate
  8050. */
  8051. enableEffect(effect: Nullable<Effect>): void;
  8052. /**
  8053. * Set the value of an uniform to an array of int32
  8054. * @param uniform defines the webGL uniform location where to store the value
  8055. * @param array defines the array of int32 to store
  8056. */
  8057. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8058. /**
  8059. * Set the value of an uniform to an array of int32 (stored as vec2)
  8060. * @param uniform defines the webGL uniform location where to store the value
  8061. * @param array defines the array of int32 to store
  8062. */
  8063. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8064. /**
  8065. * Set the value of an uniform to an array of int32 (stored as vec3)
  8066. * @param uniform defines the webGL uniform location where to store the value
  8067. * @param array defines the array of int32 to store
  8068. */
  8069. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8070. /**
  8071. * Set the value of an uniform to an array of int32 (stored as vec4)
  8072. * @param uniform defines the webGL uniform location where to store the value
  8073. * @param array defines the array of int32 to store
  8074. */
  8075. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8076. /**
  8077. * Set the value of an uniform to an array of float32
  8078. * @param uniform defines the webGL uniform location where to store the value
  8079. * @param array defines the array of float32 to store
  8080. */
  8081. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8082. /**
  8083. * Set the value of an uniform to an array of float32 (stored as vec2)
  8084. * @param uniform defines the webGL uniform location where to store the value
  8085. * @param array defines the array of float32 to store
  8086. */
  8087. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8088. /**
  8089. * Set the value of an uniform to an array of float32 (stored as vec3)
  8090. * @param uniform defines the webGL uniform location where to store the value
  8091. * @param array defines the array of float32 to store
  8092. */
  8093. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8094. /**
  8095. * Set the value of an uniform to an array of float32 (stored as vec4)
  8096. * @param uniform defines the webGL uniform location where to store the value
  8097. * @param array defines the array of float32 to store
  8098. */
  8099. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8100. /**
  8101. * Set the value of an uniform to an array of number
  8102. * @param uniform defines the webGL uniform location where to store the value
  8103. * @param array defines the array of number to store
  8104. */
  8105. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8106. /**
  8107. * Set the value of an uniform to an array of number (stored as vec2)
  8108. * @param uniform defines the webGL uniform location where to store the value
  8109. * @param array defines the array of number to store
  8110. */
  8111. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8112. /**
  8113. * Set the value of an uniform to an array of number (stored as vec3)
  8114. * @param uniform defines the webGL uniform location where to store the value
  8115. * @param array defines the array of number to store
  8116. */
  8117. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8118. /**
  8119. * Set the value of an uniform to an array of number (stored as vec4)
  8120. * @param uniform defines the webGL uniform location where to store the value
  8121. * @param array defines the array of number to store
  8122. */
  8123. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8124. /**
  8125. * Set the value of an uniform to an array of float32 (stored as matrices)
  8126. * @param uniform defines the webGL uniform location where to store the value
  8127. * @param matrices defines the array of float32 to store
  8128. */
  8129. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8130. /**
  8131. * Set the value of an uniform to a matrix
  8132. * @param uniform defines the webGL uniform location where to store the value
  8133. * @param matrix defines the matrix to store
  8134. */
  8135. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8136. /**
  8137. * Set the value of an uniform to a matrix (3x3)
  8138. * @param uniform defines the webGL uniform location where to store the value
  8139. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8140. */
  8141. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8142. /**
  8143. * Set the value of an uniform to a matrix (2x2)
  8144. * @param uniform defines the webGL uniform location where to store the value
  8145. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8146. */
  8147. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8148. /**
  8149. * Set the value of an uniform to a number (int)
  8150. * @param uniform defines the webGL uniform location where to store the value
  8151. * @param value defines the int number to store
  8152. */
  8153. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8154. /**
  8155. * Set the value of an uniform to a number (float)
  8156. * @param uniform defines the webGL uniform location where to store the value
  8157. * @param value defines the float number to store
  8158. */
  8159. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8160. /**
  8161. * Set the value of an uniform to a vec2
  8162. * @param uniform defines the webGL uniform location where to store the value
  8163. * @param x defines the 1st component of the value
  8164. * @param y defines the 2nd component of the value
  8165. */
  8166. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8167. /**
  8168. * Set the value of an uniform to a vec3
  8169. * @param uniform defines the webGL uniform location where to store the value
  8170. * @param x defines the 1st component of the value
  8171. * @param y defines the 2nd component of the value
  8172. * @param z defines the 3rd component of the value
  8173. */
  8174. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8175. /**
  8176. * Set the value of an uniform to a boolean
  8177. * @param uniform defines the webGL uniform location where to store the value
  8178. * @param bool defines the boolean to store
  8179. */
  8180. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8181. /**
  8182. * Set the value of an uniform to a vec4
  8183. * @param uniform defines the webGL uniform location where to store the value
  8184. * @param x defines the 1st component of the value
  8185. * @param y defines the 2nd component of the value
  8186. * @param z defines the 3rd component of the value
  8187. * @param w defines the 4th component of the value
  8188. */
  8189. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8190. /**
  8191. * Set the value of an uniform to a Color3
  8192. * @param uniform defines the webGL uniform location where to store the value
  8193. * @param color3 defines the color to store
  8194. */
  8195. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8196. /**
  8197. * Set the value of an uniform to a Color3 and an alpha value
  8198. * @param uniform defines the webGL uniform location where to store the value
  8199. * @param color3 defines the color to store
  8200. * @param alpha defines the alpha component to store
  8201. */
  8202. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8203. /**
  8204. * Sets a Color4 on a uniform variable
  8205. * @param uniform defines the uniform location
  8206. * @param color4 defines the value to be set
  8207. */
  8208. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8209. /**
  8210. * Set various states to the webGL context
  8211. * @param culling defines backface culling state
  8212. * @param zOffset defines the value to apply to zOffset (0 by default)
  8213. * @param force defines if states must be applied even if cache is up to date
  8214. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8215. */
  8216. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8217. /**
  8218. * Set the z offset to apply to current rendering
  8219. * @param value defines the offset to apply
  8220. */
  8221. setZOffset(value: number): void;
  8222. /**
  8223. * Gets the current value of the zOffset
  8224. * @returns the current zOffset state
  8225. */
  8226. getZOffset(): number;
  8227. /**
  8228. * Enable or disable depth buffering
  8229. * @param enable defines the state to set
  8230. */
  8231. setDepthBuffer(enable: boolean): void;
  8232. /**
  8233. * Gets a boolean indicating if depth writing is enabled
  8234. * @returns the current depth writing state
  8235. */
  8236. getDepthWrite(): boolean;
  8237. /**
  8238. * Enable or disable depth writing
  8239. * @param enable defines the state to set
  8240. */
  8241. setDepthWrite(enable: boolean): void;
  8242. /**
  8243. * Enable or disable color writing
  8244. * @param enable defines the state to set
  8245. */
  8246. setColorWrite(enable: boolean): void;
  8247. /**
  8248. * Gets a boolean indicating if color writing is enabled
  8249. * @returns the current color writing state
  8250. */
  8251. getColorWrite(): boolean;
  8252. /**
  8253. * Sets alpha constants used by some alpha blending modes
  8254. * @param r defines the red component
  8255. * @param g defines the green component
  8256. * @param b defines the blue component
  8257. * @param a defines the alpha component
  8258. */
  8259. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8260. /**
  8261. * Sets the current alpha mode
  8262. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8263. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8264. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8265. */
  8266. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8267. /**
  8268. * Gets the current alpha mode
  8269. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8270. * @returns the current alpha mode
  8271. */
  8272. getAlphaMode(): number;
  8273. /**
  8274. * Clears the list of texture accessible through engine.
  8275. * This can help preventing texture load conflict due to name collision.
  8276. */
  8277. clearInternalTexturesCache(): void;
  8278. /**
  8279. * Force the entire cache to be cleared
  8280. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8281. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8282. */
  8283. wipeCaches(bruteForce?: boolean): void;
  8284. /**
  8285. * Set the compressed texture format to use, based on the formats you have, and the formats
  8286. * supported by the hardware / browser.
  8287. *
  8288. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8289. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8290. * to API arguments needed to compressed textures. This puts the burden on the container
  8291. * generator to house the arcane code for determining these for current & future formats.
  8292. *
  8293. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8294. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8295. *
  8296. * Note: The result of this call is not taken into account when a texture is base64.
  8297. *
  8298. * @param formatsAvailable defines the list of those format families you have created
  8299. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8300. *
  8301. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8302. * @returns The extension selected.
  8303. */
  8304. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8305. private _getSamplingParameters(samplingMode, generateMipMaps);
  8306. private _partialLoadImg(url, index, loadedImages, scene, onfinish, onErrorCallBack?);
  8307. private _cascadeLoadImgs(rootUrl, scene, onfinish, files, onError?);
  8308. /** @hidden */
  8309. _createTexture(): WebGLTexture;
  8310. /**
  8311. * Usually called from BABYLON.Texture.ts.
  8312. * Passed information to create a WebGLTexture
  8313. * @param urlArg defines a value which contains one of the following:
  8314. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8315. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8316. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8317. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8318. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8319. * @param scene needed for loading to the correct scene
  8320. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8321. * @param onLoad optional callback to be called upon successful completion
  8322. * @param onError optional callback to be called upon failure
  8323. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  8324. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8325. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8326. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8327. */
  8328. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  8329. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  8330. /**
  8331. * Update a raw texture
  8332. * @param texture defines the texture to update
  8333. * @param data defines the data to store in the texture
  8334. * @param format defines the format of the data
  8335. * @param invertY defines if data must be stored with Y axis inverted
  8336. * @param compression defines the compression used (null by default)
  8337. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8338. */
  8339. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8340. /**
  8341. * Creates a raw texture
  8342. * @param data defines the data to store in the texture
  8343. * @param width defines the width of the texture
  8344. * @param height defines the height of the texture
  8345. * @param format defines the format of the data
  8346. * @param generateMipMaps defines if the engine should generate the mip levels
  8347. * @param invertY defines if data must be stored with Y axis inverted
  8348. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8349. * @param compression defines the compression used (null by default)
  8350. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8351. * @returns the raw texture inside an InternalTexture
  8352. */
  8353. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8354. private _unpackFlipYCached;
  8355. /** @hidden */
  8356. _unpackFlipY(value: boolean): void;
  8357. /** @hidden */
  8358. _getUnpackAlignement(): number;
  8359. /**
  8360. * Creates a dynamic texture
  8361. * @param width defines the width of the texture
  8362. * @param height defines the height of the texture
  8363. * @param generateMipMaps defines if the engine should generate the mip levels
  8364. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8365. * @returns the dynamic texture inside an InternalTexture
  8366. */
  8367. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8368. /**
  8369. * Update the sampling mode of a given texture
  8370. * @param samplingMode defines the required sampling mode
  8371. * @param texture defines the texture to update
  8372. */
  8373. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8374. /**
  8375. * Update the content of a dynamic texture
  8376. * @param texture defines the texture to update
  8377. * @param canvas defines the canvas containing the source
  8378. * @param invertY defines if data must be stored with Y axis inverted
  8379. * @param premulAlpha defines if alpha is stored as premultiplied
  8380. * @param format defines the format of the data
  8381. */
  8382. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8383. /**
  8384. * Update a video texture
  8385. * @param texture defines the texture to update
  8386. * @param video defines the video element to use
  8387. * @param invertY defines if data must be stored with Y axis inverted
  8388. */
  8389. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8390. /**
  8391. * Updates a depth texture Comparison Mode and Function.
  8392. * If the comparison Function is equal to 0, the mode will be set to none.
  8393. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8394. * @param texture The texture to set the comparison function for
  8395. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8396. */
  8397. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8398. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  8399. /**
  8400. * Creates a depth stencil texture.
  8401. * This is only available in WebGL 2 or with the depth texture extension available.
  8402. * @param size The size of face edge in the texture.
  8403. * @param options The options defining the texture.
  8404. * @returns The texture
  8405. */
  8406. createDepthStencilTexture(size: number | {
  8407. width: number;
  8408. height: number;
  8409. }, options: DepthTextureCreationOptions): InternalTexture;
  8410. /**
  8411. * Creates a depth stencil texture.
  8412. * This is only available in WebGL 2 or with the depth texture extension available.
  8413. * @param size The size of face edge in the texture.
  8414. * @param options The options defining the texture.
  8415. * @returns The texture
  8416. */
  8417. private _createDepthStencilTexture(size, options);
  8418. /**
  8419. * Creates a depth stencil cube texture.
  8420. * This is only available in WebGL 2.
  8421. * @param size The size of face edge in the cube texture.
  8422. * @param options The options defining the cube texture.
  8423. * @returns The cube texture
  8424. */
  8425. private _createDepthStencilCubeTexture(size, options);
  8426. /**
  8427. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8428. * @param renderTarget The render target to set the frame buffer for
  8429. */
  8430. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8431. /**
  8432. * Creates a new render target texture
  8433. * @param size defines the size of the texture
  8434. * @param options defines the options used to create the texture
  8435. * @returns a new render target texture stored in an InternalTexture
  8436. */
  8437. createRenderTargetTexture(size: number | {
  8438. width: number;
  8439. height: number;
  8440. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8441. /**
  8442. * Create a multi render target texture
  8443. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8444. * @param size defines the size of the texture
  8445. * @param options defines the creation options
  8446. * @returns the cube texture as an InternalTexture
  8447. */
  8448. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8449. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  8450. /**
  8451. * Updates the sample count of a render target texture
  8452. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8453. * @param texture defines the texture to update
  8454. * @param samples defines the sample count to set
  8455. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8456. */
  8457. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8458. /**
  8459. * Update the sample count for a given multiple render target texture
  8460. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8461. * @param textures defines the textures to update
  8462. * @param samples defines the sample count to set
  8463. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8464. */
  8465. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8466. /** @hidden */
  8467. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8468. /** @hidden */
  8469. _uploadDataToTextureDirectly(texture: InternalTexture, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8470. /** @hidden */
  8471. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8472. /** @hidden */
  8473. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  8474. /**
  8475. * Creates a new render target cube texture
  8476. * @param size defines the size of the texture
  8477. * @param options defines the options used to create the texture
  8478. * @returns a new render target cube texture stored in an InternalTexture
  8479. */
  8480. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8481. /**
  8482. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8483. * @param rootUrl defines the url where the file to load is located
  8484. * @param scene defines the current scene
  8485. * @param lodScale defines scale to apply to the mip map selection
  8486. * @param lodOffset defines offset to apply to the mip map selection
  8487. * @param onLoad defines an optional callback raised when the texture is loaded
  8488. * @param onError defines an optional callback raised if there is an issue to load the texture
  8489. * @param format defines the format of the data
  8490. * @param forcedExtension defines the extension to use to pick the right loader
  8491. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8492. * @returns the cube texture as an InternalTexture
  8493. */
  8494. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  8495. /**
  8496. * Creates a cube texture
  8497. * @param rootUrl defines the url where the files to load is located
  8498. * @param scene defines the current scene
  8499. * @param files defines the list of files to load (1 per face)
  8500. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8501. * @param onLoad defines an optional callback raised when the texture is loaded
  8502. * @param onError defines an optional callback raised if there is an issue to load the texture
  8503. * @param format defines the format of the data
  8504. * @param forcedExtension defines the extension to use to pick the right loader
  8505. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8506. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8507. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8508. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8509. * @returns the cube texture as an InternalTexture
  8510. */
  8511. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  8512. private setCubeMapTextureParams(gl, loadMipmap);
  8513. /**
  8514. * Update a raw cube texture
  8515. * @param texture defines the texture to udpdate
  8516. * @param data defines the data to store
  8517. * @param format defines the data format
  8518. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8519. * @param invertY defines if data must be stored with Y axis inverted
  8520. * @param compression defines the compression used (null by default)
  8521. * @param level defines which level of the texture to update
  8522. */
  8523. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8524. /**
  8525. * Creates a new raw cube texture
  8526. * @param data defines the array of data to use to create each face
  8527. * @param size defines the size of the textures
  8528. * @param format defines the format of the data
  8529. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8530. * @param generateMipMaps defines if the engine should generate the mip levels
  8531. * @param invertY defines if data must be stored with Y axis inverted
  8532. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8533. * @param compression defines the compression used (null by default)
  8534. * @returns the cube texture as an InternalTexture
  8535. */
  8536. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8537. /**
  8538. * Creates a new raw cube texture from a specified url
  8539. * @param url defines the url where the data is located
  8540. * @param scene defines the current scene
  8541. * @param size defines the size of the textures
  8542. * @param format defines the format of the data
  8543. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8544. * @param noMipmap defines if the engine should avoid generating the mip levels
  8545. * @param callback defines a callback used to extract texture data from loaded data
  8546. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8547. * @param onLoad defines a callback called when texture is loaded
  8548. * @param onError defines a callback called if there is an error
  8549. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8550. * @param invertY defines if data must be stored with Y axis inverted
  8551. * @returns the cube texture as an InternalTexture
  8552. */
  8553. 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;
  8554. /**
  8555. * Update a raw 3D texture
  8556. * @param texture defines the texture to update
  8557. * @param data defines the data to store
  8558. * @param format defines the data format
  8559. * @param invertY defines if data must be stored with Y axis inverted
  8560. * @param compression defines the used compression (can be null)
  8561. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  8562. */
  8563. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  8564. /**
  8565. * Creates a new raw 3D texture
  8566. * @param data defines the data used to create the texture
  8567. * @param width defines the width of the texture
  8568. * @param height defines the height of the texture
  8569. * @param depth defines the depth of the texture
  8570. * @param format defines the format of the texture
  8571. * @param generateMipMaps defines if the engine must generate mip levels
  8572. * @param invertY defines if data must be stored with Y axis inverted
  8573. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8574. * @param compression defines the compressed used (can be null)
  8575. * @param textureType defines the compressed used (can be null)
  8576. * @returns a new raw 3D texture (stored in an InternalTexture)
  8577. */
  8578. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  8579. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  8580. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  8581. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  8582. /** @hidden */
  8583. _releaseFramebufferObjects(texture: InternalTexture): void;
  8584. /** @hidden */
  8585. _releaseTexture(texture: InternalTexture): void;
  8586. private setProgram(program);
  8587. private _boundUniforms;
  8588. /**
  8589. * Binds an effect to the webGL context
  8590. * @param effect defines the effect to bind
  8591. */
  8592. bindSamplers(effect: Effect): void;
  8593. private _moveBoundTextureOnTop(internalTexture);
  8594. private _getCorrectTextureChannel(channel, internalTexture);
  8595. private _linkTrackers(previous, next);
  8596. private _removeDesignatedSlot(internalTexture);
  8597. private _activateCurrentTexture();
  8598. /** @hidden */
  8599. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  8600. /** @hidden */
  8601. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  8602. /**
  8603. * Sets a texture to the webGL context from a postprocess
  8604. * @param channel defines the channel to use
  8605. * @param postProcess defines the source postprocess
  8606. */
  8607. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8608. /**
  8609. * Binds the output of the passed in post process to the texture channel specified
  8610. * @param channel The channel the texture should be bound to
  8611. * @param postProcess The post process which's output should be bound
  8612. */
  8613. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8614. /**
  8615. * Unbind all textures from the webGL context
  8616. */
  8617. unbindAllTextures(): void;
  8618. /**
  8619. * Sets a texture to the according uniform.
  8620. * @param channel The texture channel
  8621. * @param uniform The uniform to set
  8622. * @param texture The texture to apply
  8623. */
  8624. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8625. /**
  8626. * Sets a depth stencil texture from a render target to the according uniform.
  8627. * @param channel The texture channel
  8628. * @param uniform The uniform to set
  8629. * @param texture The render target texture containing the depth stencil texture to apply
  8630. */
  8631. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8632. private _bindSamplerUniformToChannel(sourceSlot, destination);
  8633. private _getTextureWrapMode(mode);
  8634. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  8635. /**
  8636. * Sets an array of texture to the webGL context
  8637. * @param channel defines the channel where the texture array must be set
  8638. * @param uniform defines the associated uniform location
  8639. * @param textures defines the array of textures to bind
  8640. */
  8641. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8642. /** @hidden */
  8643. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  8644. private _setTextureParameterFloat(target, parameter, value, texture);
  8645. private _setTextureParameterInteger(target, parameter, value, texture?);
  8646. /**
  8647. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8648. * @param x defines the x coordinate of the rectangle where pixels must be read
  8649. * @param y defines the y coordinate of the rectangle where pixels must be read
  8650. * @param width defines the width of the rectangle where pixels must be read
  8651. * @param height defines the height of the rectangle where pixels must be read
  8652. * @returns a Uint8Array containing RGBA colors
  8653. */
  8654. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8655. /**
  8656. * Add an externaly attached data from its key.
  8657. * This method call will fail and return false, if such key already exists.
  8658. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8659. * @param key the unique key that identifies the data
  8660. * @param data the data object to associate to the key for this Engine instance
  8661. * @return true if no such key were already present and the data was added successfully, false otherwise
  8662. */
  8663. addExternalData<T>(key: string, data: T): boolean;
  8664. /**
  8665. * Get an externaly attached data from its key
  8666. * @param key the unique key that identifies the data
  8667. * @return the associated data, if present (can be null), or undefined if not present
  8668. */
  8669. getExternalData<T>(key: string): T;
  8670. /**
  8671. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8672. * @param key the unique key that identifies the data
  8673. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8674. * @return the associated data, can be null if the factory returned null.
  8675. */
  8676. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8677. /**
  8678. * Remove an externaly attached data from the Engine instance
  8679. * @param key the unique key that identifies the data
  8680. * @return true if the data was successfully removed, false if it doesn't exist
  8681. */
  8682. removeExternalData(key: string): boolean;
  8683. /**
  8684. * Unbind all vertex attributes from the webGL context
  8685. */
  8686. unbindAllAttributes(): void;
  8687. /**
  8688. * 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
  8689. */
  8690. releaseEffects(): void;
  8691. /**
  8692. * Dispose and release all associated resources
  8693. */
  8694. dispose(): void;
  8695. /**
  8696. * Display the loading screen
  8697. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8698. */
  8699. displayLoadingUI(): void;
  8700. /**
  8701. * Hide the loading screen
  8702. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8703. */
  8704. hideLoadingUI(): void;
  8705. /**
  8706. * Gets the current loading screen object
  8707. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8708. */
  8709. /**
  8710. * Sets the current loading screen object
  8711. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8712. */
  8713. loadingScreen: ILoadingScreen;
  8714. /**
  8715. * Sets the current loading screen text
  8716. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8717. */
  8718. loadingUIText: string;
  8719. /**
  8720. * Sets the current loading screen background color
  8721. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8722. */
  8723. loadingUIBackgroundColor: string;
  8724. /**
  8725. * Attach a new callback raised when context lost event is fired
  8726. * @param callback defines the callback to call
  8727. */
  8728. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8729. /**
  8730. * Attach a new callback raised when context restored event is fired
  8731. * @param callback defines the callback to call
  8732. */
  8733. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8734. /**
  8735. * Gets the source code of the vertex shader associated with a specific webGL program
  8736. * @param program defines the program to use
  8737. * @returns a string containing the source code of the vertex shader associated with the program
  8738. */
  8739. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  8740. /**
  8741. * Gets the source code of the fragment shader associated with a specific webGL program
  8742. * @param program defines the program to use
  8743. * @returns a string containing the source code of the fragment shader associated with the program
  8744. */
  8745. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  8746. /**
  8747. * Get the current error code of the webGL context
  8748. * @returns the error code
  8749. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8750. */
  8751. getError(): number;
  8752. /**
  8753. * Gets the current framerate
  8754. * @returns a number representing the framerate
  8755. */
  8756. getFps(): number;
  8757. /**
  8758. * Gets the time spent between current and previous frame
  8759. * @returns a number representing the delta time in ms
  8760. */
  8761. getDeltaTime(): number;
  8762. private _measureFps();
  8763. /** @hidden */
  8764. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number): ArrayBufferView;
  8765. private _canRenderToFloatFramebuffer();
  8766. private _canRenderToHalfFloatFramebuffer();
  8767. private _canRenderToFramebuffer(type);
  8768. /** @hidden */
  8769. _getWebGLTextureType(type: number): number;
  8770. private _getInternalFormat(format);
  8771. /** @hidden */
  8772. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  8773. /** @hidden */
  8774. _getRGBAMultiSampleBufferFormat(type: number): number;
  8775. /**
  8776. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  8777. * @return the new query
  8778. */
  8779. createQuery(): WebGLQuery;
  8780. /**
  8781. * Delete and release a webGL query
  8782. * @param query defines the query to delete
  8783. * @return the current engine
  8784. */
  8785. deleteQuery(query: WebGLQuery): Engine;
  8786. /**
  8787. * Check if a given query has resolved and got its value
  8788. * @param query defines the query to check
  8789. * @returns true if the query got its value
  8790. */
  8791. isQueryResultAvailable(query: WebGLQuery): boolean;
  8792. /**
  8793. * Gets the value of a given query
  8794. * @param query defines the query to check
  8795. * @returns the value of the query
  8796. */
  8797. getQueryResult(query: WebGLQuery): number;
  8798. /**
  8799. * Initiates an occlusion query
  8800. * @param algorithmType defines the algorithm to use
  8801. * @param query defines the query to use
  8802. * @returns the current engine
  8803. * @see http://doc.babylonjs.com/features/occlusionquery
  8804. */
  8805. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  8806. /**
  8807. * Ends an occlusion query
  8808. * @see http://doc.babylonjs.com/features/occlusionquery
  8809. * @param algorithmType defines the algorithm to use
  8810. * @returns the current engine
  8811. */
  8812. endOcclusionQuery(algorithmType: number): Engine;
  8813. private _createTimeQuery();
  8814. private _deleteTimeQuery(query);
  8815. private _getTimeQueryResult(query);
  8816. private _getTimeQueryAvailability(query);
  8817. private _currentNonTimestampToken;
  8818. /**
  8819. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  8820. * Please note that only one query can be issued at a time
  8821. * @returns a time token used to track the time span
  8822. */
  8823. startTimeQuery(): Nullable<_TimeToken>;
  8824. /**
  8825. * Ends a time query
  8826. * @param token defines the token used to measure the time span
  8827. * @returns the time spent (in ns)
  8828. */
  8829. endTimeQuery(token: _TimeToken): int;
  8830. private getGlAlgorithmType(algorithmType);
  8831. /**
  8832. * Creates a webGL transform feedback object
  8833. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  8834. * @returns the webGL transform feedback object
  8835. */
  8836. createTransformFeedback(): WebGLTransformFeedback;
  8837. /**
  8838. * Delete a webGL transform feedback object
  8839. * @param value defines the webGL transform feedback object to delete
  8840. */
  8841. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  8842. /**
  8843. * Bind a webGL transform feedback object to the webgl context
  8844. * @param value defines the webGL transform feedback object to bind
  8845. */
  8846. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  8847. /**
  8848. * Begins a transform feedback operation
  8849. * @param usePoints defines if points or triangles must be used
  8850. */
  8851. beginTransformFeedback(usePoints?: boolean): void;
  8852. /**
  8853. * Ends a transform feedback operation
  8854. */
  8855. endTransformFeedback(): void;
  8856. /**
  8857. * Specify the varyings to use with transform feedback
  8858. * @param program defines the associated webGL program
  8859. * @param value defines the list of strings representing the varying names
  8860. */
  8861. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  8862. /**
  8863. * Bind a webGL buffer for a transform feedback operation
  8864. * @param value defines the webGL buffer to bind
  8865. */
  8866. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  8867. /** @hidden */
  8868. _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;
  8869. /** @hidden */
  8870. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  8871. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  8872. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  8873. /**
  8874. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  8875. * @returns true if the engine can be created
  8876. * @ignorenaming
  8877. */
  8878. static isSupported(): boolean;
  8879. }
  8880. }
  8881. declare module BABYLON {
  8882. class NullEngineOptions {
  8883. renderWidth: number;
  8884. renderHeight: number;
  8885. textureSize: number;
  8886. deterministicLockstep: boolean;
  8887. lockstepMaxSteps: number;
  8888. }
  8889. /**
  8890. * The null engine class provides support for headless version of babylon.js.
  8891. * This can be used in server side scenario or for testing purposes
  8892. */
  8893. class NullEngine extends Engine {
  8894. private _options;
  8895. isDeterministicLockStep(): boolean;
  8896. getLockstepMaxSteps(): number;
  8897. getHardwareScalingLevel(): number;
  8898. constructor(options?: NullEngineOptions);
  8899. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8900. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  8901. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8902. getRenderWidth(useScreen?: boolean): number;
  8903. getRenderHeight(useScreen?: boolean): number;
  8904. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8905. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  8906. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  8907. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8908. bindSamplers(effect: Effect): void;
  8909. enableEffect(effect: Effect): void;
  8910. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8911. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  8912. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  8913. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  8914. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  8915. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  8916. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  8917. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  8918. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  8919. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  8920. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  8921. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  8922. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  8923. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  8924. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  8925. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8926. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8927. setFloat(uniform: WebGLUniformLocation, value: number): void;
  8928. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  8929. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  8930. setBool(uniform: WebGLUniformLocation, bool: number): void;
  8931. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  8932. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  8933. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  8934. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8935. bindBuffers(vertexBuffers: {
  8936. [key: string]: VertexBuffer;
  8937. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  8938. wipeCaches(bruteForce?: boolean): void;
  8939. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8940. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8941. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8942. _createTexture(): WebGLTexture;
  8943. _releaseTexture(texture: InternalTexture): void;
  8944. 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;
  8945. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8946. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8947. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  8948. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8949. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8950. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8951. /**
  8952. * Get the current error code of the webGL context
  8953. * @returns the error code
  8954. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8955. */
  8956. getError(): number;
  8957. /** @hidden */
  8958. _getUnpackAlignement(): number;
  8959. /** @hidden */
  8960. _unpackFlipY(value: boolean): void;
  8961. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8962. /**
  8963. * Updates a dynamic vertex buffer.
  8964. * @param vertexBuffer the vertex buffer to update
  8965. * @param data the data used to update the vertex buffer
  8966. * @param byteOffset the byte offset of the data (optional)
  8967. * @param byteLength the byte length of the data (optional)
  8968. */
  8969. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  8970. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  8971. _bindTexture(channel: number, texture: InternalTexture): void;
  8972. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8973. releaseEffects(): void;
  8974. displayLoadingUI(): void;
  8975. hideLoadingUI(): void;
  8976. /** @hidden */
  8977. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8978. /** @hidden */
  8979. _uploadDataToTextureDirectly(texture: InternalTexture, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8980. /** @hidden */
  8981. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8982. /** @hidden */
  8983. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  8984. }
  8985. }
  8986. interface WebGLRenderingContext {
  8987. readonly RASTERIZER_DISCARD: number;
  8988. readonly DEPTH_COMPONENT24: number;
  8989. readonly TEXTURE_3D: number;
  8990. readonly TEXTURE_2D_ARRAY: number;
  8991. readonly TEXTURE_COMPARE_FUNC: number;
  8992. readonly TEXTURE_COMPARE_MODE: number;
  8993. readonly COMPARE_REF_TO_TEXTURE: number;
  8994. readonly TEXTURE_WRAP_R: number;
  8995. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  8996. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  8997. 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;
  8998. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  8999. readonly TRANSFORM_FEEDBACK: number;
  9000. readonly INTERLEAVED_ATTRIBS: number;
  9001. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  9002. createTransformFeedback(): WebGLTransformFeedback;
  9003. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  9004. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  9005. beginTransformFeedback(primitiveMode: number): void;
  9006. endTransformFeedback(): void;
  9007. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  9008. }
  9009. interface ImageBitmap {
  9010. readonly width: number;
  9011. readonly height: number;
  9012. close(): void;
  9013. }
  9014. interface WebGLQuery extends WebGLObject {
  9015. }
  9016. declare var WebGLQuery: {
  9017. prototype: WebGLQuery;
  9018. new (): WebGLQuery;
  9019. };
  9020. interface WebGLSampler extends WebGLObject {
  9021. }
  9022. declare var WebGLSampler: {
  9023. prototype: WebGLSampler;
  9024. new (): WebGLSampler;
  9025. };
  9026. interface WebGLSync extends WebGLObject {
  9027. }
  9028. declare var WebGLSync: {
  9029. prototype: WebGLSync;
  9030. new (): WebGLSync;
  9031. };
  9032. interface WebGLTransformFeedback extends WebGLObject {
  9033. }
  9034. declare var WebGLTransformFeedback: {
  9035. prototype: WebGLTransformFeedback;
  9036. new (): WebGLTransformFeedback;
  9037. };
  9038. interface WebGLVertexArrayObject extends WebGLObject {
  9039. }
  9040. declare var WebGLVertexArrayObject: {
  9041. prototype: WebGLVertexArrayObject;
  9042. new (): WebGLVertexArrayObject;
  9043. };
  9044. /**
  9045. * Module Debug contains the (visual) components to debug a scene correctly
  9046. */
  9047. declare module BABYLON.Debug {
  9048. /**
  9049. * The Axes viewer will show 3 axes in a specific point in space
  9050. */
  9051. class AxesViewer {
  9052. private _xline;
  9053. private _yline;
  9054. private _zline;
  9055. private _xmesh;
  9056. private _ymesh;
  9057. private _zmesh;
  9058. /**
  9059. * Gets the hosting scene
  9060. */
  9061. scene: Nullable<Scene>;
  9062. /**
  9063. * Gets or sets a number used to scale line length
  9064. */
  9065. scaleLines: number;
  9066. /**
  9067. * Creates a new AxesViewer
  9068. * @param scene defines the hosting scene
  9069. * @param scaleLines defines a number used to scale line length (1 by default)
  9070. */
  9071. constructor(scene: Scene, scaleLines?: number);
  9072. /**
  9073. * Force the viewer to update
  9074. * @param position defines the position of the viewer
  9075. * @param xaxis defines the x axis of the viewer
  9076. * @param yaxis defines the y axis of the viewer
  9077. * @param zaxis defines the z axis of the viewer
  9078. */
  9079. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9080. /** Releases resources */
  9081. dispose(): void;
  9082. }
  9083. }
  9084. declare module BABYLON.Debug {
  9085. /**
  9086. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9087. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9088. */
  9089. class BoneAxesViewer extends AxesViewer {
  9090. /**
  9091. * Gets or sets the target mesh where to display the axes viewer
  9092. */
  9093. mesh: Nullable<Mesh>;
  9094. /**
  9095. * Gets or sets the target bone where to display the axes viewer
  9096. */
  9097. bone: Nullable<Bone>;
  9098. /** Gets current position */
  9099. pos: Vector3;
  9100. /** Gets direction of X axis */
  9101. xaxis: Vector3;
  9102. /** Gets direction of Y axis */
  9103. yaxis: Vector3;
  9104. /** Gets direction of Z axis */
  9105. zaxis: Vector3;
  9106. /**
  9107. * Creates a new BoneAxesViewer
  9108. * @param scene defines the hosting scene
  9109. * @param bone defines the target bone
  9110. * @param mesh defines the target mesh
  9111. * @param scaleLines defines a scaling factor for line length (1 by default)
  9112. */
  9113. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9114. /**
  9115. * Force the viewer to update
  9116. */
  9117. update(): void;
  9118. /** Releases resources */
  9119. dispose(): void;
  9120. }
  9121. }
  9122. declare module BABYLON {
  9123. class DebugLayer {
  9124. private _scene;
  9125. static InspectorURL: string;
  9126. private _inspector;
  9127. private BJSINSPECTOR;
  9128. onPropertyChangedObservable: BABYLON.Observable<{
  9129. object: any;
  9130. property: string;
  9131. value: any;
  9132. initialValue: any;
  9133. }>;
  9134. constructor(scene: Scene);
  9135. /** Creates the inspector window. */
  9136. private _createInspector(config?);
  9137. isVisible(): boolean;
  9138. hide(): void;
  9139. /**
  9140. *
  9141. * Launch the debugLayer.
  9142. *
  9143. * initialTab:
  9144. * | Value | Tab Name |
  9145. * | --- | --- |
  9146. * | 0 | Scene |
  9147. * | 1 | Console |
  9148. * | 2 | Stats |
  9149. * | 3 | Textures |
  9150. * | 4 | Mesh |
  9151. * | 5 | Light |
  9152. * | 6 | Material |
  9153. * | 7 | GLTF |
  9154. * | 8 | GUI |
  9155. * | 9 | Physics |
  9156. * | 10 | Camera |
  9157. * | 11 | Audio |
  9158. *
  9159. */
  9160. show(config?: {
  9161. popup?: boolean;
  9162. initialTab?: number;
  9163. parentElement?: HTMLElement;
  9164. newColors?: {
  9165. backgroundColor?: string;
  9166. backgroundColorLighter?: string;
  9167. backgroundColorLighter2?: string;
  9168. backgroundColorLighter3?: string;
  9169. color?: string;
  9170. colorTop?: string;
  9171. colorBot?: string;
  9172. };
  9173. }): void;
  9174. /**
  9175. * Gets the active tab
  9176. * @return the index of the active tab or -1 if the inspector is hidden
  9177. */
  9178. getActiveTab(): number;
  9179. }
  9180. }
  9181. declare module BABYLON.Debug {
  9182. /**
  9183. * Used to show the physics impostor around the specific mesh
  9184. */
  9185. class PhysicsViewer {
  9186. /** @hidden */
  9187. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9188. /** @hidden */
  9189. protected _meshes: Array<Nullable<AbstractMesh>>;
  9190. /** @hidden */
  9191. protected _scene: Nullable<Scene>;
  9192. /** @hidden */
  9193. protected _numMeshes: number;
  9194. /** @hidden */
  9195. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9196. private _renderFunction;
  9197. private _debugBoxMesh;
  9198. private _debugSphereMesh;
  9199. private _debugMaterial;
  9200. /**
  9201. * Creates a new PhysicsViewer
  9202. * @param scene defines the hosting scene
  9203. */
  9204. constructor(scene: Scene);
  9205. /** @hidden */
  9206. protected _updateDebugMeshes(): void;
  9207. /**
  9208. * Renders a specified physic impostor
  9209. * @param impostor defines the impostor to render
  9210. */
  9211. showImpostor(impostor: PhysicsImpostor): void;
  9212. /**
  9213. * Hides a specified physic impostor
  9214. * @param impostor defines the impostor to hide
  9215. */
  9216. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9217. private _getDebugMaterial(scene);
  9218. private _getDebugBoxMesh(scene);
  9219. private _getDebugSphereMesh(scene);
  9220. private _getDebugMesh(impostor, scene);
  9221. /** Releases all resources */
  9222. dispose(): void;
  9223. }
  9224. }
  9225. declare module BABYLON {
  9226. class RayHelper {
  9227. ray: Nullable<Ray>;
  9228. private _renderPoints;
  9229. private _renderLine;
  9230. private _renderFunction;
  9231. private _scene;
  9232. private _updateToMeshFunction;
  9233. private _attachedToMesh;
  9234. private _meshSpaceDirection;
  9235. private _meshSpaceOrigin;
  9236. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9237. constructor(ray: Ray);
  9238. show(scene: Scene, color?: Color3): void;
  9239. hide(): void;
  9240. private _render();
  9241. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9242. detachFromMesh(): void;
  9243. private _updateToMesh();
  9244. dispose(): void;
  9245. }
  9246. }
  9247. declare module BABYLON.Debug {
  9248. /**
  9249. * Class used to render a debug view of a given skeleton
  9250. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9251. */
  9252. class SkeletonViewer {
  9253. /** defines the skeleton to render */
  9254. skeleton: Skeleton;
  9255. /** defines the mesh attached to the skeleton */
  9256. mesh: AbstractMesh;
  9257. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9258. autoUpdateBonesMatrices: boolean;
  9259. /** defines the rendering group id to use with the viewer */
  9260. renderingGroupId: number;
  9261. /** Gets or sets the color used to render the skeleton */
  9262. color: Color3;
  9263. private _scene;
  9264. private _debugLines;
  9265. private _debugMesh;
  9266. private _isEnabled;
  9267. private _renderFunction;
  9268. /**
  9269. * Creates a new SkeletonViewer
  9270. * @param skeleton defines the skeleton to render
  9271. * @param mesh defines the mesh attached to the skeleton
  9272. * @param scene defines the hosting scene
  9273. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9274. * @param renderingGroupId defines the rendering group id to use with the viewer
  9275. */
  9276. constructor(
  9277. /** defines the skeleton to render */
  9278. skeleton: Skeleton,
  9279. /** defines the mesh attached to the skeleton */
  9280. mesh: AbstractMesh, scene: Scene,
  9281. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9282. autoUpdateBonesMatrices?: boolean,
  9283. /** defines the rendering group id to use with the viewer */
  9284. renderingGroupId?: number);
  9285. /** Gets or sets a boolean indicating if the viewer is enabled */
  9286. isEnabled: boolean;
  9287. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  9288. private _getLinesForBonesWithLength(bones, meshMat);
  9289. private _getLinesForBonesNoLength(bones, meshMat);
  9290. /** Update the viewer to sync with current skeleton state */
  9291. update(): void;
  9292. /** Release associated resources */
  9293. dispose(): void;
  9294. }
  9295. }
  9296. declare module BABYLON {
  9297. class KeyboardEventTypes {
  9298. static _KEYDOWN: number;
  9299. static _KEYUP: number;
  9300. static readonly KEYDOWN: number;
  9301. static readonly KEYUP: number;
  9302. }
  9303. class KeyboardInfo {
  9304. type: number;
  9305. event: KeyboardEvent;
  9306. constructor(type: number, event: KeyboardEvent);
  9307. }
  9308. /**
  9309. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9310. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9311. */
  9312. class KeyboardInfoPre extends KeyboardInfo {
  9313. constructor(type: number, event: KeyboardEvent);
  9314. skipOnPointerObservable: boolean;
  9315. }
  9316. }
  9317. declare module BABYLON {
  9318. class PointerEventTypes {
  9319. static _POINTERDOWN: number;
  9320. static _POINTERUP: number;
  9321. static _POINTERMOVE: number;
  9322. static _POINTERWHEEL: number;
  9323. static _POINTERPICK: number;
  9324. static _POINTERTAP: number;
  9325. static _POINTERDOUBLETAP: number;
  9326. static readonly POINTERDOWN: number;
  9327. static readonly POINTERUP: number;
  9328. static readonly POINTERMOVE: number;
  9329. static readonly POINTERWHEEL: number;
  9330. static readonly POINTERPICK: number;
  9331. static readonly POINTERTAP: number;
  9332. static readonly POINTERDOUBLETAP: number;
  9333. }
  9334. class PointerInfoBase {
  9335. type: number;
  9336. event: PointerEvent | MouseWheelEvent;
  9337. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9338. }
  9339. /**
  9340. * This class is used to store pointer related info for the onPrePointerObservable event.
  9341. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9342. */
  9343. class PointerInfoPre extends PointerInfoBase {
  9344. /**
  9345. * Ray from a pointer if availible (eg. 6dof controller)
  9346. */
  9347. ray: Nullable<Ray>;
  9348. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9349. localPosition: Vector2;
  9350. skipOnPointerObservable: boolean;
  9351. }
  9352. /**
  9353. * This type contains all the data related to a pointer event in Babylon.js.
  9354. * 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.
  9355. */
  9356. class PointerInfo extends PointerInfoBase {
  9357. pickInfo: Nullable<PickingInfo>;
  9358. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9359. }
  9360. }
  9361. declare module BABYLON {
  9362. /**
  9363. * Single axis drag gizmo
  9364. */
  9365. class AxisDragGizmo extends Gizmo {
  9366. /**
  9367. * Drag behavior responsible for the gizmos dragging interactions
  9368. */
  9369. dragBehavior: PointerDragBehavior;
  9370. private _pointerObserver;
  9371. /**
  9372. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9373. */
  9374. snapDistance: number;
  9375. /**
  9376. * Event that fires each time the gizmo snaps to a new location.
  9377. * * snapDistance is the the change in distance
  9378. */
  9379. onSnapObservable: Observable<{
  9380. snapDistance: number;
  9381. }>;
  9382. /**
  9383. * Creates an AxisDragGizmo
  9384. * @param gizmoLayer The utility layer the gizmo will be added to
  9385. * @param dragAxis The axis which the gizmo will be able to drag on
  9386. * @param color The color of the gizmo
  9387. */
  9388. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9389. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9390. /**
  9391. * Disposes of the gizmo
  9392. */
  9393. dispose(): void;
  9394. }
  9395. }
  9396. declare module BABYLON {
  9397. /**
  9398. * Single axis scale gizmo
  9399. */
  9400. class AxisScaleGizmo extends Gizmo {
  9401. /**
  9402. * Drag behavior responsible for the gizmos dragging interactions
  9403. */
  9404. dragBehavior: PointerDragBehavior;
  9405. private _pointerObserver;
  9406. /**
  9407. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9408. */
  9409. snapDistance: number;
  9410. /**
  9411. * Event that fires each time the gizmo snaps to a new location.
  9412. * * snapDistance is the the change in distance
  9413. */
  9414. onSnapObservable: Observable<{
  9415. snapDistance: number;
  9416. }>;
  9417. /**
  9418. * Creates an AxisScaleGizmo
  9419. * @param gizmoLayer The utility layer the gizmo will be added to
  9420. * @param dragAxis The axis which the gizmo will be able to scale on
  9421. * @param color The color of the gizmo
  9422. */
  9423. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9424. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9425. /**
  9426. * Disposes of the gizmo
  9427. */
  9428. dispose(): void;
  9429. }
  9430. }
  9431. declare module BABYLON {
  9432. /**
  9433. * Bounding box gizmo
  9434. */
  9435. class BoundingBoxGizmo extends Gizmo {
  9436. private _lineBoundingBox;
  9437. private _rotateSpheresParent;
  9438. private _scaleBoxesParent;
  9439. private _boundingDimensions;
  9440. private _renderObserver;
  9441. private _pointerObserver;
  9442. private _scaleDragSpeed;
  9443. private _tmpQuaternion;
  9444. private _tmpVector;
  9445. /**
  9446. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  9447. */
  9448. rotationSphereSize: number;
  9449. /**
  9450. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  9451. */
  9452. scaleBoxSize: number;
  9453. /**
  9454. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  9455. */
  9456. fixedDragMeshScreenSize: boolean;
  9457. /**
  9458. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  9459. */
  9460. fixedDragMeshScreenSizeDistanceFactor: number;
  9461. /**
  9462. * Fired when a rotation sphere or scale box is dragged
  9463. */
  9464. onDragStartObservable: Observable<{}>;
  9465. /**
  9466. * Fired when a rotation sphere or scale box drag is started
  9467. */
  9468. onDragObservable: Observable<{}>;
  9469. /**
  9470. * Fired when a rotation sphere or scale box drag is needed
  9471. */
  9472. onDragEndObservable: Observable<{}>;
  9473. /**
  9474. * Creates an BoundingBoxGizmo
  9475. * @param gizmoLayer The utility layer the gizmo will be added to
  9476. * @param color The color of the gizmo
  9477. */
  9478. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9479. private _selectNode(selectedMesh);
  9480. private _updateBoundingBox();
  9481. /**
  9482. * Enables rotation on the specified axis and disables rotation on the others
  9483. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  9484. */
  9485. setEnabledRotationAxis(axis: string): void;
  9486. /**
  9487. * Disposes of the gizmo
  9488. */
  9489. dispose(): void;
  9490. }
  9491. }
  9492. declare module BABYLON {
  9493. /**
  9494. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  9495. */
  9496. class Gizmo implements IDisposable {
  9497. /** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer;
  9498. /**
  9499. * The root mesh of the gizmo
  9500. */
  9501. protected _rootMesh: Mesh;
  9502. private _attachedMesh;
  9503. private _scaleFactor;
  9504. private _tmpMatrix;
  9505. /**
  9506. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  9507. * * When set, interactions will be enabled
  9508. */
  9509. attachedMesh: Nullable<AbstractMesh>;
  9510. /**
  9511. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  9512. */
  9513. updateGizmoRotationToMatchAttachedMesh: boolean;
  9514. /**
  9515. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  9516. */
  9517. updateGizmoPositionToMatchAttachedMesh: boolean;
  9518. /**
  9519. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  9520. */
  9521. protected _updateScale: boolean;
  9522. protected _interactionsEnabled: boolean;
  9523. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9524. private _beforeRenderObserver;
  9525. /**
  9526. * Creates a gizmo
  9527. * @param gizmoLayer The utility layer the gizmo will be added to
  9528. */
  9529. constructor(/** The utility layer the gizmo will be added to */ gizmoLayer?: UtilityLayerRenderer);
  9530. /**
  9531. * Disposes of the gizmo
  9532. */
  9533. dispose(): void;
  9534. }
  9535. }
  9536. declare module BABYLON {
  9537. /**
  9538. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  9539. */
  9540. class GizmoManager implements IDisposable {
  9541. private scene;
  9542. private _gizmoLayer;
  9543. private _gizmoSet;
  9544. private _pointerObserver;
  9545. /**
  9546. * Instatiates a gizmo manager
  9547. * @param scene the scene to overlay the gizmos on top of
  9548. * @param options If only a single gizmo should exist at one time
  9549. */
  9550. constructor(scene: Scene, options?: {
  9551. singleGizmo?: boolean;
  9552. });
  9553. /**
  9554. * Disposes of the gizmo manager
  9555. */
  9556. dispose(): void;
  9557. private _clearGizmos();
  9558. }
  9559. }
  9560. declare module BABYLON {
  9561. /**
  9562. * Single plane rotation gizmo
  9563. */
  9564. class PlaneRotationGizmo extends Gizmo {
  9565. /**
  9566. * Drag behavior responsible for the gizmos dragging interactions
  9567. */
  9568. dragBehavior: PointerDragBehavior;
  9569. private _pointerObserver;
  9570. /**
  9571. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  9572. */
  9573. snapDistance: number;
  9574. /**
  9575. * Event that fires each time the gizmo snaps to a new location.
  9576. * * snapDistance is the the change in distance
  9577. */
  9578. onSnapObservable: Observable<{
  9579. snapDistance: number;
  9580. }>;
  9581. /**
  9582. * Creates a PlaneRotationGizmo
  9583. * @param gizmoLayer The utility layer the gizmo will be added to
  9584. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  9585. * @param color The color of the gizmo
  9586. */
  9587. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9588. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9589. /**
  9590. * Disposes of the gizmo
  9591. */
  9592. dispose(): void;
  9593. }
  9594. }
  9595. declare module BABYLON {
  9596. /**
  9597. * Gizmo that enables dragging a mesh along 3 axis
  9598. */
  9599. class PositionGizmo extends Gizmo {
  9600. /**
  9601. * Internal gizmo used for interactions on the x axis
  9602. */
  9603. xGizmo: AxisDragGizmo;
  9604. /**
  9605. * Internal gizmo used for interactions on the y axis
  9606. */
  9607. yGizmo: AxisDragGizmo;
  9608. /**
  9609. * Internal gizmo used for interactions on the z axis
  9610. */
  9611. zGizmo: AxisDragGizmo;
  9612. attachedMesh: Nullable<AbstractMesh>;
  9613. /**
  9614. * Creates a PositionGizmo
  9615. * @param gizmoLayer The utility layer the gizmo will be added to
  9616. */
  9617. constructor(gizmoLayer?: UtilityLayerRenderer);
  9618. updateGizmoRotationToMatchAttachedMesh: boolean;
  9619. /**
  9620. * Disposes of the gizmo
  9621. */
  9622. dispose(): void;
  9623. }
  9624. }
  9625. declare module BABYLON {
  9626. /**
  9627. * Gizmo that enables rotating a mesh along 3 axis
  9628. */
  9629. class RotationGizmo extends Gizmo {
  9630. /**
  9631. * Internal gizmo used for interactions on the x axis
  9632. */
  9633. xGizmo: PlaneRotationGizmo;
  9634. /**
  9635. * Internal gizmo used for interactions on the y axis
  9636. */
  9637. yGizmo: PlaneRotationGizmo;
  9638. /**
  9639. * Internal gizmo used for interactions on the z axis
  9640. */
  9641. zGizmo: PlaneRotationGizmo;
  9642. attachedMesh: Nullable<AbstractMesh>;
  9643. /**
  9644. * Creates a RotationGizmo
  9645. * @param gizmoLayer The utility layer the gizmo will be added to
  9646. */
  9647. constructor(gizmoLayer?: UtilityLayerRenderer);
  9648. updateGizmoRotationToMatchAttachedMesh: boolean;
  9649. /**
  9650. * Disposes of the gizmo
  9651. */
  9652. dispose(): void;
  9653. }
  9654. }
  9655. declare module BABYLON {
  9656. /**
  9657. * Gizmo that enables scaling a mesh along 3 axis
  9658. */
  9659. class ScaleGizmo extends Gizmo {
  9660. /**
  9661. * Internal gizmo used for interactions on the x axis
  9662. */
  9663. xGizmo: AxisScaleGizmo;
  9664. /**
  9665. * Internal gizmo used for interactions on the y axis
  9666. */
  9667. yGizmo: AxisScaleGizmo;
  9668. /**
  9669. * Internal gizmo used for interactions on the z axis
  9670. */
  9671. zGizmo: AxisScaleGizmo;
  9672. attachedMesh: Nullable<AbstractMesh>;
  9673. /**
  9674. * Creates a ScaleGizmo
  9675. * @param gizmoLayer The utility layer the gizmo will be added to
  9676. */
  9677. constructor(gizmoLayer?: UtilityLayerRenderer);
  9678. updateGizmoRotationToMatchAttachedMesh: boolean;
  9679. /**
  9680. * Disposes of the gizmo
  9681. */
  9682. dispose(): void;
  9683. }
  9684. }
  9685. declare module BABYLON {
  9686. class StickValues {
  9687. x: number;
  9688. y: number;
  9689. constructor(x: number, y: number);
  9690. }
  9691. interface GamepadButtonChanges {
  9692. changed: boolean;
  9693. pressChanged: boolean;
  9694. touchChanged: boolean;
  9695. valueChanged: boolean;
  9696. }
  9697. class Gamepad {
  9698. id: string;
  9699. index: number;
  9700. browserGamepad: any;
  9701. type: number;
  9702. private _leftStick;
  9703. private _rightStick;
  9704. _isConnected: boolean;
  9705. private _leftStickAxisX;
  9706. private _leftStickAxisY;
  9707. private _rightStickAxisX;
  9708. private _rightStickAxisY;
  9709. private _onleftstickchanged;
  9710. private _onrightstickchanged;
  9711. static GAMEPAD: number;
  9712. static GENERIC: number;
  9713. static XBOX: number;
  9714. static POSE_ENABLED: number;
  9715. protected _invertLeftStickY: boolean;
  9716. readonly isConnected: boolean;
  9717. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9718. onleftstickchanged(callback: (values: StickValues) => void): void;
  9719. onrightstickchanged(callback: (values: StickValues) => void): void;
  9720. leftStick: StickValues;
  9721. rightStick: StickValues;
  9722. update(): void;
  9723. dispose(): void;
  9724. }
  9725. class GenericPad extends Gamepad {
  9726. private _buttons;
  9727. private _onbuttondown;
  9728. private _onbuttonup;
  9729. onButtonDownObservable: Observable<number>;
  9730. onButtonUpObservable: Observable<number>;
  9731. onbuttondown(callback: (buttonPressed: number) => void): void;
  9732. onbuttonup(callback: (buttonReleased: number) => void): void;
  9733. constructor(id: string, index: number, browserGamepad: any);
  9734. private _setButtonValue(newValue, currentValue, buttonIndex);
  9735. update(): void;
  9736. dispose(): void;
  9737. }
  9738. }
  9739. declare module BABYLON {
  9740. class GamepadManager {
  9741. private _scene;
  9742. private _babylonGamepads;
  9743. private _oneGamepadConnected;
  9744. _isMonitoring: boolean;
  9745. private _gamepadEventSupported;
  9746. private _gamepadSupport;
  9747. onGamepadConnectedObservable: Observable<Gamepad>;
  9748. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9749. private _onGamepadConnectedEvent;
  9750. private _onGamepadDisconnectedEvent;
  9751. constructor(_scene?: Scene | undefined);
  9752. readonly gamepads: Gamepad[];
  9753. getGamepadByType(type?: number): Nullable<Gamepad>;
  9754. dispose(): void;
  9755. private _addNewGamepad(gamepad);
  9756. private _startMonitoringGamepads();
  9757. private _stopMonitoringGamepads();
  9758. _checkGamepadsStatus(): void;
  9759. private _updateGamepadObjects();
  9760. }
  9761. }
  9762. declare module BABYLON {
  9763. interface Scene {
  9764. /** @hidden */
  9765. _gamepadManager: Nullable<GamepadManager>;
  9766. /**
  9767. * Gets the gamepad manager associated with the scene
  9768. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  9769. */
  9770. gamepadManager: GamepadManager;
  9771. }
  9772. interface FreeCameraInputsManager {
  9773. addGamepad(): FreeCameraInputsManager;
  9774. }
  9775. interface ArcRotateCameraInputsManager {
  9776. addGamepad(): ArcRotateCameraInputsManager;
  9777. }
  9778. /**
  9779. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  9780. */
  9781. class GamepadSystemSceneComponent implements ISceneComponent {
  9782. /**
  9783. * The component name helpfull to identify the component in the list of scene components.
  9784. */
  9785. readonly name: string;
  9786. /**
  9787. * The scene the component belongs to.
  9788. */
  9789. scene: Scene;
  9790. /**
  9791. * Creates a new instance of the component for the given scene
  9792. * @param scene Defines the scene to register the component in
  9793. */
  9794. constructor(scene: Scene);
  9795. /**
  9796. * Registers the component in a given scene
  9797. */
  9798. register(): void;
  9799. /**
  9800. * Rebuilds the elements related to this component in case of
  9801. * context lost for instance.
  9802. */
  9803. rebuild(): void;
  9804. /**
  9805. * Disposes the component and the associated ressources
  9806. */
  9807. dispose(): void;
  9808. private _beforeCameraUpdate();
  9809. }
  9810. }
  9811. declare module BABYLON {
  9812. /**
  9813. * Defines supported buttons for XBox360 compatible gamepads
  9814. */
  9815. enum Xbox360Button {
  9816. /** A */
  9817. A = 0,
  9818. /** B */
  9819. B = 1,
  9820. /** X */
  9821. X = 2,
  9822. /** Y */
  9823. Y = 3,
  9824. /** Start */
  9825. Start = 4,
  9826. /** Back */
  9827. Back = 5,
  9828. /** Left button */
  9829. LB = 6,
  9830. /** Right button */
  9831. RB = 7,
  9832. /** Left stick */
  9833. LeftStick = 8,
  9834. /** Right stick */
  9835. RightStick = 9,
  9836. }
  9837. /** Defines values for XBox360 DPad */
  9838. enum Xbox360Dpad {
  9839. /** Up */
  9840. Up = 0,
  9841. /** Down */
  9842. Down = 1,
  9843. /** Left */
  9844. Left = 2,
  9845. /** Right */
  9846. Right = 3,
  9847. }
  9848. /**
  9849. * Defines a XBox360 gamepad
  9850. */
  9851. class Xbox360Pad extends Gamepad {
  9852. private _leftTrigger;
  9853. private _rightTrigger;
  9854. private _onlefttriggerchanged;
  9855. private _onrighttriggerchanged;
  9856. private _onbuttondown;
  9857. private _onbuttonup;
  9858. private _ondpaddown;
  9859. private _ondpadup;
  9860. /** Observable raised when a button is pressed */
  9861. onButtonDownObservable: Observable<Xbox360Button>;
  9862. /** Observable raised when a button is released */
  9863. onButtonUpObservable: Observable<Xbox360Button>;
  9864. /** Observable raised when a pad is pressed */
  9865. onPadDownObservable: Observable<Xbox360Dpad>;
  9866. /** Observable raised when a pad is released */
  9867. onPadUpObservable: Observable<Xbox360Dpad>;
  9868. private _buttonA;
  9869. private _buttonB;
  9870. private _buttonX;
  9871. private _buttonY;
  9872. private _buttonBack;
  9873. private _buttonStart;
  9874. private _buttonLB;
  9875. private _buttonRB;
  9876. private _buttonLeftStick;
  9877. private _buttonRightStick;
  9878. private _dPadUp;
  9879. private _dPadDown;
  9880. private _dPadLeft;
  9881. private _dPadRight;
  9882. private _isXboxOnePad;
  9883. /**
  9884. * Creates a new XBox360 gamepad object
  9885. * @param id defines the id of this gamepad
  9886. * @param index defines its index
  9887. * @param gamepad defines the internal HTML gamepad object
  9888. * @param xboxOne defines if it is a XBox One gamepad
  9889. */
  9890. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9891. /**
  9892. * Defines the callback to call when left trigger is pressed
  9893. * @param callback defines the callback to use
  9894. */
  9895. onlefttriggerchanged(callback: (value: number) => void): void;
  9896. /**
  9897. * Defines the callback to call when right trigger is pressed
  9898. * @param callback defines the callback to use
  9899. */
  9900. onrighttriggerchanged(callback: (value: number) => void): void;
  9901. /**
  9902. * Gets or sets left trigger value
  9903. */
  9904. leftTrigger: number;
  9905. /**
  9906. * Gets or sets right trigger value
  9907. */
  9908. rightTrigger: number;
  9909. /**
  9910. * Defines the callback to call when a button is pressed
  9911. * @param callback defines the callback to use
  9912. */
  9913. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9914. /**
  9915. * Defines the callback to call when a button is released
  9916. * @param callback defines the callback to use
  9917. */
  9918. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9919. /**
  9920. * Defines the callback to call when a pad is pressed
  9921. * @param callback defines the callback to use
  9922. */
  9923. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9924. /**
  9925. * Defines the callback to call when a pad is released
  9926. * @param callback defines the callback to use
  9927. */
  9928. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9929. private _setButtonValue(newValue, currentValue, buttonType);
  9930. private _setDPadValue(newValue, currentValue, buttonType);
  9931. /** Gets or sets value of A button */
  9932. buttonA: number;
  9933. /** Gets or sets value of B button */
  9934. buttonB: number;
  9935. /** Gets or sets value of X button */
  9936. buttonX: number;
  9937. /** Gets or sets value of Y button */
  9938. buttonY: number;
  9939. /** Gets or sets value of Start button */
  9940. buttonStart: number;
  9941. /** Gets or sets value of Back button */
  9942. buttonBack: number;
  9943. /** Gets or sets value of Left button */
  9944. buttonLB: number;
  9945. /** Gets or sets value of Right button */
  9946. buttonRB: number;
  9947. /** Gets or sets value of left stick */
  9948. buttonLeftStick: number;
  9949. /** Gets or sets value of right stick */
  9950. buttonRightStick: number;
  9951. /** Gets or sets value of DPad up */
  9952. dPadUp: number;
  9953. /** Gets or sets value of DPad down */
  9954. dPadDown: number;
  9955. /** Gets or sets value of DPad left */
  9956. dPadLeft: number;
  9957. /** Gets or sets value of DPad right */
  9958. dPadRight: number;
  9959. /**
  9960. * Force the gamepad to synchronize with device values
  9961. */
  9962. update(): void;
  9963. dispose(): void;
  9964. }
  9965. }
  9966. declare module BABYLON {
  9967. /**
  9968. * Represents the different options available during the creation of
  9969. * a Environment helper.
  9970. *
  9971. * This can control the default ground, skybox and image processing setup of your scene.
  9972. */
  9973. interface IEnvironmentHelperOptions {
  9974. /**
  9975. * Specifies wether or not to create a ground.
  9976. * True by default.
  9977. */
  9978. createGround: boolean;
  9979. /**
  9980. * Specifies the ground size.
  9981. * 15 by default.
  9982. */
  9983. groundSize: number;
  9984. /**
  9985. * The texture used on the ground for the main color.
  9986. * Comes from the BabylonJS CDN by default.
  9987. *
  9988. * Remarks: Can be either a texture or a url.
  9989. */
  9990. groundTexture: string | BaseTexture;
  9991. /**
  9992. * The color mixed in the ground texture by default.
  9993. * BabylonJS clearColor by default.
  9994. */
  9995. groundColor: Color3;
  9996. /**
  9997. * Specifies the ground opacity.
  9998. * 1 by default.
  9999. */
  10000. groundOpacity: number;
  10001. /**
  10002. * Enables the ground to receive shadows.
  10003. * True by default.
  10004. */
  10005. enableGroundShadow: boolean;
  10006. /**
  10007. * Helps preventing the shadow to be fully black on the ground.
  10008. * 0.5 by default.
  10009. */
  10010. groundShadowLevel: number;
  10011. /**
  10012. * Creates a mirror texture attach to the ground.
  10013. * false by default.
  10014. */
  10015. enableGroundMirror: boolean;
  10016. /**
  10017. * Specifies the ground mirror size ratio.
  10018. * 0.3 by default as the default kernel is 64.
  10019. */
  10020. groundMirrorSizeRatio: number;
  10021. /**
  10022. * Specifies the ground mirror blur kernel size.
  10023. * 64 by default.
  10024. */
  10025. groundMirrorBlurKernel: number;
  10026. /**
  10027. * Specifies the ground mirror visibility amount.
  10028. * 1 by default
  10029. */
  10030. groundMirrorAmount: number;
  10031. /**
  10032. * Specifies the ground mirror reflectance weight.
  10033. * This uses the standard weight of the background material to setup the fresnel effect
  10034. * of the mirror.
  10035. * 1 by default.
  10036. */
  10037. groundMirrorFresnelWeight: number;
  10038. /**
  10039. * Specifies the ground mirror Falloff distance.
  10040. * This can helps reducing the size of the reflection.
  10041. * 0 by Default.
  10042. */
  10043. groundMirrorFallOffDistance: number;
  10044. /**
  10045. * Specifies the ground mirror texture type.
  10046. * Unsigned Int by Default.
  10047. */
  10048. groundMirrorTextureType: number;
  10049. /**
  10050. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  10051. * the shown objects.
  10052. */
  10053. groundYBias: number;
  10054. /**
  10055. * Specifies wether or not to create a skybox.
  10056. * True by default.
  10057. */
  10058. createSkybox: boolean;
  10059. /**
  10060. * Specifies the skybox size.
  10061. * 20 by default.
  10062. */
  10063. skyboxSize: number;
  10064. /**
  10065. * The texture used on the skybox for the main color.
  10066. * Comes from the BabylonJS CDN by default.
  10067. *
  10068. * Remarks: Can be either a texture or a url.
  10069. */
  10070. skyboxTexture: string | BaseTexture;
  10071. /**
  10072. * The color mixed in the skybox texture by default.
  10073. * BabylonJS clearColor by default.
  10074. */
  10075. skyboxColor: Color3;
  10076. /**
  10077. * The background rotation around the Y axis of the scene.
  10078. * This helps aligning the key lights of your scene with the background.
  10079. * 0 by default.
  10080. */
  10081. backgroundYRotation: number;
  10082. /**
  10083. * Compute automatically the size of the elements to best fit with the scene.
  10084. */
  10085. sizeAuto: boolean;
  10086. /**
  10087. * Default position of the rootMesh if autoSize is not true.
  10088. */
  10089. rootPosition: Vector3;
  10090. /**
  10091. * Sets up the image processing in the scene.
  10092. * true by default.
  10093. */
  10094. setupImageProcessing: boolean;
  10095. /**
  10096. * The texture used as your environment texture in the scene.
  10097. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  10098. *
  10099. * Remarks: Can be either a texture or a url.
  10100. */
  10101. environmentTexture: string | BaseTexture;
  10102. /**
  10103. * The value of the exposure to apply to the scene.
  10104. * 0.6 by default if setupImageProcessing is true.
  10105. */
  10106. cameraExposure: number;
  10107. /**
  10108. * The value of the contrast to apply to the scene.
  10109. * 1.6 by default if setupImageProcessing is true.
  10110. */
  10111. cameraContrast: number;
  10112. /**
  10113. * Specifies wether or not tonemapping should be enabled in the scene.
  10114. * true by default if setupImageProcessing is true.
  10115. */
  10116. toneMappingEnabled: boolean;
  10117. }
  10118. /**
  10119. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  10120. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  10121. * It also helps with the default setup of your imageProcessing configuration.
  10122. */
  10123. class EnvironmentHelper {
  10124. /**
  10125. * Default ground texture URL.
  10126. */
  10127. private static _groundTextureCDNUrl;
  10128. /**
  10129. * Default skybox texture URL.
  10130. */
  10131. private static _skyboxTextureCDNUrl;
  10132. /**
  10133. * Default environment texture URL.
  10134. */
  10135. private static _environmentTextureCDNUrl;
  10136. /**
  10137. * Creates the default options for the helper.
  10138. */
  10139. private static _getDefaultOptions();
  10140. private _rootMesh;
  10141. /**
  10142. * Gets the root mesh created by the helper.
  10143. */
  10144. readonly rootMesh: Mesh;
  10145. private _skybox;
  10146. /**
  10147. * Gets the skybox created by the helper.
  10148. */
  10149. readonly skybox: Nullable<Mesh>;
  10150. private _skyboxTexture;
  10151. /**
  10152. * Gets the skybox texture created by the helper.
  10153. */
  10154. readonly skyboxTexture: Nullable<BaseTexture>;
  10155. private _skyboxMaterial;
  10156. /**
  10157. * Gets the skybox material created by the helper.
  10158. */
  10159. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  10160. private _ground;
  10161. /**
  10162. * Gets the ground mesh created by the helper.
  10163. */
  10164. readonly ground: Nullable<Mesh>;
  10165. private _groundTexture;
  10166. /**
  10167. * Gets the ground texture created by the helper.
  10168. */
  10169. readonly groundTexture: Nullable<BaseTexture>;
  10170. private _groundMirror;
  10171. /**
  10172. * Gets the ground mirror created by the helper.
  10173. */
  10174. readonly groundMirror: Nullable<MirrorTexture>;
  10175. /**
  10176. * Gets the ground mirror render list to helps pushing the meshes
  10177. * you wish in the ground reflection.
  10178. */
  10179. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  10180. private _groundMaterial;
  10181. /**
  10182. * Gets the ground material created by the helper.
  10183. */
  10184. readonly groundMaterial: Nullable<BackgroundMaterial>;
  10185. /**
  10186. * Stores the creation options.
  10187. */
  10188. private readonly _scene;
  10189. private _options;
  10190. /**
  10191. * This observable will be notified with any error during the creation of the environment,
  10192. * mainly texture creation errors.
  10193. */
  10194. onErrorObservable: Observable<{
  10195. message?: string;
  10196. exception?: any;
  10197. }>;
  10198. /**
  10199. * constructor
  10200. * @param options
  10201. * @param scene The scene to add the material to
  10202. */
  10203. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  10204. /**
  10205. * Updates the background according to the new options
  10206. * @param options
  10207. */
  10208. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  10209. /**
  10210. * Sets the primary color of all the available elements.
  10211. * @param color the main color to affect to the ground and the background
  10212. */
  10213. setMainColor(color: Color3): void;
  10214. /**
  10215. * Setup the image processing according to the specified options.
  10216. */
  10217. private _setupImageProcessing();
  10218. /**
  10219. * Setup the environment texture according to the specified options.
  10220. */
  10221. private _setupEnvironmentTexture();
  10222. /**
  10223. * Setup the background according to the specified options.
  10224. */
  10225. private _setupBackground();
  10226. /**
  10227. * Get the scene sizes according to the setup.
  10228. */
  10229. private _getSceneSize();
  10230. /**
  10231. * Setup the ground according to the specified options.
  10232. */
  10233. private _setupGround(sceneSize);
  10234. /**
  10235. * Setup the ground material according to the specified options.
  10236. */
  10237. private _setupGroundMaterial();
  10238. /**
  10239. * Setup the ground diffuse texture according to the specified options.
  10240. */
  10241. private _setupGroundDiffuseTexture();
  10242. /**
  10243. * Setup the ground mirror texture according to the specified options.
  10244. */
  10245. private _setupGroundMirrorTexture(sceneSize);
  10246. /**
  10247. * Setup the ground to receive the mirror texture.
  10248. */
  10249. private _setupMirrorInGroundMaterial();
  10250. /**
  10251. * Setup the skybox according to the specified options.
  10252. */
  10253. private _setupSkybox(sceneSize);
  10254. /**
  10255. * Setup the skybox material according to the specified options.
  10256. */
  10257. private _setupSkyboxMaterial();
  10258. /**
  10259. * Setup the skybox reflection texture according to the specified options.
  10260. */
  10261. private _setupSkyboxReflectionTexture();
  10262. private _errorHandler;
  10263. /**
  10264. * Dispose all the elements created by the Helper.
  10265. */
  10266. dispose(): void;
  10267. }
  10268. }
  10269. declare module BABYLON {
  10270. /**
  10271. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  10272. * As a subclass of Node, this allow parenting to the camera with different locations in the scene.
  10273. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  10274. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10275. */
  10276. class PhotoDome extends Node {
  10277. private _useDirectMapping;
  10278. /**
  10279. * The texture being displayed on the sphere
  10280. */
  10281. protected _photoTexture: Texture;
  10282. /**
  10283. * Gets or sets the texture being displayed on the sphere
  10284. */
  10285. photoTexture: Texture;
  10286. /**
  10287. * The skybox material
  10288. */
  10289. protected _material: BackgroundMaterial;
  10290. /**
  10291. * The surface used for the skybox
  10292. */
  10293. protected _mesh: Mesh;
  10294. /**
  10295. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10296. * Also see the options.resolution property.
  10297. */
  10298. fovMultiplier: number;
  10299. /**
  10300. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10301. * @param name Element's name, child elements will append suffixes for their own names.
  10302. * @param urlsOfPhoto define the url of the photo to display
  10303. * @param options An object containing optional or exposed sub element properties
  10304. */
  10305. constructor(name: string, urlOfPhoto: string, options: {
  10306. resolution?: number;
  10307. size?: number;
  10308. useDirectMapping?: boolean;
  10309. }, scene: Scene);
  10310. /**
  10311. * Releases resources associated with this node.
  10312. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10313. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10314. */
  10315. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10316. }
  10317. }
  10318. declare module BABYLON {
  10319. /**
  10320. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10321. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  10322. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10323. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10324. */
  10325. class VideoDome extends Node {
  10326. private _useDirectMapping;
  10327. /**
  10328. * The video texture being displayed on the sphere
  10329. */
  10330. protected _videoTexture: VideoTexture;
  10331. /**
  10332. * Gets the video texture being displayed on the sphere
  10333. */
  10334. readonly videoTexture: VideoTexture;
  10335. /**
  10336. * The skybox material
  10337. */
  10338. protected _material: BackgroundMaterial;
  10339. /**
  10340. * The surface used for the skybox
  10341. */
  10342. protected _mesh: Mesh;
  10343. /**
  10344. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10345. * Also see the options.resolution property.
  10346. */
  10347. fovMultiplier: number;
  10348. /**
  10349. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10350. * @param name Element's name, child elements will append suffixes for their own names.
  10351. * @param urlsOrVideo defines the url(s) or the video element to use
  10352. * @param options An object containing optional or exposed sub element properties
  10353. */
  10354. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10355. resolution?: number;
  10356. clickToPlay?: boolean;
  10357. autoPlay?: boolean;
  10358. loop?: boolean;
  10359. size?: number;
  10360. poster?: string;
  10361. useDirectMapping?: boolean;
  10362. }, scene: Scene);
  10363. /**
  10364. * Releases resources associated with this node.
  10365. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10366. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10367. */
  10368. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10369. }
  10370. }
  10371. declare module BABYLON {
  10372. /**
  10373. * This class can be used to get instrumentation data from a Babylon engine
  10374. */
  10375. class EngineInstrumentation implements IDisposable {
  10376. engine: Engine;
  10377. private _captureGPUFrameTime;
  10378. private _gpuFrameTimeToken;
  10379. private _gpuFrameTime;
  10380. private _captureShaderCompilationTime;
  10381. private _shaderCompilationTime;
  10382. private _onBeginFrameObserver;
  10383. private _onEndFrameObserver;
  10384. private _onBeforeShaderCompilationObserver;
  10385. private _onAfterShaderCompilationObserver;
  10386. /**
  10387. * Gets the perf counter used for GPU frame time
  10388. */
  10389. readonly gpuFrameTimeCounter: PerfCounter;
  10390. /**
  10391. * Gets the GPU frame time capture status
  10392. */
  10393. /**
  10394. * Enable or disable the GPU frame time capture
  10395. */
  10396. captureGPUFrameTime: boolean;
  10397. /**
  10398. * Gets the perf counter used for shader compilation time
  10399. */
  10400. readonly shaderCompilationTimeCounter: PerfCounter;
  10401. /**
  10402. * Gets the shader compilation time capture status
  10403. */
  10404. /**
  10405. * Enable or disable the shader compilation time capture
  10406. */
  10407. captureShaderCompilationTime: boolean;
  10408. constructor(engine: Engine);
  10409. dispose(): void;
  10410. }
  10411. }
  10412. declare module BABYLON {
  10413. /**
  10414. * This class can be used to get instrumentation data from a Babylon engine
  10415. */
  10416. class SceneInstrumentation implements IDisposable {
  10417. scene: Scene;
  10418. private _captureActiveMeshesEvaluationTime;
  10419. private _activeMeshesEvaluationTime;
  10420. private _captureRenderTargetsRenderTime;
  10421. private _renderTargetsRenderTime;
  10422. private _captureFrameTime;
  10423. private _frameTime;
  10424. private _captureRenderTime;
  10425. private _renderTime;
  10426. private _captureInterFrameTime;
  10427. private _interFrameTime;
  10428. private _captureParticlesRenderTime;
  10429. private _particlesRenderTime;
  10430. private _captureSpritesRenderTime;
  10431. private _spritesRenderTime;
  10432. private _capturePhysicsTime;
  10433. private _physicsTime;
  10434. private _captureAnimationsTime;
  10435. private _animationsTime;
  10436. private _captureCameraRenderTime;
  10437. private _cameraRenderTime;
  10438. private _onBeforeActiveMeshesEvaluationObserver;
  10439. private _onAfterActiveMeshesEvaluationObserver;
  10440. private _onBeforeRenderTargetsRenderObserver;
  10441. private _onAfterRenderTargetsRenderObserver;
  10442. private _onAfterRenderObserver;
  10443. private _onBeforeDrawPhaseObserver;
  10444. private _onAfterDrawPhaseObserver;
  10445. private _onBeforeAnimationsObserver;
  10446. private _onBeforeParticlesRenderingObserver;
  10447. private _onAfterParticlesRenderingObserver;
  10448. private _onBeforeSpritesRenderingObserver;
  10449. private _onAfterSpritesRenderingObserver;
  10450. private _onBeforePhysicsObserver;
  10451. private _onAfterPhysicsObserver;
  10452. private _onAfterAnimationsObserver;
  10453. private _onBeforeCameraRenderObserver;
  10454. private _onAfterCameraRenderObserver;
  10455. /**
  10456. * Gets the perf counter used for active meshes evaluation time
  10457. */
  10458. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10459. /**
  10460. * Gets the active meshes evaluation time capture status
  10461. */
  10462. /**
  10463. * Enable or disable the active meshes evaluation time capture
  10464. */
  10465. captureActiveMeshesEvaluationTime: boolean;
  10466. /**
  10467. * Gets the perf counter used for render targets render time
  10468. */
  10469. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10470. /**
  10471. * Gets the render targets render time capture status
  10472. */
  10473. /**
  10474. * Enable or disable the render targets render time capture
  10475. */
  10476. captureRenderTargetsRenderTime: boolean;
  10477. /**
  10478. * Gets the perf counter used for particles render time
  10479. */
  10480. readonly particlesRenderTimeCounter: PerfCounter;
  10481. /**
  10482. * Gets the particles render time capture status
  10483. */
  10484. /**
  10485. * Enable or disable the particles render time capture
  10486. */
  10487. captureParticlesRenderTime: boolean;
  10488. /**
  10489. * Gets the perf counter used for sprites render time
  10490. */
  10491. readonly spritesRenderTimeCounter: PerfCounter;
  10492. /**
  10493. * Gets the sprites render time capture status
  10494. */
  10495. /**
  10496. * Enable or disable the sprites render time capture
  10497. */
  10498. captureSpritesRenderTime: boolean;
  10499. /**
  10500. * Gets the perf counter used for physics time
  10501. */
  10502. readonly physicsTimeCounter: PerfCounter;
  10503. /**
  10504. * Gets the physics time capture status
  10505. */
  10506. /**
  10507. * Enable or disable the physics time capture
  10508. */
  10509. capturePhysicsTime: boolean;
  10510. /**
  10511. * Gets the perf counter used for animations time
  10512. */
  10513. readonly animationsTimeCounter: PerfCounter;
  10514. /**
  10515. * Gets the animations time capture status
  10516. */
  10517. /**
  10518. * Enable or disable the animations time capture
  10519. */
  10520. captureAnimationsTime: boolean;
  10521. /**
  10522. * Gets the perf counter used for frame time capture
  10523. */
  10524. readonly frameTimeCounter: PerfCounter;
  10525. /**
  10526. * Gets the frame time capture status
  10527. */
  10528. /**
  10529. * Enable or disable the frame time capture
  10530. */
  10531. captureFrameTime: boolean;
  10532. /**
  10533. * Gets the perf counter used for inter-frames time capture
  10534. */
  10535. readonly interFrameTimeCounter: PerfCounter;
  10536. /**
  10537. * Gets the inter-frames time capture status
  10538. */
  10539. /**
  10540. * Enable or disable the inter-frames time capture
  10541. */
  10542. captureInterFrameTime: boolean;
  10543. /**
  10544. * Gets the perf counter used for render time capture
  10545. */
  10546. readonly renderTimeCounter: PerfCounter;
  10547. /**
  10548. * Gets the render time capture status
  10549. */
  10550. /**
  10551. * Enable or disable the render time capture
  10552. */
  10553. captureRenderTime: boolean;
  10554. /**
  10555. * Gets the perf counter used for camera render time capture
  10556. */
  10557. readonly cameraRenderTimeCounter: PerfCounter;
  10558. /**
  10559. * Gets the camera render time capture status
  10560. */
  10561. /**
  10562. * Enable or disable the camera render time capture
  10563. */
  10564. captureCameraRenderTime: boolean;
  10565. /**
  10566. * Gets the perf counter used for draw calls
  10567. */
  10568. readonly drawCallsCounter: PerfCounter;
  10569. /**
  10570. * Gets the perf counter used for texture collisions
  10571. */
  10572. readonly textureCollisionsCounter: PerfCounter;
  10573. constructor(scene: Scene);
  10574. dispose(): void;
  10575. }
  10576. }
  10577. declare module BABYLON {
  10578. /**
  10579. * @hidden
  10580. **/
  10581. class _TimeToken {
  10582. _startTimeQuery: Nullable<WebGLQuery>;
  10583. _endTimeQuery: Nullable<WebGLQuery>;
  10584. _timeElapsedQuery: Nullable<WebGLQuery>;
  10585. _timeElapsedQueryEnded: boolean;
  10586. }
  10587. }
  10588. declare module BABYLON {
  10589. /**
  10590. * Effect layer options. This helps customizing the behaviour
  10591. * of the effect layer.
  10592. */
  10593. interface IEffectLayerOptions {
  10594. /**
  10595. * Multiplication factor apply to the canvas size to compute the render target size
  10596. * used to generated the objects (the smaller the faster).
  10597. */
  10598. mainTextureRatio: number;
  10599. /**
  10600. * Enforces a fixed size texture to ensure effect stability across devices.
  10601. */
  10602. mainTextureFixedSize?: number;
  10603. /**
  10604. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10605. */
  10606. alphaBlendingMode: number;
  10607. /**
  10608. * The camera attached to the layer.
  10609. */
  10610. camera: Nullable<Camera>;
  10611. /**
  10612. * The rendering group to draw the layer in.
  10613. */
  10614. renderingGroupId: number;
  10615. }
  10616. /**
  10617. * The effect layer Helps adding post process effect blended with the main pass.
  10618. *
  10619. * This can be for instance use to generate glow or higlight effects on the scene.
  10620. *
  10621. * The effect layer class can not be used directly and is intented to inherited from to be
  10622. * customized per effects.
  10623. */
  10624. abstract class EffectLayer {
  10625. private _vertexBuffers;
  10626. private _indexBuffer;
  10627. private _cachedDefines;
  10628. private _effectLayerMapGenerationEffect;
  10629. private _effectLayerOptions;
  10630. private _mergeEffect;
  10631. protected _scene: Scene;
  10632. protected _engine: Engine;
  10633. protected _maxSize: number;
  10634. protected _mainTextureDesiredSize: ISize;
  10635. protected _mainTexture: RenderTargetTexture;
  10636. protected _shouldRender: boolean;
  10637. protected _postProcesses: PostProcess[];
  10638. protected _textures: BaseTexture[];
  10639. protected _emissiveTextureAndColor: {
  10640. texture: Nullable<BaseTexture>;
  10641. color: Color4;
  10642. };
  10643. /**
  10644. * The name of the layer
  10645. */
  10646. name: string;
  10647. /**
  10648. * The clear color of the texture used to generate the glow map.
  10649. */
  10650. neutralColor: Color4;
  10651. /**
  10652. * Specifies wether the highlight layer is enabled or not.
  10653. */
  10654. isEnabled: boolean;
  10655. /**
  10656. * Gets the camera attached to the layer.
  10657. */
  10658. readonly camera: Nullable<Camera>;
  10659. /**
  10660. * Gets the rendering group id the layer should render in.
  10661. */
  10662. readonly renderingGroupId: number;
  10663. /**
  10664. * An event triggered when the effect layer has been disposed.
  10665. */
  10666. onDisposeObservable: Observable<EffectLayer>;
  10667. /**
  10668. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  10669. */
  10670. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  10671. /**
  10672. * An event triggered when the generated texture is being merged in the scene.
  10673. */
  10674. onBeforeComposeObservable: Observable<EffectLayer>;
  10675. /**
  10676. * An event triggered when the generated texture has been merged in the scene.
  10677. */
  10678. onAfterComposeObservable: Observable<EffectLayer>;
  10679. /**
  10680. * An event triggered when the efffect layer changes its size.
  10681. */
  10682. onSizeChangedObservable: Observable<EffectLayer>;
  10683. /**
  10684. * Instantiates a new effect Layer and references it in the scene.
  10685. * @param name The name of the layer
  10686. * @param scene The scene to use the layer in
  10687. */
  10688. constructor(
  10689. /** The Friendly of the effect in the scene */
  10690. name: string, scene: Scene);
  10691. /**
  10692. * Get the effect name of the layer.
  10693. * @return The effect name
  10694. */
  10695. abstract getEffectName(): string;
  10696. /**
  10697. * Checks for the readiness of the element composing the layer.
  10698. * @param subMesh the mesh to check for
  10699. * @param useInstances specify wether or not to use instances to render the mesh
  10700. * @return true if ready otherwise, false
  10701. */
  10702. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10703. /**
  10704. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10705. * @returns true if the effect requires stencil during the main canvas render pass.
  10706. */
  10707. abstract needStencil(): boolean;
  10708. /**
  10709. * Create the merge effect. This is the shader use to blit the information back
  10710. * to the main canvas at the end of the scene rendering.
  10711. * @returns The effect containing the shader used to merge the effect on the main canvas
  10712. */
  10713. protected abstract _createMergeEffect(): Effect;
  10714. /**
  10715. * Creates the render target textures and post processes used in the effect layer.
  10716. */
  10717. protected abstract _createTextureAndPostProcesses(): void;
  10718. /**
  10719. * Implementation specific of rendering the generating effect on the main canvas.
  10720. * @param effect The effect used to render through
  10721. */
  10722. protected abstract _internalRender(effect: Effect): void;
  10723. /**
  10724. * Sets the required values for both the emissive texture and and the main color.
  10725. */
  10726. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10727. /**
  10728. * Free any resources and references associated to a mesh.
  10729. * Internal use
  10730. * @param mesh The mesh to free.
  10731. */
  10732. abstract _disposeMesh(mesh: Mesh): void;
  10733. /**
  10734. * Serializes this layer (Glow or Highlight for example)
  10735. * @returns a serialized layer object
  10736. */
  10737. abstract serialize?(): any;
  10738. /**
  10739. * Initializes the effect layer with the required options.
  10740. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10741. */
  10742. protected _init(options: Partial<IEffectLayerOptions>): void;
  10743. /**
  10744. * Generates the index buffer of the full screen quad blending to the main canvas.
  10745. */
  10746. private _generateIndexBuffer();
  10747. /**
  10748. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10749. */
  10750. private _genrateVertexBuffer();
  10751. /**
  10752. * Sets the main texture desired size which is the closest power of two
  10753. * of the engine canvas size.
  10754. */
  10755. private _setMainTextureSize();
  10756. /**
  10757. * Creates the main texture for the effect layer.
  10758. */
  10759. protected _createMainTexture(): void;
  10760. /**
  10761. * Checks for the readiness of the element composing the layer.
  10762. * @param subMesh the mesh to check for
  10763. * @param useInstances specify wether or not to use instances to render the mesh
  10764. * @param emissiveTexture the associated emissive texture used to generate the glow
  10765. * @return true if ready otherwise, false
  10766. */
  10767. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10768. /**
  10769. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10770. */
  10771. render(): void;
  10772. /**
  10773. * Determine if a given mesh will be used in the current effect.
  10774. * @param mesh mesh to test
  10775. * @returns true if the mesh will be used
  10776. */
  10777. hasMesh(mesh: AbstractMesh): boolean;
  10778. /**
  10779. * Returns true if the layer contains information to display, otherwise false.
  10780. * @returns true if the glow layer should be rendered
  10781. */
  10782. shouldRender(): boolean;
  10783. /**
  10784. * Returns true if the mesh should render, otherwise false.
  10785. * @param mesh The mesh to render
  10786. * @returns true if it should render otherwise false
  10787. */
  10788. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10789. /**
  10790. * Returns true if the mesh should render, otherwise false.
  10791. * @param mesh The mesh to render
  10792. * @returns true if it should render otherwise false
  10793. */
  10794. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10795. /**
  10796. * Renders the submesh passed in parameter to the generation map.
  10797. */
  10798. protected _renderSubMesh(subMesh: SubMesh): void;
  10799. /**
  10800. * Rebuild the required buffers.
  10801. * @hidden Internal use only.
  10802. */
  10803. _rebuild(): void;
  10804. /**
  10805. * Dispose only the render target textures and post process.
  10806. */
  10807. private _disposeTextureAndPostProcesses();
  10808. /**
  10809. * Dispose the highlight layer and free resources.
  10810. */
  10811. dispose(): void;
  10812. /**
  10813. * Gets the class name of the effect layer
  10814. * @returns the string with the class name of the effect layer
  10815. */
  10816. getClassName(): string;
  10817. /**
  10818. * Creates an effect layer from parsed effect layer data
  10819. * @param parsedEffectLayer defines effect layer data
  10820. * @param scene defines the current scene
  10821. * @param rootUrl defines the root URL containing the effect layer information
  10822. * @returns a parsed effect Layer
  10823. */
  10824. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10825. }
  10826. }
  10827. declare module BABYLON {
  10828. interface AbstractScene {
  10829. /**
  10830. * The list of effect layers (highlights/glow) added to the scene
  10831. * @see http://doc.babylonjs.com/how_to/highlight_layer
  10832. * @see http://doc.babylonjs.com/how_to/glow_layer
  10833. */
  10834. effectLayers: Array<EffectLayer>;
  10835. /**
  10836. * Removes the given effect layer from this scene.
  10837. * @param toRemove defines the effect layer to remove
  10838. * @returns the index of the removed effect layer
  10839. */
  10840. removeEffectLayer(toRemove: EffectLayer): number;
  10841. /**
  10842. * Adds the given effect layer to this scene
  10843. * @param newEffectLayer defines the effect layer to add
  10844. */
  10845. addEffectLayer(newEffectLayer: EffectLayer): void;
  10846. }
  10847. /**
  10848. * Defines the layer scene component responsible to manage any effect layers
  10849. * in a given scene.
  10850. */
  10851. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  10852. /**
  10853. * The component name helpfull to identify the component in the list of scene components.
  10854. */
  10855. readonly name: string;
  10856. /**
  10857. * The scene the component belongs to.
  10858. */
  10859. scene: Scene;
  10860. private _engine;
  10861. private _renderEffects;
  10862. private _needStencil;
  10863. private _previousStencilState;
  10864. /**
  10865. * Creates a new instance of the component for the given scene
  10866. * @param scene Defines the scene to register the component in
  10867. */
  10868. constructor(scene: Scene);
  10869. /**
  10870. * Registers the component in a given scene
  10871. */
  10872. register(): void;
  10873. /**
  10874. * Rebuilds the elements related to this component in case of
  10875. * context lost for instance.
  10876. */
  10877. rebuild(): void;
  10878. /**
  10879. * Serializes the component data to the specified json object
  10880. * @param serializationObject The object to serialize to
  10881. */
  10882. serialize(serializationObject: any): void;
  10883. /**
  10884. * Adds all the element from the container to the scene
  10885. * @param container the container holding the elements
  10886. */
  10887. addFromContainer(container: AbstractScene): void;
  10888. /**
  10889. * Removes all the elements in the container from the scene
  10890. * @param container contains the elements to remove
  10891. */
  10892. removeFromContainer(container: AbstractScene): void;
  10893. /**
  10894. * Disposes the component and the associated ressources.
  10895. */
  10896. dispose(): void;
  10897. private _isReadyForMesh(mesh, hardwareInstancedRendering);
  10898. private _renderMainTexture(camera);
  10899. private _setStencil(camera);
  10900. private _setStencilBack(camera);
  10901. private _draw(renderingGroupId);
  10902. private _drawCamera(camera);
  10903. private _drawRenderingGroup(index);
  10904. }
  10905. }
  10906. declare module BABYLON {
  10907. interface AbstractScene {
  10908. /**
  10909. * Return a the first highlight layer of the scene with a given name.
  10910. * @param name The name of the highlight layer to look for.
  10911. * @return The highlight layer if found otherwise null.
  10912. */
  10913. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  10914. }
  10915. /**
  10916. * Glow layer options. This helps customizing the behaviour
  10917. * of the glow layer.
  10918. */
  10919. interface IGlowLayerOptions {
  10920. /**
  10921. * Multiplication factor apply to the canvas size to compute the render target size
  10922. * used to generated the glowing objects (the smaller the faster).
  10923. */
  10924. mainTextureRatio: number;
  10925. /**
  10926. * Enforces a fixed size texture to ensure resize independant blur.
  10927. */
  10928. mainTextureFixedSize?: number;
  10929. /**
  10930. * How big is the kernel of the blur texture.
  10931. */
  10932. blurKernelSize: number;
  10933. /**
  10934. * The camera attached to the layer.
  10935. */
  10936. camera: Nullable<Camera>;
  10937. /**
  10938. * Enable MSAA by chosing the number of samples.
  10939. */
  10940. mainTextureSamples?: number;
  10941. /**
  10942. * The rendering group to draw the layer in.
  10943. */
  10944. renderingGroupId: number;
  10945. }
  10946. /**
  10947. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  10948. *
  10949. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10950. * glowy meshes to your scene.
  10951. *
  10952. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  10953. */
  10954. class GlowLayer extends EffectLayer {
  10955. /**
  10956. * Effect Name of the layer.
  10957. */
  10958. static readonly EffectName: string;
  10959. /**
  10960. * The default blur kernel size used for the glow.
  10961. */
  10962. static DefaultBlurKernelSize: number;
  10963. /**
  10964. * The default texture size ratio used for the glow.
  10965. */
  10966. static DefaultTextureRatio: number;
  10967. /**
  10968. * Gets the kernel size of the blur.
  10969. */
  10970. /**
  10971. * Sets the kernel size of the blur.
  10972. */
  10973. blurKernelSize: number;
  10974. /**
  10975. * Gets the glow intensity.
  10976. */
  10977. /**
  10978. * Sets the glow intensity.
  10979. */
  10980. intensity: number;
  10981. private _options;
  10982. private _intensity;
  10983. private _horizontalBlurPostprocess1;
  10984. private _verticalBlurPostprocess1;
  10985. private _horizontalBlurPostprocess2;
  10986. private _verticalBlurPostprocess2;
  10987. private _blurTexture1;
  10988. private _blurTexture2;
  10989. private _postProcesses1;
  10990. private _postProcesses2;
  10991. private _includedOnlyMeshes;
  10992. private _excludedMeshes;
  10993. /**
  10994. * Callback used to let the user override the color selection on a per mesh basis
  10995. */
  10996. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  10997. /**
  10998. * Callback used to let the user override the texture selection on a per mesh basis
  10999. */
  11000. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  11001. /**
  11002. * Instantiates a new glow Layer and references it to the scene.
  11003. * @param name The name of the layer
  11004. * @param scene The scene to use the layer in
  11005. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  11006. */
  11007. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  11008. /**
  11009. * Get the effect name of the layer.
  11010. * @return The effect name
  11011. */
  11012. getEffectName(): string;
  11013. /**
  11014. * Create the merge effect. This is the shader use to blit the information back
  11015. * to the main canvas at the end of the scene rendering.
  11016. */
  11017. protected _createMergeEffect(): Effect;
  11018. /**
  11019. * Creates the render target textures and post processes used in the glow layer.
  11020. */
  11021. protected _createTextureAndPostProcesses(): void;
  11022. /**
  11023. * Checks for the readiness of the element composing the layer.
  11024. * @param subMesh the mesh to check for
  11025. * @param useInstances specify wether or not to use instances to render the mesh
  11026. * @param emissiveTexture the associated emissive texture used to generate the glow
  11027. * @return true if ready otherwise, false
  11028. */
  11029. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11030. /**
  11031. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11032. */
  11033. needStencil(): boolean;
  11034. /**
  11035. * Implementation specific of rendering the generating effect on the main canvas.
  11036. * @param effect The effect used to render through
  11037. */
  11038. protected _internalRender(effect: Effect): void;
  11039. /**
  11040. * Sets the required values for both the emissive texture and and the main color.
  11041. */
  11042. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11043. /**
  11044. * Returns true if the mesh should render, otherwise false.
  11045. * @param mesh The mesh to render
  11046. * @returns true if it should render otherwise false
  11047. */
  11048. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11049. /**
  11050. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  11051. * @param mesh The mesh to exclude from the glow layer
  11052. */
  11053. addExcludedMesh(mesh: Mesh): void;
  11054. /**
  11055. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  11056. * @param mesh The mesh to remove
  11057. */
  11058. removeExcludedMesh(mesh: Mesh): void;
  11059. /**
  11060. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  11061. * @param mesh The mesh to include in the glow layer
  11062. */
  11063. addIncludedOnlyMesh(mesh: Mesh): void;
  11064. /**
  11065. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  11066. * @param mesh The mesh to remove
  11067. */
  11068. removeIncludedOnlyMesh(mesh: Mesh): void;
  11069. /**
  11070. * Determine if a given mesh will be used in the glow layer
  11071. * @param mesh The mesh to test
  11072. * @returns true if the mesh will be highlighted by the current glow layer
  11073. */
  11074. hasMesh(mesh: AbstractMesh): boolean;
  11075. /**
  11076. * Free any resources and references associated to a mesh.
  11077. * Internal use
  11078. * @param mesh The mesh to free.
  11079. */
  11080. _disposeMesh(mesh: Mesh): void;
  11081. /**
  11082. * Gets the class name of the effect layer
  11083. * @returns the string with the class name of the effect layer
  11084. */
  11085. getClassName(): string;
  11086. /**
  11087. * Serializes this glow layer
  11088. * @returns a serialized glow layer object
  11089. */
  11090. serialize(): any;
  11091. /**
  11092. * Creates a Glow Layer from parsed glow layer data
  11093. * @param parsedGlowLayer defines glow layer data
  11094. * @param scene defines the current scene
  11095. * @param rootUrl defines the root URL containing the glow layer information
  11096. * @returns a parsed Glow Layer
  11097. */
  11098. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11099. }
  11100. }
  11101. declare module BABYLON {
  11102. interface AbstractScene {
  11103. /**
  11104. * Return a the first highlight layer of the scene with a given name.
  11105. * @param name The name of the highlight layer to look for.
  11106. * @return The highlight layer if found otherwise null.
  11107. */
  11108. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  11109. }
  11110. /**
  11111. * Highlight layer options. This helps customizing the behaviour
  11112. * of the highlight layer.
  11113. */
  11114. interface IHighlightLayerOptions {
  11115. /**
  11116. * Multiplication factor apply to the canvas size to compute the render target size
  11117. * used to generated the glowing objects (the smaller the faster).
  11118. */
  11119. mainTextureRatio: number;
  11120. /**
  11121. * Enforces a fixed size texture to ensure resize independant blur.
  11122. */
  11123. mainTextureFixedSize?: number;
  11124. /**
  11125. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11126. * of the picture to blur (the smaller the faster).
  11127. */
  11128. blurTextureSizeRatio: number;
  11129. /**
  11130. * How big in texel of the blur texture is the vertical blur.
  11131. */
  11132. blurVerticalSize: number;
  11133. /**
  11134. * How big in texel of the blur texture is the horizontal blur.
  11135. */
  11136. blurHorizontalSize: number;
  11137. /**
  11138. * Alpha blending mode used to apply the blur. Default is combine.
  11139. */
  11140. alphaBlendingMode: number;
  11141. /**
  11142. * The camera attached to the layer.
  11143. */
  11144. camera: Nullable<Camera>;
  11145. /**
  11146. * Should we display highlight as a solid stroke?
  11147. */
  11148. isStroke?: boolean;
  11149. /**
  11150. * The rendering group to draw the layer in.
  11151. */
  11152. renderingGroupId: number;
  11153. }
  11154. /**
  11155. * The highlight layer Helps adding a glow effect around a mesh.
  11156. *
  11157. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11158. * glowy meshes to your scene.
  11159. *
  11160. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11161. */
  11162. class HighlightLayer extends EffectLayer {
  11163. name: string;
  11164. /**
  11165. * Effect Name of the highlight layer.
  11166. */
  11167. static readonly EffectName: string;
  11168. /**
  11169. * The neutral color used during the preparation of the glow effect.
  11170. * This is black by default as the blend operation is a blend operation.
  11171. */
  11172. static NeutralColor: Color4;
  11173. /**
  11174. * Stencil value used for glowing meshes.
  11175. */
  11176. static GlowingMeshStencilReference: number;
  11177. /**
  11178. * Stencil value used for the other meshes in the scene.
  11179. */
  11180. static NormalMeshStencilReference: number;
  11181. /**
  11182. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11183. */
  11184. innerGlow: boolean;
  11185. /**
  11186. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11187. */
  11188. outerGlow: boolean;
  11189. /**
  11190. * Gets the horizontal size of the blur.
  11191. */
  11192. /**
  11193. * Specifies the horizontal size of the blur.
  11194. */
  11195. blurHorizontalSize: number;
  11196. /**
  11197. * Gets the vertical size of the blur.
  11198. */
  11199. /**
  11200. * Specifies the vertical size of the blur.
  11201. */
  11202. blurVerticalSize: number;
  11203. /**
  11204. * An event triggered when the highlight layer is being blurred.
  11205. */
  11206. onBeforeBlurObservable: Observable<HighlightLayer>;
  11207. /**
  11208. * An event triggered when the highlight layer has been blurred.
  11209. */
  11210. onAfterBlurObservable: Observable<HighlightLayer>;
  11211. private _instanceGlowingMeshStencilReference;
  11212. private _options;
  11213. private _downSamplePostprocess;
  11214. private _horizontalBlurPostprocess;
  11215. private _verticalBlurPostprocess;
  11216. private _blurTexture;
  11217. private _meshes;
  11218. private _excludedMeshes;
  11219. /**
  11220. * Instantiates a new highlight Layer and references it to the scene..
  11221. * @param name The name of the layer
  11222. * @param scene The scene to use the layer in
  11223. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11224. */
  11225. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11226. /**
  11227. * Get the effect name of the layer.
  11228. * @return The effect name
  11229. */
  11230. getEffectName(): string;
  11231. /**
  11232. * Create the merge effect. This is the shader use to blit the information back
  11233. * to the main canvas at the end of the scene rendering.
  11234. */
  11235. protected _createMergeEffect(): Effect;
  11236. /**
  11237. * Creates the render target textures and post processes used in the highlight layer.
  11238. */
  11239. protected _createTextureAndPostProcesses(): void;
  11240. /**
  11241. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11242. */
  11243. needStencil(): boolean;
  11244. /**
  11245. * Checks for the readiness of the element composing the layer.
  11246. * @param subMesh the mesh to check for
  11247. * @param useInstances specify wether or not to use instances to render the mesh
  11248. * @param emissiveTexture the associated emissive texture used to generate the glow
  11249. * @return true if ready otherwise, false
  11250. */
  11251. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11252. /**
  11253. * Implementation specific of rendering the generating effect on the main canvas.
  11254. * @param effect The effect used to render through
  11255. */
  11256. protected _internalRender(effect: Effect): void;
  11257. /**
  11258. * Returns true if the layer contains information to display, otherwise false.
  11259. */
  11260. shouldRender(): boolean;
  11261. /**
  11262. * Returns true if the mesh should render, otherwise false.
  11263. * @param mesh The mesh to render
  11264. * @returns true if it should render otherwise false
  11265. */
  11266. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11267. /**
  11268. * Sets the required values for both the emissive texture and and the main color.
  11269. */
  11270. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11271. /**
  11272. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11273. * @param mesh The mesh to exclude from the highlight layer
  11274. */
  11275. addExcludedMesh(mesh: Mesh): void;
  11276. /**
  11277. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11278. * @param mesh The mesh to highlight
  11279. */
  11280. removeExcludedMesh(mesh: Mesh): void;
  11281. /**
  11282. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11283. * @param mesh mesh to test
  11284. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11285. */
  11286. hasMesh(mesh: AbstractMesh): boolean;
  11287. /**
  11288. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11289. * @param mesh The mesh to highlight
  11290. * @param color The color of the highlight
  11291. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11292. */
  11293. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11294. /**
  11295. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11296. * @param mesh The mesh to highlight
  11297. */
  11298. removeMesh(mesh: Mesh): void;
  11299. /**
  11300. * Force the stencil to the normal expected value for none glowing parts
  11301. */
  11302. private _defaultStencilReference(mesh);
  11303. /**
  11304. * Free any resources and references associated to a mesh.
  11305. * Internal use
  11306. * @param mesh The mesh to free.
  11307. */
  11308. _disposeMesh(mesh: Mesh): void;
  11309. /**
  11310. * Dispose the highlight layer and free resources.
  11311. */
  11312. dispose(): void;
  11313. /**
  11314. * Gets the class name of the effect layer
  11315. * @returns the string with the class name of the effect layer
  11316. */
  11317. getClassName(): string;
  11318. /**
  11319. * Serializes this Highlight layer
  11320. * @returns a serialized Highlight layer object
  11321. */
  11322. serialize(): any;
  11323. /**
  11324. * Creates a Highlight layer from parsed Highlight layer data
  11325. * @param parsedHightlightLayer defines the Highlight layer data
  11326. * @param scene defines the current scene
  11327. * @param rootUrl defines the root URL containing the Highlight layer information
  11328. * @returns a parsed Highlight layer
  11329. */
  11330. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11331. }
  11332. }
  11333. declare module BABYLON {
  11334. class Layer {
  11335. name: string;
  11336. texture: Nullable<Texture>;
  11337. isBackground: boolean;
  11338. color: Color4;
  11339. scale: Vector2;
  11340. offset: Vector2;
  11341. alphaBlendingMode: number;
  11342. alphaTest: boolean;
  11343. layerMask: number;
  11344. private _scene;
  11345. private _vertexBuffers;
  11346. private _indexBuffer;
  11347. private _effect;
  11348. private _alphaTestEffect;
  11349. /**
  11350. * An event triggered when the layer is disposed.
  11351. */
  11352. onDisposeObservable: Observable<Layer>;
  11353. private _onDisposeObserver;
  11354. onDispose: () => void;
  11355. /**
  11356. * An event triggered before rendering the scene
  11357. */
  11358. onBeforeRenderObservable: Observable<Layer>;
  11359. private _onBeforeRenderObserver;
  11360. onBeforeRender: () => void;
  11361. /**
  11362. * An event triggered after rendering the scene
  11363. */
  11364. onAfterRenderObservable: Observable<Layer>;
  11365. private _onAfterRenderObserver;
  11366. onAfterRender: () => void;
  11367. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11368. private _createIndexBuffer();
  11369. _rebuild(): void;
  11370. render(): void;
  11371. dispose(): void;
  11372. }
  11373. }
  11374. declare module BABYLON {
  11375. interface AbstractScene {
  11376. /**
  11377. * The list of layers (background and foreground) of the scene
  11378. */
  11379. layers: Array<Layer>;
  11380. }
  11381. /**
  11382. * Defines the layer scene component responsible to manage any layers
  11383. * in a given scene.
  11384. */
  11385. class LayerSceneComponent implements ISceneComponent {
  11386. /**
  11387. * The component name helpfull to identify the component in the list of scene components.
  11388. */
  11389. readonly name: string;
  11390. /**
  11391. * The scene the component belongs to.
  11392. */
  11393. scene: Scene;
  11394. private _engine;
  11395. /**
  11396. * Creates a new instance of the component for the given scene
  11397. * @param scene Defines the scene to register the component in
  11398. */
  11399. constructor(scene: Scene);
  11400. /**
  11401. * Registers the component in a given scene
  11402. */
  11403. register(): void;
  11404. /**
  11405. * Rebuilds the elements related to this component in case of
  11406. * context lost for instance.
  11407. */
  11408. rebuild(): void;
  11409. /**
  11410. * Disposes the component and the associated ressources.
  11411. */
  11412. dispose(): void;
  11413. private _draw(camera, isBackground);
  11414. private _drawBackground(camera);
  11415. private _drawForeground(camera);
  11416. }
  11417. }
  11418. declare module BABYLON {
  11419. class LensFlare {
  11420. size: number;
  11421. position: number;
  11422. color: Color3;
  11423. texture: Nullable<Texture>;
  11424. alphaMode: number;
  11425. private _system;
  11426. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  11427. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  11428. dispose(): void;
  11429. }
  11430. }
  11431. declare module BABYLON {
  11432. class LensFlareSystem {
  11433. name: string;
  11434. lensFlares: LensFlare[];
  11435. borderLimit: number;
  11436. viewportBorder: number;
  11437. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  11438. layerMask: number;
  11439. id: string;
  11440. private _scene;
  11441. private _emitter;
  11442. private _vertexBuffers;
  11443. private _indexBuffer;
  11444. private _effect;
  11445. private _positionX;
  11446. private _positionY;
  11447. private _isEnabled;
  11448. constructor(name: string, emitter: any, scene: Scene);
  11449. isEnabled: boolean;
  11450. getScene(): Scene;
  11451. getEmitter(): any;
  11452. setEmitter(newEmitter: any): void;
  11453. getEmitterPosition(): Vector3;
  11454. computeEffectivePosition(globalViewport: Viewport): boolean;
  11455. _isVisible(): boolean;
  11456. render(): boolean;
  11457. dispose(): void;
  11458. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  11459. serialize(): any;
  11460. }
  11461. }
  11462. declare module BABYLON {
  11463. interface AbstractScene {
  11464. /**
  11465. * The list of lens flare system added to the scene
  11466. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  11467. */
  11468. lensFlareSystems: Array<LensFlareSystem>;
  11469. /**
  11470. * Removes the given lens flare system from this scene.
  11471. * @param toRemove The lens flare system to remove
  11472. * @returns The index of the removed lens flare system
  11473. */
  11474. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  11475. /**
  11476. * Adds the given lens flare system to this scene
  11477. * @param newLensFlareSystem The lens flare system to add
  11478. */
  11479. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  11480. /**
  11481. * Gets a lens flare system using its name
  11482. * @param name defines the name to look for
  11483. * @returns the lens flare system or null if not found
  11484. */
  11485. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  11486. /**
  11487. * Gets a lens flare system using its id
  11488. * @param id defines the id to look for
  11489. * @returns the lens flare system or null if not found
  11490. */
  11491. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  11492. }
  11493. /**
  11494. * Defines the lens flare scene component responsible to manage any lens flares
  11495. * in a given scene.
  11496. */
  11497. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  11498. /**
  11499. * The component name helpfull to identify the component in the list of scene components.
  11500. */
  11501. readonly name: string;
  11502. /**
  11503. * The scene the component belongs to.
  11504. */
  11505. scene: Scene;
  11506. /**
  11507. * Creates a new instance of the component for the given scene
  11508. * @param scene Defines the scene to register the component in
  11509. */
  11510. constructor(scene: Scene);
  11511. /**
  11512. * Registers the component in a given scene
  11513. */
  11514. register(): void;
  11515. /**
  11516. * Rebuilds the elements related to this component in case of
  11517. * context lost for instance.
  11518. */
  11519. rebuild(): void;
  11520. /**
  11521. * Adds all the element from the container to the scene
  11522. * @param container the container holding the elements
  11523. */
  11524. addFromContainer(container: AbstractScene): void;
  11525. /**
  11526. * Removes all the elements in the container from the scene
  11527. * @param container contains the elements to remove
  11528. */
  11529. removeFromContainer(container: AbstractScene): void;
  11530. /**
  11531. * Serializes the component data to the specified json object
  11532. * @param serializationObject The object to serialize to
  11533. */
  11534. serialize(serializationObject: any): void;
  11535. /**
  11536. * Disposes the component and the associated ressources.
  11537. */
  11538. dispose(): void;
  11539. private _draw(camera);
  11540. }
  11541. }
  11542. declare module BABYLON {
  11543. interface ILoadingScreen {
  11544. displayLoadingUI: () => void;
  11545. hideLoadingUI: () => void;
  11546. loadingUIBackgroundColor: string;
  11547. loadingUIText: string;
  11548. }
  11549. class DefaultLoadingScreen implements ILoadingScreen {
  11550. private _renderingCanvas;
  11551. private _loadingText;
  11552. private _loadingDivBackgroundColor;
  11553. private _loadingDiv;
  11554. private _loadingTextDiv;
  11555. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  11556. displayLoadingUI(): void;
  11557. hideLoadingUI(): void;
  11558. loadingUIText: string;
  11559. loadingUIBackgroundColor: string;
  11560. private _resizeLoadingUI;
  11561. }
  11562. }
  11563. declare module BABYLON {
  11564. class SceneLoaderProgressEvent {
  11565. readonly lengthComputable: boolean;
  11566. readonly loaded: number;
  11567. readonly total: number;
  11568. constructor(lengthComputable: boolean, loaded: number, total: number);
  11569. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  11570. }
  11571. interface ISceneLoaderPluginExtensions {
  11572. [extension: string]: {
  11573. isBinary: boolean;
  11574. };
  11575. }
  11576. interface ISceneLoaderPluginFactory {
  11577. name: string;
  11578. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  11579. canDirectLoad?: (data: string) => boolean;
  11580. }
  11581. interface ISceneLoaderPlugin {
  11582. /**
  11583. * The friendly name of this plugin.
  11584. */
  11585. name: string;
  11586. /**
  11587. * The file extensions supported by this plugin.
  11588. */
  11589. extensions: string | ISceneLoaderPluginExtensions;
  11590. /**
  11591. * Import meshes into a scene.
  11592. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11593. * @param scene The scene to import into
  11594. * @param data The data to import
  11595. * @param rootUrl The root url for scene and resources
  11596. * @param meshes The meshes array to import into
  11597. * @param particleSystems The particle systems array to import into
  11598. * @param skeletons The skeletons array to import into
  11599. * @param onError The callback when import fails
  11600. * @returns True if successful or false otherwise
  11601. */
  11602. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  11603. /**
  11604. * Load into a scene.
  11605. * @param scene The scene to load into
  11606. * @param data The data to import
  11607. * @param rootUrl The root url for scene and resources
  11608. * @param onError The callback when import fails
  11609. * @returns true if successful or false otherwise
  11610. */
  11611. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  11612. /**
  11613. * The callback that returns true if the data can be directly loaded.
  11614. */
  11615. canDirectLoad?: (data: string) => boolean;
  11616. /**
  11617. * The callback that allows custom handling of the root url based on the response url.
  11618. */
  11619. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  11620. /**
  11621. * Load into an asset container.
  11622. * @param scene The scene to load into
  11623. * @param data The data to import
  11624. * @param rootUrl The root url for scene and resources
  11625. * @param onError The callback when import fails
  11626. * @returns The loaded asset container
  11627. */
  11628. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  11629. }
  11630. interface ISceneLoaderPluginAsync {
  11631. /**
  11632. * The friendly name of this plugin.
  11633. */
  11634. name: string;
  11635. /**
  11636. * The file extensions supported by this plugin.
  11637. */
  11638. extensions: string | ISceneLoaderPluginExtensions;
  11639. /**
  11640. * Import meshes into a scene.
  11641. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11642. * @param scene The scene to import into
  11643. * @param data The data to import
  11644. * @param rootUrl The root url for scene and resources
  11645. * @param onProgress The callback when the load progresses
  11646. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  11647. */
  11648. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  11649. meshes: AbstractMesh[];
  11650. particleSystems: IParticleSystem[];
  11651. skeletons: Skeleton[];
  11652. animationGroups: AnimationGroup[];
  11653. }>;
  11654. /**
  11655. * Load into a scene.
  11656. * @param scene The scene to load into
  11657. * @param data The data to import
  11658. * @param rootUrl The root url for scene and resources
  11659. * @param onProgress The callback when the load progresses
  11660. * @returns Nothing
  11661. */
  11662. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  11663. /**
  11664. * The callback that returns true if the data can be directly loaded.
  11665. */
  11666. canDirectLoad?: (data: string) => boolean;
  11667. /**
  11668. * The callback that allows custom handling of the root url based on the response url.
  11669. */
  11670. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  11671. /**
  11672. * Load into an asset container.
  11673. * @param scene The scene to load into
  11674. * @param data The data to import
  11675. * @param rootUrl The root url for scene and resources
  11676. * @param onProgress The callback when the load progresses
  11677. * @returns The loaded asset container
  11678. */
  11679. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  11680. }
  11681. class SceneLoader {
  11682. private static _ForceFullSceneLoadingForIncremental;
  11683. private static _ShowLoadingScreen;
  11684. private static _CleanBoneMatrixWeights;
  11685. static readonly NO_LOGGING: number;
  11686. static readonly MINIMAL_LOGGING: number;
  11687. static readonly SUMMARY_LOGGING: number;
  11688. static readonly DETAILED_LOGGING: number;
  11689. private static _loggingLevel;
  11690. static ForceFullSceneLoadingForIncremental: boolean;
  11691. static ShowLoadingScreen: boolean;
  11692. static loggingLevel: number;
  11693. static CleanBoneMatrixWeights: boolean;
  11694. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11695. private static _registeredPlugins;
  11696. private static _getDefaultPlugin();
  11697. private static _getPluginForExtension(extension);
  11698. private static _getPluginForDirectLoad(data);
  11699. private static _getPluginForFilename(sceneFilename);
  11700. private static _getDirectLoad(sceneFilename);
  11701. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  11702. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  11703. static IsPluginForExtensionAvailable(extension: string): boolean;
  11704. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  11705. /**
  11706. * Import meshes into a scene
  11707. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11708. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  11709. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  11710. * @param scene the instance of BABYLON.Scene to append to
  11711. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  11712. * @param onProgress a callback with a progress event for each file being loaded
  11713. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11714. * @param pluginExtension the extension used to determine the plugin
  11715. * @returns The loaded plugin
  11716. */
  11717. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11718. /**
  11719. * Import meshes into a scene
  11720. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11721. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  11722. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  11723. * @param scene the instance of BABYLON.Scene to append to
  11724. * @param onProgress a callback with a progress event for each file being loaded
  11725. * @param pluginExtension the extension used to determine the plugin
  11726. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  11727. */
  11728. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  11729. meshes: AbstractMesh[];
  11730. particleSystems: IParticleSystem[];
  11731. skeletons: Skeleton[];
  11732. animationGroups: AnimationGroup[];
  11733. }>;
  11734. /**
  11735. * Load a scene
  11736. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  11737. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  11738. * @param engine is the instance of BABYLON.Engine to use to create the scene
  11739. * @param onSuccess a callback with the scene when import succeeds
  11740. * @param onProgress a callback with a progress event for each file being loaded
  11741. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11742. * @param pluginExtension the extension used to determine the plugin
  11743. * @returns The loaded plugin
  11744. */
  11745. 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>;
  11746. /**
  11747. * Load a scene
  11748. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  11749. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  11750. * @param engine is the instance of BABYLON.Engine to use to create the scene
  11751. * @param onProgress a callback with a progress event for each file being loaded
  11752. * @param pluginExtension the extension used to determine the plugin
  11753. * @returns The loaded scene
  11754. */
  11755. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  11756. /**
  11757. * Append a scene
  11758. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  11759. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  11760. * @param scene is the instance of BABYLON.Scene to append to
  11761. * @param onSuccess a callback with the scene when import succeeds
  11762. * @param onProgress a callback with a progress event for each file being loaded
  11763. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11764. * @param pluginExtension the extension used to determine the plugin
  11765. * @returns The loaded plugin
  11766. */
  11767. static Append(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11768. /**
  11769. * Append a scene
  11770. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  11771. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  11772. * @param scene is the instance of BABYLON.Scene to append to
  11773. * @param onProgress a callback with a progress event for each file being loaded
  11774. * @param pluginExtension the extension used to determine the plugin
  11775. * @returns The given scene
  11776. */
  11777. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  11778. /**
  11779. * Load a scene into an asset container
  11780. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  11781. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  11782. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  11783. * @param onSuccess a callback with the scene when import succeeds
  11784. * @param onProgress a callback with a progress event for each file being loaded
  11785. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11786. * @param pluginExtension the extension used to determine the plugin
  11787. * @returns The loaded plugin
  11788. */
  11789. static LoadAssetContainer(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11790. /**
  11791. * Load a scene into an asset container
  11792. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  11793. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  11794. * @param scene is the instance of BABYLON.Scene to append to
  11795. * @param onProgress a callback with a progress event for each file being loaded
  11796. * @param pluginExtension the extension used to determine the plugin
  11797. * @returns The loaded asset container
  11798. */
  11799. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  11800. }
  11801. }
  11802. declare module BABYLON {
  11803. /**
  11804. * A directional light is defined by a direction (what a surprise!).
  11805. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11806. * 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.
  11807. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11808. */
  11809. class DirectionalLight extends ShadowLight {
  11810. private _shadowFrustumSize;
  11811. /**
  11812. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11813. */
  11814. /**
  11815. * Specifies a fix frustum size for the shadow generation.
  11816. */
  11817. shadowFrustumSize: number;
  11818. private _shadowOrthoScale;
  11819. /**
  11820. * Gets the shadow projection scale against the optimal computed one.
  11821. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11822. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11823. */
  11824. /**
  11825. * Sets the shadow projection scale against the optimal computed one.
  11826. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11827. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11828. */
  11829. shadowOrthoScale: number;
  11830. /**
  11831. * Automatically compute the projection matrix to best fit (including all the casters)
  11832. * on each frame.
  11833. */
  11834. autoUpdateExtends: boolean;
  11835. private _orthoLeft;
  11836. private _orthoRight;
  11837. private _orthoTop;
  11838. private _orthoBottom;
  11839. /**
  11840. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11841. * The directional light is emitted from everywhere in the given direction.
  11842. * It can cast shawdows.
  11843. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11844. * @param name The friendly name of the light
  11845. * @param direction The direction of the light
  11846. * @param scene The scene the light belongs to
  11847. */
  11848. constructor(name: string, direction: Vector3, scene: Scene);
  11849. /**
  11850. * Returns the string "DirectionalLight".
  11851. * @return The class name
  11852. */
  11853. getClassName(): string;
  11854. /**
  11855. * Returns the integer 1.
  11856. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11857. */
  11858. getTypeID(): number;
  11859. /**
  11860. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  11861. * Returns the DirectionalLight Shadow projection matrix.
  11862. */
  11863. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11864. /**
  11865. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  11866. * Returns the DirectionalLight Shadow projection matrix.
  11867. */
  11868. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  11869. /**
  11870. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  11871. * Returns the DirectionalLight Shadow projection matrix.
  11872. */
  11873. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11874. protected _buildUniformLayout(): void;
  11875. /**
  11876. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11877. * @param effect The effect to update
  11878. * @param lightIndex The index of the light in the effect to update
  11879. * @returns The directional light
  11880. */
  11881. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  11882. /**
  11883. * Gets the minZ used for shadow according to both the scene and the light.
  11884. *
  11885. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11886. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11887. * @param activeCamera The camera we are returning the min for
  11888. * @returns the depth min z
  11889. */
  11890. getDepthMinZ(activeCamera: Camera): number;
  11891. /**
  11892. * Gets the maxZ used for shadow according to both the scene and the light.
  11893. *
  11894. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11895. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11896. * @param activeCamera The camera we are returning the max for
  11897. * @returns the depth max z
  11898. */
  11899. getDepthMaxZ(activeCamera: Camera): number;
  11900. }
  11901. }
  11902. declare module BABYLON {
  11903. /**
  11904. * The HemisphericLight simulates the ambient environment light,
  11905. * so the passed direction is the light reflection direction, not the incoming direction.
  11906. */
  11907. class HemisphericLight extends Light {
  11908. /**
  11909. * The groundColor is the light in the opposite direction to the one specified during creation.
  11910. * 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.
  11911. */
  11912. groundColor: Color3;
  11913. /**
  11914. * The light reflection direction, not the incoming direction.
  11915. */
  11916. direction: Vector3;
  11917. private _worldMatrix;
  11918. /**
  11919. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11920. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11921. * The HemisphericLight can't cast shadows.
  11922. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11923. * @param name The friendly name of the light
  11924. * @param direction The direction of the light reflection
  11925. * @param scene The scene the light belongs to
  11926. */
  11927. constructor(name: string, direction: Vector3, scene: Scene);
  11928. protected _buildUniformLayout(): void;
  11929. /**
  11930. * Returns the string "HemisphericLight".
  11931. * @return The class name
  11932. */
  11933. getClassName(): string;
  11934. /**
  11935. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11936. * Returns the updated direction.
  11937. * @param target The target the direction should point to
  11938. * @return The computed direction
  11939. */
  11940. setDirectionToTarget(target: Vector3): Vector3;
  11941. /**
  11942. * Returns the shadow generator associated to the light.
  11943. * @returns Always null for hemispheric lights because it does not support shadows.
  11944. */
  11945. getShadowGenerator(): Nullable<ShadowGenerator>;
  11946. /**
  11947. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11948. * @param effect The effect to update
  11949. * @param lightIndex The index of the light in the effect to update
  11950. * @returns The hemispheric light
  11951. */
  11952. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11953. /**
  11954. * @hidden internal use only.
  11955. */
  11956. _getWorldMatrix(): Matrix;
  11957. /**
  11958. * Returns the integer 3.
  11959. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11960. */
  11961. getTypeID(): number;
  11962. }
  11963. }
  11964. declare module BABYLON {
  11965. /**
  11966. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11967. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11968. * 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.
  11969. */
  11970. abstract class Light extends Node {
  11971. private static _LIGHTMAP_DEFAULT;
  11972. private static _LIGHTMAP_SPECULAR;
  11973. private static _LIGHTMAP_SHADOWSONLY;
  11974. /**
  11975. * If every light affecting the material is in this lightmapMode,
  11976. * material.lightmapTexture adds or multiplies
  11977. * (depends on material.useLightmapAsShadowmap)
  11978. * after every other light calculations.
  11979. */
  11980. static readonly LIGHTMAP_DEFAULT: number;
  11981. /**
  11982. * material.lightmapTexture as only diffuse lighting from this light
  11983. * adds only specular lighting from this light
  11984. * adds dynamic shadows
  11985. */
  11986. static readonly LIGHTMAP_SPECULAR: number;
  11987. /**
  11988. * material.lightmapTexture as only lighting
  11989. * no light calculation from this light
  11990. * only adds dynamic shadows from this light
  11991. */
  11992. static readonly LIGHTMAP_SHADOWSONLY: number;
  11993. private static _INTENSITYMODE_AUTOMATIC;
  11994. private static _INTENSITYMODE_LUMINOUSPOWER;
  11995. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  11996. private static _INTENSITYMODE_ILLUMINANCE;
  11997. private static _INTENSITYMODE_LUMINANCE;
  11998. /**
  11999. * Each light type uses the default quantity according to its type:
  12000. * point/spot lights use luminous intensity
  12001. * directional lights use illuminance
  12002. */
  12003. static readonly INTENSITYMODE_AUTOMATIC: number;
  12004. /**
  12005. * lumen (lm)
  12006. */
  12007. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  12008. /**
  12009. * candela (lm/sr)
  12010. */
  12011. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  12012. /**
  12013. * lux (lm/m^2)
  12014. */
  12015. static readonly INTENSITYMODE_ILLUMINANCE: number;
  12016. /**
  12017. * nit (cd/m^2)
  12018. */
  12019. static readonly INTENSITYMODE_LUMINANCE: number;
  12020. private static _LIGHTTYPEID_POINTLIGHT;
  12021. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  12022. private static _LIGHTTYPEID_SPOTLIGHT;
  12023. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  12024. /**
  12025. * Light type const id of the point light.
  12026. */
  12027. static readonly LIGHTTYPEID_POINTLIGHT: number;
  12028. /**
  12029. * Light type const id of the directional light.
  12030. */
  12031. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  12032. /**
  12033. * Light type const id of the spot light.
  12034. */
  12035. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  12036. /**
  12037. * Light type const id of the hemispheric light.
  12038. */
  12039. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  12040. /**
  12041. * Diffuse gives the basic color to an object.
  12042. */
  12043. diffuse: Color3;
  12044. /**
  12045. * Specular produces a highlight color on an object.
  12046. * Note: This is note affecting PBR materials.
  12047. */
  12048. specular: Color3;
  12049. /**
  12050. * Strength of the light.
  12051. * Note: By default it is define in the framework own unit.
  12052. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12053. */
  12054. intensity: number;
  12055. /**
  12056. * Defines how far from the source the light is impacting in scene units.
  12057. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12058. */
  12059. range: number;
  12060. /**
  12061. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12062. * of light.
  12063. */
  12064. private _photometricScale;
  12065. private _intensityMode;
  12066. /**
  12067. * Gets the photometric scale used to interpret the intensity.
  12068. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12069. */
  12070. /**
  12071. * Sets the photometric scale used to interpret the intensity.
  12072. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12073. */
  12074. intensityMode: number;
  12075. private _radius;
  12076. /**
  12077. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12078. */
  12079. /**
  12080. * sets the light radius used by PBR Materials to simulate soft area lights.
  12081. */
  12082. radius: number;
  12083. private _renderPriority;
  12084. /**
  12085. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12086. * exceeding the number allowed of the materials.
  12087. */
  12088. renderPriority: number;
  12089. private _shadowEnabled;
  12090. /**
  12091. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12092. * the current shadow generator.
  12093. */
  12094. /**
  12095. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12096. * the current shadow generator.
  12097. */
  12098. shadowEnabled: boolean;
  12099. private _includedOnlyMeshes;
  12100. /**
  12101. * Gets the only meshes impacted by this light.
  12102. */
  12103. /**
  12104. * Sets the only meshes impacted by this light.
  12105. */
  12106. includedOnlyMeshes: AbstractMesh[];
  12107. private _excludedMeshes;
  12108. /**
  12109. * Gets the meshes not impacted by this light.
  12110. */
  12111. /**
  12112. * Sets the meshes not impacted by this light.
  12113. */
  12114. excludedMeshes: AbstractMesh[];
  12115. private _excludeWithLayerMask;
  12116. /**
  12117. * Gets the layer id use to find what meshes are not impacted by the light.
  12118. * Inactive if 0
  12119. */
  12120. /**
  12121. * Sets the layer id use to find what meshes are not impacted by the light.
  12122. * Inactive if 0
  12123. */
  12124. excludeWithLayerMask: number;
  12125. private _includeOnlyWithLayerMask;
  12126. /**
  12127. * Gets the layer id use to find what meshes are impacted by the light.
  12128. * Inactive if 0
  12129. */
  12130. /**
  12131. * Sets the layer id use to find what meshes are impacted by the light.
  12132. * Inactive if 0
  12133. */
  12134. includeOnlyWithLayerMask: number;
  12135. private _lightmapMode;
  12136. /**
  12137. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12138. */
  12139. /**
  12140. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12141. */
  12142. lightmapMode: number;
  12143. private _parentedWorldMatrix;
  12144. /**
  12145. * Shadow generator associted to the light.
  12146. * Internal use only.
  12147. */
  12148. _shadowGenerator: Nullable<IShadowGenerator>;
  12149. /**
  12150. * @hidden Internal use only.
  12151. */
  12152. _excludedMeshesIds: string[];
  12153. /**
  12154. * @hidden Internal use only.
  12155. */
  12156. _includedOnlyMeshesIds: string[];
  12157. /**
  12158. * The current light unifom buffer.
  12159. * @hidden Internal use only.
  12160. */
  12161. _uniformBuffer: UniformBuffer;
  12162. /**
  12163. * Creates a Light object in the scene.
  12164. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12165. * @param name The firendly name of the light
  12166. * @param scene The scene the light belongs too
  12167. */
  12168. constructor(name: string, scene: Scene);
  12169. protected abstract _buildUniformLayout(): void;
  12170. /**
  12171. * Sets the passed Effect "effect" with the Light information.
  12172. * @param effect The effect to update
  12173. * @param lightIndex The index of the light in the effect to update
  12174. * @returns The light
  12175. */
  12176. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12177. /**
  12178. * @hidden internal use only.
  12179. */
  12180. abstract _getWorldMatrix(): Matrix;
  12181. /**
  12182. * Returns the string "Light".
  12183. * @returns the class name
  12184. */
  12185. getClassName(): string;
  12186. /**
  12187. * Converts the light information to a readable string for debug purpose.
  12188. * @param fullDetails Supports for multiple levels of logging within scene loading
  12189. * @returns the human readable light info
  12190. */
  12191. toString(fullDetails?: boolean): string;
  12192. /**
  12193. * Set the enabled state of this node.
  12194. * @param value - the new enabled state
  12195. */
  12196. setEnabled(value: boolean): void;
  12197. /**
  12198. * Returns the Light associated shadow generator if any.
  12199. * @return the associated shadow generator.
  12200. */
  12201. getShadowGenerator(): Nullable<IShadowGenerator>;
  12202. /**
  12203. * Returns a Vector3, the absolute light position in the World.
  12204. * @returns the world space position of the light
  12205. */
  12206. getAbsolutePosition(): Vector3;
  12207. /**
  12208. * Specifies if the light will affect the passed mesh.
  12209. * @param mesh The mesh to test against the light
  12210. * @return true the mesh is affected otherwise, false.
  12211. */
  12212. canAffectMesh(mesh: AbstractMesh): boolean;
  12213. /**
  12214. * Computes and Returns the light World matrix.
  12215. * @returns the world matrix
  12216. */
  12217. getWorldMatrix(): Matrix;
  12218. /**
  12219. * Sort function to order lights for rendering.
  12220. * @param a First Light object to compare to second.
  12221. * @param b Second Light object to compare first.
  12222. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12223. */
  12224. static CompareLightsPriority(a: Light, b: Light): number;
  12225. /**
  12226. * Releases resources associated with this node.
  12227. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12228. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12229. */
  12230. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12231. /**
  12232. * Returns the light type ID (integer).
  12233. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12234. */
  12235. getTypeID(): number;
  12236. /**
  12237. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12238. * @returns the scaled intensity in intensity mode unit
  12239. */
  12240. getScaledIntensity(): number;
  12241. /**
  12242. * Returns a new Light object, named "name", from the current one.
  12243. * @param name The name of the cloned light
  12244. * @returns the new created light
  12245. */
  12246. clone(name: string): Nullable<Light>;
  12247. /**
  12248. * Serializes the current light into a Serialization object.
  12249. * @returns the serialized object.
  12250. */
  12251. serialize(): any;
  12252. /**
  12253. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12254. * This new light is named "name" and added to the passed scene.
  12255. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12256. * @param name The friendly name of the light
  12257. * @param scene The scene the new light will belong to
  12258. * @returns the constructor function
  12259. */
  12260. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12261. /**
  12262. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12263. * @param parsedLight The JSON representation of the light
  12264. * @param scene The scene to create the parsed light in
  12265. * @returns the created light after parsing
  12266. */
  12267. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12268. private _hookArrayForExcluded(array);
  12269. private _hookArrayForIncludedOnly(array);
  12270. private _resyncMeshes();
  12271. /**
  12272. * Forces the meshes to update their light related information in their rendering used effects
  12273. * @hidden Internal Use Only
  12274. */
  12275. _markMeshesAsLightDirty(): void;
  12276. /**
  12277. * Recomputes the cached photometric scale if needed.
  12278. */
  12279. private _computePhotometricScale();
  12280. /**
  12281. * Returns the Photometric Scale according to the light type and intensity mode.
  12282. */
  12283. private _getPhotometricScale();
  12284. /**
  12285. * Reorder the light in the scene according to their defined priority.
  12286. * @hidden Internal Use Only
  12287. */
  12288. _reorderLightsInScene(): void;
  12289. }
  12290. }
  12291. declare module BABYLON {
  12292. /**
  12293. * A point light is a light defined by an unique point in world space.
  12294. * The light is emitted in every direction from this point.
  12295. * A good example of a point light is a standard light bulb.
  12296. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12297. */
  12298. class PointLight extends ShadowLight {
  12299. private _shadowAngle;
  12300. /**
  12301. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12302. * This specifies what angle the shadow will use to be created.
  12303. *
  12304. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12305. */
  12306. /**
  12307. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12308. * This specifies what angle the shadow will use to be created.
  12309. *
  12310. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12311. */
  12312. shadowAngle: number;
  12313. /**
  12314. * Gets the direction if it has been set.
  12315. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12316. */
  12317. /**
  12318. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12319. */
  12320. direction: Vector3;
  12321. /**
  12322. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  12323. * A PointLight emits the light in every direction.
  12324. * It can cast shadows.
  12325. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  12326. * ```javascript
  12327. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  12328. * ```
  12329. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12330. * @param name The light friendly name
  12331. * @param position The position of the point light in the scene
  12332. * @param scene The scene the lights belongs to
  12333. */
  12334. constructor(name: string, position: Vector3, scene: Scene);
  12335. /**
  12336. * Returns the string "PointLight"
  12337. * @returns the class name
  12338. */
  12339. getClassName(): string;
  12340. /**
  12341. * Returns the integer 0.
  12342. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12343. */
  12344. getTypeID(): number;
  12345. /**
  12346. * Specifies wether or not the shadowmap should be a cube texture.
  12347. * @returns true if the shadowmap needs to be a cube texture.
  12348. */
  12349. needCube(): boolean;
  12350. /**
  12351. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  12352. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12353. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12354. */
  12355. getShadowDirection(faceIndex?: number): Vector3;
  12356. /**
  12357. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  12358. * - fov = PI / 2
  12359. * - aspect ratio : 1.0
  12360. * - z-near and far equal to the active camera minZ and maxZ.
  12361. * Returns the PointLight.
  12362. */
  12363. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12364. protected _buildUniformLayout(): void;
  12365. /**
  12366. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  12367. * @param effect The effect to update
  12368. * @param lightIndex The index of the light in the effect to update
  12369. * @returns The point light
  12370. */
  12371. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  12372. }
  12373. }
  12374. declare module BABYLON {
  12375. /**
  12376. * Interface describing all the common properties and methods a shadow light needs to implement.
  12377. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  12378. * as well as binding the different shadow properties to the effects.
  12379. */
  12380. interface IShadowLight extends Light {
  12381. /**
  12382. * The light id in the scene (used in scene.findLighById for instance)
  12383. */
  12384. id: string;
  12385. /**
  12386. * The position the shdow will be casted from.
  12387. */
  12388. position: Vector3;
  12389. /**
  12390. * In 2d mode (needCube being false), the direction used to cast the shadow.
  12391. */
  12392. direction: Vector3;
  12393. /**
  12394. * The transformed position. Position of the light in world space taking parenting in account.
  12395. */
  12396. transformedPosition: Vector3;
  12397. /**
  12398. * The transformed direction. Direction of the light in world space taking parenting in account.
  12399. */
  12400. transformedDirection: Vector3;
  12401. /**
  12402. * The friendly name of the light in the scene.
  12403. */
  12404. name: string;
  12405. /**
  12406. * Defines the shadow projection clipping minimum z value.
  12407. */
  12408. shadowMinZ: number;
  12409. /**
  12410. * Defines the shadow projection clipping maximum z value.
  12411. */
  12412. shadowMaxZ: number;
  12413. /**
  12414. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12415. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12416. */
  12417. computeTransformedInformation(): boolean;
  12418. /**
  12419. * Gets the scene the light belongs to.
  12420. * @returns The scene
  12421. */
  12422. getScene(): Scene;
  12423. /**
  12424. * Callback defining a custom Projection Matrix Builder.
  12425. * This can be used to override the default projection matrix computation.
  12426. */
  12427. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12428. /**
  12429. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12430. * @param matrix The materix to updated with the projection information
  12431. * @param viewMatrix The transform matrix of the light
  12432. * @param renderList The list of mesh to render in the map
  12433. * @returns The current light
  12434. */
  12435. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12436. /**
  12437. * Gets the current depth scale used in ESM.
  12438. * @returns The scale
  12439. */
  12440. getDepthScale(): number;
  12441. /**
  12442. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12443. * @returns true if a cube texture needs to be use
  12444. */
  12445. needCube(): boolean;
  12446. /**
  12447. * Detects if the projection matrix requires to be recomputed this frame.
  12448. * @returns true if it requires to be recomputed otherwise, false.
  12449. */
  12450. needProjectionMatrixCompute(): boolean;
  12451. /**
  12452. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12453. */
  12454. forceProjectionMatrixCompute(): void;
  12455. /**
  12456. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12457. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12458. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12459. */
  12460. getShadowDirection(faceIndex?: number): Vector3;
  12461. /**
  12462. * Gets the minZ used for shadow according to both the scene and the light.
  12463. * @param activeCamera The camera we are returning the min for
  12464. * @returns the depth min z
  12465. */
  12466. getDepthMinZ(activeCamera: Camera): number;
  12467. /**
  12468. * Gets the maxZ used for shadow according to both the scene and the light.
  12469. * @param activeCamera The camera we are returning the max for
  12470. * @returns the depth max z
  12471. */
  12472. getDepthMaxZ(activeCamera: Camera): number;
  12473. }
  12474. /**
  12475. * Base implementation IShadowLight
  12476. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  12477. */
  12478. abstract class ShadowLight extends Light implements IShadowLight {
  12479. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12480. protected _position: Vector3;
  12481. protected _setPosition(value: Vector3): void;
  12482. /**
  12483. * Sets the position the shadow will be casted from. Also use as the light position for both
  12484. * point and spot lights.
  12485. */
  12486. /**
  12487. * Sets the position the shadow will be casted from. Also use as the light position for both
  12488. * point and spot lights.
  12489. */
  12490. position: Vector3;
  12491. protected _direction: Vector3;
  12492. protected _setDirection(value: Vector3): void;
  12493. /**
  12494. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  12495. * Also use as the light direction on spot and directional lights.
  12496. */
  12497. /**
  12498. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  12499. * Also use as the light direction on spot and directional lights.
  12500. */
  12501. direction: Vector3;
  12502. private _shadowMinZ;
  12503. /**
  12504. * Gets the shadow projection clipping minimum z value.
  12505. */
  12506. /**
  12507. * Sets the shadow projection clipping minimum z value.
  12508. */
  12509. shadowMinZ: number;
  12510. private _shadowMaxZ;
  12511. /**
  12512. * Sets the shadow projection clipping maximum z value.
  12513. */
  12514. /**
  12515. * Gets the shadow projection clipping maximum z value.
  12516. */
  12517. shadowMaxZ: number;
  12518. /**
  12519. * Callback defining a custom Projection Matrix Builder.
  12520. * This can be used to override the default projection matrix computation.
  12521. */
  12522. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12523. /**
  12524. * The transformed position. Position of the light in world space taking parenting in account.
  12525. */
  12526. transformedPosition: Vector3;
  12527. /**
  12528. * The transformed direction. Direction of the light in world space taking parenting in account.
  12529. */
  12530. transformedDirection: Vector3;
  12531. private _worldMatrix;
  12532. private _needProjectionMatrixCompute;
  12533. /**
  12534. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12535. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12536. */
  12537. computeTransformedInformation(): boolean;
  12538. /**
  12539. * Return the depth scale used for the shadow map.
  12540. * @returns the depth scale.
  12541. */
  12542. getDepthScale(): number;
  12543. /**
  12544. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12545. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12546. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12547. */
  12548. getShadowDirection(faceIndex?: number): Vector3;
  12549. /**
  12550. * Returns the ShadowLight absolute position in the World.
  12551. * @returns the position vector in world space
  12552. */
  12553. getAbsolutePosition(): Vector3;
  12554. /**
  12555. * Sets the ShadowLight direction toward the passed target.
  12556. * @param target The point tot target in local space
  12557. * @returns the updated ShadowLight direction
  12558. */
  12559. setDirectionToTarget(target: Vector3): Vector3;
  12560. /**
  12561. * Returns the light rotation in euler definition.
  12562. * @returns the x y z rotation in local space.
  12563. */
  12564. getRotation(): Vector3;
  12565. /**
  12566. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12567. * @returns true if a cube texture needs to be use
  12568. */
  12569. needCube(): boolean;
  12570. /**
  12571. * Detects if the projection matrix requires to be recomputed this frame.
  12572. * @returns true if it requires to be recomputed otherwise, false.
  12573. */
  12574. needProjectionMatrixCompute(): boolean;
  12575. /**
  12576. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12577. */
  12578. forceProjectionMatrixCompute(): void;
  12579. /**
  12580. * Get the world matrix of the sahdow lights.
  12581. * @hidden Internal Use Only
  12582. */
  12583. _getWorldMatrix(): Matrix;
  12584. /**
  12585. * Gets the minZ used for shadow according to both the scene and the light.
  12586. * @param activeCamera The camera we are returning the min for
  12587. * @returns the depth min z
  12588. */
  12589. getDepthMinZ(activeCamera: Camera): number;
  12590. /**
  12591. * Gets the maxZ used for shadow according to both the scene and the light.
  12592. * @param activeCamera The camera we are returning the max for
  12593. * @returns the depth max z
  12594. */
  12595. getDepthMaxZ(activeCamera: Camera): number;
  12596. /**
  12597. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12598. * @param matrix The materix to updated with the projection information
  12599. * @param viewMatrix The transform matrix of the light
  12600. * @param renderList The list of mesh to render in the map
  12601. * @returns The current light
  12602. */
  12603. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12604. }
  12605. }
  12606. declare module BABYLON {
  12607. /**
  12608. * A spot light is defined by a position, a direction, an angle, and an exponent.
  12609. * These values define a cone of light starting from the position, emitting toward the direction.
  12610. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  12611. * and the exponent defines the speed of the decay of the light with distance (reach).
  12612. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12613. */
  12614. class SpotLight extends ShadowLight {
  12615. private _angle;
  12616. /**
  12617. * Gets the cone angle of the spot light in Radians.
  12618. */
  12619. /**
  12620. * Sets the cone angle of the spot light in Radians.
  12621. */
  12622. angle: number;
  12623. private _shadowAngleScale;
  12624. /**
  12625. * Allows scaling the angle of the light for shadow generation only.
  12626. */
  12627. /**
  12628. * Allows scaling the angle of the light for shadow generation only.
  12629. */
  12630. shadowAngleScale: number;
  12631. /**
  12632. * The light decay speed with the distance from the emission spot.
  12633. */
  12634. exponent: number;
  12635. private _projectionTextureMatrix;
  12636. /**
  12637. * Allows reading the projecton texture
  12638. */
  12639. readonly projectionTextureMatrix: Matrix;
  12640. protected _projectionTextureLightNear: number;
  12641. /**
  12642. * Gets the near clip of the Spotlight for texture projection.
  12643. */
  12644. /**
  12645. * Sets the near clip of the Spotlight for texture projection.
  12646. */
  12647. projectionTextureLightNear: number;
  12648. protected _projectionTextureLightFar: number;
  12649. /**
  12650. * Gets the far clip of the Spotlight for texture projection.
  12651. */
  12652. /**
  12653. * Sets the far clip of the Spotlight for texture projection.
  12654. */
  12655. projectionTextureLightFar: number;
  12656. protected _projectionTextureUpDirection: Vector3;
  12657. /**
  12658. * Gets the Up vector of the Spotlight for texture projection.
  12659. */
  12660. /**
  12661. * Sets the Up vector of the Spotlight for texture projection.
  12662. */
  12663. projectionTextureUpDirection: Vector3;
  12664. private _projectionTexture;
  12665. /**
  12666. * Gets the projection texture of the light.
  12667. */
  12668. /**
  12669. * Sets the projection texture of the light.
  12670. */
  12671. projectionTexture: Nullable<BaseTexture>;
  12672. private _projectionTextureViewLightDirty;
  12673. private _projectionTextureProjectionLightDirty;
  12674. private _projectionTextureDirty;
  12675. private _projectionTextureViewTargetVector;
  12676. private _projectionTextureViewLightMatrix;
  12677. private _projectionTextureProjectionLightMatrix;
  12678. private _projectionTextureScalingMatrix;
  12679. /**
  12680. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12681. * It can cast shadows.
  12682. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12683. * @param name The light friendly name
  12684. * @param position The position of the spot light in the scene
  12685. * @param direction The direction of the light in the scene
  12686. * @param angle The cone angle of the light in Radians
  12687. * @param exponent The light decay speed with the distance from the emission spot
  12688. * @param scene The scene the lights belongs to
  12689. */
  12690. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12691. /**
  12692. * Returns the string "SpotLight".
  12693. * @returns the class name
  12694. */
  12695. getClassName(): string;
  12696. /**
  12697. * Returns the integer 2.
  12698. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12699. */
  12700. getTypeID(): number;
  12701. /**
  12702. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12703. */
  12704. protected _setDirection(value: Vector3): void;
  12705. /**
  12706. * Overrides the position setter to recompute the projection texture view light Matrix.
  12707. */
  12708. protected _setPosition(value: Vector3): void;
  12709. /**
  12710. * 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.
  12711. * Returns the SpotLight.
  12712. */
  12713. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12714. protected _computeProjectionTextureViewLightMatrix(): void;
  12715. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12716. /**
  12717. * Main function for light texture projection matrix computing.
  12718. */
  12719. protected _computeProjectionTextureMatrix(): void;
  12720. protected _buildUniformLayout(): void;
  12721. /**
  12722. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12723. * @param effect The effect to update
  12724. * @param lightIndex The index of the light in the effect to update
  12725. * @returns The spot light
  12726. */
  12727. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12728. /**
  12729. * Disposes the light and the associated resources.
  12730. */
  12731. dispose(): void;
  12732. }
  12733. }
  12734. declare module BABYLON {
  12735. /**
  12736. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  12737. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  12738. * 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;
  12739. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  12740. */
  12741. class ColorCurves {
  12742. private _dirty;
  12743. private _tempColor;
  12744. private _globalCurve;
  12745. private _highlightsCurve;
  12746. private _midtonesCurve;
  12747. private _shadowsCurve;
  12748. private _positiveCurve;
  12749. private _negativeCurve;
  12750. private _globalHue;
  12751. private _globalDensity;
  12752. private _globalSaturation;
  12753. private _globalExposure;
  12754. /**
  12755. * Gets the global Hue value.
  12756. * 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).
  12757. */
  12758. /**
  12759. * Sets the global Hue value.
  12760. * 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).
  12761. */
  12762. globalHue: number;
  12763. /**
  12764. * Gets the global Density value.
  12765. * 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.
  12766. * Values less than zero provide a filter of opposite hue.
  12767. */
  12768. /**
  12769. * Sets the global Density value.
  12770. * 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.
  12771. * Values less than zero provide a filter of opposite hue.
  12772. */
  12773. globalDensity: number;
  12774. /**
  12775. * Gets the global Saturation value.
  12776. * 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.
  12777. */
  12778. /**
  12779. * Sets the global Saturation value.
  12780. * 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.
  12781. */
  12782. globalSaturation: number;
  12783. /**
  12784. * Gets the global Exposure value.
  12785. * 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.
  12786. */
  12787. /**
  12788. * Sets the global Exposure value.
  12789. * 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.
  12790. */
  12791. globalExposure: number;
  12792. private _highlightsHue;
  12793. private _highlightsDensity;
  12794. private _highlightsSaturation;
  12795. private _highlightsExposure;
  12796. /**
  12797. * Gets the highlights Hue value.
  12798. * 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).
  12799. */
  12800. /**
  12801. * Sets the highlights Hue value.
  12802. * 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).
  12803. */
  12804. highlightsHue: number;
  12805. /**
  12806. * Gets the highlights Density value.
  12807. * 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.
  12808. * Values less than zero provide a filter of opposite hue.
  12809. */
  12810. /**
  12811. * Sets the highlights Density value.
  12812. * 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.
  12813. * Values less than zero provide a filter of opposite hue.
  12814. */
  12815. highlightsDensity: number;
  12816. /**
  12817. * Gets the highlights Saturation value.
  12818. * 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.
  12819. */
  12820. /**
  12821. * Sets the highlights Saturation value.
  12822. * 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.
  12823. */
  12824. highlightsSaturation: number;
  12825. /**
  12826. * Gets the highlights Exposure value.
  12827. * 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.
  12828. */
  12829. /**
  12830. * Sets the highlights Exposure value.
  12831. * 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.
  12832. */
  12833. highlightsExposure: number;
  12834. private _midtonesHue;
  12835. private _midtonesDensity;
  12836. private _midtonesSaturation;
  12837. private _midtonesExposure;
  12838. /**
  12839. * Gets the midtones Hue value.
  12840. * 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).
  12841. */
  12842. /**
  12843. * Sets the midtones Hue value.
  12844. * 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).
  12845. */
  12846. midtonesHue: number;
  12847. /**
  12848. * Gets the midtones Density value.
  12849. * 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.
  12850. * Values less than zero provide a filter of opposite hue.
  12851. */
  12852. /**
  12853. * Sets the midtones Density value.
  12854. * 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.
  12855. * Values less than zero provide a filter of opposite hue.
  12856. */
  12857. midtonesDensity: number;
  12858. /**
  12859. * Gets the midtones Saturation value.
  12860. * 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.
  12861. */
  12862. /**
  12863. * Sets the midtones Saturation value.
  12864. * 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.
  12865. */
  12866. midtonesSaturation: number;
  12867. /**
  12868. * Gets the midtones Exposure value.
  12869. * 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.
  12870. */
  12871. /**
  12872. * Sets the midtones Exposure value.
  12873. * 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.
  12874. */
  12875. midtonesExposure: number;
  12876. private _shadowsHue;
  12877. private _shadowsDensity;
  12878. private _shadowsSaturation;
  12879. private _shadowsExposure;
  12880. /**
  12881. * Gets the shadows Hue value.
  12882. * 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).
  12883. */
  12884. /**
  12885. * Sets the shadows Hue value.
  12886. * 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).
  12887. */
  12888. shadowsHue: number;
  12889. /**
  12890. * Gets the shadows Density value.
  12891. * 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.
  12892. * Values less than zero provide a filter of opposite hue.
  12893. */
  12894. /**
  12895. * Sets the shadows Density value.
  12896. * 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.
  12897. * Values less than zero provide a filter of opposite hue.
  12898. */
  12899. shadowsDensity: number;
  12900. /**
  12901. * Gets the shadows Saturation value.
  12902. * 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.
  12903. */
  12904. /**
  12905. * Sets the shadows Saturation value.
  12906. * 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.
  12907. */
  12908. shadowsSaturation: number;
  12909. /**
  12910. * Gets the shadows Exposure value.
  12911. * 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.
  12912. */
  12913. /**
  12914. * Sets the shadows Exposure value.
  12915. * 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.
  12916. */
  12917. shadowsExposure: number;
  12918. getClassName(): string;
  12919. /**
  12920. * Binds the color curves to the shader.
  12921. * @param colorCurves The color curve to bind
  12922. * @param effect The effect to bind to
  12923. */
  12924. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  12925. /**
  12926. * Prepare the list of uniforms associated with the ColorCurves effects.
  12927. * @param uniformsList The list of uniforms used in the effect
  12928. */
  12929. static PrepareUniforms(uniformsList: string[]): void;
  12930. /**
  12931. * Returns color grading data based on a hue, density, saturation and exposure value.
  12932. * @param filterHue The hue of the color filter.
  12933. * @param filterDensity The density of the color filter.
  12934. * @param saturation The saturation.
  12935. * @param exposure The exposure.
  12936. * @param result The result data container.
  12937. */
  12938. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  12939. /**
  12940. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  12941. * @param value The input slider value in range [-100,100].
  12942. * @returns Adjusted value.
  12943. */
  12944. private static applyColorGradingSliderNonlinear(value);
  12945. /**
  12946. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  12947. * @param hue The hue (H) input.
  12948. * @param saturation The saturation (S) input.
  12949. * @param brightness The brightness (B) input.
  12950. * @result An RGBA color represented as Vector4.
  12951. */
  12952. private static fromHSBToRef(hue, saturation, brightness, result);
  12953. /**
  12954. * Returns a value clamped between min and max
  12955. * @param value The value to clamp
  12956. * @param min The minimum of value
  12957. * @param max The maximum of value
  12958. * @returns The clamped value.
  12959. */
  12960. private static clamp(value, min, max);
  12961. /**
  12962. * Clones the current color curve instance.
  12963. * @return The cloned curves
  12964. */
  12965. clone(): ColorCurves;
  12966. /**
  12967. * Serializes the current color curve instance to a json representation.
  12968. * @return a JSON representation
  12969. */
  12970. serialize(): any;
  12971. /**
  12972. * Parses the color curve from a json representation.
  12973. * @param source the JSON source to parse
  12974. * @return The parsed curves
  12975. */
  12976. static Parse(source: any): ColorCurves;
  12977. }
  12978. }
  12979. declare module BABYLON {
  12980. /**
  12981. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12982. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12983. */
  12984. class EffectFallbacks {
  12985. private _defines;
  12986. private _currentRank;
  12987. private _maxRank;
  12988. private _mesh;
  12989. /**
  12990. * Removes the fallback from the bound mesh.
  12991. */
  12992. unBindMesh(): void;
  12993. /**
  12994. * Adds a fallback on the specified property.
  12995. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12996. * @param define The name of the define in the shader
  12997. */
  12998. addFallback(rank: number, define: string): void;
  12999. /**
  13000. * Sets the mesh to use CPU skinning when needing to fallback.
  13001. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13002. * @param mesh The mesh to use the fallbacks.
  13003. */
  13004. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13005. /**
  13006. * Checks to see if more fallbacks are still availible.
  13007. */
  13008. readonly isMoreFallbacks: boolean;
  13009. /**
  13010. * Removes the defines that shoould be removed when falling back.
  13011. * @param currentDefines defines the current define statements for the shader.
  13012. * @param effect defines the current effect we try to compile
  13013. * @returns The resulting defines with defines of the current rank removed.
  13014. */
  13015. reduce(currentDefines: string, effect: Effect): string;
  13016. }
  13017. /**
  13018. * Options to be used when creating an effect.
  13019. */
  13020. class EffectCreationOptions {
  13021. /**
  13022. * Atrributes that will be used in the shader.
  13023. */
  13024. attributes: string[];
  13025. /**
  13026. * Uniform varible names that will be set in the shader.
  13027. */
  13028. uniformsNames: string[];
  13029. /**
  13030. * Uniform buffer varible names that will be set in the shader.
  13031. */
  13032. uniformBuffersNames: string[];
  13033. /**
  13034. * Sampler texture variable names that will be set in the shader.
  13035. */
  13036. samplers: string[];
  13037. /**
  13038. * Define statements that will be set in the shader.
  13039. */
  13040. defines: any;
  13041. /**
  13042. * Possible fallbacks for this effect to improve performance when needed.
  13043. */
  13044. fallbacks: Nullable<EffectFallbacks>;
  13045. /**
  13046. * Callback that will be called when the shader is compiled.
  13047. */
  13048. onCompiled: Nullable<(effect: Effect) => void>;
  13049. /**
  13050. * Callback that will be called if an error occurs during shader compilation.
  13051. */
  13052. onError: Nullable<(effect: Effect, errors: string) => void>;
  13053. /**
  13054. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13055. */
  13056. indexParameters: any;
  13057. /**
  13058. * Max number of lights that can be used in the shader.
  13059. */
  13060. maxSimultaneousLights: number;
  13061. /**
  13062. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  13063. */
  13064. transformFeedbackVaryings: Nullable<string[]>;
  13065. }
  13066. /**
  13067. * Effect containing vertex and fragment shader that can be executed on an object.
  13068. */
  13069. class Effect {
  13070. /**
  13071. * Name of the effect.
  13072. */
  13073. name: any;
  13074. /**
  13075. * String container all the define statements that should be set on the shader.
  13076. */
  13077. defines: string;
  13078. /**
  13079. * Callback that will be called when the shader is compiled.
  13080. */
  13081. onCompiled: Nullable<(effect: Effect) => void>;
  13082. /**
  13083. * Callback that will be called if an error occurs during shader compilation.
  13084. */
  13085. onError: Nullable<(effect: Effect, errors: string) => void>;
  13086. /**
  13087. * Callback that will be called when effect is bound.
  13088. */
  13089. onBind: Nullable<(effect: Effect) => void>;
  13090. /**
  13091. * Unique ID of the effect.
  13092. */
  13093. uniqueId: number;
  13094. /**
  13095. * Observable that will be called when the shader is compiled.
  13096. */
  13097. onCompileObservable: Observable<Effect>;
  13098. /**
  13099. * Observable that will be called if an error occurs during shader compilation.
  13100. */
  13101. onErrorObservable: Observable<Effect>;
  13102. /**
  13103. * Observable that will be called when effect is bound.
  13104. */
  13105. onBindObservable: Observable<Effect>;
  13106. /** @hidden */
  13107. _bonesComputationForcedToCPU: boolean;
  13108. private static _uniqueIdSeed;
  13109. private _engine;
  13110. private _uniformBuffersNames;
  13111. private _uniformsNames;
  13112. private _samplers;
  13113. private _isReady;
  13114. private _compilationError;
  13115. private _attributesNames;
  13116. private _attributes;
  13117. private _uniforms;
  13118. /**
  13119. * Key for the effect.
  13120. */
  13121. _key: string;
  13122. private _indexParameters;
  13123. private _fallbacks;
  13124. private _vertexSourceCode;
  13125. private _fragmentSourceCode;
  13126. private _vertexSourceCodeOverride;
  13127. private _fragmentSourceCodeOverride;
  13128. private _transformFeedbackVaryings;
  13129. /**
  13130. * Compiled shader to webGL program.
  13131. */
  13132. _program: WebGLProgram;
  13133. private _valueCache;
  13134. private static _baseCache;
  13135. /**
  13136. * Instantiates an effect.
  13137. * An effect can be used to create/manage/execute vertex and fragment shaders.
  13138. * @param baseName Name of the effect.
  13139. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  13140. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  13141. * @param samplers List of sampler variables that will be passed to the shader.
  13142. * @param engine Engine to be used to render the effect
  13143. * @param defines Define statements to be added to the shader.
  13144. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  13145. * @param onCompiled Callback that will be called when the shader is compiled.
  13146. * @param onError Callback that will be called if an error occurs during shader compilation.
  13147. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13148. */
  13149. 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);
  13150. /**
  13151. * Unique key for this effect
  13152. */
  13153. readonly key: string;
  13154. /**
  13155. * If the effect has been compiled and prepared.
  13156. * @returns if the effect is compiled and prepared.
  13157. */
  13158. isReady(): boolean;
  13159. /**
  13160. * The engine the effect was initialized with.
  13161. * @returns the engine.
  13162. */
  13163. getEngine(): Engine;
  13164. /**
  13165. * The compiled webGL program for the effect
  13166. * @returns the webGL program.
  13167. */
  13168. getProgram(): WebGLProgram;
  13169. /**
  13170. * The set of names of attribute variables for the shader.
  13171. * @returns An array of attribute names.
  13172. */
  13173. getAttributesNames(): string[];
  13174. /**
  13175. * Returns the attribute at the given index.
  13176. * @param index The index of the attribute.
  13177. * @returns The location of the attribute.
  13178. */
  13179. getAttributeLocation(index: number): number;
  13180. /**
  13181. * Returns the attribute based on the name of the variable.
  13182. * @param name of the attribute to look up.
  13183. * @returns the attribute location.
  13184. */
  13185. getAttributeLocationByName(name: string): number;
  13186. /**
  13187. * The number of attributes.
  13188. * @returns the numnber of attributes.
  13189. */
  13190. getAttributesCount(): number;
  13191. /**
  13192. * Gets the index of a uniform variable.
  13193. * @param uniformName of the uniform to look up.
  13194. * @returns the index.
  13195. */
  13196. getUniformIndex(uniformName: string): number;
  13197. /**
  13198. * Returns the attribute based on the name of the variable.
  13199. * @param uniformName of the uniform to look up.
  13200. * @returns the location of the uniform.
  13201. */
  13202. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  13203. /**
  13204. * Returns an array of sampler variable names
  13205. * @returns The array of sampler variable neames.
  13206. */
  13207. getSamplers(): string[];
  13208. /**
  13209. * The error from the last compilation.
  13210. * @returns the error string.
  13211. */
  13212. getCompilationError(): string;
  13213. /**
  13214. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  13215. * @param func The callback to be used.
  13216. */
  13217. executeWhenCompiled(func: (effect: Effect) => void): void;
  13218. /** @hidden */
  13219. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  13220. /** @hidden */
  13221. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  13222. /** @hidden */
  13223. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  13224. private _processShaderConversion(sourceCode, isFragment, callback);
  13225. private _processIncludes(sourceCode, callback);
  13226. private _processPrecision(source);
  13227. /**
  13228. * Recompiles the webGL program
  13229. * @param vertexSourceCode The source code for the vertex shader.
  13230. * @param fragmentSourceCode The source code for the fragment shader.
  13231. * @param onCompiled Callback called when completed.
  13232. * @param onError Callback called on error.
  13233. */
  13234. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  13235. /**
  13236. * Gets the uniform locations of the the specified variable names
  13237. * @param names THe names of the variables to lookup.
  13238. * @returns Array of locations in the same order as variable names.
  13239. */
  13240. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  13241. /**
  13242. * Prepares the effect
  13243. */
  13244. _prepareEffect(): void;
  13245. /**
  13246. * Checks if the effect is supported. (Must be called after compilation)
  13247. */
  13248. readonly isSupported: boolean;
  13249. /**
  13250. * Binds a texture to the engine to be used as output of the shader.
  13251. * @param channel Name of the output variable.
  13252. * @param texture Texture to bind.
  13253. */
  13254. _bindTexture(channel: string, texture: InternalTexture): void;
  13255. /**
  13256. * Sets a texture on the engine to be used in the shader.
  13257. * @param channel Name of the sampler variable.
  13258. * @param texture Texture to set.
  13259. */
  13260. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  13261. /**
  13262. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  13263. * @param channel Name of the sampler variable.
  13264. * @param texture Texture to set.
  13265. */
  13266. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  13267. /**
  13268. * Sets an array of textures on the engine to be used in the shader.
  13269. * @param channel Name of the variable.
  13270. * @param textures Textures to set.
  13271. */
  13272. setTextureArray(channel: string, textures: BaseTexture[]): void;
  13273. /**
  13274. * 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)
  13275. * @param channel Name of the sampler variable.
  13276. * @param postProcess Post process to get the input texture from.
  13277. */
  13278. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  13279. /**
  13280. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  13281. * 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)
  13282. * @param channel Name of the sampler variable.
  13283. * @param postProcess Post process to get the output texture from.
  13284. */
  13285. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  13286. /** @hidden */
  13287. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  13288. /** @hidden */
  13289. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  13290. /** @hidden */
  13291. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  13292. /** @hidden */
  13293. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  13294. /**
  13295. * Binds a buffer to a uniform.
  13296. * @param buffer Buffer to bind.
  13297. * @param name Name of the uniform variable to bind to.
  13298. */
  13299. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  13300. /**
  13301. * Binds block to a uniform.
  13302. * @param blockName Name of the block to bind.
  13303. * @param index Index to bind.
  13304. */
  13305. bindUniformBlock(blockName: string, index: number): void;
  13306. /**
  13307. * Sets an interger value on a uniform variable.
  13308. * @param uniformName Name of the variable.
  13309. * @param value Value to be set.
  13310. * @returns this effect.
  13311. */
  13312. setInt(uniformName: string, value: number): Effect;
  13313. /**
  13314. * Sets an int array on a uniform variable.
  13315. * @param uniformName Name of the variable.
  13316. * @param array array to be set.
  13317. * @returns this effect.
  13318. */
  13319. setIntArray(uniformName: string, array: Int32Array): Effect;
  13320. /**
  13321. * 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)
  13322. * @param uniformName Name of the variable.
  13323. * @param array array to be set.
  13324. * @returns this effect.
  13325. */
  13326. setIntArray2(uniformName: string, array: Int32Array): Effect;
  13327. /**
  13328. * 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)
  13329. * @param uniformName Name of the variable.
  13330. * @param array array to be set.
  13331. * @returns this effect.
  13332. */
  13333. setIntArray3(uniformName: string, array: Int32Array): Effect;
  13334. /**
  13335. * 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)
  13336. * @param uniformName Name of the variable.
  13337. * @param array array to be set.
  13338. * @returns this effect.
  13339. */
  13340. setIntArray4(uniformName: string, array: Int32Array): Effect;
  13341. /**
  13342. * Sets an float array on a uniform variable.
  13343. * @param uniformName Name of the variable.
  13344. * @param array array to be set.
  13345. * @returns this effect.
  13346. */
  13347. setFloatArray(uniformName: string, array: Float32Array): Effect;
  13348. /**
  13349. * 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)
  13350. * @param uniformName Name of the variable.
  13351. * @param array array to be set.
  13352. * @returns this effect.
  13353. */
  13354. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  13355. /**
  13356. * 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)
  13357. * @param uniformName Name of the variable.
  13358. * @param array array to be set.
  13359. * @returns this effect.
  13360. */
  13361. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  13362. /**
  13363. * 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)
  13364. * @param uniformName Name of the variable.
  13365. * @param array array to be set.
  13366. * @returns this effect.
  13367. */
  13368. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  13369. /**
  13370. * Sets an array on a uniform variable.
  13371. * @param uniformName Name of the variable.
  13372. * @param array array to be set.
  13373. * @returns this effect.
  13374. */
  13375. setArray(uniformName: string, array: number[]): Effect;
  13376. /**
  13377. * 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)
  13378. * @param uniformName Name of the variable.
  13379. * @param array array to be set.
  13380. * @returns this effect.
  13381. */
  13382. setArray2(uniformName: string, array: number[]): Effect;
  13383. /**
  13384. * 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)
  13385. * @param uniformName Name of the variable.
  13386. * @param array array to be set.
  13387. * @returns this effect.
  13388. */
  13389. setArray3(uniformName: string, array: number[]): Effect;
  13390. /**
  13391. * 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)
  13392. * @param uniformName Name of the variable.
  13393. * @param array array to be set.
  13394. * @returns this effect.
  13395. */
  13396. setArray4(uniformName: string, array: number[]): Effect;
  13397. /**
  13398. * Sets matrices on a uniform variable.
  13399. * @param uniformName Name of the variable.
  13400. * @param matrices matrices to be set.
  13401. * @returns this effect.
  13402. */
  13403. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  13404. /**
  13405. * Sets matrix on a uniform variable.
  13406. * @param uniformName Name of the variable.
  13407. * @param matrix matrix to be set.
  13408. * @returns this effect.
  13409. */
  13410. setMatrix(uniformName: string, matrix: Matrix): Effect;
  13411. /**
  13412. * 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)
  13413. * @param uniformName Name of the variable.
  13414. * @param matrix matrix to be set.
  13415. * @returns this effect.
  13416. */
  13417. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  13418. /**
  13419. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  13420. * @param uniformName Name of the variable.
  13421. * @param matrix matrix to be set.
  13422. * @returns this effect.
  13423. */
  13424. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  13425. /**
  13426. * Sets a float on a uniform variable.
  13427. * @param uniformName Name of the variable.
  13428. * @param value value to be set.
  13429. * @returns this effect.
  13430. */
  13431. setFloat(uniformName: string, value: number): Effect;
  13432. /**
  13433. * Sets a boolean on a uniform variable.
  13434. * @param uniformName Name of the variable.
  13435. * @param bool value to be set.
  13436. * @returns this effect.
  13437. */
  13438. setBool(uniformName: string, bool: boolean): Effect;
  13439. /**
  13440. * Sets a Vector2 on a uniform variable.
  13441. * @param uniformName Name of the variable.
  13442. * @param vector2 vector2 to be set.
  13443. * @returns this effect.
  13444. */
  13445. setVector2(uniformName: string, vector2: Vector2): Effect;
  13446. /**
  13447. * Sets a float2 on a uniform variable.
  13448. * @param uniformName Name of the variable.
  13449. * @param x First float in float2.
  13450. * @param y Second float in float2.
  13451. * @returns this effect.
  13452. */
  13453. setFloat2(uniformName: string, x: number, y: number): Effect;
  13454. /**
  13455. * Sets a Vector3 on a uniform variable.
  13456. * @param uniformName Name of the variable.
  13457. * @param vector3 Value to be set.
  13458. * @returns this effect.
  13459. */
  13460. setVector3(uniformName: string, vector3: Vector3): Effect;
  13461. /**
  13462. * Sets a float3 on a uniform variable.
  13463. * @param uniformName Name of the variable.
  13464. * @param x First float in float3.
  13465. * @param y Second float in float3.
  13466. * @param z Third float in float3.
  13467. * @returns this effect.
  13468. */
  13469. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  13470. /**
  13471. * Sets a Vector4 on a uniform variable.
  13472. * @param uniformName Name of the variable.
  13473. * @param vector4 Value to be set.
  13474. * @returns this effect.
  13475. */
  13476. setVector4(uniformName: string, vector4: Vector4): Effect;
  13477. /**
  13478. * Sets a float4 on a uniform variable.
  13479. * @param uniformName Name of the variable.
  13480. * @param x First float in float4.
  13481. * @param y Second float in float4.
  13482. * @param z Third float in float4.
  13483. * @param w Fourth float in float4.
  13484. * @returns this effect.
  13485. */
  13486. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  13487. /**
  13488. * Sets a Color3 on a uniform variable.
  13489. * @param uniformName Name of the variable.
  13490. * @param color3 Value to be set.
  13491. * @returns this effect.
  13492. */
  13493. setColor3(uniformName: string, color3: Color3): Effect;
  13494. /**
  13495. * Sets a Color4 on a uniform variable.
  13496. * @param uniformName Name of the variable.
  13497. * @param color3 Value to be set.
  13498. * @param alpha Alpha value to be set.
  13499. * @returns this effect.
  13500. */
  13501. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  13502. /**
  13503. * Sets a Color4 on a uniform variable
  13504. * @param uniformName defines the name of the variable
  13505. * @param color4 defines the value to be set
  13506. * @returns this effect.
  13507. */
  13508. setDirectColor4(uniformName: string, color4: Color4): Effect;
  13509. /**
  13510. * Store of each shader (The can be looked up using effect.key)
  13511. */
  13512. static ShadersStore: {
  13513. [key: string]: string;
  13514. };
  13515. /**
  13516. * Store of each included file for a shader (The can be looked up using effect.key)
  13517. */
  13518. static IncludesShadersStore: {
  13519. [key: string]: string;
  13520. };
  13521. /**
  13522. * Resets the cache of effects.
  13523. */
  13524. static ResetCache(): void;
  13525. }
  13526. }
  13527. declare module BABYLON {
  13528. class FresnelParameters {
  13529. private _isEnabled;
  13530. isEnabled: boolean;
  13531. leftColor: Color3;
  13532. rightColor: Color3;
  13533. bias: number;
  13534. power: number;
  13535. clone(): FresnelParameters;
  13536. serialize(): any;
  13537. static Parse(parsedFresnelParameters: any): FresnelParameters;
  13538. }
  13539. }
  13540. declare module BABYLON {
  13541. /**
  13542. * Interface to follow in your material defines to integrate easily the
  13543. * Image proccessing functions.
  13544. * @hidden
  13545. */
  13546. interface IImageProcessingConfigurationDefines {
  13547. IMAGEPROCESSING: boolean;
  13548. VIGNETTE: boolean;
  13549. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13550. VIGNETTEBLENDMODEOPAQUE: boolean;
  13551. TONEMAPPING: boolean;
  13552. CONTRAST: boolean;
  13553. EXPOSURE: boolean;
  13554. COLORCURVES: boolean;
  13555. COLORGRADING: boolean;
  13556. COLORGRADING3D: boolean;
  13557. SAMPLER3DGREENDEPTH: boolean;
  13558. SAMPLER3DBGRMAP: boolean;
  13559. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13560. }
  13561. /**
  13562. * This groups together the common properties used for image processing either in direct forward pass
  13563. * or through post processing effect depending on the use of the image processing pipeline in your scene
  13564. * or not.
  13565. */
  13566. class ImageProcessingConfiguration {
  13567. /**
  13568. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  13569. */
  13570. colorCurves: Nullable<ColorCurves>;
  13571. private _colorCurvesEnabled;
  13572. /**
  13573. * Gets wether the color curves effect is enabled.
  13574. */
  13575. /**
  13576. * Sets wether the color curves effect is enabled.
  13577. */
  13578. colorCurvesEnabled: boolean;
  13579. /**
  13580. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  13581. */
  13582. colorGradingTexture: Nullable<BaseTexture>;
  13583. private _colorGradingEnabled;
  13584. /**
  13585. * Gets wether the color grading effect is enabled.
  13586. */
  13587. /**
  13588. * Sets wether the color grading effect is enabled.
  13589. */
  13590. colorGradingEnabled: boolean;
  13591. private _colorGradingWithGreenDepth;
  13592. /**
  13593. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  13594. */
  13595. /**
  13596. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  13597. */
  13598. colorGradingWithGreenDepth: boolean;
  13599. private _colorGradingBGR;
  13600. /**
  13601. * Gets wether the color grading texture contains BGR values.
  13602. */
  13603. /**
  13604. * Sets wether the color grading texture contains BGR values.
  13605. */
  13606. colorGradingBGR: boolean;
  13607. _exposure: number;
  13608. /**
  13609. * Gets the Exposure used in the effect.
  13610. */
  13611. /**
  13612. * Sets the Exposure used in the effect.
  13613. */
  13614. exposure: number;
  13615. private _toneMappingEnabled;
  13616. /**
  13617. * Gets wether the tone mapping effect is enabled.
  13618. */
  13619. /**
  13620. * Sets wether the tone mapping effect is enabled.
  13621. */
  13622. toneMappingEnabled: boolean;
  13623. protected _contrast: number;
  13624. /**
  13625. * Gets the contrast used in the effect.
  13626. */
  13627. /**
  13628. * Sets the contrast used in the effect.
  13629. */
  13630. contrast: number;
  13631. /**
  13632. * Vignette stretch size.
  13633. */
  13634. vignetteStretch: number;
  13635. /**
  13636. * Vignette centre X Offset.
  13637. */
  13638. vignetteCentreX: number;
  13639. /**
  13640. * Vignette centre Y Offset.
  13641. */
  13642. vignetteCentreY: number;
  13643. /**
  13644. * Vignette weight or intensity of the vignette effect.
  13645. */
  13646. vignetteWeight: number;
  13647. /**
  13648. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  13649. * if vignetteEnabled is set to true.
  13650. */
  13651. vignetteColor: Color4;
  13652. /**
  13653. * Camera field of view used by the Vignette effect.
  13654. */
  13655. vignetteCameraFov: number;
  13656. private _vignetteBlendMode;
  13657. /**
  13658. * Gets the vignette blend mode allowing different kind of effect.
  13659. */
  13660. /**
  13661. * Sets the vignette blend mode allowing different kind of effect.
  13662. */
  13663. vignetteBlendMode: number;
  13664. private _vignetteEnabled;
  13665. /**
  13666. * Gets wether the vignette effect is enabled.
  13667. */
  13668. /**
  13669. * Sets wether the vignette effect is enabled.
  13670. */
  13671. vignetteEnabled: boolean;
  13672. private _applyByPostProcess;
  13673. /**
  13674. * Gets wether the image processing is applied through a post process or not.
  13675. */
  13676. /**
  13677. * Sets wether the image processing is applied through a post process or not.
  13678. */
  13679. applyByPostProcess: boolean;
  13680. private _isEnabled;
  13681. /**
  13682. * Gets wether the image processing is enabled or not.
  13683. */
  13684. /**
  13685. * Sets wether the image processing is enabled or not.
  13686. */
  13687. isEnabled: boolean;
  13688. /**
  13689. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  13690. */
  13691. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  13692. /**
  13693. * Method called each time the image processing information changes requires to recompile the effect.
  13694. */
  13695. protected _updateParameters(): void;
  13696. getClassName(): string;
  13697. /**
  13698. * Prepare the list of uniforms associated with the Image Processing effects.
  13699. * @param uniformsList The list of uniforms used in the effect
  13700. * @param defines the list of defines currently in use
  13701. */
  13702. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  13703. /**
  13704. * Prepare the list of samplers associated with the Image Processing effects.
  13705. * @param uniformsList The list of uniforms used in the effect
  13706. * @param defines the list of defines currently in use
  13707. */
  13708. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  13709. /**
  13710. * Prepare the list of defines associated to the shader.
  13711. * @param defines the list of defines to complete
  13712. */
  13713. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  13714. /**
  13715. * Returns true if all the image processing information are ready.
  13716. */
  13717. isReady(): boolean;
  13718. /**
  13719. * Binds the image processing to the shader.
  13720. * @param effect The effect to bind to
  13721. */
  13722. bind(effect: Effect, aspectRatio?: number): void;
  13723. /**
  13724. * Clones the current image processing instance.
  13725. * @return The cloned image processing
  13726. */
  13727. clone(): ImageProcessingConfiguration;
  13728. /**
  13729. * Serializes the current image processing instance to a json representation.
  13730. * @return a JSON representation
  13731. */
  13732. serialize(): any;
  13733. /**
  13734. * Parses the image processing from a json representation.
  13735. * @param source the JSON source to parse
  13736. * @return The parsed image processing
  13737. */
  13738. static Parse(source: any): ImageProcessingConfiguration;
  13739. private static _VIGNETTEMODE_MULTIPLY;
  13740. private static _VIGNETTEMODE_OPAQUE;
  13741. /**
  13742. * Used to apply the vignette as a mix with the pixel color.
  13743. */
  13744. static readonly VIGNETTEMODE_MULTIPLY: number;
  13745. /**
  13746. * Used to apply the vignette as a replacement of the pixel color.
  13747. */
  13748. static readonly VIGNETTEMODE_OPAQUE: number;
  13749. }
  13750. }
  13751. declare module BABYLON {
  13752. /**
  13753. * Manages the defines for the Material
  13754. */
  13755. class MaterialDefines {
  13756. private _keys;
  13757. private _isDirty;
  13758. /** @hidden */
  13759. _renderId: number;
  13760. /** @hidden */
  13761. _areLightsDirty: boolean;
  13762. /** @hidden */
  13763. _areAttributesDirty: boolean;
  13764. /** @hidden */
  13765. _areTexturesDirty: boolean;
  13766. /** @hidden */
  13767. _areFresnelDirty: boolean;
  13768. /** @hidden */
  13769. _areMiscDirty: boolean;
  13770. /** @hidden */
  13771. _areImageProcessingDirty: boolean;
  13772. /** @hidden */
  13773. _normals: boolean;
  13774. /** @hidden */
  13775. _uvs: boolean;
  13776. /** @hidden */
  13777. _needNormals: boolean;
  13778. /** @hidden */
  13779. _needUVs: boolean;
  13780. /**
  13781. * Specifies if the material needs to be re-calculated
  13782. */
  13783. readonly isDirty: boolean;
  13784. /**
  13785. * Marks the material to indicate that it has been re-calculated
  13786. */
  13787. markAsProcessed(): void;
  13788. /**
  13789. * Marks the material to indicate that it needs to be re-calculated
  13790. */
  13791. markAsUnprocessed(): void;
  13792. /**
  13793. * Marks the material to indicate all of its defines need to be re-calculated
  13794. */
  13795. markAllAsDirty(): void;
  13796. /**
  13797. * Marks the material to indicate that image processing needs to be re-calculated
  13798. */
  13799. markAsImageProcessingDirty(): void;
  13800. /**
  13801. * Marks the material to indicate the lights need to be re-calculated
  13802. */
  13803. markAsLightDirty(): void;
  13804. /**
  13805. * Marks the attribute state as changed
  13806. */
  13807. markAsAttributesDirty(): void;
  13808. /**
  13809. * Marks the texture state as changed
  13810. */
  13811. markAsTexturesDirty(): void;
  13812. /**
  13813. * Marks the fresnel state as changed
  13814. */
  13815. markAsFresnelDirty(): void;
  13816. /**
  13817. * Marks the misc state as changed
  13818. */
  13819. markAsMiscDirty(): void;
  13820. /**
  13821. * Rebuilds the material defines
  13822. */
  13823. rebuild(): void;
  13824. /**
  13825. * Specifies if two material defines are equal
  13826. * @param other - A material define instance to compare to
  13827. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  13828. */
  13829. isEqual(other: MaterialDefines): boolean;
  13830. /**
  13831. * Clones this instance's defines to another instance
  13832. * @param other - material defines to clone values to
  13833. */
  13834. cloneTo(other: MaterialDefines): void;
  13835. /**
  13836. * Resets the material define values
  13837. */
  13838. reset(): void;
  13839. /**
  13840. * Converts the material define values to a string
  13841. * @returns - String of material define information
  13842. */
  13843. toString(): string;
  13844. }
  13845. /**
  13846. * Base class for the main features of a material in Babylon.js
  13847. */
  13848. class Material implements IAnimatable {
  13849. private static _TriangleFillMode;
  13850. private static _WireFrameFillMode;
  13851. private static _PointFillMode;
  13852. private static _PointListDrawMode;
  13853. private static _LineListDrawMode;
  13854. private static _LineLoopDrawMode;
  13855. private static _LineStripDrawMode;
  13856. private static _TriangleStripDrawMode;
  13857. private static _TriangleFanDrawMode;
  13858. /**
  13859. * Returns the triangle fill mode
  13860. */
  13861. static readonly TriangleFillMode: number;
  13862. /**
  13863. * Returns the wireframe mode
  13864. */
  13865. static readonly WireFrameFillMode: number;
  13866. /**
  13867. * Returns the point fill mode
  13868. */
  13869. static readonly PointFillMode: number;
  13870. /**
  13871. * Returns the point list draw mode
  13872. */
  13873. static readonly PointListDrawMode: number;
  13874. /**
  13875. * Returns the line list draw mode
  13876. */
  13877. static readonly LineListDrawMode: number;
  13878. /**
  13879. * Returns the line loop draw mode
  13880. */
  13881. static readonly LineLoopDrawMode: number;
  13882. /**
  13883. * Returns the line strip draw mode
  13884. */
  13885. static readonly LineStripDrawMode: number;
  13886. /**
  13887. * Returns the triangle strip draw mode
  13888. */
  13889. static readonly TriangleStripDrawMode: number;
  13890. /**
  13891. * Returns the triangle fan draw mode
  13892. */
  13893. static readonly TriangleFanDrawMode: number;
  13894. /**
  13895. * Stores the clock-wise side orientation
  13896. */
  13897. private static _ClockWiseSideOrientation;
  13898. /**
  13899. * Stores the counter clock-wise side orientation
  13900. */
  13901. private static _CounterClockWiseSideOrientation;
  13902. /**
  13903. * Returns the clock-wise side orientation
  13904. */
  13905. static readonly ClockWiseSideOrientation: number;
  13906. /**
  13907. * Returns the counter clock-wise side orientation
  13908. */
  13909. static readonly CounterClockWiseSideOrientation: number;
  13910. /**
  13911. * The dirty texture flag value
  13912. */
  13913. private static _TextureDirtyFlag;
  13914. /**
  13915. * The dirty light flag value
  13916. */
  13917. private static _LightDirtyFlag;
  13918. /**
  13919. * The dirty fresnel flag value
  13920. */
  13921. private static _FresnelDirtyFlag;
  13922. /**
  13923. * The dirty attribute flag value
  13924. */
  13925. private static _AttributesDirtyFlag;
  13926. /**
  13927. * The dirty misc flag value
  13928. */
  13929. private static _MiscDirtyFlag;
  13930. /**
  13931. * Returns the dirty texture flag value
  13932. */
  13933. static readonly TextureDirtyFlag: number;
  13934. /**
  13935. * Returns the dirty light flag value
  13936. */
  13937. static readonly LightDirtyFlag: number;
  13938. /**
  13939. * Returns the dirty fresnel flag value
  13940. */
  13941. static readonly FresnelDirtyFlag: number;
  13942. /**
  13943. * Returns the dirty attributes flag value
  13944. */
  13945. static readonly AttributesDirtyFlag: number;
  13946. /**
  13947. * Returns the dirty misc flag value
  13948. */
  13949. static readonly MiscDirtyFlag: number;
  13950. /**
  13951. * The ID of the material
  13952. */
  13953. id: string;
  13954. /**
  13955. * Gets or sets the unique id of the material
  13956. */
  13957. uniqueId: number;
  13958. /**
  13959. * The name of the material
  13960. */
  13961. name: string;
  13962. /**
  13963. * Specifies if the ready state should be checked on each call
  13964. */
  13965. checkReadyOnEveryCall: boolean;
  13966. /**
  13967. * Specifies if the ready state should be checked once
  13968. */
  13969. checkReadyOnlyOnce: boolean;
  13970. /**
  13971. * The state of the material
  13972. */
  13973. state: string;
  13974. /**
  13975. * The alpha value of the material
  13976. */
  13977. protected _alpha: number;
  13978. /**
  13979. * Gets the alpha value of the material
  13980. */
  13981. /**
  13982. * Sets the alpha value of the material
  13983. */
  13984. alpha: number;
  13985. /**
  13986. * Specifies if back face culling is enabled
  13987. */
  13988. protected _backFaceCulling: boolean;
  13989. /**
  13990. * Gets the back-face culling state
  13991. */
  13992. /**
  13993. * Sets the back-face culling state
  13994. */
  13995. backFaceCulling: boolean;
  13996. /**
  13997. * Stores the value for side orientation
  13998. */
  13999. sideOrientation: number;
  14000. /**
  14001. * Callback triggered when the material is compiled
  14002. */
  14003. onCompiled: (effect: Effect) => void;
  14004. /**
  14005. * Callback triggered when an error occurs
  14006. */
  14007. onError: (effect: Effect, errors: string) => void;
  14008. /**
  14009. * Callback triggered to get the render target textures
  14010. */
  14011. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  14012. /**
  14013. * Specifies if the material should be serialized
  14014. */
  14015. doNotSerialize: boolean;
  14016. /**
  14017. * Specifies if the effect should be stored on sub meshes
  14018. */
  14019. storeEffectOnSubMeshes: boolean;
  14020. /**
  14021. * Stores the animations for the material
  14022. */
  14023. animations: Array<Animation>;
  14024. /**
  14025. * An event triggered when the material is disposed
  14026. */
  14027. onDisposeObservable: Observable<Material>;
  14028. /**
  14029. * An observer which watches for dispose events
  14030. */
  14031. private _onDisposeObserver;
  14032. /**
  14033. * Called during a dispose event
  14034. */
  14035. onDispose: () => void;
  14036. /**
  14037. * An event triggered when the material is bound
  14038. */
  14039. onBindObservable: Observable<AbstractMesh>;
  14040. /**
  14041. * An observer which watches for bind events
  14042. */
  14043. private _onBindObserver;
  14044. /**
  14045. * Called during a bind event
  14046. */
  14047. onBind: (Mesh: AbstractMesh) => void;
  14048. /**
  14049. * An event triggered when the material is unbound
  14050. */
  14051. onUnBindObservable: Observable<Material>;
  14052. /**
  14053. * Stores the value of the alpha mode
  14054. */
  14055. private _alphaMode;
  14056. /**
  14057. * Gets the value of the alpha mode
  14058. */
  14059. /**
  14060. * Sets the value of the alpha mode.
  14061. *
  14062. * | Value | Type | Description |
  14063. * | --- | --- | --- |
  14064. * | 0 | ALPHA_DISABLE | |
  14065. * | 1 | ALPHA_ADD | |
  14066. * | 2 | ALPHA_COMBINE | |
  14067. * | 3 | ALPHA_SUBTRACT | |
  14068. * | 4 | ALPHA_MULTIPLY | |
  14069. * | 5 | ALPHA_MAXIMIZED | |
  14070. * | 6 | ALPHA_ONEONE | |
  14071. * | 7 | ALPHA_PREMULTIPLIED | |
  14072. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  14073. * | 9 | ALPHA_INTERPOLATE | |
  14074. * | 10 | ALPHA_SCREENMODE | |
  14075. *
  14076. */
  14077. alphaMode: number;
  14078. /**
  14079. * Stores the state of the need depth pre-pass value
  14080. */
  14081. private _needDepthPrePass;
  14082. /**
  14083. * Gets the depth pre-pass value
  14084. */
  14085. /**
  14086. * Sets the need depth pre-pass value
  14087. */
  14088. needDepthPrePass: boolean;
  14089. /**
  14090. * Specifies if depth writing should be disabled
  14091. */
  14092. disableDepthWrite: boolean;
  14093. /**
  14094. * Specifies if depth writing should be forced
  14095. */
  14096. forceDepthWrite: boolean;
  14097. /**
  14098. * Specifies if there should be a separate pass for culling
  14099. */
  14100. separateCullingPass: boolean;
  14101. /**
  14102. * Stores the state specifing if fog should be enabled
  14103. */
  14104. private _fogEnabled;
  14105. /**
  14106. * Gets the value of the fog enabled state
  14107. */
  14108. /**
  14109. * Sets the state for enabling fog
  14110. */
  14111. fogEnabled: boolean;
  14112. /**
  14113. * Stores the size of points
  14114. */
  14115. pointSize: number;
  14116. /**
  14117. * Stores the z offset value
  14118. */
  14119. zOffset: number;
  14120. /**
  14121. * Gets a value specifying if wireframe mode is enabled
  14122. */
  14123. /**
  14124. * Sets the state of wireframe mode
  14125. */
  14126. wireframe: boolean;
  14127. /**
  14128. * Gets the value specifying if point clouds are enabled
  14129. */
  14130. /**
  14131. * Sets the state of point cloud mode
  14132. */
  14133. pointsCloud: boolean;
  14134. /**
  14135. * Gets the material fill mode
  14136. */
  14137. /**
  14138. * Sets the material fill mode
  14139. */
  14140. fillMode: number;
  14141. /**
  14142. * Stores the effects for the material
  14143. */
  14144. _effect: Nullable<Effect>;
  14145. /**
  14146. * Specifies if the material was previously ready
  14147. */
  14148. _wasPreviouslyReady: boolean;
  14149. /**
  14150. * Specifies if uniform buffers should be used
  14151. */
  14152. private _useUBO;
  14153. /**
  14154. * Stores a reference to the scene
  14155. */
  14156. private _scene;
  14157. /**
  14158. * Stores the fill mode state
  14159. */
  14160. private _fillMode;
  14161. /**
  14162. * Specifies if the depth write state should be cached
  14163. */
  14164. private _cachedDepthWriteState;
  14165. /**
  14166. * Stores the uniform buffer
  14167. */
  14168. protected _uniformBuffer: UniformBuffer;
  14169. /**
  14170. * Creates a material instance
  14171. * @param name defines the name of the material
  14172. * @param scene defines the scene to reference
  14173. * @param doNotAdd specifies if the material should be added to the scene
  14174. */
  14175. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  14176. /**
  14177. * Returns a string representation of the current material
  14178. * @param fullDetails defines a boolean indicating which levels of logging is desired
  14179. * @returns a string with material information
  14180. */
  14181. toString(fullDetails?: boolean): string;
  14182. /**
  14183. * Gets the class name of the material
  14184. * @returns a string with the class name of the material
  14185. */
  14186. getClassName(): string;
  14187. /**
  14188. * Specifies if updates for the material been locked
  14189. */
  14190. readonly isFrozen: boolean;
  14191. /**
  14192. * Locks updates for the material
  14193. */
  14194. freeze(): void;
  14195. /**
  14196. * Unlocks updates for the material
  14197. */
  14198. unfreeze(): void;
  14199. /**
  14200. * Specifies if the material is ready to be used
  14201. * @param mesh defines the mesh to check
  14202. * @param useInstances specifies if instances should be used
  14203. * @returns a boolean indicating if the material is ready to be used
  14204. */
  14205. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14206. /**
  14207. * Specifies that the submesh is ready to be used
  14208. * @param mesh defines the mesh to check
  14209. * @param subMesh defines which submesh to check
  14210. * @param useInstances specifies that instances should be used
  14211. * @returns a boolean indicating that the submesh is ready or not
  14212. */
  14213. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14214. /**
  14215. * Returns the material effect
  14216. * @returns the effect associated with the material
  14217. */
  14218. getEffect(): Nullable<Effect>;
  14219. /**
  14220. * Returns the current scene
  14221. * @returns a Scene
  14222. */
  14223. getScene(): Scene;
  14224. /**
  14225. * Specifies if the material will require alpha blending
  14226. * @returns a boolean specifying if alpha blending is needed
  14227. */
  14228. needAlphaBlending(): boolean;
  14229. /**
  14230. * Specifies if the mesh will require alpha blending
  14231. * @param mesh defines the mesh to check
  14232. * @returns a boolean specifying if alpha blending is needed for the mesh
  14233. */
  14234. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  14235. /**
  14236. * Specifies if this material should be rendered in alpha test mode
  14237. * @returns a boolean specifying if an alpha test is needed.
  14238. */
  14239. needAlphaTesting(): boolean;
  14240. /**
  14241. * Gets the texture used for the alpha test
  14242. * @returns the texture to use for alpha testing
  14243. */
  14244. getAlphaTestTexture(): Nullable<BaseTexture>;
  14245. /**
  14246. * Marks the material to indicate that it needs to be re-calculated
  14247. */
  14248. markDirty(): void;
  14249. /** @hidden */
  14250. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  14251. /**
  14252. * Binds the material to the mesh
  14253. * @param world defines the world transformation matrix
  14254. * @param mesh defines the mesh to bind the material to
  14255. */
  14256. bind(world: Matrix, mesh?: Mesh): void;
  14257. /**
  14258. * Binds the submesh to the material
  14259. * @param world defines the world transformation matrix
  14260. * @param mesh defines the mesh containing the submesh
  14261. * @param subMesh defines the submesh to bind the material to
  14262. */
  14263. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14264. /**
  14265. * Binds the world matrix to the material
  14266. * @param world defines the world transformation matrix
  14267. */
  14268. bindOnlyWorldMatrix(world: Matrix): void;
  14269. /**
  14270. * Binds the scene's uniform buffer to the effect.
  14271. * @param effect defines the effect to bind to the scene uniform buffer
  14272. * @param sceneUbo defines the uniform buffer storing scene data
  14273. */
  14274. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  14275. /**
  14276. * Binds the view matrix to the effect
  14277. * @param effect defines the effect to bind the view matrix to
  14278. */
  14279. bindView(effect: Effect): void;
  14280. /**
  14281. * Binds the view projection matrix to the effect
  14282. * @param effect defines the effect to bind the view projection matrix to
  14283. */
  14284. bindViewProjection(effect: Effect): void;
  14285. /**
  14286. * Specifies if material alpha testing should be turned on for the mesh
  14287. * @param mesh defines the mesh to check
  14288. */
  14289. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  14290. /**
  14291. * Processes to execute after binding the material to a mesh
  14292. * @param mesh defines the rendered mesh
  14293. */
  14294. protected _afterBind(mesh?: Mesh): void;
  14295. /**
  14296. * Unbinds the material from the mesh
  14297. */
  14298. unbind(): void;
  14299. /**
  14300. * Gets the active textures from the material
  14301. * @returns an array of textures
  14302. */
  14303. getActiveTextures(): BaseTexture[];
  14304. /**
  14305. * Specifies if the material uses a texture
  14306. * @param texture defines the texture to check against the material
  14307. * @returns a boolean specifying if the material uses the texture
  14308. */
  14309. hasTexture(texture: BaseTexture): boolean;
  14310. /**
  14311. * Makes a duplicate of the material, and gives it a new name
  14312. * @param name defines the new name for the duplicated material
  14313. * @returns the cloned material
  14314. */
  14315. clone(name: string): Nullable<Material>;
  14316. /**
  14317. * Gets the meshes bound to the material
  14318. * @returns an array of meshes bound to the material
  14319. */
  14320. getBindedMeshes(): AbstractMesh[];
  14321. /**
  14322. * Force shader compilation
  14323. * @param mesh defines the mesh associated with this material
  14324. * @param onCompiled defines a function to execute once the material is compiled
  14325. * @param options defines the options to configure the compilation
  14326. */
  14327. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  14328. clipPlane: boolean;
  14329. }>): void;
  14330. /**
  14331. * Force shader compilation
  14332. * @param mesh defines the mesh that will use this material
  14333. * @param options defines additional options for compiling the shaders
  14334. * @returns a promise that resolves when the compilation completes
  14335. */
  14336. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  14337. clipPlane: boolean;
  14338. }>): Promise<void>;
  14339. /**
  14340. * Marks a define in the material to indicate that it needs to be re-computed
  14341. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  14342. */
  14343. markAsDirty(flag: number): void;
  14344. /**
  14345. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  14346. * @param func defines a function which checks material defines against the submeshes
  14347. */
  14348. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  14349. /**
  14350. * Indicates that image processing needs to be re-calculated for all submeshes
  14351. */
  14352. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  14353. /**
  14354. * Indicates that textures need to be re-calculated for all submeshes
  14355. */
  14356. protected _markAllSubMeshesAsTexturesDirty(): void;
  14357. /**
  14358. * Indicates that fresnel needs to be re-calculated for all submeshes
  14359. */
  14360. protected _markAllSubMeshesAsFresnelDirty(): void;
  14361. /**
  14362. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  14363. */
  14364. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  14365. /**
  14366. * Indicates that lights need to be re-calculated for all submeshes
  14367. */
  14368. protected _markAllSubMeshesAsLightsDirty(): void;
  14369. /**
  14370. * Indicates that attributes need to be re-calculated for all submeshes
  14371. */
  14372. protected _markAllSubMeshesAsAttributesDirty(): void;
  14373. /**
  14374. * Indicates that misc needs to be re-calculated for all submeshes
  14375. */
  14376. protected _markAllSubMeshesAsMiscDirty(): void;
  14377. /**
  14378. * Indicates that textures and misc need to be re-calculated for all submeshes
  14379. */
  14380. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  14381. /**
  14382. * Disposes the material
  14383. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  14384. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  14385. */
  14386. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14387. /**
  14388. * Serializes this material
  14389. * @returns the serialized material object
  14390. */
  14391. serialize(): any;
  14392. /**
  14393. * Creates a MultiMaterial from parsed MultiMaterial data.
  14394. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  14395. * @param scene defines the hosting scene
  14396. * @returns a new MultiMaterial
  14397. */
  14398. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  14399. /**
  14400. * Creates a material from parsed material data
  14401. * @param parsedMaterial defines parsed material data
  14402. * @param scene defines the hosting scene
  14403. * @param rootUrl defines the root URL to use to load textures
  14404. * @returns a new material
  14405. */
  14406. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  14407. }
  14408. }
  14409. declare module BABYLON {
  14410. /**
  14411. * "Static Class" containing the most commonly used helper while dealing with material for
  14412. * rendering purpose.
  14413. *
  14414. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  14415. *
  14416. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14417. */
  14418. class MaterialHelper {
  14419. /**
  14420. * Bind the current view position to an effect.
  14421. * @param effect The effect to be bound
  14422. * @param scene The scene the eyes position is used from
  14423. */
  14424. static BindEyePosition(effect: Effect, scene: Scene): void;
  14425. /**
  14426. * Helps preparing the defines values about the UVs in used in the effect.
  14427. * UVs are shared as much as we can accross chanels in the shaders.
  14428. * @param texture The texture we are preparing the UVs for
  14429. * @param defines The defines to update
  14430. * @param key The chanel key "diffuse", "specular"... used in the shader
  14431. */
  14432. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  14433. /**
  14434. * Binds a texture matrix value to its corrsponding uniform
  14435. * @param texture The texture to bind the matrix for
  14436. * @param uniformBuffer The uniform buffer receivin the data
  14437. * @param key The chanel key "diffuse", "specular"... used in the shader
  14438. */
  14439. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  14440. /**
  14441. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  14442. * @param mesh defines the current mesh
  14443. * @param scene defines the current scene
  14444. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  14445. * @param pointsCloud defines if point cloud rendering has to be turned on
  14446. * @param fogEnabled defines if fog has to be turned on
  14447. * @param alphaTest defines if alpha testing has to be turned on
  14448. * @param defines defines the current list of defines
  14449. */
  14450. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  14451. /**
  14452. * Helper used to prepare the list of defines associated with frame values for shader compilation
  14453. * @param scene defines the current scene
  14454. * @param engine defines the current engine
  14455. * @param defines specifies the list of active defines
  14456. * @param useInstances defines if instances have to be turned on
  14457. * @param useClipPlane defines if clip plane have to be turned on
  14458. */
  14459. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  14460. /**
  14461. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  14462. * @param mesh The mesh containing the geometry data we will draw
  14463. * @param defines The defines to update
  14464. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  14465. * @param useBones Precise whether bones should be used or not (override mesh info)
  14466. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  14467. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  14468. * @returns false if defines are considered not dirty and have not been checked
  14469. */
  14470. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  14471. /**
  14472. * Prepares the defines related to the light information passed in parameter
  14473. * @param scene The scene we are intending to draw
  14474. * @param mesh The mesh the effect is compiling for
  14475. * @param defines The defines to update
  14476. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  14477. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  14478. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  14479. * @returns true if normals will be required for the rest of the effect
  14480. */
  14481. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  14482. /**
  14483. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  14484. * that won t be acctive due to defines being turned off.
  14485. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  14486. * @param samplersList The samplers list
  14487. * @param defines The defines helping in the list generation
  14488. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  14489. */
  14490. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  14491. /**
  14492. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  14493. * @param defines The defines to update while falling back
  14494. * @param fallbacks The authorized effect fallbacks
  14495. * @param maxSimultaneousLights The maximum number of lights allowed
  14496. * @param rank the current rank of the Effect
  14497. * @returns The newly affected rank
  14498. */
  14499. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  14500. /**
  14501. * Prepares the list of attributes required for morph targets according to the effect defines.
  14502. * @param attribs The current list of supported attribs
  14503. * @param mesh The mesh to prepare the morph targets attributes for
  14504. * @param defines The current Defines of the effect
  14505. */
  14506. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  14507. /**
  14508. * Prepares the list of attributes required for bones according to the effect defines.
  14509. * @param attribs The current list of supported attribs
  14510. * @param mesh The mesh to prepare the bones attributes for
  14511. * @param defines The current Defines of the effect
  14512. * @param fallbacks The current efffect fallback strategy
  14513. */
  14514. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  14515. /**
  14516. * Prepares the list of attributes required for instances according to the effect defines.
  14517. * @param attribs The current list of supported attribs
  14518. * @param defines The current Defines of the effect
  14519. */
  14520. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  14521. /**
  14522. * Binds the light shadow information to the effect for the given mesh.
  14523. * @param light The light containing the generator
  14524. * @param scene The scene the lights belongs to
  14525. * @param mesh The mesh we are binding the information to render
  14526. * @param lightIndex The light index in the effect used to render the mesh
  14527. * @param effect The effect we are binding the data to
  14528. */
  14529. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  14530. /**
  14531. * Binds the light information to the effect.
  14532. * @param light The light containing the generator
  14533. * @param effect The effect we are binding the data to
  14534. * @param lightIndex The light index in the effect used to render
  14535. */
  14536. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  14537. /**
  14538. * Binds the lights information from the scene to the effect for the given mesh.
  14539. * @param scene The scene the lights belongs to
  14540. * @param mesh The mesh we are binding the information to render
  14541. * @param effect The effect we are binding the data to
  14542. * @param defines The generated defines for the effect
  14543. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  14544. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  14545. */
  14546. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  14547. /**
  14548. * Binds the fog information from the scene to the effect for the given mesh.
  14549. * @param scene The scene the lights belongs to
  14550. * @param mesh The mesh we are binding the information to render
  14551. * @param effect The effect we are binding the data to
  14552. */
  14553. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  14554. /**
  14555. * Binds the bones information from the mesh to the effect.
  14556. * @param mesh The mesh we are binding the information to render
  14557. * @param effect The effect we are binding the data to
  14558. */
  14559. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  14560. /**
  14561. * Binds the morph targets information from the mesh to the effect.
  14562. * @param abstractMesh The mesh we are binding the information to render
  14563. * @param effect The effect we are binding the data to
  14564. */
  14565. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  14566. /**
  14567. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  14568. * @param defines The generated defines used in the effect
  14569. * @param effect The effect we are binding the data to
  14570. * @param scene The scene we are willing to render with logarithmic scale for
  14571. */
  14572. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  14573. /**
  14574. * Binds the clip plane information from the scene to the effect.
  14575. * @param scene The scene the clip plane information are extracted from
  14576. * @param effect The effect we are binding the data to
  14577. */
  14578. static BindClipPlane(effect: Effect, scene: Scene): void;
  14579. }
  14580. }
  14581. declare module BABYLON {
  14582. class MultiMaterial extends Material {
  14583. private _subMaterials;
  14584. subMaterials: Nullable<Material>[];
  14585. constructor(name: string, scene: Scene);
  14586. private _hookArray(array);
  14587. getSubMaterial(index: number): Nullable<Material>;
  14588. getActiveTextures(): BaseTexture[];
  14589. getClassName(): string;
  14590. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14591. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  14592. serialize(): any;
  14593. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14594. }
  14595. }
  14596. declare module BABYLON {
  14597. class PushMaterial extends Material {
  14598. protected _activeEffect: Effect;
  14599. protected _normalMatrix: Matrix;
  14600. constructor(name: string, scene: Scene);
  14601. getEffect(): Effect;
  14602. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14603. /**
  14604. * Binds the given world matrix to the active effect
  14605. *
  14606. * @param world the matrix to bind
  14607. */
  14608. bindOnlyWorldMatrix(world: Matrix): void;
  14609. /**
  14610. * Binds the given normal matrix to the active effect
  14611. *
  14612. * @param normalMatrix the matrix to bind
  14613. */
  14614. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14615. bind(world: Matrix, mesh?: Mesh): void;
  14616. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14617. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14618. }
  14619. }
  14620. declare module BABYLON {
  14621. class ShaderMaterial extends Material {
  14622. private _shaderPath;
  14623. private _options;
  14624. private _textures;
  14625. private _textureArrays;
  14626. private _floats;
  14627. private _ints;
  14628. private _floatsArrays;
  14629. private _colors3;
  14630. private _colors3Arrays;
  14631. private _colors4;
  14632. private _vectors2;
  14633. private _vectors3;
  14634. private _vectors4;
  14635. private _matrices;
  14636. private _matrices3x3;
  14637. private _matrices2x2;
  14638. private _vectors2Arrays;
  14639. private _vectors3Arrays;
  14640. private _cachedWorldViewMatrix;
  14641. private _renderId;
  14642. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  14643. getClassName(): string;
  14644. needAlphaBlending(): boolean;
  14645. needAlphaTesting(): boolean;
  14646. private _checkUniform(uniformName);
  14647. setTexture(name: string, texture: Texture): ShaderMaterial;
  14648. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  14649. setFloat(name: string, value: number): ShaderMaterial;
  14650. setInt(name: string, value: number): ShaderMaterial;
  14651. setFloats(name: string, value: number[]): ShaderMaterial;
  14652. setColor3(name: string, value: Color3): ShaderMaterial;
  14653. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  14654. setColor4(name: string, value: Color4): ShaderMaterial;
  14655. setVector2(name: string, value: Vector2): ShaderMaterial;
  14656. setVector3(name: string, value: Vector3): ShaderMaterial;
  14657. setVector4(name: string, value: Vector4): ShaderMaterial;
  14658. setMatrix(name: string, value: Matrix): ShaderMaterial;
  14659. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  14660. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  14661. setArray2(name: string, value: number[]): ShaderMaterial;
  14662. setArray3(name: string, value: number[]): ShaderMaterial;
  14663. private _checkCache(scene, mesh?, useInstances?);
  14664. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14665. bindOnlyWorldMatrix(world: Matrix): void;
  14666. bind(world: Matrix, mesh?: Mesh): void;
  14667. getActiveTextures(): BaseTexture[];
  14668. hasTexture(texture: BaseTexture): boolean;
  14669. clone(name: string): ShaderMaterial;
  14670. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14671. serialize(): any;
  14672. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  14673. }
  14674. }
  14675. declare module BABYLON {
  14676. /** @hidden */
  14677. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  14678. MAINUV1: boolean;
  14679. MAINUV2: boolean;
  14680. DIFFUSE: boolean;
  14681. DIFFUSEDIRECTUV: number;
  14682. AMBIENT: boolean;
  14683. AMBIENTDIRECTUV: number;
  14684. OPACITY: boolean;
  14685. OPACITYDIRECTUV: number;
  14686. OPACITYRGB: boolean;
  14687. REFLECTION: boolean;
  14688. EMISSIVE: boolean;
  14689. EMISSIVEDIRECTUV: number;
  14690. SPECULAR: boolean;
  14691. SPECULARDIRECTUV: number;
  14692. BUMP: boolean;
  14693. BUMPDIRECTUV: number;
  14694. PARALLAX: boolean;
  14695. PARALLAXOCCLUSION: boolean;
  14696. SPECULAROVERALPHA: boolean;
  14697. CLIPPLANE: boolean;
  14698. ALPHATEST: boolean;
  14699. DEPTHPREPASS: boolean;
  14700. ALPHAFROMDIFFUSE: boolean;
  14701. POINTSIZE: boolean;
  14702. FOG: boolean;
  14703. SPECULARTERM: boolean;
  14704. DIFFUSEFRESNEL: boolean;
  14705. OPACITYFRESNEL: boolean;
  14706. REFLECTIONFRESNEL: boolean;
  14707. REFRACTIONFRESNEL: boolean;
  14708. EMISSIVEFRESNEL: boolean;
  14709. FRESNEL: boolean;
  14710. NORMAL: boolean;
  14711. UV1: boolean;
  14712. UV2: boolean;
  14713. VERTEXCOLOR: boolean;
  14714. VERTEXALPHA: boolean;
  14715. NUM_BONE_INFLUENCERS: number;
  14716. BonesPerMesh: number;
  14717. INSTANCES: boolean;
  14718. GLOSSINESS: boolean;
  14719. ROUGHNESS: boolean;
  14720. EMISSIVEASILLUMINATION: boolean;
  14721. LINKEMISSIVEWITHDIFFUSE: boolean;
  14722. REFLECTIONFRESNELFROMSPECULAR: boolean;
  14723. LIGHTMAP: boolean;
  14724. LIGHTMAPDIRECTUV: number;
  14725. OBJECTSPACE_NORMALMAP: boolean;
  14726. USELIGHTMAPASSHADOWMAP: boolean;
  14727. REFLECTIONMAP_3D: boolean;
  14728. REFLECTIONMAP_SPHERICAL: boolean;
  14729. REFLECTIONMAP_PLANAR: boolean;
  14730. REFLECTIONMAP_CUBIC: boolean;
  14731. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  14732. REFLECTIONMAP_PROJECTION: boolean;
  14733. REFLECTIONMAP_SKYBOX: boolean;
  14734. REFLECTIONMAP_EXPLICIT: boolean;
  14735. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  14736. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  14737. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  14738. INVERTCUBICMAP: boolean;
  14739. LOGARITHMICDEPTH: boolean;
  14740. REFRACTION: boolean;
  14741. REFRACTIONMAP_3D: boolean;
  14742. REFLECTIONOVERALPHA: boolean;
  14743. TWOSIDEDLIGHTING: boolean;
  14744. SHADOWFLOAT: boolean;
  14745. MORPHTARGETS: boolean;
  14746. MORPHTARGETS_NORMAL: boolean;
  14747. MORPHTARGETS_TANGENT: boolean;
  14748. NUM_MORPH_INFLUENCERS: number;
  14749. NONUNIFORMSCALING: boolean;
  14750. PREMULTIPLYALPHA: boolean;
  14751. IMAGEPROCESSING: boolean;
  14752. VIGNETTE: boolean;
  14753. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14754. VIGNETTEBLENDMODEOPAQUE: boolean;
  14755. TONEMAPPING: boolean;
  14756. CONTRAST: boolean;
  14757. COLORCURVES: boolean;
  14758. COLORGRADING: boolean;
  14759. COLORGRADING3D: boolean;
  14760. SAMPLER3DGREENDEPTH: boolean;
  14761. SAMPLER3DBGRMAP: boolean;
  14762. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14763. /**
  14764. * If the reflection texture on this material is in linear color space
  14765. * @hidden
  14766. */
  14767. IS_REFLECTION_LINEAR: boolean;
  14768. /**
  14769. * If the refraction texture on this material is in linear color space
  14770. * @hidden
  14771. */
  14772. IS_REFRACTION_LINEAR: boolean;
  14773. EXPOSURE: boolean;
  14774. constructor();
  14775. setReflectionMode(modeToEnable: string): void;
  14776. }
  14777. class StandardMaterial extends PushMaterial {
  14778. private _diffuseTexture;
  14779. diffuseTexture: Nullable<BaseTexture>;
  14780. private _ambientTexture;
  14781. ambientTexture: Nullable<BaseTexture>;
  14782. private _opacityTexture;
  14783. opacityTexture: Nullable<BaseTexture>;
  14784. private _reflectionTexture;
  14785. reflectionTexture: Nullable<BaseTexture>;
  14786. private _emissiveTexture;
  14787. emissiveTexture: Nullable<BaseTexture>;
  14788. private _specularTexture;
  14789. specularTexture: Nullable<BaseTexture>;
  14790. private _bumpTexture;
  14791. bumpTexture: Nullable<BaseTexture>;
  14792. private _lightmapTexture;
  14793. lightmapTexture: Nullable<BaseTexture>;
  14794. private _refractionTexture;
  14795. refractionTexture: Nullable<BaseTexture>;
  14796. ambientColor: Color3;
  14797. diffuseColor: Color3;
  14798. specularColor: Color3;
  14799. emissiveColor: Color3;
  14800. specularPower: number;
  14801. private _useAlphaFromDiffuseTexture;
  14802. useAlphaFromDiffuseTexture: boolean;
  14803. private _useEmissiveAsIllumination;
  14804. useEmissiveAsIllumination: boolean;
  14805. private _linkEmissiveWithDiffuse;
  14806. linkEmissiveWithDiffuse: boolean;
  14807. private _useSpecularOverAlpha;
  14808. useSpecularOverAlpha: boolean;
  14809. private _useReflectionOverAlpha;
  14810. useReflectionOverAlpha: boolean;
  14811. private _disableLighting;
  14812. disableLighting: boolean;
  14813. private _useObjectSpaceNormalMap;
  14814. /**
  14815. * Allows using an object space normal map (instead of tangent space).
  14816. */
  14817. useObjectSpaceNormalMap: boolean;
  14818. private _useParallax;
  14819. useParallax: boolean;
  14820. private _useParallaxOcclusion;
  14821. useParallaxOcclusion: boolean;
  14822. parallaxScaleBias: number;
  14823. private _roughness;
  14824. roughness: number;
  14825. indexOfRefraction: number;
  14826. invertRefractionY: boolean;
  14827. /**
  14828. * Defines the alpha limits in alpha test mode
  14829. */
  14830. alphaCutOff: number;
  14831. private _useLightmapAsShadowmap;
  14832. useLightmapAsShadowmap: boolean;
  14833. private _diffuseFresnelParameters;
  14834. diffuseFresnelParameters: FresnelParameters;
  14835. private _opacityFresnelParameters;
  14836. opacityFresnelParameters: FresnelParameters;
  14837. private _reflectionFresnelParameters;
  14838. reflectionFresnelParameters: FresnelParameters;
  14839. private _refractionFresnelParameters;
  14840. refractionFresnelParameters: FresnelParameters;
  14841. private _emissiveFresnelParameters;
  14842. emissiveFresnelParameters: FresnelParameters;
  14843. private _useReflectionFresnelFromSpecular;
  14844. useReflectionFresnelFromSpecular: boolean;
  14845. private _useGlossinessFromSpecularMapAlpha;
  14846. useGlossinessFromSpecularMapAlpha: boolean;
  14847. private _maxSimultaneousLights;
  14848. maxSimultaneousLights: number;
  14849. /**
  14850. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  14851. */
  14852. private _invertNormalMapX;
  14853. invertNormalMapX: boolean;
  14854. /**
  14855. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  14856. */
  14857. private _invertNormalMapY;
  14858. invertNormalMapY: boolean;
  14859. /**
  14860. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  14861. */
  14862. private _twoSidedLighting;
  14863. twoSidedLighting: boolean;
  14864. /**
  14865. * Default configuration related to image processing available in the standard Material.
  14866. */
  14867. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14868. /**
  14869. * Gets the image processing configuration used either in this material.
  14870. */
  14871. /**
  14872. * Sets the Default image processing configuration used either in the this material.
  14873. *
  14874. * If sets to null, the scene one is in use.
  14875. */
  14876. imageProcessingConfiguration: ImageProcessingConfiguration;
  14877. /**
  14878. * Keep track of the image processing observer to allow dispose and replace.
  14879. */
  14880. private _imageProcessingObserver;
  14881. /**
  14882. * Attaches a new image processing configuration to the Standard Material.
  14883. * @param configuration
  14884. */
  14885. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14886. /**
  14887. * Gets wether the color curves effect is enabled.
  14888. */
  14889. /**
  14890. * Sets wether the color curves effect is enabled.
  14891. */
  14892. cameraColorCurvesEnabled: boolean;
  14893. /**
  14894. * Gets wether the color grading effect is enabled.
  14895. */
  14896. /**
  14897. * Gets wether the color grading effect is enabled.
  14898. */
  14899. cameraColorGradingEnabled: boolean;
  14900. /**
  14901. * Gets wether tonemapping is enabled or not.
  14902. */
  14903. /**
  14904. * Sets wether tonemapping is enabled or not
  14905. */
  14906. cameraToneMappingEnabled: boolean;
  14907. /**
  14908. * The camera exposure used on this material.
  14909. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14910. * This corresponds to a photographic exposure.
  14911. */
  14912. /**
  14913. * The camera exposure used on this material.
  14914. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14915. * This corresponds to a photographic exposure.
  14916. */
  14917. cameraExposure: number;
  14918. /**
  14919. * Gets The camera contrast used on this material.
  14920. */
  14921. /**
  14922. * Sets The camera contrast used on this material.
  14923. */
  14924. cameraContrast: number;
  14925. /**
  14926. * Gets the Color Grading 2D Lookup Texture.
  14927. */
  14928. /**
  14929. * Sets the Color Grading 2D Lookup Texture.
  14930. */
  14931. cameraColorGradingTexture: Nullable<BaseTexture>;
  14932. /**
  14933. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14934. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14935. * 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;
  14936. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14937. */
  14938. /**
  14939. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14940. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14941. * 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;
  14942. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14943. */
  14944. cameraColorCurves: Nullable<ColorCurves>;
  14945. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  14946. protected _renderTargets: SmartArray<RenderTargetTexture>;
  14947. protected _worldViewProjectionMatrix: Matrix;
  14948. protected _globalAmbientColor: Color3;
  14949. protected _useLogarithmicDepth: boolean;
  14950. constructor(name: string, scene: Scene);
  14951. getClassName(): string;
  14952. useLogarithmicDepth: boolean;
  14953. needAlphaBlending(): boolean;
  14954. needAlphaTesting(): boolean;
  14955. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  14956. getAlphaTestTexture(): Nullable<BaseTexture>;
  14957. /**
  14958. * Child classes can use it to update shaders
  14959. */
  14960. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  14961. buildUniformLayout(): void;
  14962. unbind(): void;
  14963. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14964. getAnimatables(): IAnimatable[];
  14965. getActiveTextures(): BaseTexture[];
  14966. hasTexture(texture: BaseTexture): boolean;
  14967. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14968. clone(name: string): StandardMaterial;
  14969. serialize(): any;
  14970. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  14971. static _DiffuseTextureEnabled: boolean;
  14972. static DiffuseTextureEnabled: boolean;
  14973. static _AmbientTextureEnabled: boolean;
  14974. static AmbientTextureEnabled: boolean;
  14975. static _OpacityTextureEnabled: boolean;
  14976. static OpacityTextureEnabled: boolean;
  14977. static _ReflectionTextureEnabled: boolean;
  14978. static ReflectionTextureEnabled: boolean;
  14979. static _EmissiveTextureEnabled: boolean;
  14980. static EmissiveTextureEnabled: boolean;
  14981. static _SpecularTextureEnabled: boolean;
  14982. static SpecularTextureEnabled: boolean;
  14983. static _BumpTextureEnabled: boolean;
  14984. static BumpTextureEnabled: boolean;
  14985. static _LightmapTextureEnabled: boolean;
  14986. static LightmapTextureEnabled: boolean;
  14987. static _RefractionTextureEnabled: boolean;
  14988. static RefractionTextureEnabled: boolean;
  14989. static _ColorGradingTextureEnabled: boolean;
  14990. static ColorGradingTextureEnabled: boolean;
  14991. static _FresnelEnabled: boolean;
  14992. static FresnelEnabled: boolean;
  14993. }
  14994. }
  14995. declare module BABYLON {
  14996. class UniformBuffer {
  14997. private _engine;
  14998. private _buffer;
  14999. private _data;
  15000. private _bufferData;
  15001. private _dynamic?;
  15002. private _uniformLocations;
  15003. private _uniformSizes;
  15004. private _uniformLocationPointer;
  15005. private _needSync;
  15006. private _noUBO;
  15007. private _currentEffect;
  15008. private static _MAX_UNIFORM_SIZE;
  15009. private static _tempBuffer;
  15010. /**
  15011. * Wrapper for updateUniform.
  15012. * @method updateMatrix3x3
  15013. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15014. * @param {Float32Array} matrix
  15015. */
  15016. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  15017. /**
  15018. * Wrapper for updateUniform.
  15019. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15020. * @param {Float32Array} matrix
  15021. */
  15022. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  15023. /**
  15024. * Wrapper for updateUniform.
  15025. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15026. * @param {number} x
  15027. */
  15028. updateFloat: (name: string, x: number) => void;
  15029. /**
  15030. * Wrapper for updateUniform.
  15031. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15032. * @param {number} x
  15033. * @param {number} y
  15034. * @param {string} [suffix] Suffix to add to the uniform name.
  15035. */
  15036. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  15037. /**
  15038. * Wrapper for updateUniform.
  15039. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15040. * @param {number} x
  15041. * @param {number} y
  15042. * @param {number} z
  15043. * @param {string} [suffix] Suffix to add to the uniform name.
  15044. */
  15045. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  15046. /**
  15047. * Wrapper for updateUniform.
  15048. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15049. * @param {number} x
  15050. * @param {number} y
  15051. * @param {number} z
  15052. * @param {number} w
  15053. * @param {string} [suffix] Suffix to add to the uniform name.
  15054. */
  15055. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  15056. /**
  15057. * Wrapper for updateUniform.
  15058. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15059. * @param {Matrix} A 4x4 matrix.
  15060. */
  15061. updateMatrix: (name: string, mat: Matrix) => void;
  15062. /**
  15063. * Wrapper for updateUniform.
  15064. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15065. * @param {Vector3} vector
  15066. */
  15067. updateVector3: (name: string, vector: Vector3) => void;
  15068. /**
  15069. * Wrapper for updateUniform.
  15070. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15071. * @param {Vector4} vector
  15072. */
  15073. updateVector4: (name: string, vector: Vector4) => void;
  15074. /**
  15075. * Wrapper for updateUniform.
  15076. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15077. * @param {Color3} color
  15078. * @param {string} [suffix] Suffix to add to the uniform name.
  15079. */
  15080. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  15081. /**
  15082. * Wrapper for updateUniform.
  15083. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15084. * @param {Color3} color
  15085. * @param {number} alpha
  15086. * @param {string} [suffix] Suffix to add to the uniform name.
  15087. */
  15088. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  15089. /**
  15090. * Uniform buffer objects.
  15091. *
  15092. * Handles blocks of uniform on the GPU.
  15093. *
  15094. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  15095. *
  15096. * For more information, please refer to :
  15097. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  15098. */
  15099. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  15100. /**
  15101. * Indicates if the buffer is using the WebGL2 UBO implementation,
  15102. * or just falling back on setUniformXXX calls.
  15103. */
  15104. readonly useUbo: boolean;
  15105. /**
  15106. * Indicates if the WebGL underlying uniform buffer is in sync
  15107. * with the javascript cache data.
  15108. */
  15109. readonly isSync: boolean;
  15110. /**
  15111. * Indicates if the WebGL underlying uniform buffer is dynamic.
  15112. * Also, a dynamic UniformBuffer will disable cache verification and always
  15113. * update the underlying WebGL uniform buffer to the GPU.
  15114. */
  15115. isDynamic(): boolean;
  15116. /**
  15117. * The data cache on JS side.
  15118. */
  15119. getData(): Float32Array;
  15120. /**
  15121. * The underlying WebGL Uniform buffer.
  15122. */
  15123. getBuffer(): Nullable<WebGLBuffer>;
  15124. /**
  15125. * std140 layout specifies how to align data within an UBO structure.
  15126. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  15127. * for specs.
  15128. */
  15129. private _fillAlignment(size);
  15130. /**
  15131. * Adds an uniform in the buffer.
  15132. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  15133. * for the layout to be correct !
  15134. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15135. * @param {number|number[]} size Data size, or data directly.
  15136. */
  15137. addUniform(name: string, size: number | number[]): void;
  15138. /**
  15139. * Wrapper for addUniform.
  15140. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15141. * @param {Matrix} mat A 4x4 matrix.
  15142. */
  15143. addMatrix(name: string, mat: Matrix): void;
  15144. /**
  15145. * Wrapper for addUniform.
  15146. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15147. * @param {number} x
  15148. * @param {number} y
  15149. */
  15150. addFloat2(name: string, x: number, y: number): void;
  15151. /**
  15152. * Wrapper for addUniform.
  15153. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15154. * @param {number} x
  15155. * @param {number} y
  15156. * @param {number} z
  15157. */
  15158. addFloat3(name: string, x: number, y: number, z: number): void;
  15159. /**
  15160. * Wrapper for addUniform.
  15161. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15162. * @param {Color3} color
  15163. */
  15164. addColor3(name: string, color: Color3): void;
  15165. /**
  15166. * Wrapper for addUniform.
  15167. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15168. * @param {Color3} color
  15169. * @param {number} alpha
  15170. */
  15171. addColor4(name: string, color: Color3, alpha: number): void;
  15172. /**
  15173. * Wrapper for addUniform.
  15174. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15175. * @param {Vector3} vector
  15176. */
  15177. addVector3(name: string, vector: Vector3): void;
  15178. /**
  15179. * Wrapper for addUniform.
  15180. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15181. */
  15182. addMatrix3x3(name: string): void;
  15183. /**
  15184. * Wrapper for addUniform.
  15185. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15186. */
  15187. addMatrix2x2(name: string): void;
  15188. /**
  15189. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  15190. */
  15191. create(): void;
  15192. _rebuild(): void;
  15193. /**
  15194. * Updates the WebGL Uniform Buffer on the GPU.
  15195. * If the `dynamic` flag is set to true, no cache comparison is done.
  15196. * Otherwise, the buffer will be updated only if the cache differs.
  15197. */
  15198. update(): void;
  15199. /**
  15200. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  15201. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15202. * @param {number[]|Float32Array} data Flattened data
  15203. * @param {number} size Size of the data.
  15204. */
  15205. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  15206. private _updateMatrix3x3ForUniform(name, matrix);
  15207. private _updateMatrix3x3ForEffect(name, matrix);
  15208. private _updateMatrix2x2ForEffect(name, matrix);
  15209. private _updateMatrix2x2ForUniform(name, matrix);
  15210. private _updateFloatForEffect(name, x);
  15211. private _updateFloatForUniform(name, x);
  15212. private _updateFloat2ForEffect(name, x, y, suffix?);
  15213. private _updateFloat2ForUniform(name, x, y, suffix?);
  15214. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  15215. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  15216. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  15217. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  15218. private _updateMatrixForEffect(name, mat);
  15219. private _updateMatrixForUniform(name, mat);
  15220. private _updateVector3ForEffect(name, vector);
  15221. private _updateVector3ForUniform(name, vector);
  15222. private _updateVector4ForEffect(name, vector);
  15223. private _updateVector4ForUniform(name, vector);
  15224. private _updateColor3ForEffect(name, color, suffix?);
  15225. private _updateColor3ForUniform(name, color, suffix?);
  15226. private _updateColor4ForEffect(name, color, alpha, suffix?);
  15227. private _updateColor4ForUniform(name, color, alpha, suffix?);
  15228. /**
  15229. * Sets a sampler uniform on the effect.
  15230. * @param {string} name Name of the sampler.
  15231. * @param {Texture} texture
  15232. */
  15233. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  15234. /**
  15235. * Directly updates the value of the uniform in the cache AND on the GPU.
  15236. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15237. * @param {number[]|Float32Array} data Flattened data
  15238. */
  15239. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  15240. /**
  15241. * Binds this uniform buffer to an effect.
  15242. * @param {Effect} effect
  15243. * @param {string} name Name of the uniform block in the shader.
  15244. */
  15245. bindToEffect(effect: Effect, name: string): void;
  15246. /**
  15247. * Disposes the uniform buffer.
  15248. */
  15249. dispose(): void;
  15250. }
  15251. }
  15252. declare module BABYLON {
  15253. class Scalar {
  15254. /**
  15255. * Two pi constants convenient for computation.
  15256. */
  15257. static TwoPi: number;
  15258. /**
  15259. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  15260. */
  15261. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  15262. /**
  15263. * Returns a string : the upper case translation of the number i to hexadecimal.
  15264. */
  15265. static ToHex(i: number): string;
  15266. /**
  15267. * Returns -1 if value is negative and +1 is value is positive.
  15268. * Returns the value itself if it's equal to zero.
  15269. */
  15270. static Sign(value: number): number;
  15271. /**
  15272. * Returns the value itself if it's between min and max.
  15273. * Returns min if the value is lower than min.
  15274. * Returns max if the value is greater than max.
  15275. */
  15276. static Clamp(value: number, min?: number, max?: number): number;
  15277. /**
  15278. * Returns the log2 of value.
  15279. */
  15280. static Log2(value: number): number;
  15281. /**
  15282. * Loops the value, so that it is never larger than length and never smaller than 0.
  15283. *
  15284. * This is similar to the modulo operator but it works with floating point numbers.
  15285. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  15286. * With t = 5 and length = 2.5, the result would be 0.0.
  15287. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  15288. */
  15289. static Repeat(value: number, length: number): number;
  15290. /**
  15291. * Normalize the value between 0.0 and 1.0 using min and max values
  15292. */
  15293. static Normalize(value: number, min: number, max: number): number;
  15294. /**
  15295. * Denormalize the value from 0.0 and 1.0 using min and max values
  15296. */
  15297. static Denormalize(normalized: number, min: number, max: number): number;
  15298. /**
  15299. * Calculates the shortest difference between two given angles given in degrees.
  15300. */
  15301. static DeltaAngle(current: number, target: number): number;
  15302. /**
  15303. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  15304. *
  15305. * The returned value will move back and forth between 0 and length
  15306. */
  15307. static PingPong(tx: number, length: number): number;
  15308. /**
  15309. * Interpolates between min and max with smoothing at the limits.
  15310. *
  15311. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  15312. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  15313. */
  15314. static SmoothStep(from: number, to: number, tx: number): number;
  15315. /**
  15316. * Moves a value current towards target.
  15317. *
  15318. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  15319. * Negative values of maxDelta pushes the value away from target.
  15320. */
  15321. static MoveTowards(current: number, target: number, maxDelta: number): number;
  15322. /**
  15323. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15324. *
  15325. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  15326. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  15327. */
  15328. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  15329. /**
  15330. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  15331. */
  15332. static Lerp(start: number, end: number, amount: number): number;
  15333. /**
  15334. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15335. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  15336. */
  15337. static LerpAngle(start: number, end: number, amount: number): number;
  15338. /**
  15339. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  15340. */
  15341. static InverseLerp(a: number, b: number, value: number): number;
  15342. /**
  15343. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  15344. */
  15345. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  15346. /**
  15347. * Returns a random float number between and min and max values
  15348. */
  15349. static RandomRange(min: number, max: number): number;
  15350. /**
  15351. * This function returns percentage of a number in a given range.
  15352. *
  15353. * RangeToPercent(40,20,60) will return 0.5 (50%)
  15354. * RangeToPercent(34,0,100) will return 0.34 (34%)
  15355. */
  15356. static RangeToPercent(number: number, min: number, max: number): number;
  15357. /**
  15358. * This function returns number that corresponds to the percentage in a given range.
  15359. *
  15360. * PercentToRange(0.34,0,100) will return 34.
  15361. */
  15362. static PercentToRange(percent: number, min: number, max: number): number;
  15363. /**
  15364. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  15365. * @param angle The angle to normalize in radian.
  15366. * @return The converted angle.
  15367. */
  15368. static NormalizeRadians(angle: number): number;
  15369. }
  15370. }
  15371. declare module BABYLON {
  15372. const ToGammaSpace: number;
  15373. const ToLinearSpace = 2.2;
  15374. const Epsilon = 0.001;
  15375. /**
  15376. * Class used to hold a RBG color
  15377. */
  15378. class Color3 {
  15379. /**
  15380. * Defines the red component (between 0 and 1, default is 0)
  15381. */
  15382. r: number;
  15383. /**
  15384. * Defines the green component (between 0 and 1, default is 0)
  15385. */
  15386. g: number;
  15387. /**
  15388. * Defines the blue component (between 0 and 1, default is 0)
  15389. */
  15390. b: number;
  15391. /**
  15392. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  15393. * @param r defines the red component (between 0 and 1, default is 0)
  15394. * @param g defines the green component (between 0 and 1, default is 0)
  15395. * @param b defines the blue component (between 0 and 1, default is 0)
  15396. */
  15397. constructor(
  15398. /**
  15399. * Defines the red component (between 0 and 1, default is 0)
  15400. */
  15401. r?: number,
  15402. /**
  15403. * Defines the green component (between 0 and 1, default is 0)
  15404. */
  15405. g?: number,
  15406. /**
  15407. * Defines the blue component (between 0 and 1, default is 0)
  15408. */
  15409. b?: number);
  15410. /**
  15411. * Creates a string with the Color3 current values
  15412. * @returns the string representation of the Color3 object
  15413. */
  15414. toString(): string;
  15415. /**
  15416. * Returns the string "Color3"
  15417. * @returns "Color3"
  15418. */
  15419. getClassName(): string;
  15420. /**
  15421. * Compute the Color3 hash code
  15422. * @returns an unique number that can be used to hash Color3 objects
  15423. */
  15424. getHashCode(): number;
  15425. /**
  15426. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  15427. * @param array defines the array where to store the r,g,b components
  15428. * @param index defines an optional index in the target array to define where to start storing values
  15429. * @returns the current Color3 object
  15430. */
  15431. toArray(array: FloatArray, index?: number): Color3;
  15432. /**
  15433. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  15434. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  15435. * @returns a new {BABYLON.Color4} object
  15436. */
  15437. toColor4(alpha?: number): Color4;
  15438. /**
  15439. * Returns a new array populated with 3 numeric elements : red, green and blue values
  15440. * @returns the new array
  15441. */
  15442. asArray(): number[];
  15443. /**
  15444. * Returns the luminance value
  15445. * @returns a float value
  15446. */
  15447. toLuminance(): number;
  15448. /**
  15449. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  15450. * @param otherColor defines the second operand
  15451. * @returns the new Color3 object
  15452. */
  15453. multiply(otherColor: Color3): Color3;
  15454. /**
  15455. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  15456. * @param otherColor defines the second operand
  15457. * @param result defines the Color3 object where to store the result
  15458. * @returns the current Color3
  15459. */
  15460. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  15461. /**
  15462. * Determines equality between Color3 objects
  15463. * @param otherColor defines the second operand
  15464. * @returns true if the rgb values are equal to the given ones
  15465. */
  15466. equals(otherColor: Color3): boolean;
  15467. /**
  15468. * Determines equality between the current Color3 object and a set of r,b,g values
  15469. * @param r defines the red component to check
  15470. * @param g defines the green component to check
  15471. * @param b defines the blue component to check
  15472. * @returns true if the rgb values are equal to the given ones
  15473. */
  15474. equalsFloats(r: number, g: number, b: number): boolean;
  15475. /**
  15476. * Multiplies in place each rgb value by scale
  15477. * @param scale defines the scaling factor
  15478. * @returns the updated Color3
  15479. */
  15480. scale(scale: number): Color3;
  15481. /**
  15482. * Multiplies the rgb values by scale and stores the result into "result"
  15483. * @param scale defines the scaling factor
  15484. * @param result defines the Color3 object where to store the result
  15485. * @returns the unmodified current Color3
  15486. */
  15487. scaleToRef(scale: number, result: Color3): Color3;
  15488. /**
  15489. * Scale the current Color3 values by a factor and add the result to a given Color3
  15490. * @param scale defines the scale factor
  15491. * @param result defines color to store the result into
  15492. * @returns the unmodified current Color3
  15493. */
  15494. scaleAndAddToRef(scale: number, result: Color3): Color3;
  15495. /**
  15496. * Clamps the rgb values by the min and max values and stores the result into "result"
  15497. * @param min defines minimum clamping value (default is 0)
  15498. * @param max defines maximum clamping value (default is 1)
  15499. * @param result defines color to store the result into
  15500. * @returns the original Color3
  15501. */
  15502. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  15503. /**
  15504. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  15505. * @param otherColor defines the second operand
  15506. * @returns the new Color3
  15507. */
  15508. add(otherColor: Color3): Color3;
  15509. /**
  15510. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  15511. * @param otherColor defines the second operand
  15512. * @param result defines Color3 object to store the result into
  15513. * @returns the unmodified current Color3
  15514. */
  15515. addToRef(otherColor: Color3, result: Color3): Color3;
  15516. /**
  15517. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  15518. * @param otherColor defines the second operand
  15519. * @returns the new Color3
  15520. */
  15521. subtract(otherColor: Color3): Color3;
  15522. /**
  15523. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  15524. * @param otherColor defines the second operand
  15525. * @param result defines Color3 object to store the result into
  15526. * @returns the unmodified current Color3
  15527. */
  15528. subtractToRef(otherColor: Color3, result: Color3): Color3;
  15529. /**
  15530. * Copy the current object
  15531. * @returns a new Color3 copied the current one
  15532. */
  15533. clone(): Color3;
  15534. /**
  15535. * Copies the rgb values from the source in the current Color3
  15536. * @param source defines the source Color3 object
  15537. * @returns the updated Color3 object
  15538. */
  15539. copyFrom(source: Color3): Color3;
  15540. /**
  15541. * Updates the Color3 rgb values from the given floats
  15542. * @param r defines the red component to read from
  15543. * @param g defines the green component to read from
  15544. * @param b defines the blue component to read from
  15545. * @returns the current Color3 object
  15546. */
  15547. copyFromFloats(r: number, g: number, b: number): Color3;
  15548. /**
  15549. * Updates the Color3 rgb values from the given floats
  15550. * @param r defines the red component to read from
  15551. * @param g defines the green component to read from
  15552. * @param b defines the blue component to read from
  15553. * @returns the current Color3 object
  15554. */
  15555. set(r: number, g: number, b: number): Color3;
  15556. /**
  15557. * Compute the Color3 hexadecimal code as a string
  15558. * @returns a string containing the hexadecimal representation of the Color3 object
  15559. */
  15560. toHexString(): string;
  15561. /**
  15562. * Computes a new Color3 converted from the current one to linear space
  15563. * @returns a new Color3 object
  15564. */
  15565. toLinearSpace(): Color3;
  15566. /**
  15567. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  15568. * @param convertedColor defines the Color3 object where to store the linear space version
  15569. * @returns the unmodified Color3
  15570. */
  15571. toLinearSpaceToRef(convertedColor: Color3): Color3;
  15572. /**
  15573. * Computes a new Color3 converted from the current one to gamma space
  15574. * @returns a new Color3 object
  15575. */
  15576. toGammaSpace(): Color3;
  15577. /**
  15578. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  15579. * @param convertedColor defines the Color3 object where to store the gamma space version
  15580. * @returns the unmodified Color3
  15581. */
  15582. toGammaSpaceToRef(convertedColor: Color3): Color3;
  15583. /**
  15584. * Creates a new Color3 from the string containing valid hexadecimal values
  15585. * @param hex defines a string containing valid hexadecimal values
  15586. * @returns a new Color3 object
  15587. */
  15588. static FromHexString(hex: string): Color3;
  15589. /**
  15590. * Creates a new Vector3 from the starting index of the given array
  15591. * @param array defines the source array
  15592. * @param offset defines an offset in the source array
  15593. * @returns a new Color3 object
  15594. */
  15595. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  15596. /**
  15597. * Creates a new Color3 from integer values (< 256)
  15598. * @param r defines the red component to read from (value between 0 and 255)
  15599. * @param g defines the green component to read from (value between 0 and 255)
  15600. * @param b defines the blue component to read from (value between 0 and 255)
  15601. * @returns a new Color3 object
  15602. */
  15603. static FromInts(r: number, g: number, b: number): Color3;
  15604. /**
  15605. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  15606. * @param start defines the start Color3 value
  15607. * @param end defines the end Color3 value
  15608. * @param amount defines the gradient value between start and end
  15609. * @returns a new Color3 object
  15610. */
  15611. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  15612. /**
  15613. * Returns a Color3 value containing a red color
  15614. * @returns a new Color3 object
  15615. */
  15616. static Red(): Color3;
  15617. /**
  15618. * Returns a Color3 value containing a green color
  15619. * @returns a new Color3 object
  15620. */
  15621. static Green(): Color3;
  15622. /**
  15623. * Returns a Color3 value containing a blue color
  15624. * @returns a new Color3 object
  15625. */
  15626. static Blue(): Color3;
  15627. /**
  15628. * Returns a Color3 value containing a black color
  15629. * @returns a new Color3 object
  15630. */
  15631. static Black(): Color3;
  15632. /**
  15633. * Returns a Color3 value containing a white color
  15634. * @returns a new Color3 object
  15635. */
  15636. static White(): Color3;
  15637. /**
  15638. * Returns a Color3 value containing a purple color
  15639. * @returns a new Color3 object
  15640. */
  15641. static Purple(): Color3;
  15642. /**
  15643. * Returns a Color3 value containing a magenta color
  15644. * @returns a new Color3 object
  15645. */
  15646. static Magenta(): Color3;
  15647. /**
  15648. * Returns a Color3 value containing a yellow color
  15649. * @returns a new Color3 object
  15650. */
  15651. static Yellow(): Color3;
  15652. /**
  15653. * Returns a Color3 value containing a gray color
  15654. * @returns a new Color3 object
  15655. */
  15656. static Gray(): Color3;
  15657. /**
  15658. * Returns a Color3 value containing a teal color
  15659. * @returns a new Color3 object
  15660. */
  15661. static Teal(): Color3;
  15662. /**
  15663. * Returns a Color3 value containing a random color
  15664. * @returns a new Color3 object
  15665. */
  15666. static Random(): Color3;
  15667. }
  15668. /**
  15669. * Class used to hold a RBGA color
  15670. */
  15671. class Color4 {
  15672. /**
  15673. * Defines the red component (between 0 and 1, default is 0)
  15674. */
  15675. r: number;
  15676. /**
  15677. * Defines the green component (between 0 and 1, default is 0)
  15678. */
  15679. g: number;
  15680. /**
  15681. * Defines the blue component (between 0 and 1, default is 0)
  15682. */
  15683. b: number;
  15684. /**
  15685. * Defines the alpha component (between 0 and 1, default is 1)
  15686. */
  15687. a: number;
  15688. /**
  15689. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  15690. * @param r defines the red component (between 0 and 1, default is 0)
  15691. * @param g defines the green component (between 0 and 1, default is 0)
  15692. * @param b defines the blue component (between 0 and 1, default is 0)
  15693. * @param a defines the alpha component (between 0 and 1, default is 1)
  15694. */
  15695. constructor(
  15696. /**
  15697. * Defines the red component (between 0 and 1, default is 0)
  15698. */
  15699. r?: number,
  15700. /**
  15701. * Defines the green component (between 0 and 1, default is 0)
  15702. */
  15703. g?: number,
  15704. /**
  15705. * Defines the blue component (between 0 and 1, default is 0)
  15706. */
  15707. b?: number,
  15708. /**
  15709. * Defines the alpha component (between 0 and 1, default is 1)
  15710. */
  15711. a?: number);
  15712. /**
  15713. * Adds in place the given Color4 values to the current Color4 object
  15714. * @param right defines the second operand
  15715. * @returns the current updated Color4 object
  15716. */
  15717. addInPlace(right: Color4): Color4;
  15718. /**
  15719. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  15720. * @returns the new array
  15721. */
  15722. asArray(): number[];
  15723. /**
  15724. * Stores from the starting index in the given array the Color4 successive values
  15725. * @param array defines the array where to store the r,g,b components
  15726. * @param index defines an optional index in the target array to define where to start storing values
  15727. * @returns the current Color4 object
  15728. */
  15729. toArray(array: number[], index?: number): Color4;
  15730. /**
  15731. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  15732. * @param right defines the second operand
  15733. * @returns a new Color4 object
  15734. */
  15735. add(right: Color4): Color4;
  15736. /**
  15737. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  15738. * @param right defines the second operand
  15739. * @returns a new Color4 object
  15740. */
  15741. subtract(right: Color4): Color4;
  15742. /**
  15743. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  15744. * @param right defines the second operand
  15745. * @param result defines the Color4 object where to store the result
  15746. * @returns the current Color4 object
  15747. */
  15748. subtractToRef(right: Color4, result: Color4): Color4;
  15749. /**
  15750. * Creates a new Color4 with the current Color4 values multiplied by scale
  15751. * @param scale defines the scaling factor to apply
  15752. * @returns a new Color4 object
  15753. */
  15754. scale(scale: number): Color4;
  15755. /**
  15756. * Multiplies the current Color4 values by scale and stores the result in "result"
  15757. * @param scale defines the scaling factor to apply
  15758. * @param result defines the Color4 object where to store the result
  15759. * @returns the current unmodified Color4
  15760. */
  15761. scaleToRef(scale: number, result: Color4): Color4;
  15762. /**
  15763. * Scale the current Color4 values by a factor and add the result to a given Color4
  15764. * @param scale defines the scale factor
  15765. * @param result defines the Color4 object where to store the result
  15766. * @returns the unmodified current Color4
  15767. */
  15768. scaleAndAddToRef(scale: number, result: Color4): Color4;
  15769. /**
  15770. * Clamps the rgb values by the min and max values and stores the result into "result"
  15771. * @param min defines minimum clamping value (default is 0)
  15772. * @param max defines maximum clamping value (default is 1)
  15773. * @param result defines color to store the result into.
  15774. * @returns the cuurent Color4
  15775. */
  15776. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  15777. /**
  15778. * Multipy an Color4 value by another and return a new Color4 object
  15779. * @param color defines the Color4 value to multiply by
  15780. * @returns a new Color4 object
  15781. */
  15782. multiply(color: Color4): Color4;
  15783. /**
  15784. * Multipy a Color4 value by another and push the result in a reference value
  15785. * @param color defines the Color4 value to multiply by
  15786. * @param result defines the Color4 to fill the result in
  15787. * @returns the result Color4
  15788. */
  15789. multiplyToRef(color: Color4, result: Color4): Color4;
  15790. /**
  15791. * Creates a string with the Color4 current values
  15792. * @returns the string representation of the Color4 object
  15793. */
  15794. toString(): string;
  15795. /**
  15796. * Returns the string "Color4"
  15797. * @returns "Color4"
  15798. */
  15799. getClassName(): string;
  15800. /**
  15801. * Compute the Color4 hash code
  15802. * @returns an unique number that can be used to hash Color4 objects
  15803. */
  15804. getHashCode(): number;
  15805. /**
  15806. * Creates a new Color4 copied from the current one
  15807. * @returns a new Color4 object
  15808. */
  15809. clone(): Color4;
  15810. /**
  15811. * Copies the given Color4 values into the current one
  15812. * @param source defines the source Color4 object
  15813. * @returns the current updated Color4 object
  15814. */
  15815. copyFrom(source: Color4): Color4;
  15816. /**
  15817. * Copies the given float values into the current one
  15818. * @param r defines the red component to read from
  15819. * @param g defines the green component to read from
  15820. * @param b defines the blue component to read from
  15821. * @param a defines the alpha component to read from
  15822. * @returns the current updated Color4 object
  15823. */
  15824. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  15825. /**
  15826. * Copies the given float values into the current one
  15827. * @param r defines the red component to read from
  15828. * @param g defines the green component to read from
  15829. * @param b defines the blue component to read from
  15830. * @param a defines the alpha component to read from
  15831. * @returns the current updated Color4 object
  15832. */
  15833. set(r: number, g: number, b: number, a: number): Color4;
  15834. /**
  15835. * Compute the Color4 hexadecimal code as a string
  15836. * @returns a string containing the hexadecimal representation of the Color4 object
  15837. */
  15838. toHexString(): string;
  15839. /**
  15840. * Computes a new Color4 converted from the current one to linear space
  15841. * @returns a new Color4 object
  15842. */
  15843. toLinearSpace(): Color4;
  15844. /**
  15845. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  15846. * @param convertedColor defines the Color4 object where to store the linear space version
  15847. * @returns the unmodified Color4
  15848. */
  15849. toLinearSpaceToRef(convertedColor: Color4): Color4;
  15850. /**
  15851. * Computes a new Color4 converted from the current one to gamma space
  15852. * @returns a new Color4 object
  15853. */
  15854. toGammaSpace(): Color4;
  15855. /**
  15856. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  15857. * @param convertedColor defines the Color4 object where to store the gamma space version
  15858. * @returns the unmodified Color4
  15859. */
  15860. toGammaSpaceToRef(convertedColor: Color4): Color4;
  15861. /**
  15862. * Creates a new Color4 from the string containing valid hexadecimal values
  15863. * @param hex defines a string containing valid hexadecimal values
  15864. * @returns a new Color4 object
  15865. */
  15866. static FromHexString(hex: string): Color4;
  15867. /**
  15868. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15869. * @param left defines the start value
  15870. * @param right defines the end value
  15871. * @param amount defines the gradient factor
  15872. * @returns a new Color4 object
  15873. */
  15874. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  15875. /**
  15876. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15877. * @param left defines the start value
  15878. * @param right defines the end value
  15879. * @param amount defines the gradient factor
  15880. * @param result defines the Color4 object where to store data
  15881. */
  15882. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  15883. /**
  15884. * Creates a new Color4 from the starting index element of the given array
  15885. * @param array defines the source array to read from
  15886. * @param offset defines the offset in the source array
  15887. * @returns a new Color4 object
  15888. */
  15889. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  15890. /**
  15891. * Creates a new Color3 from integer values (< 256)
  15892. * @param r defines the red component to read from (value between 0 and 255)
  15893. * @param g defines the green component to read from (value between 0 and 255)
  15894. * @param b defines the blue component to read from (value between 0 and 255)
  15895. * @param a defines the alpha component to read from (value between 0 and 255)
  15896. * @returns a new Color3 object
  15897. */
  15898. static FromInts(r: number, g: number, b: number, a: number): Color4;
  15899. /**
  15900. * Check the content of a given array and convert it to an array containing RGBA data
  15901. * If the original array was already containing count * 4 values then it is returned directly
  15902. * @param colors defines the array to check
  15903. * @param count defines the number of RGBA data to expect
  15904. * @returns an array containing count * 4 values (RGBA)
  15905. */
  15906. static CheckColors4(colors: number[], count: number): number[];
  15907. }
  15908. /**
  15909. * Class representing a vector containing 2 coordinates
  15910. */
  15911. class Vector2 {
  15912. /** defines the first coordinate */
  15913. x: number;
  15914. /** defines the second coordinate */
  15915. y: number;
  15916. /**
  15917. * Creates a new Vector2 from the given x and y coordinates
  15918. * @param x defines the first coordinate
  15919. * @param y defines the second coordinate
  15920. */
  15921. constructor(
  15922. /** defines the first coordinate */
  15923. x?: number,
  15924. /** defines the second coordinate */
  15925. y?: number);
  15926. /**
  15927. * Gets a string with the Vector2 coordinates
  15928. * @returns a string with the Vector2 coordinates
  15929. */
  15930. toString(): string;
  15931. /**
  15932. * Gets class name
  15933. * @returns the string "Vector2"
  15934. */
  15935. getClassName(): string;
  15936. /**
  15937. * Gets current vector hash code
  15938. * @returns the Vector2 hash code as a number
  15939. */
  15940. getHashCode(): number;
  15941. /**
  15942. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  15943. * @param array defines the source array
  15944. * @param index defines the offset in source array
  15945. * @returns the current Vector2
  15946. */
  15947. toArray(array: FloatArray, index?: number): Vector2;
  15948. /**
  15949. * Copy the current vector to an array
  15950. * @returns a new array with 2 elements: the Vector2 coordinates.
  15951. */
  15952. asArray(): number[];
  15953. /**
  15954. * Sets the Vector2 coordinates with the given Vector2 coordinates
  15955. * @param source defines the source Vector2
  15956. * @returns the current updated Vector2
  15957. */
  15958. copyFrom(source: Vector2): Vector2;
  15959. /**
  15960. * Sets the Vector2 coordinates with the given floats
  15961. * @param x defines the first coordinate
  15962. * @param y defines the second coordinate
  15963. * @returns the current updated Vector2
  15964. */
  15965. copyFromFloats(x: number, y: number): Vector2;
  15966. /**
  15967. * Sets the Vector2 coordinates with the given floats
  15968. * @param x defines the first coordinate
  15969. * @param y defines the second coordinate
  15970. * @returns the current updated Vector2
  15971. */
  15972. set(x: number, y: number): Vector2;
  15973. /**
  15974. * Add another vector with the current one
  15975. * @param otherVector defines the other vector
  15976. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  15977. */
  15978. add(otherVector: Vector2): Vector2;
  15979. /**
  15980. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  15981. * @param otherVector defines the other vector
  15982. * @param result defines the target vector
  15983. * @returns the unmodified current Vector2
  15984. */
  15985. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  15986. /**
  15987. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  15988. * @param otherVector defines the other vector
  15989. * @returns the current updated Vector2
  15990. */
  15991. addInPlace(otherVector: Vector2): Vector2;
  15992. /**
  15993. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  15994. * @param otherVector defines the other vector
  15995. * @returns a new Vector2
  15996. */
  15997. addVector3(otherVector: Vector3): Vector2;
  15998. /**
  15999. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  16000. * @param otherVector defines the other vector
  16001. * @returns a new Vector2
  16002. */
  16003. subtract(otherVector: Vector2): Vector2;
  16004. /**
  16005. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  16006. * @param otherVector defines the other vector
  16007. * @param result defines the target vector
  16008. * @returns the unmodified current Vector2
  16009. */
  16010. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  16011. /**
  16012. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  16013. * @param otherVector defines the other vector
  16014. * @returns the current updated Vector2
  16015. */
  16016. subtractInPlace(otherVector: Vector2): Vector2;
  16017. /**
  16018. * Multiplies in place the current Vector2 coordinates by the given ones
  16019. * @param otherVector defines the other vector
  16020. * @returns the current updated Vector2
  16021. */
  16022. multiplyInPlace(otherVector: Vector2): Vector2;
  16023. /**
  16024. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  16025. * @param otherVector defines the other vector
  16026. * @returns a new Vector2
  16027. */
  16028. multiply(otherVector: Vector2): Vector2;
  16029. /**
  16030. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  16031. * @param otherVector defines the other vector
  16032. * @param result defines the target vector
  16033. * @returns the unmodified current Vector2
  16034. */
  16035. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  16036. /**
  16037. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  16038. * @param x defines the first coordinate
  16039. * @param y defines the second coordinate
  16040. * @returns a new Vector2
  16041. */
  16042. multiplyByFloats(x: number, y: number): Vector2;
  16043. /**
  16044. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  16045. * @param otherVector defines the other vector
  16046. * @returns a new Vector2
  16047. */
  16048. divide(otherVector: Vector2): Vector2;
  16049. /**
  16050. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  16051. * @param otherVector defines the other vector
  16052. * @param result defines the target vector
  16053. * @returns the unmodified current Vector2
  16054. */
  16055. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  16056. /**
  16057. * Divides the current Vector3 coordinates by the given ones
  16058. * @param otherVector defines the other vector
  16059. * @returns the current updated Vector2
  16060. */
  16061. divideInPlace(otherVector: Vector2): Vector2;
  16062. /**
  16063. * Gets a new Vector2 with current Vector2 negated coordinates
  16064. * @returns a new Vector2
  16065. */
  16066. negate(): Vector2;
  16067. /**
  16068. * Multiply the Vector2 coordinates by scale
  16069. * @param scale defines the scaling factor
  16070. * @returns the current updated Vector2
  16071. */
  16072. scaleInPlace(scale: number): Vector2;
  16073. /**
  16074. * Returns a new Vector2 scaled by "scale" from the current Vector2
  16075. * @param scale defines the scaling factor
  16076. * @returns a new Vector2
  16077. */
  16078. scale(scale: number): Vector2;
  16079. /**
  16080. * Scale the current Vector2 values by a factor to a given Vector2
  16081. * @param scale defines the scale factor
  16082. * @param result defines the Vector2 object where to store the result
  16083. * @returns the unmodified current Vector2
  16084. */
  16085. scaleToRef(scale: number, result: Vector2): Vector2;
  16086. /**
  16087. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  16088. * @param scale defines the scale factor
  16089. * @param result defines the Vector2 object where to store the result
  16090. * @returns the unmodified current Vector2
  16091. */
  16092. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  16093. /**
  16094. * Gets a boolean if two vectors are equals
  16095. * @param otherVector defines the other vector
  16096. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  16097. */
  16098. equals(otherVector: Vector2): boolean;
  16099. /**
  16100. * Gets a boolean if two vectors are equals (using an epsilon value)
  16101. * @param otherVector defines the other vector
  16102. * @param epsilon defines the minimal distance to consider equality
  16103. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  16104. */
  16105. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  16106. /**
  16107. * Gets the length of the vector
  16108. * @returns the vector length (float)
  16109. */
  16110. length(): number;
  16111. /**
  16112. * Gets the vector squared length
  16113. * @returns the vector squared length (float)
  16114. */
  16115. lengthSquared(): number;
  16116. /**
  16117. * Normalize the vector
  16118. * @returns the current updated Vector2
  16119. */
  16120. normalize(): Vector2;
  16121. /**
  16122. * Gets a new Vector2 copied from the Vector2
  16123. * @returns a new Vector2
  16124. */
  16125. clone(): Vector2;
  16126. /**
  16127. * Gets a new Vector2(0, 0)
  16128. * @returns a new Vector2
  16129. */
  16130. static Zero(): Vector2;
  16131. /**
  16132. * Gets a new Vector2(1, 1)
  16133. * @returns a new Vector2
  16134. */
  16135. static One(): Vector2;
  16136. /**
  16137. * Gets a new Vector2 set from the given index element of the given array
  16138. * @param array defines the data source
  16139. * @param offset defines the offset in the data source
  16140. * @returns a new Vector2
  16141. */
  16142. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  16143. /**
  16144. * Sets "result" from the given index element of the given array
  16145. * @param array defines the data source
  16146. * @param offset defines the offset in the data source
  16147. * @param result defines the target vector
  16148. */
  16149. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  16150. /**
  16151. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  16152. * @param value1 defines 1st point of control
  16153. * @param value2 defines 2nd point of control
  16154. * @param value3 defines 3rd point of control
  16155. * @param value4 defines 4th point of control
  16156. * @param amount defines the interpolation factor
  16157. * @returns a new Vector2
  16158. */
  16159. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  16160. /**
  16161. * 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".
  16162. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  16163. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  16164. * @param value defines the value to clamp
  16165. * @param min defines the lower limit
  16166. * @param max defines the upper limit
  16167. * @returns a new Vector2
  16168. */
  16169. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  16170. /**
  16171. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  16172. * @param value1 defines the 1st control point
  16173. * @param tangent1 defines the outgoing tangent
  16174. * @param value2 defines the 2nd control point
  16175. * @param tangent2 defines the incoming tangent
  16176. * @param amount defines the interpolation factor
  16177. * @returns a new Vector2
  16178. */
  16179. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  16180. /**
  16181. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  16182. * @param start defines the start vector
  16183. * @param end defines the end vector
  16184. * @param amount defines the interpolation factor
  16185. * @returns a new Vector2
  16186. */
  16187. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  16188. /**
  16189. * Gets the dot product of the vector "left" and the vector "right"
  16190. * @param left defines first vector
  16191. * @param right defines second vector
  16192. * @returns the dot product (float)
  16193. */
  16194. static Dot(left: Vector2, right: Vector2): number;
  16195. /**
  16196. * Returns a new Vector2 equal to the normalized given vector
  16197. * @param vector defines the vector to normalize
  16198. * @returns a new Vector2
  16199. */
  16200. static Normalize(vector: Vector2): Vector2;
  16201. /**
  16202. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  16203. * @param left defines 1st vector
  16204. * @param right defines 2nd vector
  16205. * @returns a new Vector2
  16206. */
  16207. static Minimize(left: Vector2, right: Vector2): Vector2;
  16208. /**
  16209. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  16210. * @param left defines 1st vector
  16211. * @param right defines 2nd vector
  16212. * @returns a new Vector2
  16213. */
  16214. static Maximize(left: Vector2, right: Vector2): Vector2;
  16215. /**
  16216. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  16217. * @param vector defines the vector to transform
  16218. * @param transformation defines the matrix to apply
  16219. * @returns a new Vector2
  16220. */
  16221. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  16222. /**
  16223. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  16224. * @param vector defines the vector to transform
  16225. * @param transformation defines the matrix to apply
  16226. * @param result defines the target vector
  16227. */
  16228. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  16229. /**
  16230. * Determines if a given vector is included in a triangle
  16231. * @param p defines the vector to test
  16232. * @param p0 defines 1st triangle point
  16233. * @param p1 defines 2nd triangle point
  16234. * @param p2 defines 3rd triangle point
  16235. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  16236. */
  16237. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  16238. /**
  16239. * Gets the distance between the vectors "value1" and "value2"
  16240. * @param value1 defines first vector
  16241. * @param value2 defines second vector
  16242. * @returns the distance between vectors
  16243. */
  16244. static Distance(value1: Vector2, value2: Vector2): number;
  16245. /**
  16246. * Returns the squared distance between the vectors "value1" and "value2"
  16247. * @param value1 defines first vector
  16248. * @param value2 defines second vector
  16249. * @returns the squared distance between vectors
  16250. */
  16251. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  16252. /**
  16253. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  16254. * @param value1 defines first vector
  16255. * @param value2 defines second vector
  16256. * @returns a new Vector2
  16257. */
  16258. static Center(value1: Vector2, value2: Vector2): Vector2;
  16259. /**
  16260. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  16261. * @param p defines the middle point
  16262. * @param segA defines one point of the segment
  16263. * @param segB defines the other point of the segment
  16264. * @returns the shortest distance
  16265. */
  16266. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  16267. }
  16268. /**
  16269. * Classed used to store (x,y,z) vector representation
  16270. * A Vector3 is the main object used in 3D geometry
  16271. * It can represent etiher the coordinates of a point the space, either a direction
  16272. * Reminder: Babylon.js uses a left handed forward facing system
  16273. */
  16274. class Vector3 {
  16275. /**
  16276. * Defines the first coordinates (on X axis)
  16277. */
  16278. x: number;
  16279. /**
  16280. * Defines the second coordinates (on Y axis)
  16281. */
  16282. y: number;
  16283. /**
  16284. * Defines the third coordinates (on Z axis)
  16285. */
  16286. z: number;
  16287. /**
  16288. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  16289. * @param x defines the first coordinates (on X axis)
  16290. * @param y defines the second coordinates (on Y axis)
  16291. * @param z defines the third coordinates (on Z axis)
  16292. */
  16293. constructor(
  16294. /**
  16295. * Defines the first coordinates (on X axis)
  16296. */
  16297. x?: number,
  16298. /**
  16299. * Defines the second coordinates (on Y axis)
  16300. */
  16301. y?: number,
  16302. /**
  16303. * Defines the third coordinates (on Z axis)
  16304. */
  16305. z?: number);
  16306. /**
  16307. * Creates a string representation of the Vector3
  16308. * @returns a string with the Vector3 coordinates.
  16309. */
  16310. toString(): string;
  16311. /**
  16312. * Gets the class name
  16313. * @returns the string "Vector3"
  16314. */
  16315. getClassName(): string;
  16316. /**
  16317. * Creates the Vector3 hash code
  16318. * @returns a number which tends to be unique between Vector3 instances
  16319. */
  16320. getHashCode(): number;
  16321. /**
  16322. * Creates an array containing three elements : the coordinates of the Vector3
  16323. * @returns a new array of numbers
  16324. */
  16325. asArray(): number[];
  16326. /**
  16327. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  16328. * @param array defines the destination array
  16329. * @param index defines the offset in the destination array
  16330. * @returns the current Vector3
  16331. */
  16332. toArray(array: FloatArray, index?: number): Vector3;
  16333. /**
  16334. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  16335. * @returns a new Quaternion object, computed from the Vector3 coordinates
  16336. */
  16337. toQuaternion(): Quaternion;
  16338. /**
  16339. * Adds the given vector to the current Vector3
  16340. * @param otherVector defines the second operand
  16341. * @returns the current updated Vector3
  16342. */
  16343. addInPlace(otherVector: Vector3): Vector3;
  16344. /**
  16345. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  16346. * @param otherVector defines the second operand
  16347. * @returns the resulting Vector3
  16348. */
  16349. add(otherVector: Vector3): Vector3;
  16350. /**
  16351. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  16352. * @param otherVector defines the second operand
  16353. * @param result defines the Vector3 object where to store the result
  16354. * @returns the current Vector3
  16355. */
  16356. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  16357. /**
  16358. * Subtract the given vector from the current Vector3
  16359. * @param otherVector defines the second operand
  16360. * @returns the current updated Vector3
  16361. */
  16362. subtractInPlace(otherVector: Vector3): Vector3;
  16363. /**
  16364. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  16365. * @param otherVector defines the second operand
  16366. * @returns the resulting Vector3
  16367. */
  16368. subtract(otherVector: Vector3): Vector3;
  16369. /**
  16370. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  16371. * @param otherVector defines the second operand
  16372. * @param result defines the Vector3 object where to store the result
  16373. * @returns the current Vector3
  16374. */
  16375. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  16376. /**
  16377. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  16378. * @param x defines the x coordinate of the operand
  16379. * @param y defines the y coordinate of the operand
  16380. * @param z defines the z coordinate of the operand
  16381. * @returns the resulting Vector3
  16382. */
  16383. subtractFromFloats(x: number, y: number, z: number): Vector3;
  16384. /**
  16385. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  16386. * @param x defines the x coordinate of the operand
  16387. * @param y defines the y coordinate of the operand
  16388. * @param z defines the z coordinate of the operand
  16389. * @param result defines the Vector3 object where to store the result
  16390. * @returns the current Vector3
  16391. */
  16392. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  16393. /**
  16394. * Gets a new Vector3 set with the current Vector3 negated coordinates
  16395. * @returns a new Vector3
  16396. */
  16397. negate(): Vector3;
  16398. /**
  16399. * Multiplies the Vector3 coordinates by the float "scale"
  16400. * @param scale defines the multiplier factor
  16401. * @returns the current updated Vector3
  16402. */
  16403. scaleInPlace(scale: number): Vector3;
  16404. /**
  16405. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  16406. * @param scale defines the multiplier factor
  16407. * @returns a new Vector3
  16408. */
  16409. scale(scale: number): Vector3;
  16410. /**
  16411. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  16412. * @param scale defines the multiplier factor
  16413. * @param result defines the Vector3 object where to store the result
  16414. * @returns the current Vector3
  16415. */
  16416. scaleToRef(scale: number, result: Vector3): Vector3;
  16417. /**
  16418. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  16419. * @param scale defines the scale factor
  16420. * @param result defines the Vector3 object where to store the result
  16421. * @returns the unmodified current Vector3
  16422. */
  16423. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  16424. /**
  16425. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  16426. * @param otherVector defines the second operand
  16427. * @returns true if both vectors are equals
  16428. */
  16429. equals(otherVector: Vector3): boolean;
  16430. /**
  16431. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  16432. * @param otherVector defines the second operand
  16433. * @param epsilon defines the minimal distance to define values as equals
  16434. * @returns true if both vectors are distant less than epsilon
  16435. */
  16436. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  16437. /**
  16438. * Returns true if the current Vector3 coordinates equals the given floats
  16439. * @param x defines the x coordinate of the operand
  16440. * @param y defines the y coordinate of the operand
  16441. * @param z defines the z coordinate of the operand
  16442. * @returns true if both vectors are equals
  16443. */
  16444. equalsToFloats(x: number, y: number, z: number): boolean;
  16445. /**
  16446. * Multiplies the current Vector3 coordinates by the given ones
  16447. * @param otherVector defines the second operand
  16448. * @returns the current updated Vector3
  16449. */
  16450. multiplyInPlace(otherVector: Vector3): Vector3;
  16451. /**
  16452. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  16453. * @param otherVector defines the second operand
  16454. * @returns the new Vector3
  16455. */
  16456. multiply(otherVector: Vector3): Vector3;
  16457. /**
  16458. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  16459. * @param otherVector defines the second operand
  16460. * @param result defines the Vector3 object where to store the result
  16461. * @returns the current Vector3
  16462. */
  16463. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  16464. /**
  16465. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  16466. * @param x defines the x coordinate of the operand
  16467. * @param y defines the y coordinate of the operand
  16468. * @param z defines the z coordinate of the operand
  16469. * @returns the new Vector3
  16470. */
  16471. multiplyByFloats(x: number, y: number, z: number): Vector3;
  16472. /**
  16473. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  16474. * @param otherVector defines the second operand
  16475. * @returns the new Vector3
  16476. */
  16477. divide(otherVector: Vector3): Vector3;
  16478. /**
  16479. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  16480. * @param otherVector defines the second operand
  16481. * @param result defines the Vector3 object where to store the result
  16482. * @returns the current Vector3
  16483. */
  16484. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  16485. /**
  16486. * Divides the current Vector3 coordinates by the given ones.
  16487. * @param otherVector defines the second operand
  16488. * @returns the current updated Vector3
  16489. */
  16490. divideInPlace(otherVector: Vector3): Vector3;
  16491. /**
  16492. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  16493. * @param other defines the second operand
  16494. * @returns the current updated Vector3
  16495. */
  16496. minimizeInPlace(other: Vector3): Vector3;
  16497. /**
  16498. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  16499. * @param other defines the second operand
  16500. * @returns the current updated Vector3
  16501. */
  16502. maximizeInPlace(other: Vector3): Vector3;
  16503. /**
  16504. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  16505. */
  16506. readonly isNonUniform: boolean;
  16507. /**
  16508. * Gets the length of the Vector3
  16509. * @returns the length of the Vecto3
  16510. */
  16511. length(): number;
  16512. /**
  16513. * Gets the squared length of the Vector3
  16514. * @returns squared length of the Vector3
  16515. */
  16516. lengthSquared(): number;
  16517. /**
  16518. * Normalize the current Vector3.
  16519. * Please note that this is an in place operation.
  16520. * @returns the current updated Vector3
  16521. */
  16522. normalize(): Vector3;
  16523. /**
  16524. * Normalize the current Vector3 to a new vector
  16525. * @returns the new Vector3
  16526. */
  16527. normalizeToNew(): Vector3;
  16528. /**
  16529. * Normalize the current Vector3 to the reference
  16530. * @param reference define the Vector3 to update
  16531. * @returns the updated Vector3
  16532. */
  16533. normalizeToRef(reference: Vector3): Vector3;
  16534. /**
  16535. * Creates a new Vector3 copied from the current Vector3
  16536. * @returns the new Vector3
  16537. */
  16538. clone(): Vector3;
  16539. /**
  16540. * Copies the given vector coordinates to the current Vector3 ones
  16541. * @param source defines the source Vector3
  16542. * @returns the current updated Vector3
  16543. */
  16544. copyFrom(source: Vector3): Vector3;
  16545. /**
  16546. * Copies the given floats to the current Vector3 coordinates
  16547. * @param x defines the x coordinate of the operand
  16548. * @param y defines the y coordinate of the operand
  16549. * @param z defines the z coordinate of the operand
  16550. * @returns the current updated Vector3
  16551. */
  16552. copyFromFloats(x: number, y: number, z: number): Vector3;
  16553. /**
  16554. * Copies the given floats to the current Vector3 coordinates
  16555. * @param x defines the x coordinate of the operand
  16556. * @param y defines the y coordinate of the operand
  16557. * @param z defines the z coordinate of the operand
  16558. * @returns the current updated Vector3
  16559. */
  16560. set(x: number, y: number, z: number): Vector3;
  16561. /**
  16562. * Get the clip factor between two vectors
  16563. * @param vector0 defines the first operand
  16564. * @param vector1 defines the second operand
  16565. * @param axis defines the axis to use
  16566. * @param size defines the size along the axis
  16567. * @returns the clip factor
  16568. */
  16569. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  16570. /**
  16571. * Get angle between two vectors
  16572. * @param vector0 angle between vector0 and vector1
  16573. * @param vector1 angle between vector0 and vector1
  16574. * @param normal direction of the normal
  16575. * @return the angle between vector0 and vector1
  16576. */
  16577. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  16578. /**
  16579. * Returns a new Vector3 set from the index "offset" of the given array
  16580. * @param array defines the source array
  16581. * @param offset defines the offset in the source array
  16582. * @returns the new Vector3
  16583. */
  16584. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  16585. /**
  16586. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  16587. * This function is deprecated. Use FromArray instead
  16588. * @param array defines the source array
  16589. * @param offset defines the offset in the source array
  16590. * @returns the new Vector3
  16591. */
  16592. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  16593. /**
  16594. * Sets the given vector "result" with the element values from the index "offset" of the given array
  16595. * @param array defines the source array
  16596. * @param offset defines the offset in the source array
  16597. * @param result defines the Vector3 where to store the result
  16598. */
  16599. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  16600. /**
  16601. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  16602. * This function is deprecated. Use FromArrayToRef instead.
  16603. * @param array defines the source array
  16604. * @param offset defines the offset in the source array
  16605. * @param result defines the Vector3 where to store the result
  16606. */
  16607. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  16608. /**
  16609. * Sets the given vector "result" with the given floats.
  16610. * @param x defines the x coordinate of the source
  16611. * @param y defines the y coordinate of the source
  16612. * @param z defines the z coordinate of the source
  16613. * @param result defines the Vector3 where to store the result
  16614. */
  16615. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  16616. /**
  16617. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  16618. * @returns a new empty Vector3
  16619. */
  16620. static Zero(): Vector3;
  16621. /**
  16622. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  16623. * @returns a new unit Vector3
  16624. */
  16625. static One(): Vector3;
  16626. /**
  16627. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  16628. * @returns a new up Vector3
  16629. */
  16630. static Up(): Vector3;
  16631. /**
  16632. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  16633. * @returns a new down Vector3
  16634. */
  16635. static Down(): Vector3;
  16636. /**
  16637. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  16638. * @returns a new forward Vector3
  16639. */
  16640. static Forward(): Vector3;
  16641. /**
  16642. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  16643. * @returns a new right Vector3
  16644. */
  16645. static Right(): Vector3;
  16646. /**
  16647. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  16648. * @returns a new left Vector3
  16649. */
  16650. static Left(): Vector3;
  16651. /**
  16652. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  16653. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16654. * @param vector defines the Vector3 to transform
  16655. * @param transformation defines the transformation matrix
  16656. * @returns the transformed Vector3
  16657. */
  16658. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  16659. /**
  16660. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  16661. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16662. * @param vector defines the Vector3 to transform
  16663. * @param transformation defines the transformation matrix
  16664. * @param result defines the Vector3 where to store the result
  16665. */
  16666. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16667. /**
  16668. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  16669. * This method computes tranformed coordinates only, not transformed direction vectors
  16670. * @param x define the x coordinate of the source vector
  16671. * @param y define the y coordinate of the source vector
  16672. * @param z define the z coordinate of the source vector
  16673. * @param transformation defines the transformation matrix
  16674. * @param result defines the Vector3 where to store the result
  16675. */
  16676. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16677. /**
  16678. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  16679. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16680. * @param vector defines the Vector3 to transform
  16681. * @param transformation defines the transformation matrix
  16682. * @returns the new Vector3
  16683. */
  16684. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  16685. /**
  16686. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  16687. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16688. * @param vector defines the Vector3 to transform
  16689. * @param transformation defines the transformation matrix
  16690. * @param result defines the Vector3 where to store the result
  16691. */
  16692. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16693. /**
  16694. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  16695. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16696. * @param x define the x coordinate of the source vector
  16697. * @param y define the y coordinate of the source vector
  16698. * @param z define the z coordinate of the source vector
  16699. * @param transformation defines the transformation matrix
  16700. * @param result defines the Vector3 where to store the result
  16701. */
  16702. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16703. /**
  16704. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  16705. * @param value1 defines the first control point
  16706. * @param value2 defines the second control point
  16707. * @param value3 defines the third control point
  16708. * @param value4 defines the fourth control point
  16709. * @param amount defines the amount on the spline to use
  16710. * @returns the new Vector3
  16711. */
  16712. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  16713. /**
  16714. * 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"
  16715. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  16716. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  16717. * @param value defines the current value
  16718. * @param min defines the lower range value
  16719. * @param max defines the upper range value
  16720. * @returns the new Vector3
  16721. */
  16722. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  16723. /**
  16724. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  16725. * @param value1 defines the first control point
  16726. * @param tangent1 defines the first tangent vector
  16727. * @param value2 defines the second control point
  16728. * @param tangent2 defines the second tangent vector
  16729. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  16730. * @returns the new Vector3
  16731. */
  16732. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  16733. /**
  16734. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  16735. * @param start defines the start value
  16736. * @param end defines the end value
  16737. * @param amount max defines amount between both (between 0 and 1)
  16738. * @returns the new Vector3
  16739. */
  16740. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  16741. /**
  16742. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  16743. * @param start defines the start value
  16744. * @param end defines the end value
  16745. * @param amount max defines amount between both (between 0 and 1)
  16746. * @param result defines the Vector3 where to store the result
  16747. */
  16748. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  16749. /**
  16750. * Returns the dot product (float) between the vectors "left" and "right"
  16751. * @param left defines the left operand
  16752. * @param right defines the right operand
  16753. * @returns the dot product
  16754. */
  16755. static Dot(left: Vector3, right: Vector3): number;
  16756. /**
  16757. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  16758. * The cross product is then orthogonal to both "left" and "right"
  16759. * @param left defines the left operand
  16760. * @param right defines the right operand
  16761. * @returns the cross product
  16762. */
  16763. static Cross(left: Vector3, right: Vector3): Vector3;
  16764. /**
  16765. * Sets the given vector "result" with the cross product of "left" and "right"
  16766. * The cross product is then orthogonal to both "left" and "right"
  16767. * @param left defines the left operand
  16768. * @param right defines the right operand
  16769. * @param result defines the Vector3 where to store the result
  16770. */
  16771. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  16772. /**
  16773. * Returns a new Vector3 as the normalization of the given vector
  16774. * @param vector defines the Vector3 to normalize
  16775. * @returns the new Vector3
  16776. */
  16777. static Normalize(vector: Vector3): Vector3;
  16778. /**
  16779. * Sets the given vector "result" with the normalization of the given first vector
  16780. * @param vector defines the Vector3 to normalize
  16781. * @param result defines the Vector3 where to store the result
  16782. */
  16783. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  16784. private static _viewportMatrixCache;
  16785. /**
  16786. * Project a Vector3 onto screen space
  16787. * @param vector defines the Vector3 to project
  16788. * @param world defines the world matrix to use
  16789. * @param transform defines the transform (view x projection) matrix to use
  16790. * @param viewport defines the screen viewport to use
  16791. * @returns the new Vector3
  16792. */
  16793. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  16794. /**
  16795. * Unproject from screen space to object space
  16796. * @param source defines the screen space Vector3 to use
  16797. * @param viewportWidth defines the current width of the viewport
  16798. * @param viewportHeight defines the current height of the viewport
  16799. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16800. * @param transform defines the transform (view x projection) matrix to use
  16801. * @returns the new Vector3
  16802. */
  16803. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  16804. /**
  16805. * Unproject from screen space to object space
  16806. * @param source defines the screen space Vector3 to use
  16807. * @param viewportWidth defines the current width of the viewport
  16808. * @param viewportHeight defines the current height of the viewport
  16809. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16810. * @param view defines the view matrix to use
  16811. * @param projection defines the projection matrix to use
  16812. * @returns the new Vector3
  16813. */
  16814. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  16815. /**
  16816. * Unproject from screen space to object space
  16817. * @param source defines the screen space Vector3 to use
  16818. * @param viewportWidth defines the current width of the viewport
  16819. * @param viewportHeight defines the current height of the viewport
  16820. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16821. * @param view defines the view matrix to use
  16822. * @param projection defines the projection matrix to use
  16823. * @param result defines the Vector3 where to store the result
  16824. */
  16825. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16826. /**
  16827. * Unproject from screen space to object space
  16828. * @param sourceX defines the screen space x coordinate to use
  16829. * @param sourceY defines the screen space y coordinate to use
  16830. * @param sourceZ defines the screen space z coordinate to use
  16831. * @param viewportWidth defines the current width of the viewport
  16832. * @param viewportHeight defines the current height of the viewport
  16833. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16834. * @param view defines the view matrix to use
  16835. * @param projection defines the projection matrix to use
  16836. * @param result defines the Vector3 where to store the result
  16837. */
  16838. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16839. /**
  16840. * Gets the minimal coordinate values between two Vector3
  16841. * @param left defines the first operand
  16842. * @param right defines the second operand
  16843. * @returns the new Vector3
  16844. */
  16845. static Minimize(left: Vector3, right: Vector3): Vector3;
  16846. /**
  16847. * Gets the maximal coordinate values between two Vector3
  16848. * @param left defines the first operand
  16849. * @param right defines the second operand
  16850. * @returns the new Vector3
  16851. */
  16852. static Maximize(left: Vector3, right: Vector3): Vector3;
  16853. /**
  16854. * Returns the distance between the vectors "value1" and "value2"
  16855. * @param value1 defines the first operand
  16856. * @param value2 defines the second operand
  16857. * @returns the distance
  16858. */
  16859. static Distance(value1: Vector3, value2: Vector3): number;
  16860. /**
  16861. * Returns the squared distance between the vectors "value1" and "value2"
  16862. * @param value1 defines the first operand
  16863. * @param value2 defines the second operand
  16864. * @returns the squared distance
  16865. */
  16866. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  16867. /**
  16868. * Returns a new Vector3 located at the center between "value1" and "value2"
  16869. * @param value1 defines the first operand
  16870. * @param value2 defines the second operand
  16871. * @returns the new Vector3
  16872. */
  16873. static Center(value1: Vector3, value2: Vector3): Vector3;
  16874. /**
  16875. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  16876. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  16877. * to something in order to rotate it from its local system to the given target system
  16878. * Note: axis1, axis2 and axis3 are normalized during this operation
  16879. * @param axis1 defines the first axis
  16880. * @param axis2 defines the second axis
  16881. * @param axis3 defines the third axis
  16882. * @returns a new Vector3
  16883. */
  16884. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  16885. /**
  16886. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  16887. * @param axis1 defines the first axis
  16888. * @param axis2 defines the second axis
  16889. * @param axis3 defines the third axis
  16890. * @param ref defines the Vector3 where to store the result
  16891. */
  16892. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  16893. }
  16894. class Vector4 {
  16895. x: number;
  16896. y: number;
  16897. z: number;
  16898. w: number;
  16899. /**
  16900. * Creates a Vector4 object from the given floats.
  16901. */
  16902. constructor(x: number, y: number, z: number, w: number);
  16903. /**
  16904. * Returns the string with the Vector4 coordinates.
  16905. */
  16906. toString(): string;
  16907. /**
  16908. * Returns the string "Vector4".
  16909. */
  16910. getClassName(): string;
  16911. /**
  16912. * Returns the Vector4 hash code.
  16913. */
  16914. getHashCode(): number;
  16915. /**
  16916. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  16917. */
  16918. asArray(): number[];
  16919. /**
  16920. * Populates the given array from the given index with the Vector4 coordinates.
  16921. * Returns the Vector4.
  16922. */
  16923. toArray(array: FloatArray, index?: number): Vector4;
  16924. /**
  16925. * Adds the given vector to the current Vector4.
  16926. * Returns the updated Vector4.
  16927. */
  16928. addInPlace(otherVector: Vector4): Vector4;
  16929. /**
  16930. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  16931. */
  16932. add(otherVector: Vector4): Vector4;
  16933. /**
  16934. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  16935. * Returns the current Vector4.
  16936. */
  16937. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  16938. /**
  16939. * Subtract in place the given vector from the current Vector4.
  16940. * Returns the updated Vector4.
  16941. */
  16942. subtractInPlace(otherVector: Vector4): Vector4;
  16943. /**
  16944. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  16945. */
  16946. subtract(otherVector: Vector4): Vector4;
  16947. /**
  16948. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  16949. * Returns the current Vector4.
  16950. */
  16951. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  16952. /**
  16953. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16954. */
  16955. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16956. /**
  16957. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16958. * Returns the current Vector4.
  16959. */
  16960. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  16961. /**
  16962. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  16963. */
  16964. negate(): Vector4;
  16965. /**
  16966. * Multiplies the current Vector4 coordinates by scale (float).
  16967. * Returns the updated Vector4.
  16968. */
  16969. scaleInPlace(scale: number): Vector4;
  16970. /**
  16971. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  16972. */
  16973. scale(scale: number): Vector4;
  16974. /**
  16975. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  16976. * Returns the current Vector4.
  16977. */
  16978. scaleToRef(scale: number, result: Vector4): Vector4;
  16979. /**
  16980. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  16981. * @param scale defines the scale factor
  16982. * @param result defines the Vector4 object where to store the result
  16983. * @returns the unmodified current Vector4
  16984. */
  16985. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  16986. /**
  16987. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  16988. */
  16989. equals(otherVector: Vector4): boolean;
  16990. /**
  16991. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  16992. */
  16993. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  16994. /**
  16995. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  16996. */
  16997. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  16998. /**
  16999. * Multiplies in place the current Vector4 by the given one.
  17000. * Returns the updated Vector4.
  17001. */
  17002. multiplyInPlace(otherVector: Vector4): Vector4;
  17003. /**
  17004. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  17005. */
  17006. multiply(otherVector: Vector4): Vector4;
  17007. /**
  17008. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  17009. * Returns the current Vector4.
  17010. */
  17011. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  17012. /**
  17013. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  17014. */
  17015. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  17016. /**
  17017. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  17018. */
  17019. divide(otherVector: Vector4): Vector4;
  17020. /**
  17021. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  17022. * Returns the current Vector4.
  17023. */
  17024. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  17025. /**
  17026. * Divides the current Vector3 coordinates by the given ones.
  17027. * @returns the updated Vector3.
  17028. */
  17029. divideInPlace(otherVector: Vector4): Vector4;
  17030. /**
  17031. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  17032. * @param other defines the second operand
  17033. * @returns the current updated Vector4
  17034. */
  17035. minimizeInPlace(other: Vector4): Vector4;
  17036. /**
  17037. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  17038. * @param other defines the second operand
  17039. * @returns the current updated Vector4
  17040. */
  17041. maximizeInPlace(other: Vector4): Vector4;
  17042. /**
  17043. * Returns the Vector4 length (float).
  17044. */
  17045. length(): number;
  17046. /**
  17047. * Returns the Vector4 squared length (float).
  17048. */
  17049. lengthSquared(): number;
  17050. /**
  17051. * Normalizes in place the Vector4.
  17052. * Returns the updated Vector4.
  17053. */
  17054. normalize(): Vector4;
  17055. /**
  17056. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  17057. */
  17058. toVector3(): Vector3;
  17059. /**
  17060. * Returns a new Vector4 copied from the current one.
  17061. */
  17062. clone(): Vector4;
  17063. /**
  17064. * Updates the current Vector4 with the given one coordinates.
  17065. * Returns the updated Vector4.
  17066. */
  17067. copyFrom(source: Vector4): Vector4;
  17068. /**
  17069. * Updates the current Vector4 coordinates with the given floats.
  17070. * Returns the updated Vector4.
  17071. */
  17072. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17073. /**
  17074. * Updates the current Vector4 coordinates with the given floats.
  17075. * Returns the updated Vector4.
  17076. */
  17077. set(x: number, y: number, z: number, w: number): Vector4;
  17078. /**
  17079. * Returns a new Vector4 set from the starting index of the given array.
  17080. */
  17081. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  17082. /**
  17083. * Updates the given vector "result" from the starting index of the given array.
  17084. */
  17085. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  17086. /**
  17087. * Updates the given vector "result" from the starting index of the given Float32Array.
  17088. */
  17089. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  17090. /**
  17091. * Updates the given vector "result" coordinates from the given floats.
  17092. */
  17093. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  17094. /**
  17095. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  17096. */
  17097. static Zero(): Vector4;
  17098. /**
  17099. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  17100. */
  17101. static One(): Vector4;
  17102. /**
  17103. * Returns a new normalized Vector4 from the given one.
  17104. */
  17105. static Normalize(vector: Vector4): Vector4;
  17106. /**
  17107. * Updates the given vector "result" from the normalization of the given one.
  17108. */
  17109. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  17110. static Minimize(left: Vector4, right: Vector4): Vector4;
  17111. static Maximize(left: Vector4, right: Vector4): Vector4;
  17112. /**
  17113. * Returns the distance (float) between the vectors "value1" and "value2".
  17114. */
  17115. static Distance(value1: Vector4, value2: Vector4): number;
  17116. /**
  17117. * Returns the squared distance (float) between the vectors "value1" and "value2".
  17118. */
  17119. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  17120. /**
  17121. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  17122. */
  17123. static Center(value1: Vector4, value2: Vector4): Vector4;
  17124. /**
  17125. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  17126. * This methods computes transformed normalized direction vectors only.
  17127. */
  17128. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  17129. /**
  17130. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  17131. * This methods computes transformed normalized direction vectors only.
  17132. */
  17133. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  17134. /**
  17135. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  17136. * This methods computes transformed normalized direction vectors only.
  17137. */
  17138. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  17139. }
  17140. interface ISize {
  17141. width: number;
  17142. height: number;
  17143. }
  17144. class Size implements ISize {
  17145. width: number;
  17146. height: number;
  17147. /**
  17148. * Creates a Size object from the given width and height (floats).
  17149. */
  17150. constructor(width: number, height: number);
  17151. toString(): string;
  17152. /**
  17153. * Returns the string "Size"
  17154. */
  17155. getClassName(): string;
  17156. /**
  17157. * Returns the Size hash code.
  17158. */
  17159. getHashCode(): number;
  17160. /**
  17161. * Updates the current size from the given one.
  17162. * Returns the updated Size.
  17163. */
  17164. copyFrom(src: Size): void;
  17165. /**
  17166. * Updates in place the current Size from the given floats.
  17167. * Returns the updated Size.
  17168. */
  17169. copyFromFloats(width: number, height: number): Size;
  17170. /**
  17171. * Updates in place the current Size from the given floats.
  17172. * Returns the updated Size.
  17173. */
  17174. set(width: number, height: number): Size;
  17175. /**
  17176. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  17177. */
  17178. multiplyByFloats(w: number, h: number): Size;
  17179. /**
  17180. * Returns a new Size copied from the given one.
  17181. */
  17182. clone(): Size;
  17183. /**
  17184. * Boolean : True if the current Size and the given one width and height are strictly equal.
  17185. */
  17186. equals(other: Size): boolean;
  17187. /**
  17188. * Returns the surface of the Size : width * height (float).
  17189. */
  17190. readonly surface: number;
  17191. /**
  17192. * Returns a new Size set to (0.0, 0.0)
  17193. */
  17194. static Zero(): Size;
  17195. /**
  17196. * Returns a new Size set as the addition result of the current Size and the given one.
  17197. */
  17198. add(otherSize: Size): Size;
  17199. /**
  17200. * Returns a new Size set as the subtraction result of the given one from the current Size.
  17201. */
  17202. subtract(otherSize: Size): Size;
  17203. /**
  17204. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  17205. */
  17206. static Lerp(start: Size, end: Size, amount: number): Size;
  17207. }
  17208. /**
  17209. * Class used to store quaternion data
  17210. * @see https://en.wikipedia.org/wiki/Quaternion
  17211. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  17212. */
  17213. class Quaternion {
  17214. /** defines the first component (0 by default) */
  17215. x: number;
  17216. /** defines the second component (0 by default) */
  17217. y: number;
  17218. /** defines the third component (0 by default) */
  17219. z: number;
  17220. /** defines the fourth component (1.0 by default) */
  17221. w: number;
  17222. /**
  17223. * Creates a new Quaternion from the given floats
  17224. * @param x defines the first component (0 by default)
  17225. * @param y defines the second component (0 by default)
  17226. * @param z defines the third component (0 by default)
  17227. * @param w defines the fourth component (1.0 by default)
  17228. */
  17229. constructor(
  17230. /** defines the first component (0 by default) */
  17231. x?: number,
  17232. /** defines the second component (0 by default) */
  17233. y?: number,
  17234. /** defines the third component (0 by default) */
  17235. z?: number,
  17236. /** defines the fourth component (1.0 by default) */
  17237. w?: number);
  17238. /**
  17239. * Gets a string representation for the current quaternion
  17240. * @returns a string with the Quaternion coordinates
  17241. */
  17242. toString(): string;
  17243. /**
  17244. * Gets the class name of the quaternion
  17245. * @returns the string "Quaternion"
  17246. */
  17247. getClassName(): string;
  17248. /**
  17249. * Gets a hash code for this quaternion
  17250. * @returns the quaternion hash code
  17251. */
  17252. getHashCode(): number;
  17253. /**
  17254. * Copy the quaternion to an array
  17255. * @returns a new array populated with 4 elements from the quaternion coordinates
  17256. */
  17257. asArray(): number[];
  17258. /**
  17259. * Check if two quaternions are equals
  17260. * @param otherQuaternion defines the second operand
  17261. * @return true if the current quaternion and the given one coordinates are strictly equals
  17262. */
  17263. equals(otherQuaternion: Quaternion): boolean;
  17264. /**
  17265. * Clone the current quaternion
  17266. * @returns a new quaternion copied from the current one
  17267. */
  17268. clone(): Quaternion;
  17269. /**
  17270. * Copy a quaternion to the current one
  17271. * @param other defines the other quaternion
  17272. * @returns the updated current quaternion
  17273. */
  17274. copyFrom(other: Quaternion): Quaternion;
  17275. /**
  17276. * Updates the current quaternion with the given float coordinates
  17277. * @param x defines the x coordinate
  17278. * @param y defines the y coordinate
  17279. * @param z defines the z coordinate
  17280. * @param w defines the w coordinate
  17281. * @returns the updated current quaternion
  17282. */
  17283. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  17284. /**
  17285. * Updates the current quaternion from the given float coordinates
  17286. * @param x defines the x coordinate
  17287. * @param y defines the y coordinate
  17288. * @param z defines the z coordinate
  17289. * @param w defines the w coordinate
  17290. * @returns the updated current quaternion
  17291. */
  17292. set(x: number, y: number, z: number, w: number): Quaternion;
  17293. /**
  17294. * Adds two quaternions
  17295. * @param other defines the second operand
  17296. * @returns a new quaternion as the addition result of the given one and the current quaternion
  17297. */
  17298. add(other: Quaternion): Quaternion;
  17299. /**
  17300. * Add a quaternion to the current one
  17301. * @param other defines the quaternion to add
  17302. * @returns the current quaternion
  17303. */
  17304. addInPlace(other: Quaternion): Quaternion;
  17305. /**
  17306. * Subtract two quaternions
  17307. * @param other defines the second operand
  17308. * @returns a new quaternion as the subtraction result of the given one from the current one
  17309. */
  17310. subtract(other: Quaternion): Quaternion;
  17311. /**
  17312. * Multiplies the current quaternion by a scale factor
  17313. * @param value defines the scale factor
  17314. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  17315. */
  17316. scale(value: number): Quaternion;
  17317. /**
  17318. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  17319. * @param scale defines the scale factor
  17320. * @param result defines the Quaternion object where to store the result
  17321. * @returns the unmodified current quaternion
  17322. */
  17323. scaleToRef(scale: number, result: Quaternion): Quaternion;
  17324. /**
  17325. * Multiplies in place the current quaternion by a scale factor
  17326. * @param value defines the scale factor
  17327. * @returns the current modified quaternion
  17328. */
  17329. scaleInPlace(value: number): Quaternion;
  17330. /**
  17331. * Scale the current quaternion values by a factor and add the result to a given quaternion
  17332. * @param scale defines the scale factor
  17333. * @param result defines the Quaternion object where to store the result
  17334. * @returns the unmodified current quaternion
  17335. */
  17336. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  17337. /**
  17338. * Multiplies two quaternions
  17339. * @param q1 defines the second operand
  17340. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  17341. */
  17342. multiply(q1: Quaternion): Quaternion;
  17343. /**
  17344. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  17345. * @param q1 defines the second operand
  17346. * @param result defines the target quaternion
  17347. * @returns the current quaternion
  17348. */
  17349. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  17350. /**
  17351. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  17352. * @param q1 defines the second operand
  17353. * @returns the currentupdated quaternion
  17354. */
  17355. multiplyInPlace(q1: Quaternion): Quaternion;
  17356. /**
  17357. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  17358. * @param ref defines the target quaternion
  17359. * @returns the current quaternion
  17360. */
  17361. conjugateToRef(ref: Quaternion): Quaternion;
  17362. /**
  17363. * Conjugates in place (1-q) the current quaternion
  17364. * @returns the current updated quaternion
  17365. */
  17366. conjugateInPlace(): Quaternion;
  17367. /**
  17368. * Conjugates in place (1-q) the current quaternion
  17369. * @returns a new quaternion
  17370. */
  17371. conjugate(): Quaternion;
  17372. /**
  17373. * Gets length of current quaternion
  17374. * @returns the quaternion length (float)
  17375. */
  17376. length(): number;
  17377. /**
  17378. * Normalize in place the current quaternion
  17379. * @returns the current updated quaternion
  17380. */
  17381. normalize(): Quaternion;
  17382. /**
  17383. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  17384. * @param order is a reserved parameter and is ignore for now
  17385. * @returns a new Vector3 containing the Euler angles
  17386. */
  17387. toEulerAngles(order?: string): Vector3;
  17388. /**
  17389. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  17390. * @param result defines the vector which will be filled with the Euler angles
  17391. * @param order is a reserved parameter and is ignore for now
  17392. * @returns the current unchanged quaternion
  17393. */
  17394. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  17395. /**
  17396. * Updates the given rotation matrix with the current quaternion values
  17397. * @param result defines the target matrix
  17398. * @returns the current unchanged quaternion
  17399. */
  17400. toRotationMatrix(result: Matrix): Quaternion;
  17401. /**
  17402. * Updates the current quaternion from the given rotation matrix values
  17403. * @param matrix defines the source matrix
  17404. * @returns the current updated quaternion
  17405. */
  17406. fromRotationMatrix(matrix: Matrix): Quaternion;
  17407. /**
  17408. * Creates a new quaternion from a rotation matrix
  17409. * @param matrix defines the source matrix
  17410. * @returns a new quaternion created from the given rotation matrix values
  17411. */
  17412. static FromRotationMatrix(matrix: Matrix): Quaternion;
  17413. /**
  17414. * Updates the given quaternion with the given rotation matrix values
  17415. * @param matrix defines the source matrix
  17416. * @param result defines the target quaternion
  17417. */
  17418. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  17419. /**
  17420. * Returns the dot product (float) between the quaternions "left" and "right"
  17421. * @param left defines the left operand
  17422. * @param right defines the right operand
  17423. * @returns the dot product
  17424. */
  17425. static Dot(left: Quaternion, right: Quaternion): number;
  17426. /**
  17427. * Checks if the two quaternions are close to each other
  17428. * @param quat0 defines the first quaternion to check
  17429. * @param quat1 defines the second quaternion to check
  17430. * @returns true if the two quaternions are close to each other
  17431. */
  17432. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  17433. /**
  17434. * Creates an empty quaternion
  17435. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  17436. */
  17437. static Zero(): Quaternion;
  17438. /**
  17439. * Inverse a given quaternion
  17440. * @param q defines the source quaternion
  17441. * @returns a new quaternion as the inverted current quaternion
  17442. */
  17443. static Inverse(q: Quaternion): Quaternion;
  17444. /**
  17445. * Creates an identity quaternion
  17446. * @returns the identity quaternion
  17447. */
  17448. static Identity(): Quaternion;
  17449. /**
  17450. * Gets a boolean indicating if the given quaternion is identity
  17451. * @param quaternion defines the quaternion to check
  17452. * @returns true if the quaternion is identity
  17453. */
  17454. static IsIdentity(quaternion: Quaternion): boolean;
  17455. /**
  17456. * Creates a quaternion from a rotation around an axis
  17457. * @param axis defines the axis to use
  17458. * @param angle defines the angle to use
  17459. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  17460. */
  17461. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  17462. /**
  17463. * Creates a rotation around an axis and stores it into the given quaternion
  17464. * @param axis defines the axis to use
  17465. * @param angle defines the angle to use
  17466. * @param result defines the target quaternion
  17467. * @returns the target quaternion
  17468. */
  17469. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  17470. /**
  17471. * Creates a new quaternion from data stored into an array
  17472. * @param array defines the data source
  17473. * @param offset defines the offset in the source array where the data starts
  17474. * @returns a new quaternion
  17475. */
  17476. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  17477. /**
  17478. * Creates a new quaternion from the given Euler float angles (y, x, z)
  17479. * @param yaw defines the rotation around Y axis
  17480. * @param pitch defines the rotation around X axis
  17481. * @param roll defines the rotation around Z axis
  17482. * @returns the new quaternion
  17483. */
  17484. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  17485. /**
  17486. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  17487. * @param yaw defines the rotation around Y axis
  17488. * @param pitch defines the rotation around X axis
  17489. * @param roll defines the rotation around Z axis
  17490. * @param result defines the target quaternion
  17491. */
  17492. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  17493. /**
  17494. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  17495. * @param alpha defines the rotation around first axis
  17496. * @param beta defines the rotation around second axis
  17497. * @param gamma defines the rotation around third axis
  17498. * @returns the new quaternion
  17499. */
  17500. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  17501. /**
  17502. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  17503. * @param alpha defines the rotation around first axis
  17504. * @param beta defines the rotation around second axis
  17505. * @param gamma defines the rotation around third axis
  17506. * @param result defines the target quaternion
  17507. */
  17508. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  17509. /**
  17510. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  17511. * @param axis1 defines the first axis
  17512. * @param axis2 defines the second axis
  17513. * @param axis3 defines the third axis
  17514. * @returns the new quaternion
  17515. */
  17516. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  17517. /**
  17518. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  17519. * @param axis1 defines the first axis
  17520. * @param axis2 defines the second axis
  17521. * @param axis3 defines the third axis
  17522. * @param ref defines the target quaternion
  17523. */
  17524. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  17525. /**
  17526. * Interpolates between two quaternions
  17527. * @param left defines first quaternion
  17528. * @param right defines second quaternion
  17529. * @param amount defines the gradient to use
  17530. * @returns the new interpolated quaternion
  17531. */
  17532. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  17533. /**
  17534. * Interpolates between two quaternions and stores it into a target quaternion
  17535. * @param left defines first quaternion
  17536. * @param right defines second quaternion
  17537. * @param amount defines the gradient to use
  17538. * @param result defines the target quaternion
  17539. */
  17540. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  17541. /**
  17542. * Interpolate between two quaternions using Hermite interpolation
  17543. * @param value1 defines first quaternion
  17544. * @param tangent1 defines the incoming tangent
  17545. * @param value2 defines second quaternion
  17546. * @param tangent2 defines the outgoing tangent
  17547. * @param amount defines the target quaternion
  17548. * @returns the new interpolated quaternion
  17549. */
  17550. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  17551. }
  17552. /**
  17553. * Class used to store matrix data (4x4)
  17554. */
  17555. class Matrix {
  17556. private static _tempQuaternion;
  17557. private static _xAxis;
  17558. private static _yAxis;
  17559. private static _zAxis;
  17560. private static _updateFlagSeed;
  17561. private static _identityReadOnly;
  17562. private _isIdentity;
  17563. private _isIdentityDirty;
  17564. /**
  17565. * Gets the update flag of the matrix which is an unique number for the matrix.
  17566. * It will be incremented every time the matrix data change.
  17567. * You can use it to speed the comparison between two versions of the same matrix.
  17568. */
  17569. updateFlag: number;
  17570. /**
  17571. * Gets or sets the internal data of the matrix
  17572. */
  17573. m: Float32Array;
  17574. /** @hidden */
  17575. _markAsUpdated(): void;
  17576. /**
  17577. * Creates an empty matrix (filled with zeros)
  17578. */
  17579. constructor();
  17580. /**
  17581. * Check if the current matrix is indentity
  17582. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  17583. * @returns true is the matrix is the identity matrix
  17584. */
  17585. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  17586. /**
  17587. * Gets the determinant of the matrix
  17588. * @returns the matrix determinant
  17589. */
  17590. determinant(): number;
  17591. /**
  17592. * Returns the matrix as a Float32Array
  17593. * @returns the matrix underlying array
  17594. */
  17595. toArray(): Float32Array;
  17596. /**
  17597. * Returns the matrix as a Float32Array
  17598. * @returns the matrix underlying array.
  17599. */
  17600. asArray(): Float32Array;
  17601. /**
  17602. * Inverts the current matrix in place
  17603. * @returns the current inverted matrix
  17604. */
  17605. invert(): Matrix;
  17606. /**
  17607. * Sets all the matrix elements to zero
  17608. * @returns the current matrix
  17609. */
  17610. reset(): Matrix;
  17611. /**
  17612. * Adds the current matrix with a second one
  17613. * @param other defines the matrix to add
  17614. * @returns a new matrix as the addition of the current matrix and the given one
  17615. */
  17616. add(other: Matrix): Matrix;
  17617. /**
  17618. * Sets the given matrix "result" to the addition of the current matrix and the given one
  17619. * @param other defines the matrix to add
  17620. * @param result defines the target matrix
  17621. * @returns the current matrix
  17622. */
  17623. addToRef(other: Matrix, result: Matrix): Matrix;
  17624. /**
  17625. * Adds in place the given matrix to the current matrix
  17626. * @param other defines the second operand
  17627. * @returns the current updated matrix
  17628. */
  17629. addToSelf(other: Matrix): Matrix;
  17630. /**
  17631. * Sets the given matrix to the current inverted Matrix
  17632. * @param other defines the target matrix
  17633. * @returns the unmodified current matrix
  17634. */
  17635. invertToRef(other: Matrix): Matrix;
  17636. /**
  17637. * Inserts the translation vector (using 3 floats) in the current matrix
  17638. * @param x defines the 1st component of the translation
  17639. * @param y defines the 2nd component of the translation
  17640. * @param z defines the 3rd component of the translation
  17641. * @returns the current updated matrix
  17642. */
  17643. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  17644. /**
  17645. * Inserts the translation vector in the current matrix
  17646. * @param vector3 defines the translation to insert
  17647. * @returns the current updated matrix
  17648. */
  17649. setTranslation(vector3: Vector3): Matrix;
  17650. /**
  17651. * Gets the translation value of the current matrix
  17652. * @returns a new Vector3 as the extracted translation from the matrix
  17653. */
  17654. getTranslation(): Vector3;
  17655. /**
  17656. * Fill a Vector3 with the extracted translation from the matrix
  17657. * @param result defines the Vector3 where to store the translation
  17658. * @returns the current matrix
  17659. */
  17660. getTranslationToRef(result: Vector3): Matrix;
  17661. /**
  17662. * Remove rotation and scaling part from the matrix
  17663. * @returns the updated matrix
  17664. */
  17665. removeRotationAndScaling(): Matrix;
  17666. /**
  17667. * Multiply two matrices
  17668. * @param other defines the second operand
  17669. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  17670. */
  17671. multiply(other: Matrix): Matrix;
  17672. /**
  17673. * Copy the current matrix from the given one
  17674. * @param other defines the source matrix
  17675. * @returns the current updated matrix
  17676. */
  17677. copyFrom(other: Matrix): Matrix;
  17678. /**
  17679. * Populates the given array from the starting index with the current matrix values
  17680. * @param array defines the target array
  17681. * @param offset defines the offset in the target array where to start storing values
  17682. * @returns the current matrix
  17683. */
  17684. copyToArray(array: Float32Array, offset?: number): Matrix;
  17685. /**
  17686. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  17687. * @param other defines the second operand
  17688. * @param result defines the matrix where to store the multiplication
  17689. * @returns the current matrix
  17690. */
  17691. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  17692. /**
  17693. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  17694. * @param other defines the second operand
  17695. * @param result defines the array where to store the multiplication
  17696. * @param offset defines the offset in the target array where to start storing values
  17697. * @returns the current matrix
  17698. */
  17699. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  17700. /**
  17701. * Check equality between this matrix and a second one
  17702. * @param value defines the second matrix to compare
  17703. * @returns true is the current matrix and the given one values are strictly equal
  17704. */
  17705. equals(value: Matrix): boolean;
  17706. /**
  17707. * Clone the current matrix
  17708. * @returns a new matrix from the current matrix
  17709. */
  17710. clone(): Matrix;
  17711. /**
  17712. * Returns the name of the current matrix class
  17713. * @returns the string "Matrix"
  17714. */
  17715. getClassName(): string;
  17716. /**
  17717. * Gets the hash code of the current matrix
  17718. * @returns the hash code
  17719. */
  17720. getHashCode(): number;
  17721. /**
  17722. * Decomposes the current Matrix into a translation, rotation and scaling components
  17723. * @param scale defines the scale vector3 given as a reference to update
  17724. * @param rotation defines the rotation quaternion given as a reference to update
  17725. * @param translation defines the translation vector3 given as a reference to update
  17726. * @returns true if operation was successful
  17727. */
  17728. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  17729. /**
  17730. * Gets specific row of the matrix
  17731. * @param index defines the number of the row to get
  17732. * @returns the index-th row of the current matrix as a new Vector4
  17733. */
  17734. getRow(index: number): Nullable<Vector4>;
  17735. /**
  17736. * Sets the index-th row of the current matrix to the vector4 values
  17737. * @param index defines the number of the row to set
  17738. * @param row defines the target vector4
  17739. * @returns the updated current matrix
  17740. */
  17741. setRow(index: number, row: Vector4): Matrix;
  17742. /**
  17743. * Compute the transpose of the matrix
  17744. * @returns the new transposed matrix
  17745. */
  17746. transpose(): Matrix;
  17747. /**
  17748. * Compute the transpose of the matrix and store it in a given matrix
  17749. * @param result defines the target matrix
  17750. * @returns the current matrix
  17751. */
  17752. transposeToRef(result: Matrix): Matrix;
  17753. /**
  17754. * Sets the index-th row of the current matrix with the given 4 x float values
  17755. * @param index defines the row index
  17756. * @param x defines the x component to set
  17757. * @param y defines the y component to set
  17758. * @param z defines the z component to set
  17759. * @param w defines the w component to set
  17760. * @returns the updated current matrix
  17761. */
  17762. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  17763. /**
  17764. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  17765. * @param scale defines the scale factor
  17766. * @returns a new matrix
  17767. */
  17768. scale(scale: number): Matrix;
  17769. /**
  17770. * Scale the current matrix values by a factor to a given result matrix
  17771. * @param scale defines the scale factor
  17772. * @param result defines the matrix to store the result
  17773. * @returns the current matrix
  17774. */
  17775. scaleToRef(scale: number, result: Matrix): Matrix;
  17776. /**
  17777. * Scale the current matrix values by a factor and add the result to a given matrix
  17778. * @param scale defines the scale factor
  17779. * @param result defines the Matrix to store the result
  17780. * @returns the current matrix
  17781. */
  17782. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  17783. /**
  17784. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  17785. * @param ref matrix to store the result
  17786. */
  17787. toNormalMatrix(ref: Matrix): void;
  17788. /**
  17789. * Gets only rotation part of the current matrix
  17790. * @returns a new matrix sets to the extracted rotation matrix from the current one
  17791. */
  17792. getRotationMatrix(): Matrix;
  17793. /**
  17794. * Extracts the rotation matrix from the current one and sets it as the given "result"
  17795. * @param result defines the target matrix to store data to
  17796. * @returns the current matrix
  17797. */
  17798. getRotationMatrixToRef(result: Matrix): Matrix;
  17799. /**
  17800. * Creates a matrix from an array
  17801. * @param array defines the source array
  17802. * @param offset defines an offset in the source array
  17803. * @returns a new Matrix set from the starting index of the given array
  17804. */
  17805. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  17806. /**
  17807. * Copy the content of an array into a given matrix
  17808. * @param array defines the source array
  17809. * @param offset defines an offset in the source array
  17810. * @param result defines the target matrix
  17811. */
  17812. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  17813. /**
  17814. * Stores an array into a matrix after having multiplied each component by a given factor
  17815. * @param array defines the source array
  17816. * @param offset defines the offset in the source array
  17817. * @param scale defines the scaling factor
  17818. * @param result defines the target matrix
  17819. */
  17820. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  17821. /**
  17822. * Stores a list of values (16) inside a given matrix
  17823. * @param initialM11 defines 1st value of 1st row
  17824. * @param initialM12 defines 2nd value of 1st row
  17825. * @param initialM13 defines 3rd value of 1st row
  17826. * @param initialM14 defines 4th value of 1st row
  17827. * @param initialM21 defines 1st value of 2nd row
  17828. * @param initialM22 defines 2nd value of 2nd row
  17829. * @param initialM23 defines 3rd value of 2nd row
  17830. * @param initialM24 defines 4th value of 2nd row
  17831. * @param initialM31 defines 1st value of 3rd row
  17832. * @param initialM32 defines 2nd value of 3rd row
  17833. * @param initialM33 defines 3rd value of 3rd row
  17834. * @param initialM34 defines 4th value of 3rd row
  17835. * @param initialM41 defines 1st value of 4th row
  17836. * @param initialM42 defines 2nd value of 4th row
  17837. * @param initialM43 defines 3rd value of 4th row
  17838. * @param initialM44 defines 4th value of 4th row
  17839. * @param result defines the target matrix
  17840. */
  17841. 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;
  17842. /**
  17843. * Gets an identity matrix that must not be updated
  17844. */
  17845. static readonly IdentityReadOnly: Matrix;
  17846. /**
  17847. * Creates new matrix from a list of values (16)
  17848. * @param initialM11 defines 1st value of 1st row
  17849. * @param initialM12 defines 2nd value of 1st row
  17850. * @param initialM13 defines 3rd value of 1st row
  17851. * @param initialM14 defines 4th value of 1st row
  17852. * @param initialM21 defines 1st value of 2nd row
  17853. * @param initialM22 defines 2nd value of 2nd row
  17854. * @param initialM23 defines 3rd value of 2nd row
  17855. * @param initialM24 defines 4th value of 2nd row
  17856. * @param initialM31 defines 1st value of 3rd row
  17857. * @param initialM32 defines 2nd value of 3rd row
  17858. * @param initialM33 defines 3rd value of 3rd row
  17859. * @param initialM34 defines 4th value of 3rd row
  17860. * @param initialM41 defines 1st value of 4th row
  17861. * @param initialM42 defines 2nd value of 4th row
  17862. * @param initialM43 defines 3rd value of 4th row
  17863. * @param initialM44 defines 4th value of 4th row
  17864. * @returns the new matrix
  17865. */
  17866. 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;
  17867. /**
  17868. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17869. * @param scale defines the scale vector3
  17870. * @param rotation defines the rotation quaternion
  17871. * @param translation defines the translation vector3
  17872. * @returns a new matrix
  17873. */
  17874. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  17875. /**
  17876. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17877. * @param scale defines the scale vector3
  17878. * @param rotation defines the rotation quaternion
  17879. * @param translation defines the translation vector3
  17880. * @param result defines the target matrix
  17881. */
  17882. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  17883. /**
  17884. * Creates a new identity matrix
  17885. * @returns a new identity matrix
  17886. */
  17887. static Identity(): Matrix;
  17888. /**
  17889. * Creates a new identity matrix and stores the result in a given matrix
  17890. * @param result defines the target matrix
  17891. */
  17892. static IdentityToRef(result: Matrix): void;
  17893. /**
  17894. * Creates a new zero matrix
  17895. * @returns a new zero matrix
  17896. */
  17897. static Zero(): Matrix;
  17898. /**
  17899. * Creates a new rotation matrix for "angle" radians around the X axis
  17900. * @param angle defines the angle (in radians) to use
  17901. * @return the new matrix
  17902. */
  17903. static RotationX(angle: number): Matrix;
  17904. /**
  17905. * Creates a new matrix as the invert of a given matrix
  17906. * @param source defines the source matrix
  17907. * @returns the new matrix
  17908. */
  17909. static Invert(source: Matrix): Matrix;
  17910. /**
  17911. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  17912. * @param angle defines the angle (in radians) to use
  17913. * @param result defines the target matrix
  17914. */
  17915. static RotationXToRef(angle: number, result: Matrix): void;
  17916. /**
  17917. * Creates a new rotation matrix for "angle" radians around the Y axis
  17918. * @param angle defines the angle (in radians) to use
  17919. * @return the new matrix
  17920. */
  17921. static RotationY(angle: number): Matrix;
  17922. /**
  17923. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  17924. * @param angle defines the angle (in radians) to use
  17925. * @param result defines the target matrix
  17926. */
  17927. static RotationYToRef(angle: number, result: Matrix): void;
  17928. /**
  17929. * Creates a new rotation matrix for "angle" radians around the Z axis
  17930. * @param angle defines the angle (in radians) to use
  17931. * @return the new matrix
  17932. */
  17933. static RotationZ(angle: number): Matrix;
  17934. /**
  17935. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  17936. * @param angle defines the angle (in radians) to use
  17937. * @param result defines the target matrix
  17938. */
  17939. static RotationZToRef(angle: number, result: Matrix): void;
  17940. /**
  17941. * Creates a new rotation matrix for "angle" radians around the given axis
  17942. * @param axis defines the axis to use
  17943. * @param angle defines the angle (in radians) to use
  17944. * @return the new matrix
  17945. */
  17946. static RotationAxis(axis: Vector3, angle: number): Matrix;
  17947. /**
  17948. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  17949. * @param axis defines the axis to use
  17950. * @param angle defines the angle (in radians) to use
  17951. * @param result defines the target matrix
  17952. */
  17953. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  17954. /**
  17955. * Creates a rotation matrix
  17956. * @param yaw defines the yaw angle in radians (Y axis)
  17957. * @param pitch defines the pitch angle in radians (X axis)
  17958. * @param roll defines the roll angle in radians (X axis)
  17959. * @returns the new rotation matrix
  17960. */
  17961. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  17962. /**
  17963. * Creates a rotation matrix and stores it in a given matrix
  17964. * @param yaw defines the yaw angle in radians (Y axis)
  17965. * @param pitch defines the pitch angle in radians (X axis)
  17966. * @param roll defines the roll angle in radians (X axis)
  17967. * @param result defines the target matrix
  17968. */
  17969. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  17970. /**
  17971. * Creates a scaling matrix
  17972. * @param x defines the scale factor on X axis
  17973. * @param y defines the scale factor on Y axis
  17974. * @param z defines the scale factor on Z axis
  17975. * @returns the new matrix
  17976. */
  17977. static Scaling(x: number, y: number, z: number): Matrix;
  17978. /**
  17979. * Creates a scaling matrix and stores it in a given matrix
  17980. * @param x defines the scale factor on X axis
  17981. * @param y defines the scale factor on Y axis
  17982. * @param z defines the scale factor on Z axis
  17983. * @param result defines the target matrix
  17984. */
  17985. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  17986. /**
  17987. * Creates a translation matrix
  17988. * @param x defines the translation on X axis
  17989. * @param y defines the translation on Y axis
  17990. * @param z defines the translationon Z axis
  17991. * @returns the new matrix
  17992. */
  17993. static Translation(x: number, y: number, z: number): Matrix;
  17994. /**
  17995. * Creates a translation matrix and stores it in a given matrix
  17996. * @param x defines the translation on X axis
  17997. * @param y defines the translation on Y axis
  17998. * @param z defines the translationon Z axis
  17999. * @param result defines the target matrix
  18000. */
  18001. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  18002. /**
  18003. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18004. * @param startValue defines the start value
  18005. * @param endValue defines the end value
  18006. * @param gradient defines the gradient factor
  18007. * @returns the new matrix
  18008. */
  18009. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18010. /**
  18011. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18012. * @param startValue defines the start value
  18013. * @param endValue defines the end value
  18014. * @param gradient defines the gradient factor
  18015. * @param result defines the Matrix object where to store data
  18016. */
  18017. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18018. /**
  18019. * Builds a new matrix whose values are computed by:
  18020. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18021. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18022. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18023. * @param startValue defines the first matrix
  18024. * @param endValue defines the second matrix
  18025. * @param gradient defines the gradient between the two matrices
  18026. * @returns the new matrix
  18027. */
  18028. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18029. /**
  18030. * Update a matrix to values which are computed by:
  18031. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18032. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18033. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18034. * @param startValue defines the first matrix
  18035. * @param endValue defines the second matrix
  18036. * @param gradient defines the gradient between the two matrices
  18037. * @param result defines the target matrix
  18038. */
  18039. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18040. /**
  18041. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  18042. * This function works in left handed mode
  18043. * @param eye defines the final position of the entity
  18044. * @param target defines where the entity should look at
  18045. * @param up defines the up vector for the entity
  18046. * @returns the new matrix
  18047. */
  18048. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18049. /**
  18050. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  18051. * This function works in left handed mode
  18052. * @param eye defines the final position of the entity
  18053. * @param target defines where the entity should look at
  18054. * @param up defines the up vector for the entity
  18055. * @param result defines the target matrix
  18056. */
  18057. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18058. /**
  18059. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  18060. * This function works in right handed mode
  18061. * @param eye defines the final position of the entity
  18062. * @param target defines where the entity should look at
  18063. * @param up defines the up vector for the entity
  18064. * @returns the new matrix
  18065. */
  18066. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18067. /**
  18068. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  18069. * This function works in right handed mode
  18070. * @param eye defines the final position of the entity
  18071. * @param target defines where the entity should look at
  18072. * @param up defines the up vector for the entity
  18073. * @param result defines the target matrix
  18074. */
  18075. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18076. /**
  18077. * Create a left-handed orthographic projection matrix
  18078. * @param width defines the viewport width
  18079. * @param height defines the viewport height
  18080. * @param znear defines the near clip plane
  18081. * @param zfar defines the far clip plane
  18082. * @returns a new matrix as a left-handed orthographic projection matrix
  18083. */
  18084. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18085. /**
  18086. * Store a left-handed orthographic projection to a given matrix
  18087. * @param width defines the viewport width
  18088. * @param height defines the viewport height
  18089. * @param znear defines the near clip plane
  18090. * @param zfar defines the far clip plane
  18091. * @param result defines the target matrix
  18092. */
  18093. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  18094. /**
  18095. * Create a left-handed orthographic projection matrix
  18096. * @param left defines the viewport left coordinate
  18097. * @param right defines the viewport right coordinate
  18098. * @param bottom defines the viewport bottom coordinate
  18099. * @param top defines the viewport top coordinate
  18100. * @param znear defines the near clip plane
  18101. * @param zfar defines the far clip plane
  18102. * @returns a new matrix as a left-handed orthographic projection matrix
  18103. */
  18104. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18105. /**
  18106. * Stores a left-handed orthographic projection into a given matrix
  18107. * @param left defines the viewport left coordinate
  18108. * @param right defines the viewport right coordinate
  18109. * @param bottom defines the viewport bottom coordinate
  18110. * @param top defines the viewport top coordinate
  18111. * @param znear defines the near clip plane
  18112. * @param zfar defines the far clip plane
  18113. * @param result defines the target matrix
  18114. */
  18115. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18116. /**
  18117. * Creates a right-handed orthographic projection matrix
  18118. * @param left defines the viewport left coordinate
  18119. * @param right defines the viewport right coordinate
  18120. * @param bottom defines the viewport bottom coordinate
  18121. * @param top defines the viewport top coordinate
  18122. * @param znear defines the near clip plane
  18123. * @param zfar defines the far clip plane
  18124. * @returns a new matrix as a right-handed orthographic projection matrix
  18125. */
  18126. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18127. /**
  18128. * Stores a right-handed orthographic projection into a given matrix
  18129. * @param left defines the viewport left coordinate
  18130. * @param right defines the viewport right coordinate
  18131. * @param bottom defines the viewport bottom coordinate
  18132. * @param top defines the viewport top coordinate
  18133. * @param znear defines the near clip plane
  18134. * @param zfar defines the far clip plane
  18135. * @param result defines the target matrix
  18136. */
  18137. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18138. /**
  18139. * Creates a left-handed perspective projection matrix
  18140. * @param width defines the viewport width
  18141. * @param height defines the viewport height
  18142. * @param znear defines the near clip plane
  18143. * @param zfar defines the far clip plane
  18144. * @returns a new matrix as a left-handed perspective projection matrix
  18145. */
  18146. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18147. /**
  18148. * Creates a left-handed perspective projection matrix
  18149. * @param fov defines the horizontal field of view
  18150. * @param aspect defines the aspect ratio
  18151. * @param znear defines the near clip plane
  18152. * @param zfar defines the far clip plane
  18153. * @returns a new matrix as a left-handed perspective projection matrix
  18154. */
  18155. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18156. /**
  18157. * Stores a left-handed perspective projection into a given matrix
  18158. * @param fov defines the horizontal field of view
  18159. * @param aspect defines the aspect ratio
  18160. * @param znear defines the near clip plane
  18161. * @param zfar defines the far clip plane
  18162. * @param result defines the target matrix
  18163. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18164. */
  18165. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18166. /**
  18167. * Creates a right-handed perspective projection matrix
  18168. * @param fov defines the horizontal field of view
  18169. * @param aspect defines the aspect ratio
  18170. * @param znear defines the near clip plane
  18171. * @param zfar defines the far clip plane
  18172. * @returns a new matrix as a right-handed perspective projection matrix
  18173. */
  18174. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18175. /**
  18176. * Stores a right-handed perspective projection into a given matrix
  18177. * @param fov defines the horizontal field of view
  18178. * @param aspect defines the aspect ratio
  18179. * @param znear defines the near clip plane
  18180. * @param zfar defines the far clip plane
  18181. * @param result defines the target matrix
  18182. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18183. */
  18184. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18185. /**
  18186. * Stores a perspective projection for WebVR info a given matrix
  18187. * @param fov defines the field of view
  18188. * @param znear defines the near clip plane
  18189. * @param zfar defines the far clip plane
  18190. * @param result defines the target matrix
  18191. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  18192. */
  18193. static PerspectiveFovWebVRToRef(fov: {
  18194. upDegrees: number;
  18195. downDegrees: number;
  18196. leftDegrees: number;
  18197. rightDegrees: number;
  18198. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  18199. /**
  18200. * Computes a complete transformation matrix
  18201. * @param viewport defines the viewport to use
  18202. * @param world defines the world matrix
  18203. * @param view defines the view matrix
  18204. * @param projection defines the projection matrix
  18205. * @param zmin defines the near clip plane
  18206. * @param zmax defines the far clip plane
  18207. * @returns the transformation matrix
  18208. */
  18209. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  18210. /**
  18211. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  18212. * @param matrix defines the matrix to use
  18213. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  18214. */
  18215. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  18216. /**
  18217. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  18218. * @param matrix defines the matrix to use
  18219. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  18220. */
  18221. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  18222. /**
  18223. * Compute the transpose of a given matrix
  18224. * @param matrix defines the matrix to transpose
  18225. * @returns the new matrix
  18226. */
  18227. static Transpose(matrix: Matrix): Matrix;
  18228. /**
  18229. * Compute the transpose of a matrix and store it in a target matrix
  18230. * @param matrix defines the matrix to transpose
  18231. * @param result defines the target matrix
  18232. */
  18233. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  18234. /**
  18235. * Computes a reflection matrix from a plane
  18236. * @param plane defines the reflection plane
  18237. * @returns a new matrix
  18238. */
  18239. static Reflection(plane: Plane): Matrix;
  18240. /**
  18241. * Computes a reflection matrix from a plane
  18242. * @param plane defines the reflection plane
  18243. * @param result defines the target matrix
  18244. */
  18245. static ReflectionToRef(plane: Plane, result: Matrix): void;
  18246. /**
  18247. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  18248. * @param xaxis defines the value of the 1st axis
  18249. * @param yaxis defines the value of the 2nd axis
  18250. * @param zaxis defines the value of the 3rd axis
  18251. * @param result defines the target matrix
  18252. */
  18253. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  18254. /**
  18255. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  18256. * @param quat defines the quaternion to use
  18257. * @param result defines the target matrix
  18258. */
  18259. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  18260. }
  18261. class Plane {
  18262. normal: Vector3;
  18263. d: number;
  18264. /**
  18265. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  18266. */
  18267. constructor(a: number, b: number, c: number, d: number);
  18268. /**
  18269. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  18270. */
  18271. asArray(): number[];
  18272. /**
  18273. * Returns a new plane copied from the current Plane.
  18274. */
  18275. clone(): Plane;
  18276. /**
  18277. * Returns the string "Plane".
  18278. */
  18279. getClassName(): string;
  18280. /**
  18281. * Returns the Plane hash code.
  18282. */
  18283. getHashCode(): number;
  18284. /**
  18285. * Normalize the current Plane in place.
  18286. * Returns the updated Plane.
  18287. */
  18288. normalize(): Plane;
  18289. /**
  18290. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  18291. */
  18292. transform(transformation: Matrix): Plane;
  18293. /**
  18294. * Returns the dot product (float) of the point coordinates and the plane normal.
  18295. */
  18296. dotCoordinate(point: Vector3): number;
  18297. /**
  18298. * Updates the current Plane from the plane defined by the three given points.
  18299. * Returns the updated Plane.
  18300. */
  18301. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18302. /**
  18303. * Boolean : True is the vector "direction" is the same side than the plane normal.
  18304. */
  18305. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  18306. /**
  18307. * Returns the signed distance (float) from the given point to the Plane.
  18308. */
  18309. signedDistanceTo(point: Vector3): number;
  18310. /**
  18311. * Returns a new Plane from the given array.
  18312. */
  18313. static FromArray(array: ArrayLike<number>): Plane;
  18314. /**
  18315. * Returns a new Plane defined by the three given points.
  18316. */
  18317. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18318. /**
  18319. * Returns a new Plane the normal vector to this plane at the given origin point.
  18320. * Note : the vector "normal" is updated because normalized.
  18321. */
  18322. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  18323. /**
  18324. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  18325. */
  18326. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  18327. }
  18328. class Viewport {
  18329. x: number;
  18330. y: number;
  18331. width: number;
  18332. height: number;
  18333. /**
  18334. * Creates a Viewport object located at (x, y) and sized (width, height).
  18335. */
  18336. constructor(x: number, y: number, width: number, height: number);
  18337. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  18338. /**
  18339. * Returns a new Viewport copied from the current one.
  18340. */
  18341. clone(): Viewport;
  18342. }
  18343. class Frustum {
  18344. /**
  18345. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  18346. */
  18347. static GetPlanes(transform: Matrix): Plane[];
  18348. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18349. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18350. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18351. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18352. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18353. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18354. /**
  18355. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  18356. */
  18357. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  18358. }
  18359. /** Defines supported spaces */
  18360. enum Space {
  18361. /** Local (object) space */
  18362. LOCAL = 0,
  18363. /** World space */
  18364. WORLD = 1,
  18365. /** Bone space */
  18366. BONE = 2,
  18367. }
  18368. /** Defines the 3 main axes */
  18369. class Axis {
  18370. /** X axis */
  18371. static X: Vector3;
  18372. /** Y axis */
  18373. static Y: Vector3;
  18374. /** Z axis */
  18375. static Z: Vector3;
  18376. }
  18377. class BezierCurve {
  18378. /**
  18379. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  18380. */
  18381. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  18382. }
  18383. /**
  18384. * Defines potential orientation for back face culling
  18385. */
  18386. enum Orientation {
  18387. /**
  18388. * Clockwise
  18389. */
  18390. CW = 0,
  18391. /** Counter clockwise */
  18392. CCW = 1,
  18393. }
  18394. /**
  18395. * Defines angle representation
  18396. */
  18397. class Angle {
  18398. private _radians;
  18399. /**
  18400. * Creates an Angle object of "radians" radians (float).
  18401. */
  18402. constructor(radians: number);
  18403. /**
  18404. * Get value in degrees
  18405. * @returns the Angle value in degrees (float)
  18406. */
  18407. degrees(): number;
  18408. /**
  18409. * Get value in radians
  18410. * @returns the Angle value in radians (float)
  18411. */
  18412. radians(): number;
  18413. /**
  18414. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  18415. * @param a defines first vector
  18416. * @param b defines second vector
  18417. * @returns a new Angle
  18418. */
  18419. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  18420. /**
  18421. * Gets a new Angle object from the given float in radians
  18422. * @param radians defines the angle value in radians
  18423. * @returns a new Angle
  18424. */
  18425. static FromRadians(radians: number): Angle;
  18426. /**
  18427. * Gets a new Angle object from the given float in degrees
  18428. * @param degrees defines the angle value in degrees
  18429. * @returns a new Angle
  18430. */
  18431. static FromDegrees(degrees: number): Angle;
  18432. }
  18433. class Arc2 {
  18434. startPoint: Vector2;
  18435. midPoint: Vector2;
  18436. endPoint: Vector2;
  18437. centerPoint: Vector2;
  18438. radius: number;
  18439. angle: Angle;
  18440. startAngle: Angle;
  18441. orientation: Orientation;
  18442. /**
  18443. * Creates an Arc object from the three given points : start, middle and end.
  18444. */
  18445. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  18446. }
  18447. class Path2 {
  18448. private _points;
  18449. private _length;
  18450. closed: boolean;
  18451. /**
  18452. * Creates a Path2 object from the starting 2D coordinates x and y.
  18453. */
  18454. constructor(x: number, y: number);
  18455. /**
  18456. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  18457. * Returns the updated Path2.
  18458. */
  18459. addLineTo(x: number, y: number): Path2;
  18460. /**
  18461. * 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.
  18462. * Returns the updated Path2.
  18463. */
  18464. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  18465. /**
  18466. * Closes the Path2.
  18467. * Returns the Path2.
  18468. */
  18469. close(): Path2;
  18470. /**
  18471. * Returns the Path2 total length (float).
  18472. */
  18473. length(): number;
  18474. /**
  18475. * Returns the Path2 internal array of points.
  18476. */
  18477. getPoints(): Vector2[];
  18478. /**
  18479. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  18480. */
  18481. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  18482. /**
  18483. * Returns a new Path2 starting at the coordinates (x, y).
  18484. */
  18485. static StartingAt(x: number, y: number): Path2;
  18486. }
  18487. class Path3D {
  18488. path: Vector3[];
  18489. private _curve;
  18490. private _distances;
  18491. private _tangents;
  18492. private _normals;
  18493. private _binormals;
  18494. private _raw;
  18495. /**
  18496. * new Path3D(path, normal, raw)
  18497. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  18498. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  18499. * path : an array of Vector3, the curve axis of the Path3D
  18500. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  18501. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  18502. */
  18503. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  18504. /**
  18505. * Returns the Path3D array of successive Vector3 designing its curve.
  18506. */
  18507. getCurve(): Vector3[];
  18508. /**
  18509. * Returns an array populated with tangent vectors on each Path3D curve point.
  18510. */
  18511. getTangents(): Vector3[];
  18512. /**
  18513. * Returns an array populated with normal vectors on each Path3D curve point.
  18514. */
  18515. getNormals(): Vector3[];
  18516. /**
  18517. * Returns an array populated with binormal vectors on each Path3D curve point.
  18518. */
  18519. getBinormals(): Vector3[];
  18520. /**
  18521. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  18522. */
  18523. getDistances(): number[];
  18524. /**
  18525. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  18526. * Returns the same object updated.
  18527. */
  18528. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  18529. private _compute(firstNormal);
  18530. private _getFirstNonNullVector(index);
  18531. private _getLastNonNullVector(index);
  18532. private _normalVector(v0, vt, va);
  18533. }
  18534. class Curve3 {
  18535. private _points;
  18536. private _length;
  18537. /**
  18538. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  18539. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  18540. * @param v1 (Vector3) the control point
  18541. * @param v2 (Vector3) the end point of the Quadratic Bezier
  18542. * @param nbPoints (integer) the wanted number of points in the curve
  18543. */
  18544. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  18545. /**
  18546. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  18547. * @param v0 (Vector3) the origin point of the Cubic Bezier
  18548. * @param v1 (Vector3) the first control point
  18549. * @param v2 (Vector3) the second control point
  18550. * @param v3 (Vector3) the end point of the Cubic Bezier
  18551. * @param nbPoints (integer) the wanted number of points in the curve
  18552. */
  18553. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  18554. /**
  18555. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  18556. * @param p1 (Vector3) the origin point of the Hermite Spline
  18557. * @param t1 (Vector3) the tangent vector at the origin point
  18558. * @param p2 (Vector3) the end point of the Hermite Spline
  18559. * @param t2 (Vector3) the tangent vector at the end point
  18560. * @param nbPoints (integer) the wanted number of points in the curve
  18561. */
  18562. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  18563. /**
  18564. * Returns a Curve3 object along a CatmullRom Spline curve :
  18565. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  18566. * @param nbPoints (integer) the wanted number of points between each curve control points
  18567. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  18568. */
  18569. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  18570. /**
  18571. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  18572. * A Curve3 is designed from a series of successive Vector3.
  18573. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  18574. */
  18575. constructor(points: Vector3[]);
  18576. /**
  18577. * Returns the Curve3 stored array of successive Vector3
  18578. */
  18579. getPoints(): Vector3[];
  18580. /**
  18581. * Returns the computed length (float) of the curve.
  18582. */
  18583. length(): number;
  18584. /**
  18585. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  18586. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  18587. * curveA and curveB keep unchanged.
  18588. */
  18589. continue(curve: Curve3): Curve3;
  18590. private _computeLength(path);
  18591. }
  18592. class PositionNormalVertex {
  18593. position: Vector3;
  18594. normal: Vector3;
  18595. constructor(position?: Vector3, normal?: Vector3);
  18596. clone(): PositionNormalVertex;
  18597. }
  18598. class PositionNormalTextureVertex {
  18599. position: Vector3;
  18600. normal: Vector3;
  18601. uv: Vector2;
  18602. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  18603. clone(): PositionNormalTextureVertex;
  18604. }
  18605. class Tmp {
  18606. static Color3: Color3[];
  18607. static Color4: Color4[];
  18608. static Vector2: Vector2[];
  18609. static Vector3: Vector3[];
  18610. static Vector4: Vector4[];
  18611. static Quaternion: Quaternion[];
  18612. static Matrix: Matrix[];
  18613. }
  18614. }
  18615. declare module BABYLON {
  18616. /**
  18617. * Class representing spherical polynomial coefficients to the 3rd degree
  18618. */
  18619. class SphericalPolynomial {
  18620. /**
  18621. * The x coefficients of the spherical polynomial
  18622. */
  18623. x: Vector3;
  18624. /**
  18625. * The y coefficients of the spherical polynomial
  18626. */
  18627. y: Vector3;
  18628. /**
  18629. * The z coefficients of the spherical polynomial
  18630. */
  18631. z: Vector3;
  18632. /**
  18633. * The xx coefficients of the spherical polynomial
  18634. */
  18635. xx: Vector3;
  18636. /**
  18637. * The yy coefficients of the spherical polynomial
  18638. */
  18639. yy: Vector3;
  18640. /**
  18641. * The zz coefficients of the spherical polynomial
  18642. */
  18643. zz: Vector3;
  18644. /**
  18645. * The xy coefficients of the spherical polynomial
  18646. */
  18647. xy: Vector3;
  18648. /**
  18649. * The yz coefficients of the spherical polynomial
  18650. */
  18651. yz: Vector3;
  18652. /**
  18653. * The zx coefficients of the spherical polynomial
  18654. */
  18655. zx: Vector3;
  18656. /**
  18657. * Adds an ambient color to the spherical polynomial
  18658. * @param color the color to add
  18659. */
  18660. addAmbient(color: Color3): void;
  18661. /**
  18662. * Scales the spherical polynomial by the given amount
  18663. * @param scale the amount to scale
  18664. */
  18665. scale(scale: number): void;
  18666. /**
  18667. * Gets the spherical polynomial from harmonics
  18668. * @param harmonics the spherical harmonics
  18669. * @returns the spherical polynomial
  18670. */
  18671. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  18672. /**
  18673. * Constructs a spherical polynomial from an array.
  18674. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  18675. * @returns the spherical polynomial
  18676. */
  18677. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  18678. }
  18679. /**
  18680. * Class representing spherical harmonics coefficients to the 3rd degree
  18681. */
  18682. class SphericalHarmonics {
  18683. /**
  18684. * The l0,0 coefficients of the spherical harmonics
  18685. */
  18686. l00: Vector3;
  18687. /**
  18688. * The l1,-1 coefficients of the spherical harmonics
  18689. */
  18690. l1_1: Vector3;
  18691. /**
  18692. * The l1,0 coefficients of the spherical harmonics
  18693. */
  18694. l10: Vector3;
  18695. /**
  18696. * The l1,1 coefficients of the spherical harmonics
  18697. */
  18698. l11: Vector3;
  18699. /**
  18700. * The l2,-2 coefficients of the spherical harmonics
  18701. */
  18702. l2_2: Vector3;
  18703. /**
  18704. * The l2,-1 coefficients of the spherical harmonics
  18705. */
  18706. l2_1: Vector3;
  18707. /**
  18708. * The l2,0 coefficients of the spherical harmonics
  18709. */
  18710. l20: Vector3;
  18711. /**
  18712. * The l2,1 coefficients of the spherical harmonics
  18713. */
  18714. l21: Vector3;
  18715. /**
  18716. * The l2,2 coefficients of the spherical harmonics
  18717. */
  18718. lL22: Vector3;
  18719. /**
  18720. * Adds a light to the spherical harmonics
  18721. * @param direction the direction of the light
  18722. * @param color the color of the light
  18723. * @param deltaSolidAngle the delta solid angle of the light
  18724. */
  18725. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  18726. /**
  18727. * Scales the spherical harmonics by the given amount
  18728. * @param scale the amount to scale
  18729. */
  18730. scale(scale: number): void;
  18731. /**
  18732. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  18733. *
  18734. * ```
  18735. * E_lm = A_l * L_lm
  18736. * ```
  18737. *
  18738. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  18739. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  18740. * the scaling factors are given in equation 9.
  18741. */
  18742. convertIncidentRadianceToIrradiance(): void;
  18743. /**
  18744. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  18745. *
  18746. * ```
  18747. * L = (1/pi) * E * rho
  18748. * ```
  18749. *
  18750. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  18751. */
  18752. convertIrradianceToLambertianRadiance(): void;
  18753. /**
  18754. * Gets the spherical harmonics from polynomial
  18755. * @param polynomial the spherical polynomial
  18756. * @returns the spherical harmonics
  18757. */
  18758. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  18759. /**
  18760. * Constructs a spherical harmonics from an array.
  18761. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  18762. * @returns the spherical harmonics
  18763. */
  18764. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  18765. }
  18766. }
  18767. declare module BABYLON {
  18768. /**
  18769. * Class used to store all common mesh properties
  18770. */
  18771. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  18772. /** No occlusion */
  18773. static OCCLUSION_TYPE_NONE: number;
  18774. /** Occlusion set to optimisitic */
  18775. static OCCLUSION_TYPE_OPTIMISTIC: number;
  18776. /** Occlusion set to strict */
  18777. static OCCLUSION_TYPE_STRICT: number;
  18778. /** Use an accurante occlusion algorithm */
  18779. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  18780. /** Use a conservative occlusion algorithm */
  18781. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  18782. /**
  18783. * No billboard
  18784. */
  18785. static readonly BILLBOARDMODE_NONE: number;
  18786. /** Billboard on X axis */
  18787. static readonly BILLBOARDMODE_X: number;
  18788. /** Billboard on Y axis */
  18789. static readonly BILLBOARDMODE_Y: number;
  18790. /** Billboard on Z axis */
  18791. static readonly BILLBOARDMODE_Z: number;
  18792. /** Billboard on all axes */
  18793. static readonly BILLBOARDMODE_ALL: number;
  18794. private _facetPositions;
  18795. private _facetNormals;
  18796. private _facetPartitioning;
  18797. private _facetNb;
  18798. private _partitioningSubdivisions;
  18799. private _partitioningBBoxRatio;
  18800. private _facetDataEnabled;
  18801. private _facetParameters;
  18802. private _bbSize;
  18803. private _subDiv;
  18804. private _facetDepthSort;
  18805. private _facetDepthSortEnabled;
  18806. private _depthSortedIndices;
  18807. private _depthSortedFacets;
  18808. private _facetDepthSortFunction;
  18809. private _facetDepthSortFrom;
  18810. private _facetDepthSortOrigin;
  18811. private _invertedMatrix;
  18812. /**
  18813. * Gets the number of facets in the mesh
  18814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  18815. */
  18816. readonly facetNb: number;
  18817. /**
  18818. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  18819. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  18820. */
  18821. partitioningSubdivisions: number;
  18822. /**
  18823. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  18824. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  18825. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  18826. */
  18827. partitioningBBoxRatio: number;
  18828. /**
  18829. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  18830. * Works only for updatable meshes.
  18831. * Doesn't work with multi-materials
  18832. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  18833. */
  18834. mustDepthSortFacets: boolean;
  18835. /**
  18836. * The location (Vector3) where the facet depth sort must be computed from.
  18837. * By default, the active camera position.
  18838. * Used only when facet depth sort is enabled
  18839. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  18840. */
  18841. facetDepthSortFrom: Vector3;
  18842. /**
  18843. * gets a boolean indicating if facetData is enabled
  18844. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  18845. */
  18846. readonly isFacetDataEnabled: boolean;
  18847. /** @hidden */
  18848. _updateNonUniformScalingState(value: boolean): boolean;
  18849. /**
  18850. * An event triggered when this mesh collides with another one
  18851. */
  18852. onCollideObservable: Observable<AbstractMesh>;
  18853. private _onCollideObserver;
  18854. /** Set a function to call when this mesh collides with another one */
  18855. onCollide: () => void;
  18856. /**
  18857. * An event triggered when the collision's position changes
  18858. */
  18859. onCollisionPositionChangeObservable: Observable<Vector3>;
  18860. private _onCollisionPositionChangeObserver;
  18861. /** Set a function to call when the collision's position changes */
  18862. onCollisionPositionChange: () => void;
  18863. /**
  18864. * An event triggered when material is changed
  18865. */
  18866. onMaterialChangedObservable: Observable<AbstractMesh>;
  18867. /**
  18868. * Gets or sets the orientation for POV movement & rotation
  18869. */
  18870. definedFacingForward: boolean;
  18871. /**
  18872. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  18873. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  18874. * * 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.
  18875. * @see http://doc.babylonjs.com/features/occlusionquery
  18876. */
  18877. occlusionQueryAlgorithmType: number;
  18878. /**
  18879. * 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:
  18880. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  18881. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  18882. * * 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.
  18883. * @see http://doc.babylonjs.com/features/occlusionquery
  18884. */
  18885. occlusionType: number;
  18886. /**
  18887. * 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.
  18888. * The default value is -1 which means don't break the query and wait till the result
  18889. * @see http://doc.babylonjs.com/features/occlusionquery
  18890. */
  18891. occlusionRetryCount: number;
  18892. private _occlusionInternalRetryCounter;
  18893. protected _isOccluded: boolean;
  18894. /**
  18895. * 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
  18896. * @see http://doc.babylonjs.com/features/occlusionquery
  18897. */
  18898. isOccluded: boolean;
  18899. private _isOcclusionQueryInProgress;
  18900. /**
  18901. * Flag to check the progress status of the query
  18902. * @see http://doc.babylonjs.com/features/occlusionquery
  18903. */
  18904. readonly isOcclusionQueryInProgress: boolean;
  18905. private _occlusionQuery;
  18906. private _visibility;
  18907. /**
  18908. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  18909. */
  18910. /**
  18911. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  18912. */
  18913. visibility: number;
  18914. /** Gets or sets the alpha index used to sort transparent meshes
  18915. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  18916. */
  18917. alphaIndex: number;
  18918. /**
  18919. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  18920. */
  18921. isVisible: boolean;
  18922. /**
  18923. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  18924. */
  18925. isPickable: boolean;
  18926. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  18927. showSubMeshesBoundingBox: boolean;
  18928. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  18929. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  18930. */
  18931. isBlocker: boolean;
  18932. /**
  18933. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  18934. */
  18935. enablePointerMoveEvents: boolean;
  18936. /**
  18937. * Specifies the rendering group id for this mesh (0 by default)
  18938. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  18939. */
  18940. renderingGroupId: number;
  18941. private _material;
  18942. /** Gets or sets current material */
  18943. material: Nullable<Material>;
  18944. private _receiveShadows;
  18945. /**
  18946. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  18947. * @see http://doc.babylonjs.com/babylon101/shadows
  18948. */
  18949. receiveShadows: boolean;
  18950. /**
  18951. * Gets or sets a boolean indicating if the outline must be rendered as well
  18952. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  18953. */
  18954. renderOutline: boolean;
  18955. /** Defines color to use when rendering outline */
  18956. outlineColor: Color3;
  18957. /** Define width to use when rendering outline */
  18958. outlineWidth: number;
  18959. /**
  18960. * Gets or sets a boolean indicating if the overlay must be rendered as well
  18961. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  18962. */
  18963. renderOverlay: boolean;
  18964. /** Defines color to use when rendering overlay */
  18965. overlayColor: Color3;
  18966. /** Defines alpha to use when rendering overlay */
  18967. overlayAlpha: number;
  18968. private _hasVertexAlpha;
  18969. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  18970. hasVertexAlpha: boolean;
  18971. private _useVertexColors;
  18972. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  18973. useVertexColors: boolean;
  18974. private _computeBonesUsingShaders;
  18975. /**
  18976. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  18977. */
  18978. computeBonesUsingShaders: boolean;
  18979. private _numBoneInfluencers;
  18980. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  18981. numBoneInfluencers: number;
  18982. private _applyFog;
  18983. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  18984. applyFog: boolean;
  18985. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  18986. useOctreeForRenderingSelection: boolean;
  18987. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  18988. useOctreeForPicking: boolean;
  18989. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  18990. useOctreeForCollisions: boolean;
  18991. private _layerMask;
  18992. /**
  18993. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  18994. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  18995. */
  18996. layerMask: number;
  18997. /**
  18998. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  18999. */
  19000. alwaysSelectAsActiveMesh: boolean;
  19001. /**
  19002. * Gets or sets the current action manager
  19003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19004. */
  19005. actionManager: Nullable<ActionManager>;
  19006. /**
  19007. * Gets or sets impostor used for physic simulation
  19008. * @see http://doc.babylonjs.com/features/physics_engine
  19009. */
  19010. physicsImpostor: Nullable<PhysicsImpostor>;
  19011. private _checkCollisions;
  19012. private _collisionMask;
  19013. private _collisionGroup;
  19014. /**
  19015. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  19016. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19017. */
  19018. ellipsoid: Vector3;
  19019. /**
  19020. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  19021. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19022. */
  19023. ellipsoidOffset: Vector3;
  19024. private _collider;
  19025. private _oldPositionForCollisions;
  19026. private _diffPositionForCollisions;
  19027. /**
  19028. * Gets or sets a collision mask used to mask collisions (default is -1).
  19029. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19030. */
  19031. collisionMask: number;
  19032. /**
  19033. * Gets or sets the current collision group mask (-1 by default).
  19034. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19035. */
  19036. collisionGroup: number;
  19037. /**
  19038. * Defines edge width used when edgesRenderer is enabled
  19039. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19040. */
  19041. edgesWidth: number;
  19042. /**
  19043. * Defines edge color used when edgesRenderer is enabled
  19044. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19045. */
  19046. edgesColor: Color4;
  19047. /** @hidden */
  19048. _edgesRenderer: Nullable<EdgesRenderer>;
  19049. private _collisionsTransformMatrix;
  19050. private _collisionsScalingMatrix;
  19051. /** @hidden */
  19052. _masterMesh: Nullable<AbstractMesh>;
  19053. /** @hidden */
  19054. _boundingInfo: Nullable<BoundingInfo>;
  19055. /** @hidden */
  19056. _renderId: number;
  19057. /**
  19058. * Gets or sets the list of subMeshes
  19059. * @see http://doc.babylonjs.com/how_to/multi_materials
  19060. */
  19061. subMeshes: SubMesh[];
  19062. /** @hidden */
  19063. _submeshesOctree: Octree<SubMesh>;
  19064. /** @hidden */
  19065. _intersectionsInProgress: AbstractMesh[];
  19066. /** @hidden */
  19067. _unIndexed: boolean;
  19068. /** @hidden */
  19069. _lightSources: Light[];
  19070. /** @hidden */
  19071. readonly _positions: Nullable<Vector3[]>;
  19072. /** @hidden */
  19073. _waitingActions: any;
  19074. /** @hidden */
  19075. _waitingFreezeWorldMatrix: Nullable<boolean>;
  19076. private _skeleton;
  19077. /** @hidden */
  19078. _bonesTransformMatrices: Nullable<Float32Array>;
  19079. /**
  19080. * Gets or sets a skeleton to apply skining transformations
  19081. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19082. */
  19083. skeleton: Nullable<Skeleton>;
  19084. /**
  19085. * Creates a new AbstractMesh
  19086. * @param name defines the name of the mesh
  19087. * @param scene defines the hosting scene
  19088. */
  19089. constructor(name: string, scene?: Nullable<Scene>);
  19090. /**
  19091. * Returns the string "AbstractMesh"
  19092. * @returns "AbstractMesh"
  19093. */
  19094. getClassName(): string;
  19095. /**
  19096. * Gets a string representation of the current mesh
  19097. * @param fullDetails defines a boolean indicating if full details must be included
  19098. * @returns a string representation of the current mesh
  19099. */
  19100. toString(fullDetails?: boolean): string;
  19101. /** @hidden */
  19102. _rebuild(): void;
  19103. /** @hidden */
  19104. _resyncLightSources(): void;
  19105. /** @hidden */
  19106. _resyncLighSource(light: Light): void;
  19107. /** @hidden */
  19108. _unBindEffect(): void;
  19109. /** @hidden */
  19110. _removeLightSource(light: Light): void;
  19111. private _markSubMeshesAsDirty(func);
  19112. /** @hidden */
  19113. _markSubMeshesAsLightDirty(): void;
  19114. /** @hidden */
  19115. _markSubMeshesAsAttributesDirty(): void;
  19116. /** @hidden */
  19117. _markSubMeshesAsMiscDirty(): void;
  19118. /**
  19119. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  19120. */
  19121. scaling: Vector3;
  19122. /**
  19123. * Disables the mesh edge rendering mode
  19124. * @returns the currentAbstractMesh
  19125. */
  19126. disableEdgesRendering(): AbstractMesh;
  19127. /**
  19128. * Enables the edge rendering mode on the mesh.
  19129. * This mode makes the mesh edges visible
  19130. * @param epsilon defines the maximal distance between two angles to detect a face
  19131. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19132. * @returns the currentAbstractMesh
  19133. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19134. */
  19135. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19136. /**
  19137. * Gets the edgesRenderer associated with the mesh
  19138. */
  19139. readonly edgesRenderer: Nullable<EdgesRenderer>;
  19140. /**
  19141. * Returns true if the mesh is blocked. Implemented by child classes
  19142. */
  19143. readonly isBlocked: boolean;
  19144. /**
  19145. * Returns the mesh itself by default. Implemented by child classes
  19146. * @param camera defines the camera to use to pick the right LOD level
  19147. * @returns the currentAbstractMesh
  19148. */
  19149. getLOD(camera: Camera): Nullable<AbstractMesh>;
  19150. /**
  19151. * Returns 0 by default. Implemented by child classes
  19152. * @returns an integer
  19153. */
  19154. getTotalVertices(): number;
  19155. /**
  19156. * Returns null by default. Implemented by child classes
  19157. * @returns null
  19158. */
  19159. getIndices(): Nullable<IndicesArray>;
  19160. /**
  19161. * Returns the array of the requested vertex data kind. Implemented by child classes
  19162. * @param kind defines the vertex data kind to use
  19163. * @returns null
  19164. */
  19165. getVerticesData(kind: string): Nullable<FloatArray>;
  19166. /**
  19167. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19168. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19169. * Note that a new underlying VertexBuffer object is created each call.
  19170. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19171. * @param kind defines vertex data kind:
  19172. * * BABYLON.VertexBuffer.PositionKind
  19173. * * BABYLON.VertexBuffer.UVKind
  19174. * * BABYLON.VertexBuffer.UV2Kind
  19175. * * BABYLON.VertexBuffer.UV3Kind
  19176. * * BABYLON.VertexBuffer.UV4Kind
  19177. * * BABYLON.VertexBuffer.UV5Kind
  19178. * * BABYLON.VertexBuffer.UV6Kind
  19179. * * BABYLON.VertexBuffer.ColorKind
  19180. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19181. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19182. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19183. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19184. * @param data defines the data source
  19185. * @param updatable defines if the data must be flagged as updatable (or static)
  19186. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  19187. * @returns the current mesh
  19188. */
  19189. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19190. /**
  19191. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19192. * If the mesh has no geometry, it is simply returned as it is.
  19193. * @param kind defines vertex data kind:
  19194. * * BABYLON.VertexBuffer.PositionKind
  19195. * * BABYLON.VertexBuffer.UVKind
  19196. * * BABYLON.VertexBuffer.UV2Kind
  19197. * * BABYLON.VertexBuffer.UV3Kind
  19198. * * BABYLON.VertexBuffer.UV4Kind
  19199. * * BABYLON.VertexBuffer.UV5Kind
  19200. * * BABYLON.VertexBuffer.UV6Kind
  19201. * * BABYLON.VertexBuffer.ColorKind
  19202. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19203. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19204. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19205. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19206. * @param data defines the data source
  19207. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  19208. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  19209. * @returns the current mesh
  19210. */
  19211. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19212. /**
  19213. * Sets the mesh indices,
  19214. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19215. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19216. * @param totalVertices Defines the total number of vertices
  19217. * @returns the current mesh
  19218. */
  19219. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19220. /**
  19221. * Gets a boolean indicating if specific vertex data is present
  19222. * @param kind defines the vertex data kind to use
  19223. * @returns true is data kind is present
  19224. */
  19225. isVerticesDataPresent(kind: string): boolean;
  19226. /**
  19227. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  19228. * @returns a BoundingInfo
  19229. */
  19230. getBoundingInfo(): BoundingInfo;
  19231. /**
  19232. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  19233. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  19234. * @returns the current mesh
  19235. */
  19236. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19237. /**
  19238. * Overwrite the current bounding info
  19239. * @param boundingInfo defines the new bounding info
  19240. * @returns the current mesh
  19241. */
  19242. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19243. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  19244. readonly useBones: boolean;
  19245. /** @hidden */
  19246. _preActivate(): void;
  19247. /** @hidden */
  19248. _preActivateForIntermediateRendering(renderId: number): void;
  19249. /** @hidden */
  19250. _activate(renderId: number): void;
  19251. /**
  19252. * Gets the current world matrix
  19253. * @returns a Matrix
  19254. */
  19255. getWorldMatrix(): Matrix;
  19256. /** @hidden */
  19257. _getWorldMatrixDeterminant(): number;
  19258. /**
  19259. * Perform relative position change from the point of view of behind the front of the mesh.
  19260. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19261. * Supports definition of mesh facing forward or backward
  19262. * @param amountRight defines the distance on the right axis
  19263. * @param amountUp defines the distance on the up axis
  19264. * @param amountForward defines the distance on the forward axis
  19265. * @returns the current mesh
  19266. */
  19267. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  19268. /**
  19269. * Calculate relative position change from the point of view of behind the front of the mesh.
  19270. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19271. * Supports definition of mesh facing forward or backward
  19272. * @param amountRight defines the distance on the right axis
  19273. * @param amountUp defines the distance on the up axis
  19274. * @param amountForward defines the distance on the forward axis
  19275. * @returns the new displacement vector
  19276. */
  19277. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  19278. /**
  19279. * Perform relative rotation change from the point of view of behind the front of the mesh.
  19280. * Supports definition of mesh facing forward or backward
  19281. * @param flipBack defines the flip
  19282. * @param twirlClockwise defines the twirl
  19283. * @param tiltRight defines the tilt
  19284. * @returns the current mesh
  19285. */
  19286. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  19287. /**
  19288. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  19289. * Supports definition of mesh facing forward or backward.
  19290. * @param flipBack defines the flip
  19291. * @param twirlClockwise defines the twirl
  19292. * @param tiltRight defines the tilt
  19293. * @returns the new rotation vector
  19294. */
  19295. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  19296. /**
  19297. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  19298. * @param includeDescendants Include bounding info from descendants as well (true by default)
  19299. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  19300. * @returns the new bounding vectors
  19301. */
  19302. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  19303. min: Vector3;
  19304. max: Vector3;
  19305. };
  19306. /** @hidden */
  19307. _updateBoundingInfo(): AbstractMesh;
  19308. /** @hidden */
  19309. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  19310. /** @hidden */
  19311. protected _afterComputeWorldMatrix(): void;
  19312. /**
  19313. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19314. * A mesh is in the frustum if its bounding box intersects the frustum
  19315. * @param frustumPlanes defines the frustum to test
  19316. * @returns true if the mesh is in the frustum planes
  19317. */
  19318. isInFrustum(frustumPlanes: Plane[]): boolean;
  19319. /**
  19320. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  19321. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  19322. * @param frustumPlanes defines the frustum to test
  19323. * @returns true if the mesh is completely in the frustum planes
  19324. */
  19325. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19326. /**
  19327. * True if the mesh intersects another mesh or a SolidParticle object
  19328. * @param mesh defines a target mesh or SolidParticle to test
  19329. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  19330. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  19331. * @returns true if there is an intersection
  19332. */
  19333. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  19334. /**
  19335. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  19336. * @param point defines the point to test
  19337. * @returns true if there is an intersection
  19338. */
  19339. intersectsPoint(point: Vector3): boolean;
  19340. /**
  19341. * Gets the current physics impostor
  19342. * @see http://doc.babylonjs.com/features/physics_engine
  19343. * @returns a physics impostor or null
  19344. */
  19345. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  19346. /**
  19347. * Gets the position of the current mesh in camera space
  19348. * @param camera defines the camera to use
  19349. * @returns a position
  19350. */
  19351. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  19352. /**
  19353. * Returns the distance from the mesh to the active camera
  19354. * @param camera defines the camera to use
  19355. * @returns the distance
  19356. */
  19357. getDistanceToCamera(camera?: Nullable<Camera>): number;
  19358. /**
  19359. * Apply a physic impulse to the mesh
  19360. * @param force defines the force to apply
  19361. * @param contactPoint defines where to apply the force
  19362. * @returns the current mesh
  19363. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19364. */
  19365. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  19366. /**
  19367. * Creates a physic joint between two meshes
  19368. * @param otherMesh defines the other mesh to use
  19369. * @param pivot1 defines the pivot to use on this mesh
  19370. * @param pivot2 defines the pivot to use on the other mesh
  19371. * @param options defines additional options (can be plugin dependent)
  19372. * @returns the current mesh
  19373. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  19374. */
  19375. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  19376. /**
  19377. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  19378. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19379. */
  19380. checkCollisions: boolean;
  19381. /**
  19382. * Gets Collider object used to compute collisions (not physics)
  19383. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19384. */
  19385. readonly collider: Collider;
  19386. /**
  19387. * Move the mesh using collision engine
  19388. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19389. * @param displacement defines the requested displacement vector
  19390. * @returns the current mesh
  19391. */
  19392. moveWithCollisions(displacement: Vector3): AbstractMesh;
  19393. private _onCollisionPositionChange;
  19394. /**
  19395. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  19396. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19397. * @param maxCapacity defines the maximum size of each block (64 by default)
  19398. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  19399. * @returns the new octree
  19400. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  19401. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  19402. */
  19403. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  19404. /** @hidden */
  19405. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  19406. /** @hidden */
  19407. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  19408. /** @hidden */
  19409. _checkCollision(collider: Collider): AbstractMesh;
  19410. /** @hidden */
  19411. _generatePointsArray(): boolean;
  19412. /**
  19413. * Checks if the passed Ray intersects with the mesh
  19414. * @param ray defines the ray to use
  19415. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  19416. * @returns the picking info
  19417. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  19418. */
  19419. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  19420. /**
  19421. * Clones the current mesh
  19422. * @param name defines the mesh name
  19423. * @param newParent defines the new mesh parent
  19424. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  19425. * @returns the new mesh
  19426. */
  19427. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19428. /**
  19429. * Disposes all the submeshes of the current meshnp
  19430. * @returns the current mesh
  19431. */
  19432. releaseSubMeshes(): AbstractMesh;
  19433. /**
  19434. * Releases resources associated with this abstract mesh.
  19435. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19436. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19437. */
  19438. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19439. /**
  19440. * Adds the passed mesh as a child to the current mesh
  19441. * @param mesh defines the child mesh
  19442. * @returns the current mesh
  19443. */
  19444. addChild(mesh: AbstractMesh): AbstractMesh;
  19445. /**
  19446. * Removes the passed mesh from the current mesh children list
  19447. * @param mesh defines the child mesh
  19448. * @returns the current mesh
  19449. */
  19450. removeChild(mesh: AbstractMesh): AbstractMesh;
  19451. /** @hidden */
  19452. private _initFacetData();
  19453. /**
  19454. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  19455. * This method can be called within the render loop.
  19456. * 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
  19457. * @returns the current mesh
  19458. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19459. */
  19460. updateFacetData(): AbstractMesh;
  19461. /**
  19462. * Returns the facetLocalNormals array.
  19463. * The normals are expressed in the mesh local spac
  19464. * @returns an array of Vector3
  19465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19466. */
  19467. getFacetLocalNormals(): Vector3[];
  19468. /**
  19469. * Returns the facetLocalPositions array.
  19470. * The facet positions are expressed in the mesh local space
  19471. * @returns an array of Vector3
  19472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19473. */
  19474. getFacetLocalPositions(): Vector3[];
  19475. /**
  19476. * Returns the facetLocalPartioning array
  19477. * @returns an array of array of numbers
  19478. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19479. */
  19480. getFacetLocalPartitioning(): number[][];
  19481. /**
  19482. * Returns the i-th facet position in the world system.
  19483. * This method allocates a new Vector3 per call
  19484. * @param i defines the facet index
  19485. * @returns a new Vector3
  19486. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19487. */
  19488. getFacetPosition(i: number): Vector3;
  19489. /**
  19490. * Sets the reference Vector3 with the i-th facet position in the world system
  19491. * @param i defines the facet index
  19492. * @param ref defines the target vector
  19493. * @returns the current mesh
  19494. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19495. */
  19496. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  19497. /**
  19498. * Returns the i-th facet normal in the world system.
  19499. * This method allocates a new Vector3 per call
  19500. * @param i defines the facet index
  19501. * @returns a new Vector3
  19502. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19503. */
  19504. getFacetNormal(i: number): Vector3;
  19505. /**
  19506. * Sets the reference Vector3 with the i-th facet normal in the world system
  19507. * @param i defines the facet index
  19508. * @param ref defines the target vector
  19509. * @returns the current mesh
  19510. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19511. */
  19512. getFacetNormalToRef(i: number, ref: Vector3): this;
  19513. /**
  19514. * 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)
  19515. * @param x defines x coordinate
  19516. * @param y defines y coordinate
  19517. * @param z defines z coordinate
  19518. * @returns the array of facet indexes
  19519. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19520. */
  19521. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  19522. /**
  19523. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  19524. * @param projected sets as the (x,y,z) world projection on the facet
  19525. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  19526. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  19527. * @param x defines x coordinate
  19528. * @param y defines y coordinate
  19529. * @param z defines z coordinate
  19530. * @returns the face index if found (or null instead)
  19531. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19532. */
  19533. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19534. /**
  19535. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  19536. * @param projected sets as the (x,y,z) local projection on the facet
  19537. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  19538. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  19539. * @param x defines x coordinate
  19540. * @param y defines y coordinate
  19541. * @param z defines z coordinate
  19542. * @returns the face index if found (or null instead)
  19543. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19544. */
  19545. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19546. /**
  19547. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  19548. * @returns the parameters
  19549. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19550. */
  19551. getFacetDataParameters(): any;
  19552. /**
  19553. * Disables the feature FacetData and frees the related memory
  19554. * @returns the current mesh
  19555. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19556. */
  19557. disableFacetData(): AbstractMesh;
  19558. /**
  19559. * Updates the AbstractMesh indices array
  19560. * @param indices defines the data source
  19561. * @returns the current mesh
  19562. */
  19563. updateIndices(indices: IndicesArray): AbstractMesh;
  19564. /**
  19565. * Creates new normals data for the mesh
  19566. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  19567. * @returns the current mesh
  19568. */
  19569. createNormals(updatable: boolean): AbstractMesh;
  19570. /**
  19571. * Align the mesh with a normal
  19572. * @param normal defines the normal to use
  19573. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  19574. * @returns the current mesh
  19575. */
  19576. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  19577. /** @hidden */
  19578. protected _checkOcclusionQuery(): void;
  19579. }
  19580. }
  19581. declare module BABYLON {
  19582. class Buffer {
  19583. private _engine;
  19584. private _buffer;
  19585. /** @hidden */
  19586. _data: Nullable<DataArray>;
  19587. private _updatable;
  19588. private _instanced;
  19589. /**
  19590. * Gets the byte stride.
  19591. */
  19592. readonly byteStride: number;
  19593. /**
  19594. * Constructor
  19595. * @param engine the engine
  19596. * @param data the data to use for this buffer
  19597. * @param updatable whether the data is updatable
  19598. * @param stride the stride (optional)
  19599. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  19600. * @param instanced whether the buffer is instanced (optional)
  19601. * @param useBytes set to true if the stride in in bytes (optional)
  19602. */
  19603. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  19604. /**
  19605. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  19606. * @param kind defines the vertex buffer kind (position, normal, etc.)
  19607. * @param offset defines offset in the buffer (0 by default)
  19608. * @param size defines the size in floats of attributes (position is 3 for instance)
  19609. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  19610. * @param instanced defines if the vertex buffer contains indexed data
  19611. * @param useBytes defines if the offset and stride are in bytes
  19612. * @returns the new vertex buffer
  19613. */
  19614. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  19615. isUpdatable(): boolean;
  19616. getData(): Nullable<DataArray>;
  19617. getBuffer(): Nullable<WebGLBuffer>;
  19618. /**
  19619. * Gets the stride in float32 units (i.e. byte stride / 4).
  19620. * May not be an integer if the byte stride is not divisible by 4.
  19621. * DEPRECATED. Use byteStride instead.
  19622. * @returns the stride in float32 units
  19623. */
  19624. getStrideSize(): number;
  19625. create(data?: Nullable<DataArray>): void;
  19626. _rebuild(): void;
  19627. update(data: DataArray): void;
  19628. /**
  19629. * Updates the data directly.
  19630. * @param data the new data
  19631. * @param offset the new offset
  19632. * @param vertexCount the vertex count (optional)
  19633. * @param useBytes set to true if the offset is in bytes
  19634. */
  19635. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  19636. dispose(): void;
  19637. }
  19638. }
  19639. declare module BABYLON {
  19640. class CSG {
  19641. private polygons;
  19642. matrix: Matrix;
  19643. position: Vector3;
  19644. rotation: Vector3;
  19645. rotationQuaternion: Nullable<Quaternion>;
  19646. scaling: Vector3;
  19647. static FromMesh(mesh: Mesh): CSG;
  19648. private static FromPolygons(polygons);
  19649. clone(): CSG;
  19650. union(csg: CSG): CSG;
  19651. unionInPlace(csg: CSG): void;
  19652. subtract(csg: CSG): CSG;
  19653. subtractInPlace(csg: CSG): void;
  19654. intersect(csg: CSG): CSG;
  19655. intersectInPlace(csg: CSG): void;
  19656. inverse(): CSG;
  19657. inverseInPlace(): void;
  19658. copyTransformAttributes(csg: CSG): CSG;
  19659. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  19660. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  19661. }
  19662. }
  19663. declare module BABYLON {
  19664. /**
  19665. * Class used to store geometry data (vertex buffers + index buffer)
  19666. */
  19667. class Geometry implements IGetSetVerticesData {
  19668. /**
  19669. * Gets or sets the unique ID of the geometry
  19670. */
  19671. id: string;
  19672. /**
  19673. * Gets the delay loading state of the geometry (none by default which means not delayed)
  19674. */
  19675. delayLoadState: number;
  19676. /**
  19677. * Gets the file containing the data to load when running in delay load state
  19678. */
  19679. delayLoadingFile: Nullable<string>;
  19680. /**
  19681. * Callback called when the geometry is updated
  19682. */
  19683. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  19684. private _scene;
  19685. private _engine;
  19686. private _meshes;
  19687. private _totalVertices;
  19688. /** @hidden */
  19689. _indices: IndicesArray;
  19690. /** @hidden */
  19691. _vertexBuffers: {
  19692. [key: string]: VertexBuffer;
  19693. };
  19694. private _isDisposed;
  19695. private _extend;
  19696. private _boundingBias;
  19697. /** @hidden */
  19698. _delayInfo: Array<string>;
  19699. private _indexBuffer;
  19700. private _indexBufferIsUpdatable;
  19701. /** @hidden */
  19702. _boundingInfo: Nullable<BoundingInfo>;
  19703. /** @hidden */
  19704. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  19705. /** @hidden */
  19706. _softwareSkinningRenderId: number;
  19707. private _vertexArrayObjects;
  19708. private _updatable;
  19709. /** @hidden */
  19710. _positions: Nullable<Vector3[]>;
  19711. /**
  19712. * 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
  19713. */
  19714. /**
  19715. * 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
  19716. */
  19717. boundingBias: Vector2;
  19718. /**
  19719. * Static function used to attach a new empty geometry to a mesh
  19720. * @param mesh defines the mesh to attach the geometry to
  19721. * @returns the new {BABYLON.Geometry}
  19722. */
  19723. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  19724. /**
  19725. * Creates a new geometry
  19726. * @param id defines the unique ID
  19727. * @param scene defines the hosting scene
  19728. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  19729. * @param updatable defines if geometry must be updatable (false by default)
  19730. * @param mesh defines the mesh that will be associated with the geometry
  19731. */
  19732. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  19733. /**
  19734. * Gets the current extend of the geometry
  19735. */
  19736. readonly extend: {
  19737. minimum: Vector3;
  19738. maximum: Vector3;
  19739. };
  19740. /**
  19741. * Gets the hosting scene
  19742. * @returns the hosting {BABYLON.Scene}
  19743. */
  19744. getScene(): Scene;
  19745. /**
  19746. * Gets the hosting engine
  19747. * @returns the hosting {BABYLON.Engine}
  19748. */
  19749. getEngine(): Engine;
  19750. /**
  19751. * Defines if the geometry is ready to use
  19752. * @returns true if the geometry is ready to be used
  19753. */
  19754. isReady(): boolean;
  19755. /**
  19756. * Gets a value indicating that the geometry should not be serialized
  19757. */
  19758. readonly doNotSerialize: boolean;
  19759. /** @hidden */
  19760. _rebuild(): void;
  19761. /**
  19762. * Affects all geometry data in one call
  19763. * @param vertexData defines the geometry data
  19764. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  19765. */
  19766. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19767. /**
  19768. * Set specific vertex data
  19769. * @param kind defines the data kind (Position, normal, etc...)
  19770. * @param data defines the vertex data to use
  19771. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  19772. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  19773. */
  19774. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  19775. /**
  19776. * Removes a specific vertex data
  19777. * @param kind defines the data kind (Position, normal, etc...)
  19778. */
  19779. removeVerticesData(kind: string): void;
  19780. /**
  19781. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  19782. * @param buffer defines the vertex buffer to use
  19783. * @param totalVertices defines the total number of vertices for position kind (could be null)
  19784. */
  19785. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  19786. /**
  19787. * Update a specific vertex buffer
  19788. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  19789. * It will do nothing if the buffer is not updatable
  19790. * @param kind defines the data kind (Position, normal, etc...)
  19791. * @param data defines the data to use
  19792. * @param offset defines the offset in the target buffer where to store the data
  19793. * @param useBytes set to true if the offset is in bytes
  19794. */
  19795. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  19796. /**
  19797. * Update a specific vertex buffer
  19798. * This function will create a new buffer if the current one is not updatable
  19799. * @param kind defines the data kind (Position, normal, etc...)
  19800. * @param data defines the data to use
  19801. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  19802. */
  19803. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  19804. private _updateBoundingInfo(updateExtends, data);
  19805. /** @hidden */
  19806. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  19807. /**
  19808. * Gets total number of vertices
  19809. * @returns the total number of vertices
  19810. */
  19811. getTotalVertices(): number;
  19812. /**
  19813. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  19814. * @param kind defines the data kind (Position, normal, etc...)
  19815. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19816. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19817. * @returns a float array containing vertex data
  19818. */
  19819. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19820. /**
  19821. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  19822. * @param kind defines the data kind (Position, normal, etc...)
  19823. * @returns true if the vertex buffer with the specified kind is updatable
  19824. */
  19825. isVertexBufferUpdatable(kind: string): boolean;
  19826. /**
  19827. * Gets a specific vertex buffer
  19828. * @param kind defines the data kind (Position, normal, etc...)
  19829. * @returns a {BABYLON.VertexBuffer}
  19830. */
  19831. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19832. /**
  19833. * Returns all vertex buffers
  19834. * @return an object holding all vertex buffers indexed by kind
  19835. */
  19836. getVertexBuffers(): Nullable<{
  19837. [key: string]: VertexBuffer;
  19838. }>;
  19839. /**
  19840. * Gets a boolean indicating if specific vertex buffer is present
  19841. * @param kind defines the data kind (Position, normal, etc...)
  19842. * @returns true if data is present
  19843. */
  19844. isVerticesDataPresent(kind: string): boolean;
  19845. /**
  19846. * Gets a list of all attached data kinds (Position, normal, etc...)
  19847. * @returns a list of string containing all kinds
  19848. */
  19849. getVerticesDataKinds(): string[];
  19850. /**
  19851. * Update index buffer
  19852. * @param indices defines the indices to store in the index buffer
  19853. * @param offset defines the offset in the target buffer where to store the data
  19854. */
  19855. updateIndices(indices: IndicesArray, offset?: number): void;
  19856. /**
  19857. * Creates a new index buffer
  19858. * @param indices defines the indices to store in the index buffer
  19859. * @param totalVertices defines the total number of vertices (could be null)
  19860. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  19861. */
  19862. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  19863. /**
  19864. * Return the total number of indices
  19865. * @returns the total number of indices
  19866. */
  19867. getTotalIndices(): number;
  19868. /**
  19869. * Gets the index buffer array
  19870. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19871. * @returns the index buffer array
  19872. */
  19873. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  19874. /**
  19875. * Gets the index buffer
  19876. * @return the index buffer
  19877. */
  19878. getIndexBuffer(): Nullable<WebGLBuffer>;
  19879. /** @hidden */
  19880. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  19881. /**
  19882. * Release the associated resources for a specific mesh
  19883. * @param mesh defines the source mesh
  19884. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  19885. */
  19886. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  19887. /**
  19888. * Apply current geometry to a given mesh
  19889. * @param mesh defines the mesh to apply geometry to
  19890. */
  19891. applyToMesh(mesh: Mesh): void;
  19892. private _updateExtend(data?);
  19893. private _applyToMesh(mesh);
  19894. private notifyUpdate(kind?);
  19895. /**
  19896. * Load the geometry if it was flagged as delay loaded
  19897. * @param scene defines the hosting scene
  19898. * @param onLoaded defines a callback called when the geometry is loaded
  19899. */
  19900. load(scene: Scene, onLoaded?: () => void): void;
  19901. private _queueLoad(scene, onLoaded?);
  19902. /**
  19903. * Invert the geometry to move from a right handed system to a left handed one.
  19904. */
  19905. toLeftHanded(): void;
  19906. /** @hidden */
  19907. _resetPointsArrayCache(): void;
  19908. /** @hidden */
  19909. _generatePointsArray(): boolean;
  19910. /**
  19911. * Gets a value indicating if the geometry is disposed
  19912. * @returns true if the geometry was disposed
  19913. */
  19914. isDisposed(): boolean;
  19915. private _disposeVertexArrayObjects();
  19916. /**
  19917. * Free all associated resources
  19918. */
  19919. dispose(): void;
  19920. /**
  19921. * Clone the current geometry into a new geometry
  19922. * @param id defines the unique ID of the new geometry
  19923. * @returns a new geometry object
  19924. */
  19925. copy(id: string): Geometry;
  19926. /**
  19927. * Serialize the current geometry info (and not the vertices data) into a JSON object
  19928. * @return a JSON representation of the current geometry data (without the vertices data)
  19929. */
  19930. serialize(): any;
  19931. private toNumberArray(origin);
  19932. /**
  19933. * Serialize all vertices data into a JSON oject
  19934. * @returns a JSON representation of the current geometry data
  19935. */
  19936. serializeVerticeData(): any;
  19937. /**
  19938. * Extracts a clone of a mesh geometry
  19939. * @param mesh defines the source mesh
  19940. * @param id defines the unique ID of the new geometry object
  19941. * @returns the new geometry object
  19942. */
  19943. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  19944. /**
  19945. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  19946. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  19947. * Be aware Math.random() could cause collisions, but:
  19948. * "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"
  19949. * @returns a string containing a new GUID
  19950. */
  19951. static RandomId(): string;
  19952. /** @hidden */
  19953. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  19954. private static _CleanMatricesWeights(parsedGeometry, mesh);
  19955. /**
  19956. * Create a new geometry from persisted data (Using .babylon file format)
  19957. * @param parsedVertexData defines the persisted data
  19958. * @param scene defines the hosting scene
  19959. * @param rootUrl defines the root url to use to load assets (like delayed data)
  19960. * @returns the new geometry object
  19961. */
  19962. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  19963. }
  19964. /**
  19965. * Abstract class used to provide common services for all typed geometries
  19966. * @hidden
  19967. */
  19968. class _PrimitiveGeometry extends Geometry {
  19969. private _canBeRegenerated;
  19970. private _beingRegenerated;
  19971. /**
  19972. * Creates a new typed geometry
  19973. * @param id defines the unique ID of the geometry
  19974. * @param scene defines the hosting scene
  19975. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19976. * @param mesh defines the hosting mesh (can be null)
  19977. */
  19978. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19979. /**
  19980. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  19981. * @returns true if the geometry can be regenerated
  19982. */
  19983. canBeRegenerated(): boolean;
  19984. /**
  19985. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  19986. */
  19987. regenerate(): void;
  19988. /**
  19989. * Clone the geometry
  19990. * @param id defines the unique ID of the new geometry
  19991. * @returns the new geometry
  19992. */
  19993. asNewGeometry(id: string): Geometry;
  19994. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19995. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  19996. /** @hidden */
  19997. _regenerateVertexData(): VertexData;
  19998. copy(id: string): Geometry;
  19999. serialize(): any;
  20000. }
  20001. /**
  20002. * Creates a ribbon geometry
  20003. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  20004. */
  20005. class RibbonGeometry extends _PrimitiveGeometry {
  20006. /**
  20007. * Defines the array of paths to use
  20008. */
  20009. pathArray: Vector3[][];
  20010. /**
  20011. * Defines if the last and first points of each path in your pathArray must be joined
  20012. */
  20013. closeArray: boolean;
  20014. /**
  20015. * Defines if the last and first points of each path in your pathArray must be joined
  20016. */
  20017. closePath: boolean;
  20018. /**
  20019. * Defines the offset between points
  20020. */
  20021. offset: number;
  20022. /**
  20023. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20024. */
  20025. side: number;
  20026. /**
  20027. * Creates a ribbon geometry
  20028. * @param id defines the unique ID of the geometry
  20029. * @param scene defines the hosting scene
  20030. * @param pathArray defines the array of paths to use
  20031. * @param closeArray defines if the last path and the first path must be joined
  20032. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  20033. * @param offset defines the offset between points
  20034. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20035. * @param mesh defines the hosting mesh (can be null)
  20036. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20037. */
  20038. constructor(id: string, scene: Scene,
  20039. /**
  20040. * Defines the array of paths to use
  20041. */
  20042. pathArray: Vector3[][],
  20043. /**
  20044. * Defines if the last and first points of each path in your pathArray must be joined
  20045. */
  20046. closeArray: boolean,
  20047. /**
  20048. * Defines if the last and first points of each path in your pathArray must be joined
  20049. */
  20050. closePath: boolean,
  20051. /**
  20052. * Defines the offset between points
  20053. */
  20054. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  20055. /**
  20056. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20057. */
  20058. side?: number);
  20059. /** @hidden */
  20060. _regenerateVertexData(): VertexData;
  20061. copy(id: string): Geometry;
  20062. }
  20063. /**
  20064. * Creates a box geometry
  20065. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  20066. */
  20067. class BoxGeometry extends _PrimitiveGeometry {
  20068. /**
  20069. * Defines the zise of the box (width, height and depth are the same)
  20070. */
  20071. size: number;
  20072. /**
  20073. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20074. */
  20075. side: number;
  20076. /**
  20077. * Creates a box geometry
  20078. * @param id defines the unique ID of the geometry
  20079. * @param scene defines the hosting scene
  20080. * @param size defines the zise of the box (width, height and depth are the same)
  20081. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20082. * @param mesh defines the hosting mesh (can be null)
  20083. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20084. */
  20085. constructor(id: string, scene: Scene,
  20086. /**
  20087. * Defines the zise of the box (width, height and depth are the same)
  20088. */
  20089. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20090. /**
  20091. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20092. */
  20093. side?: number);
  20094. _regenerateVertexData(): VertexData;
  20095. copy(id: string): Geometry;
  20096. serialize(): any;
  20097. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  20098. }
  20099. /**
  20100. * Creates a sphere geometry
  20101. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  20102. */
  20103. class SphereGeometry extends _PrimitiveGeometry {
  20104. /**
  20105. * Defines the number of segments to use to create the sphere
  20106. */
  20107. segments: number;
  20108. /**
  20109. * Defines the diameter of the sphere
  20110. */
  20111. diameter: number;
  20112. /**
  20113. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20114. */
  20115. side: number;
  20116. /**
  20117. * Create a new sphere geometry
  20118. * @param id defines the unique ID of the geometry
  20119. * @param scene defines the hosting scene
  20120. * @param segments defines the number of segments to use to create the sphere
  20121. * @param diameter defines the diameter of the sphere
  20122. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20123. * @param mesh defines the hosting mesh (can be null)
  20124. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20125. */
  20126. constructor(id: string, scene: Scene,
  20127. /**
  20128. * Defines the number of segments to use to create the sphere
  20129. */
  20130. segments: number,
  20131. /**
  20132. * Defines the diameter of the sphere
  20133. */
  20134. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20135. /**
  20136. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20137. */
  20138. side?: number);
  20139. _regenerateVertexData(): VertexData;
  20140. copy(id: string): Geometry;
  20141. serialize(): any;
  20142. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  20143. }
  20144. /**
  20145. * Creates a disc geometry
  20146. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20147. */
  20148. class DiscGeometry extends _PrimitiveGeometry {
  20149. /**
  20150. * Defines the radius of the disc
  20151. */
  20152. radius: number;
  20153. /**
  20154. * Defines the tesselation factor to apply to the disc
  20155. */
  20156. tessellation: number;
  20157. /**
  20158. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20159. */
  20160. side: number;
  20161. /**
  20162. * Creates a new disc geometry
  20163. * @param id defines the unique ID of the geometry
  20164. * @param scene defines the hosting scene
  20165. * @param radius defines the radius of the disc
  20166. * @param tessellation defines the tesselation factor to apply to the disc
  20167. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20168. * @param mesh defines the hosting mesh (can be null)
  20169. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20170. */
  20171. constructor(id: string, scene: Scene,
  20172. /**
  20173. * Defines the radius of the disc
  20174. */
  20175. radius: number,
  20176. /**
  20177. * Defines the tesselation factor to apply to the disc
  20178. */
  20179. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20180. /**
  20181. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20182. */
  20183. side?: number);
  20184. _regenerateVertexData(): VertexData;
  20185. copy(id: string): Geometry;
  20186. }
  20187. /**
  20188. * Creates a new cylinder geometry
  20189. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20190. */
  20191. class CylinderGeometry extends _PrimitiveGeometry {
  20192. /**
  20193. * Defines the height of the cylinder
  20194. */
  20195. height: number;
  20196. /**
  20197. * Defines the diameter of the cylinder's top cap
  20198. */
  20199. diameterTop: number;
  20200. /**
  20201. * Defines the diameter of the cylinder's bottom cap
  20202. */
  20203. diameterBottom: number;
  20204. /**
  20205. * Defines the tessellation factor to apply to the cylinder
  20206. */
  20207. tessellation: number;
  20208. /**
  20209. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20210. */
  20211. subdivisions: number;
  20212. /**
  20213. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20214. */
  20215. side: number;
  20216. /**
  20217. * Creates a new cylinder geometry
  20218. * @param id defines the unique ID of the geometry
  20219. * @param scene defines the hosting scene
  20220. * @param height defines the height of the cylinder
  20221. * @param diameterTop defines the diameter of the cylinder's top cap
  20222. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20223. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20224. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20225. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20226. * @param mesh defines the hosting mesh (can be null)
  20227. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20228. */
  20229. constructor(id: string, scene: Scene,
  20230. /**
  20231. * Defines the height of the cylinder
  20232. */
  20233. height: number,
  20234. /**
  20235. * Defines the diameter of the cylinder's top cap
  20236. */
  20237. diameterTop: number,
  20238. /**
  20239. * Defines the diameter of the cylinder's bottom cap
  20240. */
  20241. diameterBottom: number,
  20242. /**
  20243. * Defines the tessellation factor to apply to the cylinder
  20244. */
  20245. tessellation: number,
  20246. /**
  20247. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20248. */
  20249. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20250. /**
  20251. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20252. */
  20253. side?: number);
  20254. _regenerateVertexData(): VertexData;
  20255. copy(id: string): Geometry;
  20256. serialize(): any;
  20257. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  20258. }
  20259. /**
  20260. * Creates a new torus geometry
  20261. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  20262. */
  20263. class TorusGeometry extends _PrimitiveGeometry {
  20264. /**
  20265. * Defines the diameter of the torus
  20266. */
  20267. diameter: number;
  20268. /**
  20269. * Defines the thickness of the torus (ie. internal diameter)
  20270. */
  20271. thickness: number;
  20272. /**
  20273. * Defines the tesselation factor to apply to the torus
  20274. */
  20275. tessellation: number;
  20276. /**
  20277. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20278. */
  20279. side: number;
  20280. /**
  20281. * Creates a new torus geometry
  20282. * @param id defines the unique ID of the geometry
  20283. * @param scene defines the hosting scene
  20284. * @param diameter defines the diameter of the torus
  20285. * @param thickness defines the thickness of the torus (ie. internal diameter)
  20286. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  20287. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20288. * @param mesh defines the hosting mesh (can be null)
  20289. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20290. */
  20291. constructor(id: string, scene: Scene,
  20292. /**
  20293. * Defines the diameter of the torus
  20294. */
  20295. diameter: number,
  20296. /**
  20297. * Defines the thickness of the torus (ie. internal diameter)
  20298. */
  20299. thickness: number,
  20300. /**
  20301. * Defines the tesselation factor to apply to the torus
  20302. */
  20303. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20304. /**
  20305. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20306. */
  20307. side?: number);
  20308. _regenerateVertexData(): VertexData;
  20309. copy(id: string): Geometry;
  20310. serialize(): any;
  20311. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  20312. }
  20313. /**
  20314. * Creates a new ground geometry
  20315. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  20316. */
  20317. class GroundGeometry extends _PrimitiveGeometry {
  20318. /**
  20319. * Defines the width of the ground
  20320. */
  20321. width: number;
  20322. /**
  20323. * Defines the height of the ground
  20324. */
  20325. height: number;
  20326. /**
  20327. * Defines the subdivisions to apply to the ground
  20328. */
  20329. subdivisions: number;
  20330. /**
  20331. * Creates a new ground geometry
  20332. * @param id defines the unique ID of the geometry
  20333. * @param scene defines the hosting scene
  20334. * @param width defines the width of the ground
  20335. * @param height defines the height of the ground
  20336. * @param subdivisions defines the subdivisions to apply to the ground
  20337. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20338. * @param mesh defines the hosting mesh (can be null)
  20339. */
  20340. constructor(id: string, scene: Scene,
  20341. /**
  20342. * Defines the width of the ground
  20343. */
  20344. width: number,
  20345. /**
  20346. * Defines the height of the ground
  20347. */
  20348. height: number,
  20349. /**
  20350. * Defines the subdivisions to apply to the ground
  20351. */
  20352. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20353. _regenerateVertexData(): VertexData;
  20354. copy(id: string): Geometry;
  20355. serialize(): any;
  20356. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  20357. }
  20358. /**
  20359. * Creates a tiled ground geometry
  20360. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  20361. */
  20362. class TiledGroundGeometry extends _PrimitiveGeometry {
  20363. /**
  20364. * Defines the minimum value on X axis
  20365. */
  20366. xmin: number;
  20367. /**
  20368. * Defines the minimum value on Z axis
  20369. */
  20370. zmin: number;
  20371. /**
  20372. * Defines the maximum value on X axis
  20373. */
  20374. xmax: number;
  20375. /**
  20376. * Defines the maximum value on Z axis
  20377. */
  20378. zmax: number;
  20379. /**
  20380. * Defines the subdivisions to apply to the ground
  20381. */
  20382. subdivisions: {
  20383. w: number;
  20384. h: number;
  20385. };
  20386. /**
  20387. * Defines the precision to use when computing the tiles
  20388. */
  20389. precision: {
  20390. w: number;
  20391. h: number;
  20392. };
  20393. /**
  20394. * Creates a tiled ground geometry
  20395. * @param id defines the unique ID of the geometry
  20396. * @param scene defines the hosting scene
  20397. * @param xmin defines the minimum value on X axis
  20398. * @param zmin defines the minimum value on Z axis
  20399. * @param xmax defines the maximum value on X axis
  20400. * @param zmax defines the maximum value on Z axis
  20401. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  20402. * @param precision defines the precision to use when computing the tiles
  20403. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20404. * @param mesh defines the hosting mesh (can be null)
  20405. */
  20406. constructor(id: string, scene: Scene,
  20407. /**
  20408. * Defines the minimum value on X axis
  20409. */
  20410. xmin: number,
  20411. /**
  20412. * Defines the minimum value on Z axis
  20413. */
  20414. zmin: number,
  20415. /**
  20416. * Defines the maximum value on X axis
  20417. */
  20418. xmax: number,
  20419. /**
  20420. * Defines the maximum value on Z axis
  20421. */
  20422. zmax: number,
  20423. /**
  20424. * Defines the subdivisions to apply to the ground
  20425. */
  20426. subdivisions: {
  20427. w: number;
  20428. h: number;
  20429. },
  20430. /**
  20431. * Defines the precision to use when computing the tiles
  20432. */
  20433. precision: {
  20434. w: number;
  20435. h: number;
  20436. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20437. _regenerateVertexData(): VertexData;
  20438. copy(id: string): Geometry;
  20439. }
  20440. /**
  20441. * Creates a plane geometry
  20442. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  20443. */
  20444. class PlaneGeometry extends _PrimitiveGeometry {
  20445. /**
  20446. * Defines the size of the plane (width === height)
  20447. */
  20448. size: number;
  20449. /**
  20450. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20451. */
  20452. side: number;
  20453. /**
  20454. * Creates a plane geometry
  20455. * @param id defines the unique ID of the geometry
  20456. * @param scene defines the hosting scene
  20457. * @param size defines the size of the plane (width === height)
  20458. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20459. * @param mesh defines the hosting mesh (can be null)
  20460. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20461. */
  20462. constructor(id: string, scene: Scene,
  20463. /**
  20464. * Defines the size of the plane (width === height)
  20465. */
  20466. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20467. /**
  20468. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20469. */
  20470. side?: number);
  20471. _regenerateVertexData(): VertexData;
  20472. copy(id: string): Geometry;
  20473. serialize(): any;
  20474. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  20475. }
  20476. /**
  20477. * Creates a torus knot geometry
  20478. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  20479. */
  20480. class TorusKnotGeometry extends _PrimitiveGeometry {
  20481. /**
  20482. * Defines the radius of the torus knot
  20483. */
  20484. radius: number;
  20485. /**
  20486. * Defines the thickness of the torus knot tube
  20487. */
  20488. tube: number;
  20489. /**
  20490. * Defines the number of radial segments
  20491. */
  20492. radialSegments: number;
  20493. /**
  20494. * Defines the number of tubular segments
  20495. */
  20496. tubularSegments: number;
  20497. /**
  20498. * Defines the first number of windings
  20499. */
  20500. p: number;
  20501. /**
  20502. * Defines the second number of windings
  20503. */
  20504. q: number;
  20505. /**
  20506. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20507. */
  20508. side: number;
  20509. /**
  20510. * Creates a torus knot geometry
  20511. * @param id defines the unique ID of the geometry
  20512. * @param scene defines the hosting scene
  20513. * @param radius defines the radius of the torus knot
  20514. * @param tube defines the thickness of the torus knot tube
  20515. * @param radialSegments defines the number of radial segments
  20516. * @param tubularSegments defines the number of tubular segments
  20517. * @param p defines the first number of windings
  20518. * @param q defines the second number of windings
  20519. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20520. * @param mesh defines the hosting mesh (can be null)
  20521. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20522. */
  20523. constructor(id: string, scene: Scene,
  20524. /**
  20525. * Defines the radius of the torus knot
  20526. */
  20527. radius: number,
  20528. /**
  20529. * Defines the thickness of the torus knot tube
  20530. */
  20531. tube: number,
  20532. /**
  20533. * Defines the number of radial segments
  20534. */
  20535. radialSegments: number,
  20536. /**
  20537. * Defines the number of tubular segments
  20538. */
  20539. tubularSegments: number,
  20540. /**
  20541. * Defines the first number of windings
  20542. */
  20543. p: number,
  20544. /**
  20545. * Defines the second number of windings
  20546. */
  20547. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20548. /**
  20549. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20550. */
  20551. side?: number);
  20552. _regenerateVertexData(): VertexData;
  20553. copy(id: string): Geometry;
  20554. serialize(): any;
  20555. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  20556. }
  20557. }
  20558. declare module BABYLON {
  20559. class GroundMesh extends Mesh {
  20560. generateOctree: boolean;
  20561. private _heightQuads;
  20562. _subdivisionsX: number;
  20563. _subdivisionsY: number;
  20564. _width: number;
  20565. _height: number;
  20566. _minX: number;
  20567. _maxX: number;
  20568. _minZ: number;
  20569. _maxZ: number;
  20570. constructor(name: string, scene: Scene);
  20571. getClassName(): string;
  20572. readonly subdivisions: number;
  20573. readonly subdivisionsX: number;
  20574. readonly subdivisionsY: number;
  20575. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20576. /**
  20577. * Returns a height (y) value in the Worl system :
  20578. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20579. * Returns the ground y position if (x, z) are outside the ground surface.
  20580. */
  20581. getHeightAtCoordinates(x: number, z: number): number;
  20582. /**
  20583. * Returns a normalized vector (Vector3) orthogonal to the ground
  20584. * at the ground coordinates (x, z) expressed in the World system.
  20585. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20586. */
  20587. getNormalAtCoordinates(x: number, z: number): Vector3;
  20588. /**
  20589. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20590. * at the ground coordinates (x, z) expressed in the World system.
  20591. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20592. * Returns the GroundMesh.
  20593. */
  20594. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20595. /**
  20596. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20597. * if the ground has been updated.
  20598. * This can be used in the render loop.
  20599. * Returns the GroundMesh.
  20600. */
  20601. updateCoordinateHeights(): GroundMesh;
  20602. private _getFacetAt(x, z);
  20603. private _initHeightQuads();
  20604. private _computeHeightQuads();
  20605. serialize(serializationObject: any): void;
  20606. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20607. }
  20608. }
  20609. declare module BABYLON {
  20610. /**
  20611. * Creates an instance based on a source mesh.
  20612. */
  20613. class InstancedMesh extends AbstractMesh {
  20614. private _sourceMesh;
  20615. private _currentLOD;
  20616. constructor(name: string, source: Mesh);
  20617. /**
  20618. * Returns the string "InstancedMesh".
  20619. */
  20620. getClassName(): string;
  20621. readonly receiveShadows: boolean;
  20622. readonly material: Nullable<Material>;
  20623. readonly visibility: number;
  20624. readonly skeleton: Nullable<Skeleton>;
  20625. renderingGroupId: number;
  20626. /**
  20627. * Returns the total number of vertices (integer).
  20628. */
  20629. getTotalVertices(): number;
  20630. readonly sourceMesh: Mesh;
  20631. /**
  20632. * Is this node ready to be used/rendered
  20633. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20634. * @return {boolean} is it ready
  20635. */
  20636. isReady(completeCheck?: boolean): boolean;
  20637. /**
  20638. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  20639. */
  20640. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  20641. /**
  20642. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20643. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20644. * The `data` are either a numeric array either a Float32Array.
  20645. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  20646. * 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).
  20647. * Note that a new underlying VertexBuffer object is created each call.
  20648. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20649. *
  20650. * Possible `kind` values :
  20651. * - BABYLON.VertexBuffer.PositionKind
  20652. * - BABYLON.VertexBuffer.UVKind
  20653. * - BABYLON.VertexBuffer.UV2Kind
  20654. * - BABYLON.VertexBuffer.UV3Kind
  20655. * - BABYLON.VertexBuffer.UV4Kind
  20656. * - BABYLON.VertexBuffer.UV5Kind
  20657. * - BABYLON.VertexBuffer.UV6Kind
  20658. * - BABYLON.VertexBuffer.ColorKind
  20659. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20660. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20661. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20662. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20663. *
  20664. * Returns the Mesh.
  20665. */
  20666. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20667. /**
  20668. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20669. * If the mesh has no geometry, it is simply returned as it is.
  20670. * The `data` are either a numeric array either a Float32Array.
  20671. * No new underlying VertexBuffer object is created.
  20672. * 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.
  20673. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  20674. *
  20675. * Possible `kind` values :
  20676. * - BABYLON.VertexBuffer.PositionKind
  20677. * - BABYLON.VertexBuffer.UVKind
  20678. * - BABYLON.VertexBuffer.UV2Kind
  20679. * - BABYLON.VertexBuffer.UV3Kind
  20680. * - BABYLON.VertexBuffer.UV4Kind
  20681. * - BABYLON.VertexBuffer.UV5Kind
  20682. * - BABYLON.VertexBuffer.UV6Kind
  20683. * - BABYLON.VertexBuffer.ColorKind
  20684. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20685. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20686. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20687. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20688. *
  20689. * Returns the Mesh.
  20690. */
  20691. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20692. /**
  20693. * Sets the mesh indices.
  20694. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  20695. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20696. * This method creates a new index buffer each call.
  20697. * Returns the Mesh.
  20698. */
  20699. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  20700. /**
  20701. * Boolean : True if the mesh owns the requested kind of data.
  20702. */
  20703. isVerticesDataPresent(kind: string): boolean;
  20704. /**
  20705. * Returns an array of indices (IndicesArray).
  20706. */
  20707. getIndices(): Nullable<IndicesArray>;
  20708. readonly _positions: Nullable<Vector3[]>;
  20709. /**
  20710. * Sets a new updated BoundingInfo to the mesh.
  20711. * Returns the mesh.
  20712. */
  20713. refreshBoundingInfo(): InstancedMesh;
  20714. _preActivate(): InstancedMesh;
  20715. _activate(renderId: number): InstancedMesh;
  20716. /**
  20717. * Returns the current associated LOD AbstractMesh.
  20718. */
  20719. getLOD(camera: Camera): AbstractMesh;
  20720. _syncSubMeshes(): InstancedMesh;
  20721. _generatePointsArray(): boolean;
  20722. /**
  20723. * Creates a new InstancedMesh from the current mesh.
  20724. * - name (string) : the cloned mesh name
  20725. * - newParent (optional Node) : the optional Node to parent the clone to.
  20726. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  20727. *
  20728. * Returns the clone.
  20729. */
  20730. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  20731. /**
  20732. * Disposes the InstancedMesh.
  20733. * Returns nothing.
  20734. */
  20735. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20736. }
  20737. }
  20738. declare module BABYLON {
  20739. class LinesMesh extends Mesh {
  20740. useVertexColor: boolean | undefined;
  20741. useVertexAlpha: boolean | undefined;
  20742. color: Color3;
  20743. alpha: number;
  20744. /**
  20745. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20746. * This margin is expressed in world space coordinates, so its value may vary.
  20747. * Default value is 0.1
  20748. * @returns the intersection Threshold value.
  20749. */
  20750. /**
  20751. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20752. * This margin is expressed in world space coordinates, so its value may vary.
  20753. * @param value the new threshold to apply
  20754. */
  20755. intersectionThreshold: number;
  20756. private _intersectionThreshold;
  20757. private _colorShader;
  20758. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  20759. /**
  20760. * Returns the string "LineMesh"
  20761. */
  20762. getClassName(): string;
  20763. material: Material;
  20764. readonly checkCollisions: boolean;
  20765. createInstance(name: string): InstancedMesh;
  20766. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  20767. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  20768. dispose(doNotRecurse?: boolean): void;
  20769. /**
  20770. * Returns a new LineMesh object cloned from the current one.
  20771. */
  20772. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  20773. }
  20774. }
  20775. declare module BABYLON {
  20776. /**
  20777. * @hidden
  20778. **/
  20779. class _InstancesBatch {
  20780. mustReturn: boolean;
  20781. visibleInstances: Nullable<InstancedMesh[]>[];
  20782. renderSelf: boolean[];
  20783. }
  20784. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20785. static _FRONTSIDE: number;
  20786. static _BACKSIDE: number;
  20787. static _DOUBLESIDE: number;
  20788. static _DEFAULTSIDE: number;
  20789. static _NO_CAP: number;
  20790. static _CAP_START: number;
  20791. static _CAP_END: number;
  20792. static _CAP_ALL: number;
  20793. /**
  20794. * Mesh side orientation : usually the external or front surface
  20795. */
  20796. static readonly FRONTSIDE: number;
  20797. /**
  20798. * Mesh side orientation : usually the internal or back surface
  20799. */
  20800. static readonly BACKSIDE: number;
  20801. /**
  20802. * Mesh side orientation : both internal and external or front and back surfaces
  20803. */
  20804. static readonly DOUBLESIDE: number;
  20805. /**
  20806. * Mesh side orientation : by default, `FRONTSIDE`
  20807. */
  20808. static readonly DEFAULTSIDE: number;
  20809. /**
  20810. * Mesh cap setting : no cap
  20811. */
  20812. static readonly NO_CAP: number;
  20813. /**
  20814. * Mesh cap setting : one cap at the beginning of the mesh
  20815. */
  20816. static readonly CAP_START: number;
  20817. /**
  20818. * Mesh cap setting : one cap at the end of the mesh
  20819. */
  20820. static readonly CAP_END: number;
  20821. /**
  20822. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20823. */
  20824. static readonly CAP_ALL: number;
  20825. /**
  20826. * An event triggered before rendering the mesh
  20827. */
  20828. onBeforeRenderObservable: Observable<Mesh>;
  20829. /**
  20830. * An event triggered after rendering the mesh
  20831. */
  20832. onAfterRenderObservable: Observable<Mesh>;
  20833. /**
  20834. * An event triggered before drawing the mesh
  20835. */
  20836. onBeforeDrawObservable: Observable<Mesh>;
  20837. private _onBeforeDrawObserver;
  20838. onBeforeDraw: () => void;
  20839. delayLoadState: number;
  20840. instances: InstancedMesh[];
  20841. delayLoadingFile: string;
  20842. _binaryInfo: any;
  20843. private _LODLevels;
  20844. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20845. private _morphTargetManager;
  20846. morphTargetManager: Nullable<MorphTargetManager>;
  20847. _geometry: Nullable<Geometry>;
  20848. _delayInfo: Array<string>;
  20849. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20850. _visibleInstances: any;
  20851. private _renderIdForInstances;
  20852. private _batchCache;
  20853. private _instancesBufferSize;
  20854. private _instancesBuffer;
  20855. private _instancesData;
  20856. private _overridenInstanceCount;
  20857. private _effectiveMaterial;
  20858. _shouldGenerateFlatShading: boolean;
  20859. private _preActivateId;
  20860. _originalBuilderSideOrientation: number;
  20861. overrideMaterialSideOrientation: Nullable<number>;
  20862. private _areNormalsFrozen;
  20863. private _sourcePositions;
  20864. private _sourceNormals;
  20865. private _source;
  20866. readonly source: Nullable<Mesh>;
  20867. isUnIndexed: boolean;
  20868. /**
  20869. * @constructor
  20870. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  20871. * @param {Scene} scene The scene to add this mesh to.
  20872. * @param {Node} parent The parent of this mesh, if it has one
  20873. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  20874. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20875. * When false, achieved by calling a clone(), also passing False.
  20876. * This will make creation of children, recursive.
  20877. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20878. */
  20879. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20880. /**
  20881. * Returns the string "Mesh".
  20882. */
  20883. getClassName(): string;
  20884. /**
  20885. * Returns a string.
  20886. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  20887. */
  20888. toString(fullDetails?: boolean): string;
  20889. _unBindEffect(): void;
  20890. /**
  20891. * True if the mesh has some Levels Of Details (LOD).
  20892. * Returns a boolean.
  20893. */
  20894. readonly hasLODLevels: boolean;
  20895. /**
  20896. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  20897. * @returns an array of {BABYLON.MeshLODLevel}
  20898. */
  20899. getLODLevels(): MeshLODLevel[];
  20900. private _sortLODLevels();
  20901. /**
  20902. * Add a mesh as LOD level triggered at the given distance.
  20903. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20904. * @param distance The distance from the center of the object to show this level
  20905. * @param mesh The mesh to be added as LOD level (can be null)
  20906. * @return This mesh (for chaining)
  20907. */
  20908. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20909. /**
  20910. * Returns the LOD level mesh at the passed distance or null if not found.
  20911. * It is related to the method `addLODLevel(distance, mesh)`.
  20912. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20913. * Returns an object Mesh or `null`.
  20914. */
  20915. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20916. /**
  20917. * Remove a mesh from the LOD array
  20918. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20919. * @param {Mesh} mesh The mesh to be removed.
  20920. * @return {Mesh} This mesh (for chaining)
  20921. */
  20922. removeLODLevel(mesh: Mesh): Mesh;
  20923. /**
  20924. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20925. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  20926. */
  20927. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20928. /**
  20929. * Returns the mesh internal Geometry object.
  20930. */
  20931. readonly geometry: Nullable<Geometry>;
  20932. /**
  20933. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20934. */
  20935. getTotalVertices(): number;
  20936. /**
  20937. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  20938. * 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.
  20939. * You can force the copy with forceCopy === true
  20940. * Returns null if the mesh has no geometry or no vertex buffer.
  20941. * Possible `kind` values :
  20942. * - BABYLON.VertexBuffer.PositionKind
  20943. * - BABYLON.VertexBuffer.UVKind
  20944. * - BABYLON.VertexBuffer.UV2Kind
  20945. * - BABYLON.VertexBuffer.UV3Kind
  20946. * - BABYLON.VertexBuffer.UV4Kind
  20947. * - BABYLON.VertexBuffer.UV5Kind
  20948. * - BABYLON.VertexBuffer.UV6Kind
  20949. * - BABYLON.VertexBuffer.ColorKind
  20950. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20951. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20952. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20953. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20954. */
  20955. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20956. /**
  20957. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  20958. * Returns `null` if the mesh has no geometry.
  20959. * Possible `kind` values :
  20960. * - BABYLON.VertexBuffer.PositionKind
  20961. * - BABYLON.VertexBuffer.UVKind
  20962. * - BABYLON.VertexBuffer.UV2Kind
  20963. * - BABYLON.VertexBuffer.UV3Kind
  20964. * - BABYLON.VertexBuffer.UV4Kind
  20965. * - BABYLON.VertexBuffer.UV5Kind
  20966. * - BABYLON.VertexBuffer.UV6Kind
  20967. * - BABYLON.VertexBuffer.ColorKind
  20968. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20969. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20970. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20971. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20972. */
  20973. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20974. isVerticesDataPresent(kind: string): boolean;
  20975. /**
  20976. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20977. * Possible `kind` values :
  20978. * - BABYLON.VertexBuffer.PositionKind
  20979. * - BABYLON.VertexBuffer.UVKind
  20980. * - BABYLON.VertexBuffer.UV2Kind
  20981. * - BABYLON.VertexBuffer.UV3Kind
  20982. * - BABYLON.VertexBuffer.UV4Kind
  20983. * - BABYLON.VertexBuffer.UV5Kind
  20984. * - BABYLON.VertexBuffer.UV6Kind
  20985. * - BABYLON.VertexBuffer.ColorKind
  20986. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20987. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20988. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20989. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20990. */
  20991. isVertexBufferUpdatable(kind: string): boolean;
  20992. /**
  20993. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  20994. * Possible `kind` values :
  20995. * - BABYLON.VertexBuffer.PositionKind
  20996. * - BABYLON.VertexBuffer.UVKind
  20997. * - BABYLON.VertexBuffer.UV2Kind
  20998. * - BABYLON.VertexBuffer.UV3Kind
  20999. * - BABYLON.VertexBuffer.UV4Kind
  21000. * - BABYLON.VertexBuffer.UV5Kind
  21001. * - BABYLON.VertexBuffer.UV6Kind
  21002. * - BABYLON.VertexBuffer.ColorKind
  21003. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21004. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21005. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21006. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21007. */
  21008. getVerticesDataKinds(): string[];
  21009. /**
  21010. * Returns a positive integer : the total number of indices in this mesh geometry.
  21011. * Returns zero if the mesh has no geometry.
  21012. */
  21013. getTotalIndices(): number;
  21014. /**
  21015. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21016. * 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.
  21017. * Returns an empty array if the mesh has no geometry.
  21018. */
  21019. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21020. readonly isBlocked: boolean;
  21021. /**
  21022. * Determine if the current mesh is ready to be rendered
  21023. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21024. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21025. * @returns true if all associated assets are ready (material, textures, shaders)
  21026. */
  21027. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21028. /**
  21029. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  21030. * This property is pertinent only for updatable parametric shapes.
  21031. */
  21032. readonly areNormalsFrozen: boolean;
  21033. /**
  21034. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21035. * It has no effect at all on other shapes.
  21036. * It prevents the mesh normals from being recomputed on next `positions` array update.
  21037. * Returns the Mesh.
  21038. */
  21039. freezeNormals(): Mesh;
  21040. /**
  21041. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21042. * It has no effect at all on other shapes.
  21043. * It reactivates the mesh normals computation if it was previously frozen.
  21044. * Returns the Mesh.
  21045. */
  21046. unfreezeNormals(): Mesh;
  21047. /**
  21048. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21049. */
  21050. overridenInstanceCount: number;
  21051. _preActivate(): Mesh;
  21052. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21053. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21054. /**
  21055. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21056. * This means the mesh underlying bounding box and sphere are recomputed.
  21057. * Returns the Mesh.
  21058. */
  21059. refreshBoundingInfo(): Mesh;
  21060. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  21061. private _getPositionData(applySkeleton);
  21062. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21063. subdivide(count: number): void;
  21064. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21065. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21066. /**
  21067. * Sets the mesh VertexBuffer.
  21068. * Returns the Mesh.
  21069. */
  21070. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21071. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21072. /**
  21073. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21074. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21075. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  21076. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  21077. * Returns the Mesh.
  21078. */
  21079. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21080. /**
  21081. * Creates a un-shared specific occurence of the geometry for the mesh.
  21082. * Returns the Mesh.
  21083. */
  21084. makeGeometryUnique(): Mesh;
  21085. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21086. /**
  21087. * Update the current index buffer
  21088. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21089. * Returns the Mesh.
  21090. */
  21091. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  21092. /**
  21093. * Invert the geometry to move from a right handed system to a left handed one.
  21094. * Returns the Mesh.
  21095. */
  21096. toLeftHanded(): Mesh;
  21097. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21098. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  21099. /**
  21100. * Registers for this mesh a javascript function called just before the rendering process.
  21101. * This function is passed the current mesh.
  21102. * Return the Mesh.
  21103. */
  21104. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21105. /**
  21106. * Disposes a previously registered javascript function called before the rendering.
  21107. * This function is passed the current mesh.
  21108. * Returns the Mesh.
  21109. */
  21110. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21111. /**
  21112. * Registers for this mesh a javascript function called just after the rendering is complete.
  21113. * This function is passed the current mesh.
  21114. * Returns the Mesh.
  21115. */
  21116. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21117. /**
  21118. * Disposes a previously registered javascript function called after the rendering.
  21119. * This function is passed the current mesh.
  21120. * Return the Mesh.
  21121. */
  21122. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21123. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21124. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21125. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21126. /**
  21127. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  21128. * @param subMesh defines the subMesh to render
  21129. * @param enableAlphaMode defines if alpha mode can be changed
  21130. * @returns the current mesh
  21131. */
  21132. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21133. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  21134. /**
  21135. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter.
  21136. */
  21137. getEmittedParticleSystems(): IParticleSystem[];
  21138. /**
  21139. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter.
  21140. */
  21141. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21142. /**
  21143. * Normalize matrix weights so that all vertices have a total weight set to 1
  21144. */
  21145. cleanMatrixWeights(): void;
  21146. _checkDelayState(): Mesh;
  21147. private _queueLoad(scene);
  21148. /**
  21149. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  21150. */
  21151. isInFrustum(frustumPlanes: Plane[]): boolean;
  21152. /**
  21153. * Sets the mesh material by the material or multiMaterial `id` property.
  21154. * The material `id` is a string identifying the material or the multiMaterial.
  21155. * This method returns the Mesh.
  21156. */
  21157. setMaterialByID(id: string): Mesh;
  21158. /**
  21159. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21160. */
  21161. getAnimatables(): IAnimatable[];
  21162. /**
  21163. * Modifies the mesh geometry according to the passed transformation matrix.
  21164. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21165. * The mesh normals are modified accordingly the same transformation.
  21166. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21167. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21168. * Returns the Mesh.
  21169. */
  21170. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21171. /**
  21172. * Modifies the mesh geometry according to its own current World Matrix.
  21173. * The mesh World Matrix is then reset.
  21174. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21175. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21176. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21177. * Returns the Mesh.
  21178. */
  21179. bakeCurrentTransformIntoVertices(): Mesh;
  21180. readonly _positions: Nullable<Vector3[]>;
  21181. _resetPointsArrayCache(): Mesh;
  21182. _generatePointsArray(): boolean;
  21183. /**
  21184. * Returns a new Mesh object generated from the current mesh properties.
  21185. * This method must not get confused with createInstance().
  21186. * The parameter `name` is a string, the name given to the new mesh.
  21187. * The optional parameter `newParent` can be any Node object (default `null`).
  21188. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21189. * 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.
  21190. */
  21191. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21192. /**
  21193. * Releases resources associated with this mesh.
  21194. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21195. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21196. */
  21197. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21198. /**
  21199. * Modifies the mesh geometry according to a displacement map.
  21200. * 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.
  21201. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21202. * This method returns nothing.
  21203. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  21204. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21205. * 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.
  21206. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21207. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21208. *
  21209. * Returns the Mesh.
  21210. */
  21211. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21212. /**
  21213. * Modifies the mesh geometry according to a displacementMap buffer.
  21214. * 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.
  21215. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21216. * This method returns nothing.
  21217. * 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.
  21218. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  21219. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21220. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21221. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21222. *
  21223. * Returns the Mesh.
  21224. */
  21225. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21226. /**
  21227. * Modify the mesh to get a flat shading rendering.
  21228. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21229. * This method returns the Mesh.
  21230. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21231. */
  21232. convertToFlatShadedMesh(): Mesh;
  21233. /**
  21234. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21235. * In other words, more vertices, no more indices and a single bigger VBO.
  21236. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21237. * Returns the Mesh.
  21238. */
  21239. convertToUnIndexedMesh(): Mesh;
  21240. /**
  21241. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  21242. * This method returns the Mesh.
  21243. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21244. */
  21245. flipFaces(flipNormals?: boolean): Mesh;
  21246. /**
  21247. * Creates a new InstancedMesh object from the mesh model.
  21248. * An instance shares the same properties and the same material than its model.
  21249. * Only these properties of each instance can then be set individually :
  21250. * - position
  21251. * - rotation
  21252. * - rotationQuaternion
  21253. * - setPivotMatrix
  21254. * - scaling
  21255. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  21256. * Warning : this method is not supported for Line mesh and LineSystem
  21257. */
  21258. createInstance(name: string): InstancedMesh;
  21259. /**
  21260. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21261. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21262. * This method returns the Mesh.
  21263. */
  21264. synchronizeInstances(): Mesh;
  21265. /**
  21266. * Simplify the mesh according to the given array of settings.
  21267. * Function will return immediately and will simplify async. It returns the Mesh.
  21268. * @param settings a collection of simplification settings.
  21269. * @param parallelProcessing should all levels calculate parallel or one after the other.
  21270. * @param type the type of simplification to run.
  21271. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  21272. */
  21273. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  21274. /**
  21275. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21276. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21277. * This should be used together with the simplification to avoid disappearing triangles.
  21278. * Returns the Mesh.
  21279. * @param successCallback an optional success callback to be called after the optimization finished.
  21280. */
  21281. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21282. serialize(serializationObject: any): void;
  21283. _syncGeometryWithMorphTargetManager(): void;
  21284. /**
  21285. * Returns a new Mesh object parsed from the source provided.
  21286. * The parameter `parsedMesh` is the source.
  21287. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  21288. */
  21289. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21290. /**
  21291. * Creates a ribbon mesh.
  21292. * Please consider using the same method from the MeshBuilder class instead.
  21293. * 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.
  21294. *
  21295. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21296. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21297. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  21298. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  21299. * 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.
  21300. * 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.
  21301. * 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
  21302. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21303. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21304. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21305. */
  21306. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21307. /**
  21308. * Creates a plane polygonal mesh. By default, this is a disc.
  21309. * Please consider using the same method from the MeshBuilder class instead.
  21310. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  21311. * 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.
  21312. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21313. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21314. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21315. */
  21316. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21317. /**
  21318. * Creates a box mesh.
  21319. * Please consider using the same method from the MeshBuilder class instead.
  21320. * The parameter `size` sets the size (float) of each box side (default 1).
  21321. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21322. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21323. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21324. */
  21325. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21326. /**
  21327. * Creates a sphere mesh.
  21328. * Please consider using the same method from the MeshBuilder class instead.
  21329. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  21330. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  21331. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21332. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21333. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21334. */
  21335. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21336. /**
  21337. * Creates a cylinder or a cone mesh.
  21338. * Please consider using the same method from the MeshBuilder class instead.
  21339. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21340. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21341. * 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.
  21342. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21343. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21344. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21345. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21346. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21347. */
  21348. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21349. /**
  21350. * Creates a torus mesh.
  21351. * Please consider using the same method from the MeshBuilder class instead.
  21352. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  21353. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  21354. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  21355. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21356. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21357. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21358. */
  21359. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21360. /**
  21361. * Creates a torus knot mesh.
  21362. * Please consider using the same method from the MeshBuilder class instead.
  21363. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  21364. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  21365. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  21366. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  21367. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21368. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21369. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21370. */
  21371. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21372. /**
  21373. * Creates a line mesh.
  21374. * Please consider using the same method from the MeshBuilder class instead.
  21375. * 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.
  21376. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21377. * The parameter `points` is an array successive Vector3.
  21378. * 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
  21379. * When updating an instance, remember that only point positions can change, not the number of points.
  21380. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21381. */
  21382. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21383. /**
  21384. * Creates a dashed line mesh.
  21385. * Please consider using the same method from the MeshBuilder class instead.
  21386. * 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.
  21387. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21388. * The parameter `points` is an array successive Vector3.
  21389. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  21390. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  21391. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  21392. * 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
  21393. * When updating an instance, remember that only point positions can change, not the number of points.
  21394. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21395. */
  21396. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21397. /**
  21398. * Creates a polygon mesh.
  21399. * Please consider using the same method from the MeshBuilder class instead.
  21400. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21401. * 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.
  21402. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21403. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21404. * Remember you can only change the shape positions, not their number when updating a polygon.
  21405. */
  21406. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21407. /**
  21408. * Creates an extruded polygon mesh, with depth in the Y direction.
  21409. * Please consider using the same method from the MeshBuilder class instead.
  21410. */
  21411. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21412. /**
  21413. * Creates an extruded shape mesh.
  21414. * 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.
  21415. * Please consider using the same method from the MeshBuilder class instead.
  21416. *
  21417. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21418. * 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
  21419. * extruded along the Z axis.
  21420. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21421. * 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.
  21422. * The parameter `scale` (float, default 1) is the value to scale the shape.
  21423. * 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
  21424. * 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
  21425. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21426. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21427. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21428. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21429. */
  21430. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21431. /**
  21432. * Creates an custom extruded shape mesh.
  21433. * 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.
  21434. * Please consider using the same method from the MeshBuilder class instead.
  21435. *
  21436. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21437. * 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
  21438. * extruded along the Z axis.
  21439. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21440. * 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
  21441. * and the distance of this point from the begining of the path :
  21442. * ```javascript
  21443. * var rotationFunction = function(i, distance) {
  21444. * // do things
  21445. * return rotationValue; }
  21446. * ```
  21447. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  21448. * 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
  21449. * and the distance of this point from the begining of the path :
  21450. * ```javascript
  21451. * var scaleFunction = function(i, distance) {
  21452. * // do things
  21453. * return scaleValue;}
  21454. * ```
  21455. * It must returns a float value that will be the scale value applied to the shape on each path point.
  21456. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  21457. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  21458. * 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
  21459. * 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
  21460. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21461. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21462. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21463. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21464. */
  21465. 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;
  21466. /**
  21467. * Creates lathe mesh.
  21468. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21469. * Please consider using the same method from the MeshBuilder class instead.
  21470. * 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
  21471. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  21472. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  21473. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  21474. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21475. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21476. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21477. */
  21478. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21479. /**
  21480. * Creates a plane mesh.
  21481. * Please consider using the same method from the MeshBuilder class instead.
  21482. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  21483. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21484. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21485. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21486. */
  21487. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21488. /**
  21489. * Creates a ground mesh.
  21490. * Please consider using the same method from the MeshBuilder class instead.
  21491. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  21492. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  21493. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21494. */
  21495. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21496. /**
  21497. * Creates a tiled ground mesh.
  21498. * Please consider using the same method from the MeshBuilder class instead.
  21499. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  21500. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  21501. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  21502. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  21503. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  21504. * numbers of subdivisions on the ground width and height of each tile.
  21505. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21506. */
  21507. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21508. w: number;
  21509. h: number;
  21510. }, precision: {
  21511. w: number;
  21512. h: number;
  21513. }, scene: Scene, updatable?: boolean): Mesh;
  21514. /**
  21515. * Creates a ground mesh from a height map.
  21516. * tuto : http://doc.babylonjs.com/babylon101/height_map
  21517. * Please consider using the same method from the MeshBuilder class instead.
  21518. * The parameter `url` sets the URL of the height map image resource.
  21519. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  21520. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  21521. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  21522. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  21523. * 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).
  21524. * This function is passed the newly built mesh :
  21525. * ```javascript
  21526. * function(mesh) { // do things
  21527. * return; }
  21528. * ```
  21529. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21530. */
  21531. 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;
  21532. /**
  21533. * Creates a tube mesh.
  21534. * 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.
  21535. * Please consider using the same method from the MeshBuilder class instead.
  21536. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  21537. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  21538. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  21539. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  21540. * 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.
  21541. * It must return a radius value (positive float) :
  21542. * ```javascript
  21543. * var radiusFunction = function(i, distance) {
  21544. * // do things
  21545. * return radius; }
  21546. * ```
  21547. * 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
  21548. * 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
  21549. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21550. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21551. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21552. */
  21553. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21554. (i: number, distance: number): number;
  21555. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21556. /**
  21557. * Creates a polyhedron mesh.
  21558. * Please consider using the same method from the MeshBuilder class instead.
  21559. * 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
  21560. * to choose the wanted type.
  21561. * The parameter `size` (positive float, default 1) sets the polygon size.
  21562. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  21563. * 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`.
  21564. * 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
  21565. * 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)`).
  21566. * 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
  21567. * 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.
  21568. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21569. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21570. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21571. */
  21572. static CreatePolyhedron(name: string, options: {
  21573. type?: number;
  21574. size?: number;
  21575. sizeX?: number;
  21576. sizeY?: number;
  21577. sizeZ?: number;
  21578. custom?: any;
  21579. faceUV?: Vector4[];
  21580. faceColors?: Color4[];
  21581. updatable?: boolean;
  21582. sideOrientation?: number;
  21583. }, scene: Scene): Mesh;
  21584. /**
  21585. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  21586. * Please consider using the same method from the MeshBuilder class instead.
  21587. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  21588. * 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`).
  21589. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  21590. * 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.
  21591. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21592. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21593. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21594. */
  21595. static CreateIcoSphere(name: string, options: {
  21596. radius?: number;
  21597. flat?: boolean;
  21598. subdivisions?: number;
  21599. sideOrientation?: number;
  21600. updatable?: boolean;
  21601. }, scene: Scene): Mesh;
  21602. /**
  21603. * Creates a decal mesh.
  21604. * Please consider using the same method from the MeshBuilder class instead.
  21605. * 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.
  21606. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  21607. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  21608. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  21609. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  21610. */
  21611. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21612. /**
  21613. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21614. */
  21615. setPositionsForCPUSkinning(): Float32Array;
  21616. /**
  21617. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21618. */
  21619. setNormalsForCPUSkinning(): Float32Array;
  21620. /**
  21621. * Updates the vertex buffer by applying transformation from the bones.
  21622. * Returns the Mesh.
  21623. *
  21624. * @param {skeleton} skeleton to apply
  21625. */
  21626. applySkeleton(skeleton: Skeleton): Mesh;
  21627. /**
  21628. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  21629. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  21630. */
  21631. static MinMax(meshes: AbstractMesh[]): {
  21632. min: Vector3;
  21633. max: Vector3;
  21634. };
  21635. /**
  21636. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  21637. */
  21638. static Center(meshesOrMinMaxVector: {
  21639. min: Vector3;
  21640. max: Vector3;
  21641. } | AbstractMesh[]): Vector3;
  21642. /**
  21643. * Merge the array of meshes into a single mesh for performance reasons.
  21644. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  21645. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  21646. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  21647. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21648. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  21649. */
  21650. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  21651. }
  21652. }
  21653. declare module BABYLON {
  21654. /**
  21655. * Define an interface for all classes that will get and set the data on vertices
  21656. */
  21657. interface IGetSetVerticesData {
  21658. isVerticesDataPresent(kind: string): boolean;
  21659. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21660. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21661. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21662. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21663. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21664. }
  21665. /**
  21666. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21667. */
  21668. class VertexData {
  21669. /**
  21670. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21671. */
  21672. positions: Nullable<FloatArray>;
  21673. /**
  21674. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21675. */
  21676. normals: Nullable<FloatArray>;
  21677. /**
  21678. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21679. */
  21680. tangents: Nullable<FloatArray>;
  21681. /**
  21682. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21683. */
  21684. uvs: Nullable<FloatArray>;
  21685. /**
  21686. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21687. */
  21688. uvs2: Nullable<FloatArray>;
  21689. /**
  21690. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21691. */
  21692. uvs3: Nullable<FloatArray>;
  21693. /**
  21694. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21695. */
  21696. uvs4: Nullable<FloatArray>;
  21697. /**
  21698. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21699. */
  21700. uvs5: Nullable<FloatArray>;
  21701. /**
  21702. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21703. */
  21704. uvs6: Nullable<FloatArray>;
  21705. /**
  21706. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21707. */
  21708. colors: Nullable<FloatArray>;
  21709. /**
  21710. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  21711. */
  21712. matricesIndices: Nullable<FloatArray>;
  21713. /**
  21714. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21715. */
  21716. matricesWeights: Nullable<FloatArray>;
  21717. /**
  21718. * An array extending the number of possible indices
  21719. */
  21720. matricesIndicesExtra: Nullable<FloatArray>;
  21721. /**
  21722. * An array extending the number of possible weights when the number of indices is extended
  21723. */
  21724. matricesWeightsExtra: Nullable<FloatArray>;
  21725. /**
  21726. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21727. */
  21728. indices: Nullable<IndicesArray>;
  21729. /**
  21730. * Uses the passed data array to set the set the values for the specified kind of data
  21731. * @param data a linear array of floating numbers
  21732. * @param kind the type of data that is being set, eg positions, colors etc
  21733. */
  21734. set(data: FloatArray, kind: string): void;
  21735. /**
  21736. * Associates the vertexData to the passed Mesh.
  21737. * Sets it as updatable or not (default `false`)
  21738. * @param mesh the mesh the vertexData is applied to
  21739. * @param updatable when used and having the value true allows new data to update the vertexData
  21740. * @returns the VertexData
  21741. */
  21742. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21743. /**
  21744. * Associates the vertexData to the passed Geometry.
  21745. * Sets it as updatable or not (default `false`)
  21746. * @param geometry the geometry the vertexData is applied to
  21747. * @param updatable when used and having the value true allows new data to update the vertexData
  21748. * @returns VertexData
  21749. */
  21750. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21751. /**
  21752. * Updates the associated mesh
  21753. * @param mesh the mesh to be updated
  21754. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21755. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  21756. * @returns VertexData
  21757. */
  21758. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21759. /**
  21760. * Updates the associated geometry
  21761. * @param geometry the geometry to be updated
  21762. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21763. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  21764. * @returns VertexData.
  21765. */
  21766. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21767. private _applyTo(meshOrGeometry, updatable?);
  21768. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  21769. /**
  21770. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21771. * @param matrix the transforming matrix
  21772. * @returns the VertexData
  21773. */
  21774. transform(matrix: Matrix): VertexData;
  21775. /**
  21776. * Merges the passed VertexData into the current one
  21777. * @param other the VertexData to be merged into the current one
  21778. * @returns the modified VertexData
  21779. */
  21780. merge(other: VertexData): VertexData;
  21781. private _mergeElement(source, other);
  21782. private _validate();
  21783. /**
  21784. * Serializes the VertexData
  21785. * @returns a serialized object
  21786. */
  21787. serialize(): any;
  21788. /**
  21789. * Extracts the vertexData from a mesh
  21790. * @param mesh the mesh from which to extract the VertexData
  21791. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21792. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21793. * @returns the object VertexData associated to the passed mesh
  21794. */
  21795. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21796. /**
  21797. * Extracts the vertexData from the geometry
  21798. * @param geometry the geometry from which to extract the VertexData
  21799. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21800. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21801. * @returns the object VertexData associated to the passed mesh
  21802. */
  21803. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21804. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  21805. /**
  21806. * Creates the VertexData for a Ribbon
  21807. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21808. * * pathArray array of paths, each of which an array of successive Vector3
  21809. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21810. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21811. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  21812. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21813. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21814. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21815. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21816. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21817. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21818. * @returns the VertexData of the ribbon
  21819. */
  21820. static CreateRibbon(options: {
  21821. pathArray: Vector3[][];
  21822. closeArray?: boolean;
  21823. closePath?: boolean;
  21824. offset?: number;
  21825. sideOrientation?: number;
  21826. frontUVs?: Vector4;
  21827. backUVs?: Vector4;
  21828. invertUV?: boolean;
  21829. uvs?: Vector2[];
  21830. colors?: Color4[];
  21831. }): VertexData;
  21832. /**
  21833. * Creates the VertexData for a box
  21834. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21835. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21836. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21837. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21838. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21839. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21840. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21841. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21842. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21843. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21844. * @returns the VertexData of the box
  21845. */
  21846. static CreateBox(options: {
  21847. size?: number;
  21848. width?: number;
  21849. height?: number;
  21850. depth?: number;
  21851. faceUV?: Vector4[];
  21852. faceColors?: Color4[];
  21853. sideOrientation?: number;
  21854. frontUVs?: Vector4;
  21855. backUVs?: Vector4;
  21856. }): VertexData;
  21857. /**
  21858. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21859. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21860. * * segments sets the number of horizontal strips optional, default 32
  21861. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21862. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21863. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21864. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21865. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  21866. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  21867. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21868. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21869. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21870. * @returns the VertexData of the ellipsoid
  21871. */
  21872. static CreateSphere(options: {
  21873. segments?: number;
  21874. diameter?: number;
  21875. diameterX?: number;
  21876. diameterY?: number;
  21877. diameterZ?: number;
  21878. arc?: number;
  21879. slice?: number;
  21880. sideOrientation?: number;
  21881. frontUVs?: Vector4;
  21882. backUVs?: Vector4;
  21883. }): VertexData;
  21884. /**
  21885. * Creates the VertexData for a cylinder, cone or prism
  21886. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21887. * * height sets the height (y direction) of the cylinder, optional, default 2
  21888. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21889. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21890. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21891. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21892. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21893. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  21894. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21895. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21896. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21897. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21898. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21899. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21900. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21901. * @returns the VertexData of the cylinder, cone or prism
  21902. */
  21903. static CreateCylinder(options: {
  21904. height?: number;
  21905. diameterTop?: number;
  21906. diameterBottom?: number;
  21907. diameter?: number;
  21908. tessellation?: number;
  21909. subdivisions?: number;
  21910. arc?: number;
  21911. faceColors?: Color4[];
  21912. faceUV?: Vector4[];
  21913. hasRings?: boolean;
  21914. enclose?: boolean;
  21915. sideOrientation?: number;
  21916. frontUVs?: Vector4;
  21917. backUVs?: Vector4;
  21918. }): VertexData;
  21919. /**
  21920. * Creates the VertexData for a torus
  21921. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21922. * * diameter the diameter of the torus, optional default 1
  21923. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21924. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21925. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21926. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21927. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21928. * @returns the VertexData of the torus
  21929. */
  21930. static CreateTorus(options: {
  21931. diameter?: number;
  21932. thickness?: number;
  21933. tessellation?: number;
  21934. sideOrientation?: number;
  21935. frontUVs?: Vector4;
  21936. backUVs?: Vector4;
  21937. }): VertexData;
  21938. /**
  21939. * Creates the VertexData of the LineSystem
  21940. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21941. * - lines an array of lines, each line being an array of successive Vector3
  21942. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21943. * @returns the VertexData of the LineSystem
  21944. */
  21945. static CreateLineSystem(options: {
  21946. lines: Vector3[][];
  21947. colors?: Nullable<Color4[][]>;
  21948. }): VertexData;
  21949. /**
  21950. * Create the VertexData for a DashedLines
  21951. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21952. * - points an array successive Vector3
  21953. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21954. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21955. * - dashNb the intended total number of dashes, optional, default 200
  21956. * @returns the VertexData for the DashedLines
  21957. */
  21958. static CreateDashedLines(options: {
  21959. points: Vector3[];
  21960. dashSize?: number;
  21961. gapSize?: number;
  21962. dashNb?: number;
  21963. }): VertexData;
  21964. /**
  21965. * Creates the VertexData for a Ground
  21966. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21967. * - width the width (x direction) of the ground, optional, default 1
  21968. * - height the height (z direction) of the ground, optional, default 1
  21969. * - subdivisions the number of subdivisions per side, optional, default 1
  21970. * @returns the VertexData of the Ground
  21971. */
  21972. static CreateGround(options: {
  21973. width?: number;
  21974. height?: number;
  21975. subdivisions?: number;
  21976. subdivisionsX?: number;
  21977. subdivisionsY?: number;
  21978. }): VertexData;
  21979. /**
  21980. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21981. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21982. * * xmin the ground minimum X coordinate, optional, default -1
  21983. * * zmin the ground minimum Z coordinate, optional, default -1
  21984. * * xmax the ground maximum X coordinate, optional, default 1
  21985. * * zmax the ground maximum Z coordinate, optional, default 1
  21986. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  21987. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  21988. * @returns the VertexData of the TiledGround
  21989. */
  21990. static CreateTiledGround(options: {
  21991. xmin: number;
  21992. zmin: number;
  21993. xmax: number;
  21994. zmax: number;
  21995. subdivisions?: {
  21996. w: number;
  21997. h: number;
  21998. };
  21999. precision?: {
  22000. w: number;
  22001. h: number;
  22002. };
  22003. }): VertexData;
  22004. /**
  22005. * Creates the VertexData of the Ground designed from a heightmap
  22006. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22007. * * width the width (x direction) of the ground
  22008. * * height the height (z direction) of the ground
  22009. * * subdivisions the number of subdivisions per side
  22010. * * minHeight the minimum altitude on the ground, optional, default 0
  22011. * * maxHeight the maximum altitude on the ground, optional default 1
  22012. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22013. * * buffer the array holding the image color data
  22014. * * bufferWidth the width of image
  22015. * * bufferHeight the height of image
  22016. * @returns the VertexData of the Ground designed from a heightmap
  22017. */
  22018. static CreateGroundFromHeightMap(options: {
  22019. width: number;
  22020. height: number;
  22021. subdivisions: number;
  22022. minHeight: number;
  22023. maxHeight: number;
  22024. colorFilter: Color3;
  22025. buffer: Uint8Array;
  22026. bufferWidth: number;
  22027. bufferHeight: number;
  22028. }): VertexData;
  22029. /**
  22030. * Creates the VertexData for a Plane
  22031. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22032. * * size sets the width and height of the plane to the value of size, optional default 1
  22033. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22034. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22035. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22036. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22037. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22038. * @returns the VertexData of the box
  22039. */
  22040. static CreatePlane(options: {
  22041. size?: number;
  22042. width?: number;
  22043. height?: number;
  22044. sideOrientation?: number;
  22045. frontUVs?: Vector4;
  22046. backUVs?: Vector4;
  22047. }): VertexData;
  22048. /**
  22049. * Creates the VertexData of the Disc or regular Polygon
  22050. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22051. * * radius the radius of the disc, optional default 0.5
  22052. * * tessellation the number of polygon sides, optional, default 64
  22053. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  22054. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22055. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22056. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22057. * @returns the VertexData of the box
  22058. */
  22059. static CreateDisc(options: {
  22060. radius?: number;
  22061. tessellation?: number;
  22062. arc?: number;
  22063. sideOrientation?: number;
  22064. frontUVs?: Vector4;
  22065. backUVs?: Vector4;
  22066. }): VertexData;
  22067. /**
  22068. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22069. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22070. * @param polygon a mesh built from polygonTriangulation.build()
  22071. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22072. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22073. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22074. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22075. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22076. * @returns the VertexData of the Polygon
  22077. */
  22078. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22079. /**
  22080. * Creates the VertexData of the IcoSphere
  22081. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22082. * * radius the radius of the IcoSphere, optional default 1
  22083. * * radiusX allows stretching in the x direction, optional, default radius
  22084. * * radiusY allows stretching in the y direction, optional, default radius
  22085. * * radiusZ allows stretching in the z direction, optional, default radius
  22086. * * flat when true creates a flat shaded mesh, optional, default true
  22087. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22088. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22089. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22090. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22091. * @returns the VertexData of the IcoSphere
  22092. */
  22093. static CreateIcoSphere(options: {
  22094. radius?: number;
  22095. radiusX?: number;
  22096. radiusY?: number;
  22097. radiusZ?: number;
  22098. flat?: boolean;
  22099. subdivisions?: number;
  22100. sideOrientation?: number;
  22101. frontUVs?: Vector4;
  22102. backUVs?: Vector4;
  22103. }): VertexData;
  22104. /**
  22105. * Creates the VertexData for a Polyhedron
  22106. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22107. * * type provided types are:
  22108. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22109. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  22110. * * size the size of the IcoSphere, optional default 1
  22111. * * sizeX allows stretching in the x direction, optional, default size
  22112. * * sizeY allows stretching in the y direction, optional, default size
  22113. * * sizeZ allows stretching in the z direction, optional, default size
  22114. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  22115. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22116. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22117. * * flat when true creates a flat shaded mesh, optional, default true
  22118. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22119. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22120. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22121. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22122. * @returns the VertexData of the Polyhedron
  22123. */
  22124. static CreatePolyhedron(options: {
  22125. type?: number;
  22126. size?: number;
  22127. sizeX?: number;
  22128. sizeY?: number;
  22129. sizeZ?: number;
  22130. custom?: any;
  22131. faceUV?: Vector4[];
  22132. faceColors?: Color4[];
  22133. flat?: boolean;
  22134. sideOrientation?: number;
  22135. frontUVs?: Vector4;
  22136. backUVs?: Vector4;
  22137. }): VertexData;
  22138. /**
  22139. * Creates the VertexData for a TorusKnot
  22140. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22141. * * radius the radius of the torus knot, optional, default 2
  22142. * * tube the thickness of the tube, optional, default 0.5
  22143. * * radialSegments the number of sides on each tube segments, optional, default 32
  22144. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22145. * * p the number of windings around the z axis, optional, default 2
  22146. * * q the number of windings around the x axis, optional, default 3
  22147. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22148. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22149. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22150. * @returns the VertexData of the Torus Knot
  22151. */
  22152. static CreateTorusKnot(options: {
  22153. radius?: number;
  22154. tube?: number;
  22155. radialSegments?: number;
  22156. tubularSegments?: number;
  22157. p?: number;
  22158. q?: number;
  22159. sideOrientation?: number;
  22160. frontUVs?: Vector4;
  22161. backUVs?: Vector4;
  22162. }): VertexData;
  22163. /**
  22164. * Compute normals for given positions and indices
  22165. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22166. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22167. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22168. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22169. * * facetNormals : optional array of facet normals (vector3)
  22170. * * facetPositions : optional array of facet positions (vector3)
  22171. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22172. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22173. * * bInfo : optional bounding info, required for facetPartitioning computation
  22174. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22175. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22176. * * useRightHandedSystem: optional boolean to for right handed system computation
  22177. * * depthSort : optional boolean to enable the facet depth sort computation
  22178. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22179. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22180. */
  22181. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22182. facetNormals?: any;
  22183. facetPositions?: any;
  22184. facetPartitioning?: any;
  22185. ratio?: number;
  22186. bInfo?: any;
  22187. bbSize?: Vector3;
  22188. subDiv?: any;
  22189. useRightHandedSystem?: boolean;
  22190. depthSort?: boolean;
  22191. distanceTo?: Vector3;
  22192. depthSortedFacets?: any;
  22193. }): void;
  22194. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  22195. /**
  22196. * Applies VertexData created from the imported parameters to the geometry
  22197. * @param parsedVertexData the parsed data from an imported file
  22198. * @param geometry the geometry to apply the VertexData to
  22199. */
  22200. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22201. }
  22202. }
  22203. declare module BABYLON {
  22204. /**
  22205. * Class containing static functions to help procedurally build meshes
  22206. */
  22207. class MeshBuilder {
  22208. private static updateSideOrientation(orientation?);
  22209. /**
  22210. * Creates a box mesh
  22211. * * The parameter `size` sets the size (float) of each box side (default 1)
  22212. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  22213. * * 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)
  22214. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22216. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22218. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  22219. * @param name defines the name of the mesh
  22220. * @param options defines the options used to create the mesh
  22221. * @param scene defines the hosting scene
  22222. * @returns the box mesh
  22223. */
  22224. static CreateBox(name: string, options: {
  22225. size?: number;
  22226. width?: number;
  22227. height?: number;
  22228. depth?: number;
  22229. faceUV?: Vector4[];
  22230. faceColors?: Color4[];
  22231. sideOrientation?: number;
  22232. frontUVs?: Vector4;
  22233. backUVs?: Vector4;
  22234. updatable?: boolean;
  22235. }, scene?: Nullable<Scene>): Mesh;
  22236. /**
  22237. * Creates a sphere mesh
  22238. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  22239. * * 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`)
  22240. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  22241. * * 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
  22242. * * 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)
  22243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22246. * @param name defines the name of the mesh
  22247. * @param options defines the options used to create the mesh
  22248. * @param scene defines the hosting scene
  22249. * @returns the sphere mesh
  22250. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  22251. */
  22252. static CreateSphere(name: string, options: {
  22253. segments?: number;
  22254. diameter?: number;
  22255. diameterX?: number;
  22256. diameterY?: number;
  22257. diameterZ?: number;
  22258. arc?: number;
  22259. slice?: number;
  22260. sideOrientation?: number;
  22261. frontUVs?: Vector4;
  22262. backUVs?: Vector4;
  22263. updatable?: boolean;
  22264. }, scene: any): Mesh;
  22265. /**
  22266. * Creates a plane polygonal mesh. By default, this is a disc
  22267. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22268. * * 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
  22269. * * 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
  22270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22273. * @param name defines the name of the mesh
  22274. * @param options defines the options used to create the mesh
  22275. * @param scene defines the hosting scene
  22276. * @returns the plane polygonal mesh
  22277. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22278. */
  22279. static CreateDisc(name: string, options: {
  22280. radius?: number;
  22281. tessellation?: number;
  22282. arc?: number;
  22283. updatable?: boolean;
  22284. sideOrientation?: number;
  22285. frontUVs?: Vector4;
  22286. backUVs?: Vector4;
  22287. }, scene?: Nullable<Scene>): Mesh;
  22288. /**
  22289. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22290. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22291. * * 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`)
  22292. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22293. * * 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
  22294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22295. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22297. * @param name defines the name of the mesh
  22298. * @param options defines the options used to create the mesh
  22299. * @param scene defines the hosting scene
  22300. * @returns the icosahedron mesh
  22301. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22302. */
  22303. static CreateIcoSphere(name: string, options: {
  22304. radius?: number;
  22305. radiusX?: number;
  22306. radiusY?: number;
  22307. radiusZ?: number;
  22308. flat?: boolean;
  22309. subdivisions?: number;
  22310. sideOrientation?: number;
  22311. frontUVs?: Vector4;
  22312. backUVs?: Vector4;
  22313. updatable?: boolean;
  22314. }, scene: Scene): Mesh;
  22315. /**
  22316. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22317. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  22318. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  22319. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  22320. * * 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
  22321. * * 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
  22322. * * 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
  22323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22325. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22326. * * 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
  22327. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  22328. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  22329. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  22330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22331. * @param name defines the name of the mesh
  22332. * @param options defines the options used to create the mesh
  22333. * @param scene defines the hosting scene
  22334. * @returns the ribbon mesh
  22335. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22336. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22337. */
  22338. static CreateRibbon(name: string, options: {
  22339. pathArray: Vector3[][];
  22340. closeArray?: boolean;
  22341. closePath?: boolean;
  22342. offset?: number;
  22343. updatable?: boolean;
  22344. sideOrientation?: number;
  22345. frontUVs?: Vector4;
  22346. backUVs?: Vector4;
  22347. instance?: Mesh;
  22348. invertUV?: boolean;
  22349. uvs?: Vector2[];
  22350. colors?: Color4[];
  22351. }, scene?: Nullable<Scene>): Mesh;
  22352. /**
  22353. * Creates a cylinder or a cone mesh
  22354. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22355. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22356. * * 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.
  22357. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22358. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22359. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  22360. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  22361. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  22362. * * 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).
  22363. * * 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
  22364. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  22365. * * 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
  22366. * * 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.
  22367. * * If `enclose` is false, a ring surface is one element.
  22368. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  22369. * * 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
  22370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22373. * @param name defines the name of the mesh
  22374. * @param options defines the options used to create the mesh
  22375. * @param scene defines the hosting scene
  22376. * @returns the cylinder mesh
  22377. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  22378. */
  22379. static CreateCylinder(name: string, options: {
  22380. height?: number;
  22381. diameterTop?: number;
  22382. diameterBottom?: number;
  22383. diameter?: number;
  22384. tessellation?: number;
  22385. subdivisions?: number;
  22386. arc?: number;
  22387. faceColors?: Color4[];
  22388. faceUV?: Vector4[];
  22389. updatable?: boolean;
  22390. hasRings?: boolean;
  22391. enclose?: boolean;
  22392. sideOrientation?: number;
  22393. frontUVs?: Vector4;
  22394. backUVs?: Vector4;
  22395. }, scene: any): Mesh;
  22396. /**
  22397. * Creates a torus mesh
  22398. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  22399. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  22400. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  22401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22402. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22404. * @param name defines the name of the mesh
  22405. * @param options defines the options used to create the mesh
  22406. * @param scene defines the hosting scene
  22407. * @returns the torus mesh
  22408. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  22409. */
  22410. static CreateTorus(name: string, options: {
  22411. diameter?: number;
  22412. thickness?: number;
  22413. tessellation?: number;
  22414. updatable?: boolean;
  22415. sideOrientation?: number;
  22416. frontUVs?: Vector4;
  22417. backUVs?: Vector4;
  22418. }, scene: any): Mesh;
  22419. /**
  22420. * Creates a torus knot mesh
  22421. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  22422. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  22423. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  22424. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  22425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22428. * @param name defines the name of the mesh
  22429. * @param options defines the options used to create the mesh
  22430. * @param scene defines the hosting scene
  22431. * @returns the torus knot mesh
  22432. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  22433. */
  22434. static CreateTorusKnot(name: string, options: {
  22435. radius?: number;
  22436. tube?: number;
  22437. radialSegments?: number;
  22438. tubularSegments?: number;
  22439. p?: number;
  22440. q?: number;
  22441. updatable?: boolean;
  22442. sideOrientation?: number;
  22443. frontUVs?: Vector4;
  22444. backUVs?: Vector4;
  22445. }, scene: any): Mesh;
  22446. /**
  22447. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  22448. * * 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
  22449. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  22450. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  22451. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  22452. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  22453. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  22454. * * 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
  22455. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  22456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22457. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  22458. * @param name defines the name of the new line system
  22459. * @param options defines the options used to create the line system
  22460. * @param scene defines the hosting scene
  22461. * @returns a new line system mesh
  22462. */
  22463. static CreateLineSystem(name: string, options: {
  22464. lines: Vector3[][];
  22465. updatable?: boolean;
  22466. instance?: Nullable<LinesMesh>;
  22467. colors?: Nullable<Color4[][]>;
  22468. useVertexAlpha?: boolean;
  22469. }, scene: Nullable<Scene>): LinesMesh;
  22470. /**
  22471. * Creates a line mesh
  22472. * 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
  22473. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22474. * * The parameter `points` is an array successive Vector3
  22475. * * 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
  22476. * * The optional parameter `colors` is an array of successive Color4, one per line point
  22477. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  22478. * * When updating an instance, remember that only point positions can change, not the number of points
  22479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22480. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  22481. * @param name defines the name of the new line system
  22482. * @param options defines the options used to create the line system
  22483. * @param scene defines the hosting scene
  22484. * @returns a new line mesh
  22485. */
  22486. static CreateLines(name: string, options: {
  22487. points: Vector3[];
  22488. updatable?: boolean;
  22489. instance?: Nullable<LinesMesh>;
  22490. colors?: Color4[];
  22491. useVertexAlpha?: boolean;
  22492. }, scene?: Nullable<Scene>): LinesMesh;
  22493. /**
  22494. * Creates a dashed line mesh
  22495. * * 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
  22496. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22497. * * The parameter `points` is an array successive Vector3
  22498. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  22499. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  22500. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22501. * * 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
  22502. * * When updating an instance, remember that only point positions can change, not the number of points
  22503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22504. * @param name defines the name of the mesh
  22505. * @param options defines the options used to create the mesh
  22506. * @param scene defines the hosting scene
  22507. * @returns the dashed line mesh
  22508. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  22509. */
  22510. static CreateDashedLines(name: string, options: {
  22511. points: Vector3[];
  22512. dashSize?: number;
  22513. gapSize?: number;
  22514. dashNb?: number;
  22515. updatable?: boolean;
  22516. instance?: LinesMesh;
  22517. }, scene?: Nullable<Scene>): LinesMesh;
  22518. /**
  22519. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  22520. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  22521. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22522. * * 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.
  22523. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  22524. * * 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
  22525. * * 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
  22526. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22528. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22529. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  22530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22531. * @param name defines the name of the mesh
  22532. * @param options defines the options used to create the mesh
  22533. * @param scene defines the hosting scene
  22534. * @returns the extruded shape mesh
  22535. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22536. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22537. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22538. */
  22539. static ExtrudeShape(name: string, options: {
  22540. shape: Vector3[];
  22541. path: Vector3[];
  22542. scale?: number;
  22543. rotation?: number;
  22544. cap?: number;
  22545. updatable?: boolean;
  22546. sideOrientation?: number;
  22547. frontUVs?: Vector4;
  22548. backUVs?: Vector4;
  22549. instance?: Mesh;
  22550. invertUV?: boolean;
  22551. }, scene?: Nullable<Scene>): Mesh;
  22552. /**
  22553. * Creates an custom extruded shape mesh.
  22554. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  22555. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  22556. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22557. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  22558. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22559. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  22560. * * It must returns a float value that will be the scale value applied to the shape on each path point
  22561. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22562. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  22563. * * 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
  22564. * * 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
  22565. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  22566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22567. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22568. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22570. * @param name defines the name of the mesh
  22571. * @param options defines the options used to create the mesh
  22572. * @param scene defines the hosting scene
  22573. * @returns the custom extruded shape mesh
  22574. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  22575. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22576. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22577. */
  22578. static ExtrudeShapeCustom(name: string, options: {
  22579. shape: Vector3[];
  22580. path: Vector3[];
  22581. scaleFunction?: any;
  22582. rotationFunction?: any;
  22583. ribbonCloseArray?: boolean;
  22584. ribbonClosePath?: boolean;
  22585. cap?: number;
  22586. updatable?: boolean;
  22587. sideOrientation?: number;
  22588. frontUVs?: Vector4;
  22589. backUVs?: Vector4;
  22590. instance?: Mesh;
  22591. invertUV?: boolean;
  22592. }, scene: Scene): Mesh;
  22593. /**
  22594. * Creates lathe mesh.
  22595. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  22596. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  22597. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  22598. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  22599. * * 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
  22600. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  22601. * * 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
  22602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22604. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22606. * @param name defines the name of the mesh
  22607. * @param options defines the options used to create the mesh
  22608. * @param scene defines the hosting scene
  22609. * @returns the lathe mesh
  22610. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  22611. */
  22612. static CreateLathe(name: string, options: {
  22613. shape: Vector3[];
  22614. radius?: number;
  22615. tessellation?: number;
  22616. arc?: number;
  22617. closed?: boolean;
  22618. updatable?: boolean;
  22619. sideOrientation?: number;
  22620. frontUVs?: Vector4;
  22621. backUVs?: Vector4;
  22622. cap?: number;
  22623. invertUV?: boolean;
  22624. }, scene: Scene): Mesh;
  22625. /**
  22626. * Creates a plane mesh
  22627. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  22628. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  22629. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  22630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22631. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22633. * @param name defines the name of the mesh
  22634. * @param options defines the options used to create the mesh
  22635. * @param scene defines the hosting scene
  22636. * @returns the plane mesh
  22637. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22638. */
  22639. static CreatePlane(name: string, options: {
  22640. size?: number;
  22641. width?: number;
  22642. height?: number;
  22643. sideOrientation?: number;
  22644. frontUVs?: Vector4;
  22645. backUVs?: Vector4;
  22646. updatable?: boolean;
  22647. sourcePlane?: Plane;
  22648. }, scene: Scene): Mesh;
  22649. /**
  22650. * Creates a ground mesh
  22651. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  22652. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  22653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22654. * @param name defines the name of the mesh
  22655. * @param options defines the options used to create the mesh
  22656. * @param scene defines the hosting scene
  22657. * @returns the ground mesh
  22658. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22659. */
  22660. static CreateGround(name: string, options: {
  22661. width?: number;
  22662. height?: number;
  22663. subdivisions?: number;
  22664. subdivisionsX?: number;
  22665. subdivisionsY?: number;
  22666. updatable?: boolean;
  22667. }, scene: any): Mesh;
  22668. /**
  22669. * Creates a tiled ground mesh
  22670. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  22671. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  22672. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  22673. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  22674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22675. * @param name defines the name of the mesh
  22676. * @param options defines the options used to create the mesh
  22677. * @param scene defines the hosting scene
  22678. * @returns the tiled ground mesh
  22679. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  22680. */
  22681. static CreateTiledGround(name: string, options: {
  22682. xmin: number;
  22683. zmin: number;
  22684. xmax: number;
  22685. zmax: number;
  22686. subdivisions?: {
  22687. w: number;
  22688. h: number;
  22689. };
  22690. precision?: {
  22691. w: number;
  22692. h: number;
  22693. };
  22694. updatable?: boolean;
  22695. }, scene: Scene): Mesh;
  22696. /**
  22697. * Creates a ground mesh from a height map
  22698. * * The parameter `url` sets the URL of the height map image resource.
  22699. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22700. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22701. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22702. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22703. * * 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.
  22704. * * 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).
  22705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22706. * @param name defines the name of the mesh
  22707. * @param url defines the url to the height map
  22708. * @param options defines the options used to create the mesh
  22709. * @param scene defines the hosting scene
  22710. * @returns the ground mesh
  22711. * @see http://doc.babylonjs.com/babylon101/height_map
  22712. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  22713. */
  22714. static CreateGroundFromHeightMap(name: string, url: string, options: {
  22715. width?: number;
  22716. height?: number;
  22717. subdivisions?: number;
  22718. minHeight?: number;
  22719. maxHeight?: number;
  22720. colorFilter?: Color3;
  22721. updatable?: boolean;
  22722. onReady?: (mesh: GroundMesh) => void;
  22723. }, scene: Scene): GroundMesh;
  22724. /**
  22725. * Creates a polygon mesh
  22726. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  22727. * * 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
  22728. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22730. * * 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)
  22731. * * Remember you can only change the shape positions, not their number when updating a polygon
  22732. * @param name defines the name of the mesh
  22733. * @param options defines the options used to create the mesh
  22734. * @param scene defines the hosting scene
  22735. * @returns the polygon mesh
  22736. */
  22737. static CreatePolygon(name: string, options: {
  22738. shape: Vector3[];
  22739. holes?: Vector3[][];
  22740. depth?: number;
  22741. faceUV?: Vector4[];
  22742. faceColors?: Color4[];
  22743. updatable?: boolean;
  22744. sideOrientation?: number;
  22745. frontUVs?: Vector4;
  22746. backUVs?: Vector4;
  22747. }, scene: Scene): Mesh;
  22748. /**
  22749. * Creates an extruded polygon mesh, with depth in the Y direction.
  22750. * * 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)
  22751. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22752. * @param name defines the name of the mesh
  22753. * @param options defines the options used to create the mesh
  22754. * @param scene defines the hosting scene
  22755. * @returns the polygon mesh
  22756. */
  22757. static ExtrudePolygon(name: string, options: {
  22758. shape: Vector3[];
  22759. holes?: Vector3[][];
  22760. depth?: number;
  22761. faceUV?: Vector4[];
  22762. faceColors?: Color4[];
  22763. updatable?: boolean;
  22764. sideOrientation?: number;
  22765. frontUVs?: Vector4;
  22766. backUVs?: Vector4;
  22767. }, scene: Scene): Mesh;
  22768. /**
  22769. * Creates a tube mesh.
  22770. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22771. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  22772. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  22773. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  22774. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  22775. * * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path. It must return a radius value (positive float)
  22776. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  22777. * * 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
  22778. * * 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
  22779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22780. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22781. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22783. * @param name defines the name of the mesh
  22784. * @param options defines the options used to create the mesh
  22785. * @param scene defines the hosting scene
  22786. * @returns the tube mesh
  22787. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22788. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  22789. */
  22790. static CreateTube(name: string, options: {
  22791. path: Vector3[];
  22792. radius?: number;
  22793. tessellation?: number;
  22794. radiusFunction?: {
  22795. (i: number, distance: number): number;
  22796. };
  22797. cap?: number;
  22798. arc?: number;
  22799. updatable?: boolean;
  22800. sideOrientation?: number;
  22801. frontUVs?: Vector4;
  22802. backUVs?: Vector4;
  22803. instance?: Mesh;
  22804. invertUV?: boolean;
  22805. }, scene: Scene): Mesh;
  22806. /**
  22807. * Creates a polyhedron mesh
  22808. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  22809. * * The parameter `size` (positive float, default 1) sets the polygon size
  22810. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22811. * * 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`
  22812. * * 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
  22813. * * 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)`)
  22814. * * 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
  22815. * * 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
  22816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22817. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22819. * @param name defines the name of the mesh
  22820. * @param options defines the options used to create the mesh
  22821. * @param scene defines the hosting scene
  22822. * @returns the polyhedron mesh
  22823. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  22824. */
  22825. static CreatePolyhedron(name: string, options: {
  22826. type?: number;
  22827. size?: number;
  22828. sizeX?: number;
  22829. sizeY?: number;
  22830. sizeZ?: number;
  22831. custom?: any;
  22832. faceUV?: Vector4[];
  22833. faceColors?: Color4[];
  22834. flat?: boolean;
  22835. updatable?: boolean;
  22836. sideOrientation?: number;
  22837. frontUVs?: Vector4;
  22838. backUVs?: Vector4;
  22839. }, scene: Scene): Mesh;
  22840. /**
  22841. * Creates a decal mesh.
  22842. * 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
  22843. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  22844. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  22845. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  22846. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  22847. * @param name defines the name of the mesh
  22848. * @param sourceMesh defines the mesh where the decal must be applied
  22849. * @param options defines the options used to create the mesh
  22850. * @param scene defines the hosting scene
  22851. * @returns the decal mesh
  22852. * @see http://doc.babylonjs.com/how_to/decals
  22853. */
  22854. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  22855. position?: Vector3;
  22856. normal?: Vector3;
  22857. size?: Vector3;
  22858. angle?: number;
  22859. }): Mesh;
  22860. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  22861. }
  22862. }
  22863. declare module BABYLON {
  22864. class MeshLODLevel {
  22865. distance: number;
  22866. mesh: Nullable<Mesh>;
  22867. constructor(distance: number, mesh: Nullable<Mesh>);
  22868. }
  22869. }
  22870. declare module BABYLON {
  22871. /**
  22872. * A simplifier interface for future simplification implementations.
  22873. */
  22874. interface ISimplifier {
  22875. /**
  22876. * Simplification of a given mesh according to the given settings.
  22877. * Since this requires computation, it is assumed that the function runs async.
  22878. * @param settings The settings of the simplification, including quality and distance
  22879. * @param successCallback A callback that will be called after the mesh was simplified.
  22880. * @param errorCallback in case of an error, this callback will be called. optional.
  22881. */
  22882. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  22883. }
  22884. /**
  22885. * Expected simplification settings.
  22886. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  22887. */
  22888. interface ISimplificationSettings {
  22889. quality: number;
  22890. distance: number;
  22891. optimizeMesh?: boolean;
  22892. }
  22893. class SimplificationSettings implements ISimplificationSettings {
  22894. quality: number;
  22895. distance: number;
  22896. optimizeMesh: boolean | undefined;
  22897. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  22898. }
  22899. interface ISimplificationTask {
  22900. settings: Array<ISimplificationSettings>;
  22901. simplificationType: SimplificationType;
  22902. mesh: Mesh;
  22903. successCallback?: () => void;
  22904. parallelProcessing: boolean;
  22905. }
  22906. class SimplificationQueue {
  22907. private _simplificationArray;
  22908. running: boolean;
  22909. constructor();
  22910. addTask(task: ISimplificationTask): void;
  22911. executeNext(): void;
  22912. runSimplification(task: ISimplificationTask): void;
  22913. private getSimplifier(task);
  22914. }
  22915. /**
  22916. * The implemented types of simplification
  22917. * At the moment only Quadratic Error Decimation is implemented
  22918. */
  22919. enum SimplificationType {
  22920. /** Quadratic error decimation */
  22921. QUADRATIC = 0,
  22922. }
  22923. class DecimationTriangle {
  22924. vertices: Array<DecimationVertex>;
  22925. normal: Vector3;
  22926. error: Array<number>;
  22927. deleted: boolean;
  22928. isDirty: boolean;
  22929. borderFactor: number;
  22930. deletePending: boolean;
  22931. originalOffset: number;
  22932. constructor(vertices: Array<DecimationVertex>);
  22933. }
  22934. class DecimationVertex {
  22935. position: Vector3;
  22936. id: number;
  22937. q: QuadraticMatrix;
  22938. isBorder: boolean;
  22939. triangleStart: number;
  22940. triangleCount: number;
  22941. originalOffsets: Array<number>;
  22942. constructor(position: Vector3, id: number);
  22943. updatePosition(newPosition: Vector3): void;
  22944. }
  22945. class QuadraticMatrix {
  22946. data: Array<number>;
  22947. constructor(data?: Array<number>);
  22948. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  22949. addInPlace(matrix: QuadraticMatrix): void;
  22950. addArrayInPlace(data: Array<number>): void;
  22951. add(matrix: QuadraticMatrix): QuadraticMatrix;
  22952. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  22953. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  22954. }
  22955. class Reference {
  22956. vertexId: number;
  22957. triangleId: number;
  22958. constructor(vertexId: number, triangleId: number);
  22959. }
  22960. /**
  22961. * An implementation of the Quadratic Error simplification algorithm.
  22962. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  22963. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  22964. * @author RaananW
  22965. */
  22966. class QuadraticErrorSimplification implements ISimplifier {
  22967. private _mesh;
  22968. private triangles;
  22969. private vertices;
  22970. private references;
  22971. private _reconstructedMesh;
  22972. syncIterations: number;
  22973. aggressiveness: number;
  22974. decimationIterations: number;
  22975. boundingBoxEpsilon: number;
  22976. constructor(_mesh: Mesh);
  22977. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  22978. private runDecimation(settings, submeshIndex, successCallback);
  22979. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  22980. private init(callback);
  22981. private reconstructMesh(submeshIndex);
  22982. private initDecimatedMesh();
  22983. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  22984. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  22985. private identifyBorder();
  22986. private updateMesh(identifyBorders?);
  22987. private vertexError(q, point);
  22988. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  22989. }
  22990. }
  22991. declare module BABYLON {
  22992. class Polygon {
  22993. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  22994. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  22995. static Parse(input: string): Vector2[];
  22996. static StartingAt(x: number, y: number): Path2;
  22997. }
  22998. class PolygonMeshBuilder {
  22999. private _points;
  23000. private _outlinepoints;
  23001. private _holes;
  23002. private _name;
  23003. private _scene;
  23004. private _epoints;
  23005. private _eholes;
  23006. private _addToepoint(points);
  23007. constructor(name: string, contours: Path2, scene: Scene);
  23008. constructor(name: string, contours: Vector2[], scene: Scene);
  23009. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23010. build(updatable?: boolean, depth?: number): Mesh;
  23011. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  23012. }
  23013. }
  23014. declare module BABYLON {
  23015. class BaseSubMesh {
  23016. _materialDefines: Nullable<MaterialDefines>;
  23017. _materialEffect: Nullable<Effect>;
  23018. readonly effect: Nullable<Effect>;
  23019. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23020. }
  23021. class SubMesh extends BaseSubMesh implements ICullable {
  23022. materialIndex: number;
  23023. verticesStart: number;
  23024. verticesCount: number;
  23025. indexStart: number;
  23026. indexCount: number;
  23027. linesIndexCount: number;
  23028. private _mesh;
  23029. private _renderingMesh;
  23030. private _boundingInfo;
  23031. private _linesIndexBuffer;
  23032. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23033. _trianglePlanes: Plane[];
  23034. _lastColliderTransformMatrix: Matrix;
  23035. _renderId: number;
  23036. _alphaIndex: number;
  23037. _distanceToCamera: number;
  23038. _id: number;
  23039. private _currentMaterial;
  23040. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23041. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23042. readonly IsGlobal: boolean;
  23043. /**
  23044. * Returns the submesh BoudingInfo object.
  23045. */
  23046. getBoundingInfo(): BoundingInfo;
  23047. /**
  23048. * Sets the submesh BoundingInfo.
  23049. * Return the SubMesh.
  23050. */
  23051. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23052. /**
  23053. * Returns the mesh of the current submesh.
  23054. */
  23055. getMesh(): AbstractMesh;
  23056. /**
  23057. * Returns the rendering mesh of the submesh.
  23058. */
  23059. getRenderingMesh(): Mesh;
  23060. /**
  23061. * Returns the submesh material.
  23062. */
  23063. getMaterial(): Nullable<Material>;
  23064. /**
  23065. * Sets a new updated BoundingInfo object to the submesh.
  23066. * Returns the SubMesh.
  23067. */
  23068. refreshBoundingInfo(): SubMesh;
  23069. _checkCollision(collider: Collider): boolean;
  23070. /**
  23071. * Updates the submesh BoundingInfo.
  23072. * Returns the Submesh.
  23073. */
  23074. updateBoundingInfo(world: Matrix): SubMesh;
  23075. /**
  23076. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23077. * Boolean returned.
  23078. */
  23079. isInFrustum(frustumPlanes: Plane[]): boolean;
  23080. /**
  23081. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  23082. * Boolean returned.
  23083. */
  23084. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23085. /**
  23086. * Renders the submesh.
  23087. * Returns it.
  23088. */
  23089. render(enableAlphaMode: boolean): SubMesh;
  23090. /**
  23091. * Returns a new Index Buffer.
  23092. * Type returned : WebGLBuffer.
  23093. */
  23094. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  23095. /**
  23096. * True is the passed Ray intersects the submesh bounding box.
  23097. * Boolean returned.
  23098. */
  23099. canIntersects(ray: Ray): boolean;
  23100. /**
  23101. * Returns an object IntersectionInfo.
  23102. */
  23103. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  23104. _rebuild(): void;
  23105. /**
  23106. * Creates a new Submesh from the passed Mesh.
  23107. */
  23108. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23109. /**
  23110. * Disposes the Submesh.
  23111. * Returns nothing.
  23112. */
  23113. dispose(): void;
  23114. /**
  23115. * Creates a new Submesh from the passed parameters :
  23116. * - materialIndex (integer) : the index of the main mesh material.
  23117. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  23118. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  23119. * - mesh (Mesh) : the main mesh to create the submesh from.
  23120. * - renderingMesh (optional Mesh) : rendering mesh.
  23121. */
  23122. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23123. }
  23124. }
  23125. declare module BABYLON {
  23126. class TransformNode extends Node {
  23127. static BILLBOARDMODE_NONE: number;
  23128. static BILLBOARDMODE_X: number;
  23129. static BILLBOARDMODE_Y: number;
  23130. static BILLBOARDMODE_Z: number;
  23131. static BILLBOARDMODE_ALL: number;
  23132. private _forward;
  23133. private _forwardInverted;
  23134. private _up;
  23135. private _right;
  23136. private _rightInverted;
  23137. private _rotation;
  23138. private _rotationQuaternion;
  23139. protected _scaling: Vector3;
  23140. protected _isDirty: boolean;
  23141. private _transformToBoneReferal;
  23142. /**
  23143. * Set the billboard mode. Default is 0.
  23144. *
  23145. * | Value | Type | Description |
  23146. * | --- | --- | --- |
  23147. * | 0 | BILLBOARDMODE_NONE | |
  23148. * | 1 | BILLBOARDMODE_X | |
  23149. * | 2 | BILLBOARDMODE_Y | |
  23150. * | 4 | BILLBOARDMODE_Z | |
  23151. * | 7 | BILLBOARDMODE_ALL | |
  23152. *
  23153. */
  23154. billboardMode: number;
  23155. scalingDeterminant: number;
  23156. infiniteDistance: boolean;
  23157. /**
  23158. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  23159. * By default the system will update normals to compensate
  23160. */
  23161. ignoreNonUniformScaling: boolean;
  23162. position: Vector3;
  23163. _poseMatrix: Matrix;
  23164. private _localWorld;
  23165. _worldMatrix: Matrix;
  23166. _worldMatrixDeterminant: number;
  23167. private _absolutePosition;
  23168. private _pivotMatrix;
  23169. private _pivotMatrixInverse;
  23170. private _postMultiplyPivotMatrix;
  23171. protected _isWorldMatrixFrozen: boolean;
  23172. /**
  23173. * An event triggered after the world matrix is updated
  23174. */
  23175. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  23176. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  23177. /**
  23178. * Gets a string idenfifying the name of the class
  23179. * @returns "TransformNode" string
  23180. */
  23181. getClassName(): string;
  23182. /**
  23183. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  23184. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  23185. * Default : (0.0, 0.0, 0.0)
  23186. */
  23187. rotation: Vector3;
  23188. /**
  23189. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23190. * Default : (1.0, 1.0, 1.0)
  23191. */
  23192. /**
  23193. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23194. * Default : (1.0, 1.0, 1.0)
  23195. */
  23196. scaling: Vector3;
  23197. /**
  23198. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  23199. * It's null by default.
  23200. * 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)
  23201. */
  23202. rotationQuaternion: Nullable<Quaternion>;
  23203. /**
  23204. * The forward direction of that transform in world space.
  23205. */
  23206. readonly forward: Vector3;
  23207. /**
  23208. * The up direction of that transform in world space.
  23209. */
  23210. readonly up: Vector3;
  23211. /**
  23212. * The right direction of that transform in world space.
  23213. */
  23214. readonly right: Vector3;
  23215. /**
  23216. * Returns the latest update of the World matrix
  23217. * Returns a Matrix.
  23218. */
  23219. getWorldMatrix(): Matrix;
  23220. /** @hidden */
  23221. _getWorldMatrixDeterminant(): number;
  23222. /**
  23223. * Returns directly the latest state of the mesh World matrix.
  23224. * A Matrix is returned.
  23225. */
  23226. readonly worldMatrixFromCache: Matrix;
  23227. /**
  23228. * Copies the paramater passed Matrix into the mesh Pose matrix.
  23229. * Returns the TransformNode.
  23230. */
  23231. updatePoseMatrix(matrix: Matrix): TransformNode;
  23232. /**
  23233. * Returns the mesh Pose matrix.
  23234. * Returned object : Matrix
  23235. */
  23236. getPoseMatrix(): Matrix;
  23237. _isSynchronized(): boolean;
  23238. _initCache(): void;
  23239. markAsDirty(property: string): TransformNode;
  23240. /**
  23241. * Returns the current mesh absolute position.
  23242. * Retuns a Vector3.
  23243. */
  23244. readonly absolutePosition: Vector3;
  23245. /**
  23246. * Sets a new matrix to apply before all other transformation
  23247. * @param matrix defines the transform matrix
  23248. * @returns the current TransformNode
  23249. */
  23250. setPreTransformMatrix(matrix: Matrix): TransformNode;
  23251. /**
  23252. * Sets a new pivot matrix to the current node
  23253. * @param matrix defines the new pivot matrix to use
  23254. * @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
  23255. * @returns the current TransformNode
  23256. */
  23257. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  23258. /**
  23259. * Returns the mesh pivot matrix.
  23260. * Default : Identity.
  23261. * A Matrix is returned.
  23262. */
  23263. getPivotMatrix(): Matrix;
  23264. /**
  23265. * Prevents the World matrix to be computed any longer.
  23266. * Returns the TransformNode.
  23267. */
  23268. freezeWorldMatrix(): TransformNode;
  23269. /**
  23270. * Allows back the World matrix computation.
  23271. * Returns the TransformNode.
  23272. */
  23273. unfreezeWorldMatrix(): this;
  23274. /**
  23275. * True if the World matrix has been frozen.
  23276. * Returns a boolean.
  23277. */
  23278. readonly isWorldMatrixFrozen: boolean;
  23279. /**
  23280. * Retuns the mesh absolute position in the World.
  23281. * Returns a Vector3.
  23282. */
  23283. getAbsolutePosition(): Vector3;
  23284. /**
  23285. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  23286. * Returns the TransformNode.
  23287. */
  23288. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23289. /**
  23290. * Sets the mesh position in its local space.
  23291. * Returns the TransformNode.
  23292. */
  23293. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  23294. /**
  23295. * Returns the mesh position in the local space from the current World matrix values.
  23296. * Returns a new Vector3.
  23297. */
  23298. getPositionExpressedInLocalSpace(): Vector3;
  23299. /**
  23300. * Translates the mesh along the passed Vector3 in its local space.
  23301. * Returns the TransformNode.
  23302. */
  23303. locallyTranslate(vector3: Vector3): TransformNode;
  23304. private static _lookAtVectorCache;
  23305. /**
  23306. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  23307. * @param targetPoint the position (must be in same space as current mesh) to look at
  23308. * @param yawCor optional yaw (y-axis) correction in radians
  23309. * @param pitchCor optional pitch (x-axis) correction in radians
  23310. * @param rollCor optional roll (z-axis) correction in radians
  23311. * @param space the choosen space of the target
  23312. * @returns the TransformNode.
  23313. */
  23314. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  23315. /**
  23316. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  23317. * This Vector3 is expressed in the World space.
  23318. */
  23319. getDirection(localAxis: Vector3): Vector3;
  23320. /**
  23321. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  23322. * localAxis is expressed in the mesh local space.
  23323. * result is computed in the Wordl space from the mesh World matrix.
  23324. * Returns the TransformNode.
  23325. */
  23326. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  23327. /**
  23328. * Sets a new pivot point to the current node
  23329. * @param point defines the new pivot point to use
  23330. * @param space defines if the point is in world or local space (local by default)
  23331. * @returns the current TransformNode
  23332. */
  23333. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  23334. /**
  23335. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  23336. */
  23337. getPivotPoint(): Vector3;
  23338. /**
  23339. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  23340. * Returns the TransformNode.
  23341. */
  23342. getPivotPointToRef(result: Vector3): TransformNode;
  23343. /**
  23344. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  23345. */
  23346. getAbsolutePivotPoint(): Vector3;
  23347. /**
  23348. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  23349. * Returns the TransformNode.
  23350. */
  23351. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  23352. /**
  23353. * Defines the passed node as the parent of the current node.
  23354. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  23355. * Returns the TransformNode.
  23356. */
  23357. setParent(node: Nullable<Node>): TransformNode;
  23358. private _nonUniformScaling;
  23359. readonly nonUniformScaling: boolean;
  23360. _updateNonUniformScalingState(value: boolean): boolean;
  23361. /**
  23362. * Attach the current TransformNode to another TransformNode associated with a bone
  23363. * @param bone Bone affecting the TransformNode
  23364. * @param affectedTransformNode TransformNode associated with the bone
  23365. */
  23366. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  23367. detachFromBone(): TransformNode;
  23368. private static _rotationAxisCache;
  23369. /**
  23370. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  23371. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23372. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23373. * The passed axis is also normalized.
  23374. * Returns the TransformNode.
  23375. */
  23376. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23377. /**
  23378. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  23379. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23380. * The passed axis is also normalized.
  23381. * Returns the TransformNode.
  23382. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  23383. */
  23384. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  23385. /**
  23386. * Translates the mesh along the axis vector for the passed distance in the given space.
  23387. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23388. * Returns the TransformNode.
  23389. */
  23390. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23391. /**
  23392. * Adds a rotation step to the mesh current rotation.
  23393. * x, y, z are Euler angles expressed in radians.
  23394. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  23395. * This means this rotation is made in the mesh local space only.
  23396. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  23397. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  23398. * ```javascript
  23399. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  23400. * ```
  23401. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  23402. * 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.
  23403. * Returns the TransformNode.
  23404. */
  23405. addRotation(x: number, y: number, z: number): TransformNode;
  23406. /**
  23407. * Computes the mesh World matrix and returns it.
  23408. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  23409. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  23410. * If the parameter `force`is set to `true`, the actual computation is done.
  23411. * Returns the mesh World Matrix.
  23412. */
  23413. computeWorldMatrix(force?: boolean): Matrix;
  23414. protected _afterComputeWorldMatrix(): void;
  23415. /**
  23416. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  23417. * @param func: callback function to add
  23418. *
  23419. * Returns the TransformNode.
  23420. */
  23421. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23422. /**
  23423. * Removes a registered callback function.
  23424. * Returns the TransformNode.
  23425. */
  23426. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23427. /**
  23428. * Clone the current transform node
  23429. * Returns the new transform node
  23430. * @param name Name of the new clone
  23431. * @param newParent New parent for the clone
  23432. * @param doNotCloneChildren Do not clone children hierarchy
  23433. */
  23434. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  23435. serialize(currentSerializationObject?: any): any;
  23436. /**
  23437. * Returns a new TransformNode object parsed from the source provided.
  23438. * The parameter `parsedMesh` is the source.
  23439. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  23440. */
  23441. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  23442. /**
  23443. * Releases resources associated with this transform node.
  23444. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23445. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23446. */
  23447. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23448. }
  23449. }
  23450. declare module BABYLON {
  23451. class VertexBuffer {
  23452. /** @hidden */
  23453. _buffer: Buffer;
  23454. private _kind;
  23455. private _size;
  23456. private _ownsBuffer;
  23457. private _instanced;
  23458. private _instanceDivisor;
  23459. /**
  23460. * The byte type.
  23461. */
  23462. static readonly BYTE: number;
  23463. /**
  23464. * The unsigned byte type.
  23465. */
  23466. static readonly UNSIGNED_BYTE: number;
  23467. /**
  23468. * The short type.
  23469. */
  23470. static readonly SHORT: number;
  23471. /**
  23472. * The unsigned short type.
  23473. */
  23474. static readonly UNSIGNED_SHORT: number;
  23475. /**
  23476. * The integer type.
  23477. */
  23478. static readonly INT: number;
  23479. /**
  23480. * The unsigned integer type.
  23481. */
  23482. static readonly UNSIGNED_INT: number;
  23483. /**
  23484. * The float type.
  23485. */
  23486. static readonly FLOAT: number;
  23487. /**
  23488. * Gets or sets the instance divisor when in instanced mode
  23489. */
  23490. instanceDivisor: number;
  23491. /**
  23492. * Gets the byte stride.
  23493. */
  23494. readonly byteStride: number;
  23495. /**
  23496. * Gets the byte offset.
  23497. */
  23498. readonly byteOffset: number;
  23499. /**
  23500. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  23501. */
  23502. readonly normalized: boolean;
  23503. /**
  23504. * Gets the data type of each component in the array.
  23505. */
  23506. readonly type: number;
  23507. /**
  23508. * Constructor
  23509. * @param engine the engine
  23510. * @param data the data to use for this vertex buffer
  23511. * @param kind the vertex buffer kind
  23512. * @param updatable whether the data is updatable
  23513. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  23514. * @param stride the stride (optional)
  23515. * @param instanced whether the buffer is instanced (optional)
  23516. * @param offset the offset of the data (optional)
  23517. * @param size the number of components (optional)
  23518. * @param type the type of the component (optional)
  23519. * @param normalized whether the data contains normalized data (optional)
  23520. * @param useBytes set to true if stride and offset are in bytes (optional)
  23521. */
  23522. 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);
  23523. _rebuild(): void;
  23524. /**
  23525. * Returns the kind of the VertexBuffer (string).
  23526. */
  23527. getKind(): string;
  23528. /**
  23529. * Boolean : is the VertexBuffer updatable ?
  23530. */
  23531. isUpdatable(): boolean;
  23532. /**
  23533. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  23534. */
  23535. getData(): Nullable<DataArray>;
  23536. /**
  23537. * Returns the WebGLBuffer associated to the VertexBuffer.
  23538. */
  23539. getBuffer(): Nullable<WebGLBuffer>;
  23540. /**
  23541. * Returns the stride as a multiple of the type byte length.
  23542. * DEPRECATED. Use byteStride instead.
  23543. */
  23544. getStrideSize(): number;
  23545. /**
  23546. * Returns the offset as a multiple of the type byte length.
  23547. * DEPRECATED. Use byteOffset instead.
  23548. */
  23549. getOffset(): number;
  23550. /**
  23551. * Returns the number of components per vertex attribute (integer).
  23552. */
  23553. getSize(): number;
  23554. /**
  23555. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  23556. */
  23557. getIsInstanced(): boolean;
  23558. /**
  23559. * Returns the instancing divisor, zero for non-instanced (integer).
  23560. */
  23561. getInstanceDivisor(): number;
  23562. /**
  23563. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  23564. * Returns the created WebGLBuffer.
  23565. */
  23566. create(data?: DataArray): void;
  23567. /**
  23568. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23569. * This function will create a new buffer if the current one is not updatable
  23570. * Returns the updated WebGLBuffer.
  23571. */
  23572. update(data: DataArray): void;
  23573. /**
  23574. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23575. * Returns the directly updated WebGLBuffer.
  23576. * @param data the new data
  23577. * @param offset the new offset
  23578. * @param useBytes set to true if the offset is in bytes
  23579. */
  23580. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  23581. /**
  23582. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  23583. */
  23584. dispose(): void;
  23585. /**
  23586. * Enumerates each value of this vertex buffer as numbers.
  23587. * @param count the number of values to enumerate
  23588. * @param callback the callback function called for each value
  23589. */
  23590. forEach(count: number, callback: (value: number, index: number) => void): void;
  23591. private static _PositionKind;
  23592. private static _NormalKind;
  23593. private static _TangentKind;
  23594. private static _UVKind;
  23595. private static _UV2Kind;
  23596. private static _UV3Kind;
  23597. private static _UV4Kind;
  23598. private static _UV5Kind;
  23599. private static _UV6Kind;
  23600. private static _ColorKind;
  23601. private static _MatricesIndicesKind;
  23602. private static _MatricesWeightsKind;
  23603. private static _MatricesIndicesExtraKind;
  23604. private static _MatricesWeightsExtraKind;
  23605. static readonly PositionKind: string;
  23606. static readonly NormalKind: string;
  23607. static readonly TangentKind: string;
  23608. static readonly UVKind: string;
  23609. static readonly UV2Kind: string;
  23610. static readonly UV3Kind: string;
  23611. static readonly UV4Kind: string;
  23612. static readonly UV5Kind: string;
  23613. static readonly UV6Kind: string;
  23614. static readonly ColorKind: string;
  23615. static readonly MatricesIndicesKind: string;
  23616. static readonly MatricesWeightsKind: string;
  23617. static readonly MatricesIndicesExtraKind: string;
  23618. static readonly MatricesWeightsExtraKind: string;
  23619. /**
  23620. * Deduces the stride given a kind.
  23621. * @param kind The kind string to deduce
  23622. * @returns The deduced stride
  23623. */
  23624. static DeduceStride(kind: string): number;
  23625. /**
  23626. * Gets the byte length of the given type.
  23627. * @param type the type
  23628. * @returns the number of bytes
  23629. */
  23630. static GetTypeByteLength(type: number): number;
  23631. /**
  23632. * Enumerates each value of the given parameters as numbers.
  23633. * @param data the data to enumerate
  23634. * @param byteOffset the byte offset of the data
  23635. * @param byteStride the byte stride of the data
  23636. * @param componentCount the number of components per element
  23637. * @param componentType the type of the component
  23638. * @param count the total number of components
  23639. * @param normalized whether the data is normalized
  23640. * @param callback the callback function called for each value
  23641. */
  23642. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  23643. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  23644. }
  23645. }
  23646. declare module BABYLON {
  23647. /**
  23648. * Defines a target to use with MorphTargetManager
  23649. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23650. */
  23651. class MorphTarget implements IAnimatable {
  23652. /** defines the name of the target */
  23653. name: string;
  23654. /**
  23655. * Gets or sets the list of animations
  23656. */
  23657. animations: Animation[];
  23658. private _scene;
  23659. private _positions;
  23660. private _normals;
  23661. private _tangents;
  23662. private _influence;
  23663. /**
  23664. * Observable raised when the influence changes
  23665. */
  23666. onInfluenceChanged: Observable<boolean>;
  23667. /**
  23668. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23669. */
  23670. influence: number;
  23671. private _animationPropertiesOverride;
  23672. /**
  23673. * Gets or sets the animation properties override
  23674. */
  23675. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23676. /**
  23677. * Creates a new MorphTarget
  23678. * @param name defines the name of the target
  23679. * @param influence defines the influence to use
  23680. */
  23681. constructor(
  23682. /** defines the name of the target */
  23683. name: string, influence?: number, scene?: Nullable<Scene>);
  23684. /**
  23685. * Gets a boolean defining if the target contains position data
  23686. */
  23687. readonly hasPositions: boolean;
  23688. /**
  23689. * Gets a boolean defining if the target contains normal data
  23690. */
  23691. readonly hasNormals: boolean;
  23692. /**
  23693. * Gets a boolean defining if the target contains tangent data
  23694. */
  23695. readonly hasTangents: boolean;
  23696. /**
  23697. * Affects position data to this target
  23698. * @param data defines the position data to use
  23699. */
  23700. setPositions(data: Nullable<FloatArray>): void;
  23701. /**
  23702. * Gets the position data stored in this target
  23703. * @returns a FloatArray containing the position data (or null if not present)
  23704. */
  23705. getPositions(): Nullable<FloatArray>;
  23706. /**
  23707. * Affects normal data to this target
  23708. * @param data defines the normal data to use
  23709. */
  23710. setNormals(data: Nullable<FloatArray>): void;
  23711. /**
  23712. * Gets the normal data stored in this target
  23713. * @returns a FloatArray containing the normal data (or null if not present)
  23714. */
  23715. getNormals(): Nullable<FloatArray>;
  23716. /**
  23717. * Affects tangent data to this target
  23718. * @param data defines the tangent data to use
  23719. */
  23720. setTangents(data: Nullable<FloatArray>): void;
  23721. /**
  23722. * Gets the tangent data stored in this target
  23723. * @returns a FloatArray containing the tangent data (or null if not present)
  23724. */
  23725. getTangents(): Nullable<FloatArray>;
  23726. /**
  23727. * Serializes the current target into a Serialization object
  23728. * @returns the serialized object
  23729. */
  23730. serialize(): any;
  23731. /**
  23732. * Creates a new target from serialized data
  23733. * @param serializationObject defines the serialized data to use
  23734. * @returns a new MorphTarget
  23735. */
  23736. static Parse(serializationObject: any): MorphTarget;
  23737. /**
  23738. * Creates a MorphTarget from mesh data
  23739. * @param mesh defines the source mesh
  23740. * @param name defines the name to use for the new target
  23741. * @param influence defines the influence to attach to the target
  23742. * @returns a new MorphTarget
  23743. */
  23744. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23745. }
  23746. }
  23747. declare module BABYLON {
  23748. /**
  23749. * This class is used to deform meshes using morphing between different targets
  23750. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23751. */
  23752. class MorphTargetManager {
  23753. private _targets;
  23754. private _targetObservable;
  23755. private _activeTargets;
  23756. private _scene;
  23757. private _influences;
  23758. private _supportsNormals;
  23759. private _supportsTangents;
  23760. private _vertexCount;
  23761. private _uniqueId;
  23762. private _tempInfluences;
  23763. /**
  23764. * Creates a new MorphTargetManager
  23765. * @param scene defines the current scene
  23766. */
  23767. constructor(scene?: Nullable<Scene>);
  23768. /**
  23769. * Gets the unique ID of this manager
  23770. */
  23771. readonly uniqueId: number;
  23772. /**
  23773. * Gets the number of vertices handled by this manager
  23774. */
  23775. readonly vertexCount: number;
  23776. /**
  23777. * Gets a boolean indicating if this manager supports morphing of normals
  23778. */
  23779. readonly supportsNormals: boolean;
  23780. /**
  23781. * Gets a boolean indicating if this manager supports morphing of tangents
  23782. */
  23783. readonly supportsTangents: boolean;
  23784. /**
  23785. * Gets the number of targets stored in this manager
  23786. */
  23787. readonly numTargets: number;
  23788. /**
  23789. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23790. */
  23791. readonly numInfluencers: number;
  23792. /**
  23793. * Gets the list of influences (one per target)
  23794. */
  23795. readonly influences: Float32Array;
  23796. /**
  23797. * Gets the active target at specified index. An active target is a target with an influence > 0
  23798. * @param index defines the index to check
  23799. * @returns the requested target
  23800. */
  23801. getActiveTarget(index: number): MorphTarget;
  23802. /**
  23803. * Gets the target at specified index
  23804. * @param index defines the index to check
  23805. * @returns the requested target
  23806. */
  23807. getTarget(index: number): MorphTarget;
  23808. /**
  23809. * Add a new target to this manager
  23810. * @param target defines the target to add
  23811. */
  23812. addTarget(target: MorphTarget): void;
  23813. /**
  23814. * Removes a target from the manager
  23815. * @param target defines the target to remove
  23816. */
  23817. removeTarget(target: MorphTarget): void;
  23818. /**
  23819. * Serializes the current manager into a Serialization object
  23820. * @returns the serialized object
  23821. */
  23822. serialize(): any;
  23823. private _syncActiveTargets(needUpdate);
  23824. /**
  23825. * Syncrhonize the targets with all the meshes using this morph target manager
  23826. */
  23827. synchronize(): void;
  23828. /**
  23829. * Creates a new MorphTargetManager from serialized data
  23830. * @param serializationObject defines the serialized data
  23831. * @param scene defines the hosting scene
  23832. * @returns the new MorphTargetManager
  23833. */
  23834. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23835. }
  23836. }
  23837. declare module BABYLON {
  23838. /**
  23839. * This represents a GPU particle system in Babylon
  23840. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  23841. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  23842. */
  23843. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  23844. /**
  23845. * The id of the Particle system.
  23846. */
  23847. id: string;
  23848. /**
  23849. * The friendly name of the Particle system.
  23850. */
  23851. name: string;
  23852. /**
  23853. * The emitter represents the Mesh or position we are attaching the particle system to.
  23854. */
  23855. emitter: Nullable<AbstractMesh | Vector3>;
  23856. /**
  23857. * The rendering group used by the Particle system to chose when to render.
  23858. */
  23859. renderingGroupId: number;
  23860. /**
  23861. * The layer mask we are rendering the particles through.
  23862. */
  23863. layerMask: number;
  23864. private _capacity;
  23865. private _activeCount;
  23866. private _currentActiveCount;
  23867. private _accumulatedCount;
  23868. private _renderEffect;
  23869. private _updateEffect;
  23870. private _buffer0;
  23871. private _buffer1;
  23872. private _spriteBuffer;
  23873. private _updateVAO;
  23874. private _renderVAO;
  23875. private _targetIndex;
  23876. private _sourceBuffer;
  23877. private _targetBuffer;
  23878. private _scene;
  23879. private _engine;
  23880. private _currentRenderId;
  23881. private _started;
  23882. private _stopped;
  23883. private _timeDelta;
  23884. private _randomTexture;
  23885. private _randomTexture2;
  23886. private _attributesStrideSize;
  23887. private _updateEffectOptions;
  23888. private _randomTextureSize;
  23889. private _actualFrame;
  23890. private readonly _rawTextureWidth;
  23891. /**
  23892. * List of animations used by the particle system.
  23893. */
  23894. animations: Animation[];
  23895. /**
  23896. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  23897. */
  23898. static readonly IsSupported: boolean;
  23899. /**
  23900. * An event triggered when the system is disposed.
  23901. */
  23902. onDisposeObservable: Observable<GPUParticleSystem>;
  23903. /**
  23904. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23905. */
  23906. updateSpeed: number;
  23907. /**
  23908. * The amount of time the particle system is running (depends of the overall update speed).
  23909. */
  23910. targetStopDuration: number;
  23911. /**
  23912. * The texture used to render each particle. (this can be a spritesheet)
  23913. */
  23914. particleTexture: Nullable<Texture>;
  23915. /**
  23916. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  23917. */
  23918. blendMode: number;
  23919. /**
  23920. * Minimum life time of emitting particles.
  23921. */
  23922. minLifeTime: number;
  23923. /**
  23924. * Maximum life time of emitting particles.
  23925. */
  23926. maxLifeTime: number;
  23927. /**
  23928. * Minimum Size of emitting particles.
  23929. */
  23930. minSize: number;
  23931. /**
  23932. * Maximum Size of emitting particles.
  23933. */
  23934. maxSize: number;
  23935. /**
  23936. * Minimum scale of emitting particles on X axis.
  23937. */
  23938. minScaleX: number;
  23939. /**
  23940. * Maximum scale of emitting particles on X axis.
  23941. */
  23942. maxScaleX: number;
  23943. /**
  23944. * Minimum scale of emitting particles on Y axis.
  23945. */
  23946. minScaleY: number;
  23947. /**
  23948. * Maximum scale of emitting particles on Y axis.
  23949. */
  23950. maxScaleY: number;
  23951. /**
  23952. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23953. */
  23954. color1: Color4;
  23955. /**
  23956. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23957. */
  23958. color2: Color4;
  23959. /**
  23960. * Color the particle will have at the end of its lifetime.
  23961. */
  23962. colorDead: Color4;
  23963. /**
  23964. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  23965. */
  23966. emitRate: number;
  23967. /**
  23968. * You can use gravity if you want to give an orientation to your particles.
  23969. */
  23970. gravity: Vector3;
  23971. /**
  23972. * Minimum power of emitting particles.
  23973. */
  23974. minEmitPower: number;
  23975. /**
  23976. * Maximum power of emitting particles.
  23977. */
  23978. maxEmitPower: number;
  23979. /**
  23980. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  23981. */
  23982. minAngularSpeed: number;
  23983. /**
  23984. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  23985. */
  23986. maxAngularSpeed: number;
  23987. /**
  23988. * The particle emitter type defines the emitter used by the particle system.
  23989. * It can be for example box, sphere, or cone...
  23990. */
  23991. particleEmitterType: Nullable<IParticleEmitterType>;
  23992. /**
  23993. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23994. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23995. */
  23996. direction1: Vector3;
  23997. /**
  23998. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23999. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24000. */
  24001. direction2: Vector3;
  24002. /**
  24003. * 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.
  24004. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24005. */
  24006. minEmitBox: Vector3;
  24007. /**
  24008. * 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.
  24009. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24010. */
  24011. maxEmitBox: Vector3;
  24012. /**
  24013. * Gets the maximum number of particles active at the same time.
  24014. * @returns The max number of active particles.
  24015. */
  24016. getCapacity(): number;
  24017. /**
  24018. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24019. * to override the particles.
  24020. */
  24021. forceDepthWrite: boolean;
  24022. /**
  24023. * Gets or set the number of active particles
  24024. */
  24025. activeParticleCount: number;
  24026. private _preWarmDone;
  24027. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  24028. preWarmCycles: number;
  24029. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  24030. preWarmStepOffset: number;
  24031. /**
  24032. * Gets or sets the minimal initial rotation in radians.
  24033. */
  24034. minInitialRotation: number;
  24035. /**
  24036. * Gets or sets the maximal initial rotation in radians.
  24037. */
  24038. maxInitialRotation: number;
  24039. /**
  24040. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  24041. */
  24042. spriteCellChangeSpeed: number;
  24043. /**
  24044. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  24045. */
  24046. startSpriteCellID: number;
  24047. /**
  24048. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  24049. */
  24050. endSpriteCellID: number;
  24051. /**
  24052. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24053. */
  24054. spriteCellWidth: number;
  24055. /**
  24056. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24057. */
  24058. spriteCellHeight: number;
  24059. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  24060. translationPivot: Vector2;
  24061. /**
  24062. * Gets or sets the billboard mode to use when isBillboardBased = true.
  24063. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  24064. */
  24065. billboardMode: number;
  24066. private _isAnimationSheetEnabled;
  24067. /**
  24068. * Gets whether an animation sprite sheet is enabled or not on the particle system
  24069. */
  24070. readonly isAnimationSheetEnabled: boolean;
  24071. /**
  24072. * Is this system ready to be used/rendered
  24073. * @return true if the system is ready
  24074. */
  24075. isReady(): boolean;
  24076. /**
  24077. * Gets Wether the system has been started.
  24078. * @returns True if it has been started, otherwise false.
  24079. */
  24080. isStarted(): boolean;
  24081. /**
  24082. * Starts the particle system and begins to emit.
  24083. */
  24084. start(): void;
  24085. /**
  24086. * Stops the particle system.
  24087. */
  24088. stop(): void;
  24089. /**
  24090. * Remove all active particles
  24091. */
  24092. reset(): void;
  24093. /**
  24094. * Returns the string "GPUParticleSystem"
  24095. * @returns a string containing the class name
  24096. */
  24097. getClassName(): string;
  24098. private _isBillboardBased;
  24099. /**
  24100. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  24101. */
  24102. isBillboardBased: boolean;
  24103. private _colorGradients;
  24104. private _colorGradientsTexture;
  24105. /**
  24106. * Gets the current list of color gradients.
  24107. * You must use addColorGradient and removeColorGradient to udpate this list
  24108. * @returns the list of color gradients
  24109. */
  24110. getColorGradients(): Nullable<Array<ColorGradient>>;
  24111. /**
  24112. * Gets the current list of size gradients.
  24113. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24114. * @returns the list of size gradients
  24115. */
  24116. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24117. /**
  24118. * Gets the current list of angular speed gradients.
  24119. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  24120. * @returns the list of angular speed gradients
  24121. */
  24122. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  24123. /**
  24124. * Gets the current list of velocity gradients.
  24125. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  24126. * @returns the list of angular speed gradients
  24127. */
  24128. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  24129. private _removeGradient(gradient, gradients, texture);
  24130. /**
  24131. * Adds a new color gradient
  24132. * @param gradient defines the gradient to use (between 0 and 1)
  24133. * @param color defines the color to affect to the specified gradient
  24134. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  24135. * @returns the current particle system
  24136. */
  24137. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  24138. /**
  24139. * Remove a specific color gradient
  24140. * @param gradient defines the gradient to remove
  24141. * @returns the current particle system
  24142. */
  24143. removeColorGradient(gradient: number): GPUParticleSystem;
  24144. private _angularSpeedGradients;
  24145. private _angularSpeedGradientsTexture;
  24146. private _sizeGradients;
  24147. private _sizeGradientsTexture;
  24148. private _velocityGradients;
  24149. private _velocityGradientsTexture;
  24150. private _addFactorGradient(factorGradients, gradient, factor);
  24151. /**
  24152. * Adds a new size gradient
  24153. * @param gradient defines the gradient to use (between 0 and 1)
  24154. * @param factor defines the size factor to affect to the specified gradient
  24155. * @returns the current particle system
  24156. */
  24157. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  24158. /**
  24159. * Remove a specific size gradient
  24160. * @param gradient defines the gradient to remove
  24161. * @returns the current particle system
  24162. */
  24163. removeSizeGradient(gradient: number): GPUParticleSystem;
  24164. /**
  24165. * Adds a new angular speed gradient
  24166. * @param gradient defines the gradient to use (between 0 and 1)
  24167. * @param factor defines the size factor to affect to the specified gradient
  24168. * @returns the current particle system
  24169. */
  24170. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  24171. /**
  24172. * Remove a specific angular speed gradient
  24173. * @param gradient defines the gradient to remove
  24174. * @returns the current particle system
  24175. */
  24176. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  24177. /**
  24178. * Adds a new velocity gradient
  24179. * @param gradient defines the gradient to use (between 0 and 1)
  24180. * @param factor defines the size factor to affect to the specified gradient
  24181. * @returns the current particle system
  24182. */
  24183. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  24184. /**
  24185. * Remove a specific velocity gradient
  24186. * @param gradient defines the gradient to remove
  24187. * @returns the current particle system
  24188. */
  24189. removeVelocityGradient(gradient: number): GPUParticleSystem;
  24190. /**
  24191. * Instantiates a GPU particle system.
  24192. * 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.
  24193. * @param name The name of the particle system
  24194. * @param options The options used to create the system
  24195. * @param scene The scene the particle system belongs to
  24196. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  24197. */
  24198. constructor(name: string, options: Partial<{
  24199. capacity: number;
  24200. randomTextureSize: number;
  24201. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  24202. private _createUpdateVAO(source);
  24203. private _createRenderVAO(source, spriteSource);
  24204. private _initialize(force?);
  24205. /** @hidden */
  24206. _recreateUpdateEffect(): void;
  24207. /** @hidden */
  24208. _recreateRenderEffect(): void;
  24209. /**
  24210. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  24211. * @param preWarm defines if we are in the pre-warmimg phase
  24212. */
  24213. animate(preWarm?: boolean): void;
  24214. private _createFactorGradientTexture(factorGradients, textureName);
  24215. private _createSizeGradientTexture();
  24216. private _createAngularSpeedGradientTexture();
  24217. private _createVelocityGradientTexture();
  24218. private _createColorGradientTexture();
  24219. /**
  24220. * Renders the particle system in its current state
  24221. * @param preWarm defines if the system should only update the particles but not render them
  24222. * @returns the current number of particles
  24223. */
  24224. render(preWarm?: boolean): number;
  24225. /**
  24226. * Rebuilds the particle system
  24227. */
  24228. rebuild(): void;
  24229. private _releaseBuffers();
  24230. private _releaseVAOs();
  24231. /**
  24232. * Disposes the particle system and free the associated resources
  24233. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  24234. */
  24235. dispose(disposeTexture?: boolean): void;
  24236. /**
  24237. * Clones the particle system.
  24238. * @param name The name of the cloned object
  24239. * @param newEmitter The new emitter to use
  24240. * @returns the cloned particle system
  24241. */
  24242. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  24243. /**
  24244. * Serializes the particle system to a JSON object.
  24245. * @returns the JSON object
  24246. */
  24247. serialize(): any;
  24248. /**
  24249. * Parses a JSON object to create a GPU particle system.
  24250. * @param parsedParticleSystem The JSON object to parse
  24251. * @param scene The scene to create the particle system in
  24252. * @param rootUrl The root url to use to load external dependencies like texture
  24253. * @returns the parsed GPU particle system
  24254. */
  24255. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  24256. }
  24257. }
  24258. declare module BABYLON {
  24259. /**
  24260. * Interface representing a particle system in Babylon.js.
  24261. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  24262. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  24263. */
  24264. interface IParticleSystem {
  24265. /**
  24266. * List of animations used by the particle system.
  24267. */
  24268. animations: Animation[];
  24269. /**
  24270. * The id of the Particle system.
  24271. */
  24272. id: string;
  24273. /**
  24274. * The name of the Particle system.
  24275. */
  24276. name: string;
  24277. /**
  24278. * The emitter represents the Mesh or position we are attaching the particle system to.
  24279. */
  24280. emitter: Nullable<AbstractMesh | Vector3>;
  24281. /**
  24282. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  24283. */
  24284. isBillboardBased: boolean;
  24285. /**
  24286. * The rendering group used by the Particle system to chose when to render.
  24287. */
  24288. renderingGroupId: number;
  24289. /**
  24290. * The layer mask we are rendering the particles through.
  24291. */
  24292. layerMask: number;
  24293. /**
  24294. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24295. */
  24296. updateSpeed: number;
  24297. /**
  24298. * The amount of time the particle system is running (depends of the overall update speed).
  24299. */
  24300. targetStopDuration: number;
  24301. /**
  24302. * The texture used to render each particle. (this can be a spritesheet)
  24303. */
  24304. particleTexture: Nullable<Texture>;
  24305. /**
  24306. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  24307. */
  24308. blendMode: number;
  24309. /**
  24310. * Minimum life time of emitting particles.
  24311. */
  24312. minLifeTime: number;
  24313. /**
  24314. * Maximum life time of emitting particles.
  24315. */
  24316. maxLifeTime: number;
  24317. /**
  24318. * Minimum Size of emitting particles.
  24319. */
  24320. minSize: number;
  24321. /**
  24322. * Maximum Size of emitting particles.
  24323. */
  24324. maxSize: number;
  24325. /**
  24326. * Minimum scale of emitting particles on X axis.
  24327. */
  24328. minScaleX: number;
  24329. /**
  24330. * Maximum scale of emitting particles on X axis.
  24331. */
  24332. maxScaleX: number;
  24333. /**
  24334. * Minimum scale of emitting particles on Y axis.
  24335. */
  24336. minScaleY: number;
  24337. /**
  24338. * Maximum scale of emitting particles on Y axis.
  24339. */
  24340. maxScaleY: number;
  24341. /**
  24342. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24343. */
  24344. color1: Color4;
  24345. /**
  24346. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24347. */
  24348. color2: Color4;
  24349. /**
  24350. * Color the particle will have at the end of its lifetime.
  24351. */
  24352. colorDead: Color4;
  24353. /**
  24354. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  24355. */
  24356. emitRate: number;
  24357. /**
  24358. * You can use gravity if you want to give an orientation to your particles.
  24359. */
  24360. gravity: Vector3;
  24361. /**
  24362. * Minimum power of emitting particles.
  24363. */
  24364. minEmitPower: number;
  24365. /**
  24366. * Maximum power of emitting particles.
  24367. */
  24368. maxEmitPower: number;
  24369. /**
  24370. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24371. */
  24372. minAngularSpeed: number;
  24373. /**
  24374. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24375. */
  24376. maxAngularSpeed: number;
  24377. /**
  24378. * Gets or sets the minimal initial rotation in radians.
  24379. */
  24380. minInitialRotation: number;
  24381. /**
  24382. * Gets or sets the maximal initial rotation in radians.
  24383. */
  24384. maxInitialRotation: number;
  24385. /**
  24386. * The particle emitter type defines the emitter used by the particle system.
  24387. * It can be for example box, sphere, or cone...
  24388. */
  24389. particleEmitterType: Nullable<IParticleEmitterType>;
  24390. /**
  24391. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  24392. */
  24393. preWarmCycles: number;
  24394. /**
  24395. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  24396. */
  24397. preWarmStepOffset: number;
  24398. /**
  24399. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  24400. */
  24401. spriteCellChangeSpeed: number;
  24402. /**
  24403. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  24404. */
  24405. startSpriteCellID: number;
  24406. /**
  24407. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  24408. */
  24409. endSpriteCellID: number;
  24410. /**
  24411. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24412. */
  24413. spriteCellWidth: number;
  24414. /**
  24415. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24416. */
  24417. spriteCellHeight: number;
  24418. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  24419. translationPivot: Vector2;
  24420. /**
  24421. * Gets or sets the billboard mode to use when isBillboardBased = true.
  24422. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  24423. */
  24424. billboardMode: number;
  24425. /**
  24426. * Gets the maximum number of particles active at the same time.
  24427. * @returns The max number of active particles.
  24428. */
  24429. getCapacity(): number;
  24430. /**
  24431. * Gets Wether the system has been started.
  24432. * @returns True if it has been started, otherwise false.
  24433. */
  24434. isStarted(): boolean;
  24435. /**
  24436. * Gets if the particle system has been started.
  24437. * @return true if the system has been started, otherwise false.
  24438. */
  24439. isStarted(): boolean;
  24440. /**
  24441. * Animates the particle system for this frame.
  24442. */
  24443. animate(): void;
  24444. /**
  24445. * Renders the particle system in its current state.
  24446. * @returns the current number of particles
  24447. */
  24448. render(): number;
  24449. /**
  24450. * Dispose the particle system and frees its associated resources.
  24451. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  24452. */
  24453. dispose(disposeTexture?: boolean): void;
  24454. /**
  24455. * Clones the particle system.
  24456. * @param name The name of the cloned object
  24457. * @param newEmitter The new emitter to use
  24458. * @returns the cloned particle system
  24459. */
  24460. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  24461. /**
  24462. * Serializes the particle system to a JSON object.
  24463. * @returns the JSON object
  24464. */
  24465. serialize(): any;
  24466. /**
  24467. * Rebuild the particle system
  24468. */
  24469. rebuild(): void;
  24470. /**
  24471. * Starts the particle system and begins to emit.
  24472. */
  24473. start(): void;
  24474. /**
  24475. * Stops the particle system.
  24476. */
  24477. stop(): void;
  24478. /**
  24479. * Remove all active particles
  24480. */
  24481. reset(): void;
  24482. /**
  24483. * Is this system ready to be used/rendered
  24484. * @return true if the system is ready
  24485. */
  24486. isReady(): boolean;
  24487. /**
  24488. * Adds a new color gradient
  24489. * @param gradient defines the gradient to use (between 0 and 1)
  24490. * @param color defines the color to affect to the specified gradient
  24491. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  24492. * @returns the current particle system
  24493. */
  24494. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  24495. /**
  24496. * Remove a specific color gradient
  24497. * @param gradient defines the gradient to remove
  24498. * @returns the current particle system
  24499. */
  24500. removeColorGradient(gradient: number): IParticleSystem;
  24501. /**
  24502. * Adds a new size gradient
  24503. * @param gradient defines the gradient to use (between 0 and 1)
  24504. * @param factor defines the size factor to affect to the specified gradient
  24505. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  24506. * @returns the current particle system
  24507. */
  24508. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  24509. /**
  24510. * Remove a specific size gradient
  24511. * @param gradient defines the gradient to remove
  24512. * @returns the current particle system
  24513. */
  24514. removeSizeGradient(gradient: number): IParticleSystem;
  24515. /**
  24516. * Gets the current list of color gradients.
  24517. * You must use addColorGradient and removeColorGradient to udpate this list
  24518. * @returns the list of color gradients
  24519. */
  24520. getColorGradients(): Nullable<Array<ColorGradient>>;
  24521. /**
  24522. * Gets the current list of size gradients.
  24523. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24524. * @returns the list of size gradients
  24525. */
  24526. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24527. /**
  24528. * Gets the current list of angular speed gradients.
  24529. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  24530. * @returns the list of angular speed gradients
  24531. */
  24532. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  24533. /**
  24534. * Adds a new angular speed gradient
  24535. * @param gradient defines the gradient to use (between 0 and 1)
  24536. * @param factor defines the size factor to affect to the specified gradient
  24537. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  24538. * @returns the current particle system
  24539. */
  24540. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  24541. /**
  24542. * Remove a specific angular speed gradient
  24543. * @param gradient defines the gradient to remove
  24544. * @returns the current particle system
  24545. */
  24546. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  24547. /**
  24548. * Gets the current list of velocity gradients.
  24549. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  24550. * @returns the list of velocity gradients
  24551. */
  24552. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  24553. /**
  24554. * Adds a new velocity gradient
  24555. * @param gradient defines the gradient to use (between 0 and 1)
  24556. * @param factor defines the size factor to affect to the specified gradient
  24557. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  24558. * @returns the current particle system
  24559. */
  24560. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  24561. /**
  24562. * Remove a specific velocity gradient
  24563. * @param gradient defines the gradient to remove
  24564. * @returns the current particle system
  24565. */
  24566. removeVelocityGradient(gradient: number): IParticleSystem;
  24567. }
  24568. }
  24569. declare module BABYLON {
  24570. /**
  24571. * A particle represents one of the element emitted by a particle system.
  24572. * This is mainly define by its coordinates, direction, velocity and age.
  24573. */
  24574. class Particle {
  24575. /**
  24576. * particleSystem the particle system the particle belongs to.
  24577. */
  24578. particleSystem: ParticleSystem;
  24579. /**
  24580. * The world position of the particle in the scene.
  24581. */
  24582. position: Vector3;
  24583. /**
  24584. * The world direction of the particle in the scene.
  24585. */
  24586. direction: Vector3;
  24587. /**
  24588. * The color of the particle.
  24589. */
  24590. color: Color4;
  24591. /**
  24592. * The color change of the particle per step.
  24593. */
  24594. colorStep: Color4;
  24595. /**
  24596. * Defines how long will the life of the particle be.
  24597. */
  24598. lifeTime: number;
  24599. /**
  24600. * The current age of the particle.
  24601. */
  24602. age: number;
  24603. /**
  24604. * The current size of the particle.
  24605. */
  24606. size: number;
  24607. /**
  24608. * The current scale of the particle.
  24609. */
  24610. scale: Vector2;
  24611. /**
  24612. * The current angle of the particle.
  24613. */
  24614. angle: number;
  24615. /**
  24616. * Defines how fast is the angle changing.
  24617. */
  24618. angularSpeed: number;
  24619. /**
  24620. * Defines the cell index used by the particle to be rendered from a sprite.
  24621. */
  24622. cellIndex: number;
  24623. /** @hidden */
  24624. _initialDirection: Nullable<Vector3>;
  24625. /** @hidden */
  24626. _initialStartSpriteCellID: number;
  24627. _initialEndSpriteCellID: number;
  24628. /** @hidden */
  24629. _currentColorGradient: Nullable<ColorGradient>;
  24630. /** @hidden */
  24631. _currentColor1: Color4;
  24632. /** @hidden */
  24633. _currentColor2: Color4;
  24634. /** @hidden */
  24635. _currentSizeGradient: Nullable<FactorGradient>;
  24636. /** @hidden */
  24637. _currentSize1: number;
  24638. /** @hidden */
  24639. _currentSize2: number;
  24640. /** @hidden */
  24641. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  24642. /** @hidden */
  24643. _currentAngularSpeed1: number;
  24644. /** @hidden */
  24645. _currentAngularSpeed2: number;
  24646. /** @hidden */
  24647. _currentVelocityGradient: Nullable<FactorGradient>;
  24648. /** @hidden */
  24649. _currentVelocity1: number;
  24650. /** @hidden */
  24651. _currentVelocity2: number;
  24652. /**
  24653. * Creates a new instance Particle
  24654. * @param particleSystem the particle system the particle belongs to
  24655. */
  24656. constructor(
  24657. /**
  24658. * particleSystem the particle system the particle belongs to.
  24659. */
  24660. particleSystem: ParticleSystem);
  24661. private updateCellInfoFromSystem();
  24662. /**
  24663. * Defines how the sprite cell index is updated for the particle
  24664. */
  24665. updateCellIndex(): void;
  24666. /**
  24667. * Copy the properties of particle to another one.
  24668. * @param other the particle to copy the information to.
  24669. */
  24670. copyTo(other: Particle): void;
  24671. }
  24672. }
  24673. declare module BABYLON {
  24674. /**
  24675. * This class is made for on one-liner static method to help creating particle system set.
  24676. */
  24677. class ParticleHelper {
  24678. /**
  24679. * Gets or sets base Assets URL
  24680. */
  24681. static BaseAssetsUrl: string;
  24682. /**
  24683. * This is the main static method (one-liner) of this helper to create different particle systems
  24684. * @param type This string represents the type to the particle system to create
  24685. * @param scene The scene where the particle system should live
  24686. * @param gpu If the system will use gpu
  24687. * @returns the ParticleSystemSet created
  24688. */
  24689. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  24690. /**
  24691. * Static function used to export a particle system to a ParticleSystemSet variable.
  24692. * Please note that the emitter shape is not exported
  24693. * @param system defines the particle systems to export
  24694. */
  24695. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  24696. }
  24697. }
  24698. declare module BABYLON {
  24699. /**
  24700. * This represents a particle system in Babylon.
  24701. * 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.
  24702. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  24703. * @example https://doc.babylonjs.com/babylon101/particles
  24704. */
  24705. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  24706. /**
  24707. * Source color is added to the destination color without alpha affecting the result.
  24708. */
  24709. static BLENDMODE_ONEONE: number;
  24710. /**
  24711. * Blend current color and particle color using particle’s alpha.
  24712. */
  24713. static BLENDMODE_STANDARD: number;
  24714. /**
  24715. * Add current color and particle color multiplied by particle’s alpha.
  24716. */
  24717. static BLENDMODE_ADD: number;
  24718. /**
  24719. * List of animations used by the particle system.
  24720. */
  24721. animations: Animation[];
  24722. /**
  24723. * The id of the Particle system.
  24724. */
  24725. id: string;
  24726. /**
  24727. * The friendly name of the Particle system.
  24728. */
  24729. name: string;
  24730. /**
  24731. * The rendering group used by the Particle system to chose when to render.
  24732. */
  24733. renderingGroupId: number;
  24734. /**
  24735. * The emitter represents the Mesh or position we are attaching the particle system to.
  24736. */
  24737. emitter: Nullable<AbstractMesh | Vector3>;
  24738. /**
  24739. * The maximum number of particles to emit per frame
  24740. */
  24741. emitRate: number;
  24742. /**
  24743. * If you want to launch only a few particles at once, that can be done, as well.
  24744. */
  24745. manualEmitCount: number;
  24746. /**
  24747. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24748. */
  24749. updateSpeed: number;
  24750. /**
  24751. * The amount of time the particle system is running (depends of the overall update speed).
  24752. */
  24753. targetStopDuration: number;
  24754. /**
  24755. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  24756. */
  24757. disposeOnStop: boolean;
  24758. /**
  24759. * Minimum power of emitting particles.
  24760. */
  24761. minEmitPower: number;
  24762. /**
  24763. * Maximum power of emitting particles.
  24764. */
  24765. maxEmitPower: number;
  24766. /**
  24767. * Minimum life time of emitting particles.
  24768. */
  24769. minLifeTime: number;
  24770. /**
  24771. * Maximum life time of emitting particles.
  24772. */
  24773. maxLifeTime: number;
  24774. /**
  24775. * Minimum Size of emitting particles.
  24776. */
  24777. minSize: number;
  24778. /**
  24779. * Maximum Size of emitting particles.
  24780. */
  24781. maxSize: number;
  24782. /**
  24783. * Minimum scale of emitting particles on X axis.
  24784. */
  24785. minScaleX: number;
  24786. /**
  24787. * Maximum scale of emitting particles on X axis.
  24788. */
  24789. maxScaleX: number;
  24790. /**
  24791. * Minimum scale of emitting particles on Y axis.
  24792. */
  24793. minScaleY: number;
  24794. /**
  24795. * Maximum scale of emitting particles on Y axis.
  24796. */
  24797. maxScaleY: number;
  24798. /**
  24799. * Gets or sets the minimal initial rotation in radians.
  24800. */
  24801. minInitialRotation: number;
  24802. /**
  24803. * Gets or sets the maximal initial rotation in radians.
  24804. */
  24805. maxInitialRotation: number;
  24806. /**
  24807. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24808. */
  24809. minAngularSpeed: number;
  24810. /**
  24811. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24812. */
  24813. maxAngularSpeed: number;
  24814. /**
  24815. * The texture used to render each particle. (this can be a spritesheet)
  24816. */
  24817. particleTexture: Nullable<Texture>;
  24818. /**
  24819. * The layer mask we are rendering the particles through.
  24820. */
  24821. layerMask: number;
  24822. /**
  24823. * This can help using your own shader to render the particle system.
  24824. * The according effect will be created
  24825. */
  24826. customShader: any;
  24827. /**
  24828. * By default particle system starts as soon as they are created. This prevents the
  24829. * automatic start to happen and let you decide when to start emitting particles.
  24830. */
  24831. preventAutoStart: boolean;
  24832. /**
  24833. * This function can be defined to provide custom update for active particles.
  24834. * This function will be called instead of regular update (age, position, color, etc.).
  24835. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  24836. */
  24837. updateFunction: (particles: Particle[]) => void;
  24838. /**
  24839. * Callback triggered when the particle animation is ending.
  24840. */
  24841. onAnimationEnd: Nullable<() => void>;
  24842. /**
  24843. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  24844. */
  24845. blendMode: number;
  24846. /**
  24847. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24848. * to override the particles.
  24849. */
  24850. forceDepthWrite: boolean;
  24851. /**
  24852. * You can use gravity if you want to give an orientation to your particles.
  24853. */
  24854. gravity: Vector3;
  24855. private _colorGradients;
  24856. private _sizeGradients;
  24857. private _lifeTimeGradients;
  24858. private _angularSpeedGradients;
  24859. private _velocityGradients;
  24860. /**
  24861. * Gets the current list of color gradients.
  24862. * You must use addColorGradient and removeColorGradient to udpate this list
  24863. * @returns the list of color gradients
  24864. */
  24865. getColorGradients(): Nullable<Array<ColorGradient>>;
  24866. /**
  24867. * Gets the current list of size gradients.
  24868. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24869. * @returns the list of size gradients
  24870. */
  24871. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24872. /**
  24873. * Gets the current list of life time gradients.
  24874. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  24875. * @returns the list of life time gradients
  24876. */
  24877. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  24878. /**
  24879. * Gets the current list of angular speed gradients.
  24880. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  24881. * @returns the list of angular speed gradients
  24882. */
  24883. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  24884. /**
  24885. * Gets the current list of velocity gradients.
  24886. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  24887. * @returns the list of velocity gradients
  24888. */
  24889. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  24890. /**
  24891. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24892. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24893. */
  24894. direction1: Vector3;
  24895. /**
  24896. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24897. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24898. */
  24899. direction2: Vector3;
  24900. /**
  24901. * 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.
  24902. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24903. */
  24904. minEmitBox: Vector3;
  24905. /**
  24906. * 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.
  24907. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24908. */
  24909. maxEmitBox: Vector3;
  24910. /**
  24911. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24912. */
  24913. color1: Color4;
  24914. /**
  24915. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24916. */
  24917. color2: Color4;
  24918. /**
  24919. * Color the particle will have at the end of its lifetime
  24920. */
  24921. colorDead: Color4;
  24922. /**
  24923. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  24924. */
  24925. textureMask: Color4;
  24926. /**
  24927. * The particle emitter type defines the emitter used by the particle system.
  24928. * It can be for example box, sphere, or cone...
  24929. */
  24930. particleEmitterType: IParticleEmitterType;
  24931. /**
  24932. * This function can be defined to specify initial direction for every new particle.
  24933. * It by default use the emitterType defined function
  24934. */
  24935. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  24936. /**
  24937. * This function can be defined to specify initial position for every new particle.
  24938. * It by default use the emitterType defined function
  24939. */
  24940. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  24941. /**
  24942. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  24943. */
  24944. spriteCellChangeSpeed: number;
  24945. /**
  24946. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  24947. */
  24948. startSpriteCellID: number;
  24949. /**
  24950. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  24951. */
  24952. endSpriteCellID: number;
  24953. /**
  24954. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24955. */
  24956. spriteCellWidth: number;
  24957. /**
  24958. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24959. */
  24960. spriteCellHeight: number;
  24961. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  24962. preWarmCycles: number;
  24963. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  24964. preWarmStepOffset: number;
  24965. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  24966. translationPivot: Vector2;
  24967. /**
  24968. * An event triggered when the system is disposed
  24969. */
  24970. onDisposeObservable: Observable<ParticleSystem>;
  24971. private _onDisposeObserver;
  24972. /**
  24973. * Sets a callback that will be triggered when the system is disposed
  24974. */
  24975. onDispose: () => void;
  24976. /**
  24977. * Gets whether an animation sprite sheet is enabled or not on the particle system
  24978. */
  24979. readonly isAnimationSheetEnabled: boolean;
  24980. /**
  24981. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  24982. */
  24983. isBillboardBased: boolean;
  24984. /**
  24985. * Gets or sets the billboard mode to use when isBillboardBased = true.
  24986. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  24987. */
  24988. billboardMode: number;
  24989. private _particles;
  24990. private _epsilon;
  24991. private _capacity;
  24992. private _scene;
  24993. private _stockParticles;
  24994. private _newPartsExcess;
  24995. private _vertexData;
  24996. private _vertexBuffer;
  24997. private _vertexBuffers;
  24998. private _spriteBuffer;
  24999. private _indexBuffer;
  25000. private _effect;
  25001. private _customEffect;
  25002. private _cachedDefines;
  25003. private _scaledColorStep;
  25004. private _colorDiff;
  25005. private _scaledDirection;
  25006. private _scaledGravity;
  25007. private _currentRenderId;
  25008. private _alive;
  25009. private _useInstancing;
  25010. private _started;
  25011. private _stopped;
  25012. private _actualFrame;
  25013. private _scaledUpdateSpeed;
  25014. private _vertexBufferSize;
  25015. private _isAnimationSheetEnabled;
  25016. private _isBillboardBased;
  25017. /**
  25018. * 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.
  25019. */
  25020. subEmitters: ParticleSystem[];
  25021. /**
  25022. * The current active Sub-systems, this property is used by the root particle system only.
  25023. */
  25024. activeSubSystems: Array<ParticleSystem>;
  25025. private _rootParticleSystem;
  25026. /**
  25027. * Gets the current list of active particles
  25028. */
  25029. readonly particles: Particle[];
  25030. /**
  25031. * Returns the string "ParticleSystem"
  25032. * @returns a string containing the class name
  25033. */
  25034. getClassName(): string;
  25035. /**
  25036. * Instantiates a particle system.
  25037. * 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.
  25038. * @param name The name of the particle system
  25039. * @param capacity The max number of particles alive at the same time
  25040. * @param scene The scene the particle system belongs to
  25041. * @param customEffect a custom effect used to change the way particles are rendered by default
  25042. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  25043. * @param epsilon Offset used to render the particles
  25044. */
  25045. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  25046. private _addFactorGradient(factorGradients, gradient, factor, factor2?);
  25047. private _removeFactorGradient(factorGradients, gradient);
  25048. /**
  25049. * Adds a new life time gradient
  25050. * @param gradient defines the gradient to use (between 0 and 1)
  25051. * @param factor defines the life time factor to affect to the specified gradient
  25052. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25053. * @returns the current particle system
  25054. */
  25055. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  25056. /**
  25057. * Remove a specific life time gradient
  25058. * @param gradient defines the gradient to remove
  25059. * @returns the current particle system
  25060. */
  25061. removeLifeTimeGradient(gradient: number): ParticleSystem;
  25062. /**
  25063. * Adds a new size gradient
  25064. * @param gradient defines the gradient to use (between 0 and 1)
  25065. * @param factor defines the size factor to affect to the specified gradient
  25066. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25067. * @returns the current particle system
  25068. */
  25069. addSizeGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  25070. /**
  25071. * Remove a specific size gradient
  25072. * @param gradient defines the gradient to remove
  25073. * @returns the current particle system
  25074. */
  25075. removeSizeGradient(gradient: number): ParticleSystem;
  25076. /**
  25077. * Adds a new angular speed gradient
  25078. * @param gradient defines the gradient to use (between 0 and 1)
  25079. * @param factor defines the size factor to affect to the specified gradient
  25080. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25081. * @returns the current particle system
  25082. */
  25083. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  25084. /**
  25085. * Remove a specific angular speed gradient
  25086. * @param gradient defines the gradient to remove
  25087. * @returns the current particle system
  25088. */
  25089. removeAngularSpeedGradient(gradient: number): ParticleSystem;
  25090. /**
  25091. * Adds a new velocity gradient
  25092. * @param gradient defines the gradient to use (between 0 and 1)
  25093. * @param factor defines the size factor to affect to the specified gradient
  25094. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25095. * @returns the current particle system
  25096. */
  25097. addVelocityGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  25098. /**
  25099. * Remove a specific velocity gradient
  25100. * @param gradient defines the gradient to remove
  25101. * @returns the current particle system
  25102. */
  25103. removeVelocityGradient(gradient: number): ParticleSystem;
  25104. /**
  25105. * Adds a new color gradient
  25106. * @param gradient defines the gradient to use (between 0 and 1)
  25107. * @param color defines the color to affect to the specified gradient
  25108. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25109. */
  25110. addColorGradient(gradient: number, color: Color4, color2?: Color4): ParticleSystem;
  25111. /**
  25112. * Remove a specific color gradient
  25113. * @param gradient defines the gradient to remove
  25114. */
  25115. removeColorGradient(gradient: number): ParticleSystem;
  25116. private _resetEffect();
  25117. private _createVertexBuffers();
  25118. private _createIndexBuffer();
  25119. /**
  25120. * Gets the maximum number of particles active at the same time.
  25121. * @returns The max number of active particles.
  25122. */
  25123. getCapacity(): number;
  25124. /**
  25125. * Gets Wether there are still active particles in the system.
  25126. * @returns True if it is alive, otherwise false.
  25127. */
  25128. isAlive(): boolean;
  25129. /**
  25130. * Gets Wether the system has been started.
  25131. * @returns True if it has been started, otherwise false.
  25132. */
  25133. isStarted(): boolean;
  25134. /**
  25135. * Starts the particle system and begins to emit.
  25136. */
  25137. start(): void;
  25138. /**
  25139. * Stops the particle system.
  25140. * @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.
  25141. */
  25142. stop(stopSubEmitters?: boolean): void;
  25143. /**
  25144. * Remove all active particles
  25145. */
  25146. reset(): void;
  25147. /**
  25148. * @hidden (for internal use only)
  25149. */
  25150. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  25151. /**
  25152. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  25153. * Its lifetime will start back at 0.
  25154. */
  25155. recycleParticle: (particle: Particle) => void;
  25156. private _stopSubEmitters();
  25157. private _createParticle;
  25158. private _removeFromRoot();
  25159. private _emitFromParticle;
  25160. private _update(newParticles);
  25161. /** @hidden */
  25162. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean): string[];
  25163. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  25164. private _getEffect();
  25165. /**
  25166. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  25167. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  25168. */
  25169. animate(preWarmOnly?: boolean): void;
  25170. private _appendParticleVertices(offset, particle);
  25171. /**
  25172. * Rebuilds the particle system.
  25173. */
  25174. rebuild(): void;
  25175. /**
  25176. * Is this system ready to be used/rendered
  25177. * @return true if the system is ready
  25178. */
  25179. isReady(): boolean;
  25180. /**
  25181. * Renders the particle system in its current state.
  25182. * @returns the current number of particles
  25183. */
  25184. render(): number;
  25185. /**
  25186. * Disposes the particle system and free the associated resources
  25187. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25188. */
  25189. dispose(disposeTexture?: boolean): void;
  25190. /**
  25191. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  25192. * @param radius The radius of the sphere to emit from
  25193. * @returns the emitter
  25194. */
  25195. createSphereEmitter(radius?: number): SphereParticleEmitter;
  25196. /**
  25197. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  25198. * @param radius The radius of the sphere to emit from
  25199. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  25200. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  25201. * @returns the emitter
  25202. */
  25203. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  25204. /**
  25205. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  25206. * @param radius The radius of the cone to emit from
  25207. * @param angle The base angle of the cone
  25208. * @returns the emitter
  25209. */
  25210. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  25211. /**
  25212. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  25213. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25214. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25215. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25216. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25217. * @returns the emitter
  25218. */
  25219. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  25220. /**
  25221. * Clones the particle system.
  25222. * @param name The name of the cloned object
  25223. * @param newEmitter The new emitter to use
  25224. * @returns the cloned particle system
  25225. */
  25226. clone(name: string, newEmitter: any): ParticleSystem;
  25227. /**
  25228. * Serializes the particle system to a JSON object.
  25229. * @returns the JSON object
  25230. */
  25231. serialize(): any;
  25232. /** @hidden */
  25233. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  25234. /** @hidden */
  25235. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  25236. /**
  25237. * Parses a JSON object to create a particle system.
  25238. * @param parsedParticleSystem The JSON object to parse
  25239. * @param scene The scene to create the particle system in
  25240. * @param rootUrl The root url to use to load external dependencies like texture
  25241. * @returns the Parsed particle system
  25242. */
  25243. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  25244. }
  25245. }
  25246. declare module BABYLON {
  25247. interface Engine {
  25248. /**
  25249. * Create an effect to use with particle systems.
  25250. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  25251. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  25252. * @param uniformsNames defines a list of attribute names
  25253. * @param samplers defines an array of string used to represent textures
  25254. * @param defines defines the string containing the defines to use to compile the shaders
  25255. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  25256. * @param onCompiled defines a function to call when the effect creation is successful
  25257. * @param onError defines a function to call when the effect creation has failed
  25258. * @returns the new Effect
  25259. */
  25260. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  25261. }
  25262. }
  25263. declare module BABYLON {
  25264. /**
  25265. * Represents a set of particle systems working together to create a specific effect
  25266. */
  25267. class ParticleSystemSet implements IDisposable {
  25268. private _emitterCreationOptions;
  25269. private _emitterNode;
  25270. /**
  25271. * Gets the particle system list
  25272. */
  25273. systems: IParticleSystem[];
  25274. /**
  25275. * Gets the emitter node used with this set
  25276. */
  25277. readonly emitterNode: Nullable<TransformNode>;
  25278. /**
  25279. * Creates a new emitter mesh as a sphere
  25280. * @param options defines the options used to create the sphere
  25281. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  25282. * @param scene defines the hosting scene
  25283. */
  25284. setEmitterAsSphere(options: {
  25285. diameter: number;
  25286. segments: number;
  25287. color: Color3;
  25288. }, renderingGroupId: number, scene: Scene): void;
  25289. /**
  25290. * Starts all particle systems of the set
  25291. * @param emitter defines an optional mesh to use as emitter for the particle systems
  25292. */
  25293. start(emitter?: AbstractMesh): void;
  25294. /**
  25295. * Release all associated resources
  25296. */
  25297. dispose(): void;
  25298. /**
  25299. * Serialize the set into a JSON compatible object
  25300. * @returns a JSON compatible representation of the set
  25301. */
  25302. serialize(): any;
  25303. /**
  25304. * Parse a new ParticleSystemSet from a serialized source
  25305. * @param data defines a JSON compatible representation of the set
  25306. * @param scene defines the hosting scene
  25307. * @param gpu defines if we want GPU particles or CPU particles
  25308. * @returns a new ParticleSystemSet
  25309. */
  25310. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  25311. }
  25312. }
  25313. declare module BABYLON {
  25314. /**
  25315. * Represents one particle of a solid particle system.
  25316. */
  25317. class SolidParticle {
  25318. /**
  25319. * particle global index
  25320. */
  25321. idx: number;
  25322. /**
  25323. * The color of the particle
  25324. */
  25325. color: Nullable<Color4>;
  25326. /**
  25327. * The world space position of the particle.
  25328. */
  25329. position: Vector3;
  25330. /**
  25331. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25332. */
  25333. rotation: Vector3;
  25334. /**
  25335. * The world space rotation quaternion of the particle.
  25336. */
  25337. rotationQuaternion: Nullable<Quaternion>;
  25338. /**
  25339. * The scaling of the particle.
  25340. */
  25341. scaling: Vector3;
  25342. /**
  25343. * The uvs of the particle.
  25344. */
  25345. uvs: Vector4;
  25346. /**
  25347. * The current speed of the particle.
  25348. */
  25349. velocity: Vector3;
  25350. /**
  25351. * The pivot point in the particle local space.
  25352. */
  25353. pivot: Vector3;
  25354. /**
  25355. * Must the particle be translated from its pivot point in its local space ?
  25356. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25357. * Default : false
  25358. */
  25359. translateFromPivot: boolean;
  25360. /**
  25361. * Is the particle active or not ?
  25362. */
  25363. alive: boolean;
  25364. /**
  25365. * Is the particle visible or not ?
  25366. */
  25367. isVisible: boolean;
  25368. /**
  25369. * Index of this particle in the global "positions" array (Internal use)
  25370. */
  25371. _pos: number;
  25372. /**
  25373. * Index of this particle in the global "indices" array (Internal use)
  25374. */
  25375. _ind: number;
  25376. /**
  25377. * ModelShape of this particle (Internal use)
  25378. */
  25379. _model: ModelShape;
  25380. /**
  25381. * ModelShape id of this particle
  25382. */
  25383. shapeId: number;
  25384. /**
  25385. * Index of the particle in its shape id (Internal use)
  25386. */
  25387. idxInShape: number;
  25388. /**
  25389. * Reference to the shape model BoundingInfo object (Internal use)
  25390. */
  25391. _modelBoundingInfo: BoundingInfo;
  25392. /**
  25393. * Particle BoundingInfo object (Internal use)
  25394. */
  25395. _boundingInfo: BoundingInfo;
  25396. /**
  25397. * Reference to the SPS what the particle belongs to (Internal use)
  25398. */
  25399. _sps: SolidParticleSystem;
  25400. /**
  25401. * Still set as invisible in order to skip useless computations (Internal use)
  25402. */
  25403. _stillInvisible: boolean;
  25404. /**
  25405. * Last computed particle rotation matrix
  25406. */
  25407. _rotationMatrix: number[];
  25408. /**
  25409. * Parent particle Id, if any.
  25410. * Default null.
  25411. */
  25412. parentId: Nullable<number>;
  25413. /**
  25414. * Internal global position in the SPS.
  25415. */
  25416. _globalPosition: Vector3;
  25417. /**
  25418. * Creates a Solid Particle object.
  25419. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25420. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25421. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25422. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25423. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25424. * @param shapeId (integer) is the model shape identifier in the SPS.
  25425. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25426. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25427. */
  25428. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25429. /**
  25430. * Legacy support, changed scale to scaling
  25431. */
  25432. /**
  25433. * Legacy support, changed scale to scaling
  25434. */
  25435. scale: Vector3;
  25436. /**
  25437. * Legacy support, changed quaternion to rotationQuaternion
  25438. */
  25439. /**
  25440. * Legacy support, changed quaternion to rotationQuaternion
  25441. */
  25442. quaternion: Nullable<Quaternion>;
  25443. /**
  25444. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25445. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25446. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25447. * @returns true if it intersects
  25448. */
  25449. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25450. }
  25451. /**
  25452. * Represents the shape of the model used by one particle of a solid particle system.
  25453. * SPS internal tool, don't use it manually.
  25454. */
  25455. class ModelShape {
  25456. /**
  25457. * The shape id.
  25458. */
  25459. shapeID: number;
  25460. /**
  25461. * flat array of model positions (internal use)
  25462. */
  25463. _shape: Vector3[];
  25464. /**
  25465. * flat array of model UVs (internal use)
  25466. */
  25467. _shapeUV: number[];
  25468. /**
  25469. * length of the shape in the model indices array (internal use)
  25470. */
  25471. _indicesLength: number;
  25472. /**
  25473. * Custom position function (internal use)
  25474. */
  25475. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25476. /**
  25477. * Custom vertex function (internal use)
  25478. */
  25479. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25480. /**
  25481. * 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.
  25482. * SPS internal tool, don't use it manually.
  25483. * @hidden
  25484. */
  25485. 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>);
  25486. }
  25487. /**
  25488. * Represents a Depth Sorted Particle in the solid particle system.
  25489. */
  25490. class DepthSortedParticle {
  25491. /**
  25492. * Index of the particle in the "indices" array
  25493. */
  25494. ind: number;
  25495. /**
  25496. * Length of the particle shape in the "indices" array
  25497. */
  25498. indicesLength: number;
  25499. /**
  25500. * Squared distance from the particle to the camera
  25501. */
  25502. sqDistance: number;
  25503. }
  25504. }
  25505. declare module BABYLON {
  25506. /**
  25507. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25508. *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.
  25509. * The SPS is also a particle system. It provides some methods to manage the particles.
  25510. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25511. *
  25512. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  25513. */
  25514. class SolidParticleSystem implements IDisposable {
  25515. /**
  25516. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25517. * Example : var p = SPS.particles[i];
  25518. */
  25519. particles: SolidParticle[];
  25520. /**
  25521. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25522. */
  25523. nbParticles: number;
  25524. /**
  25525. * If the particles must ever face the camera (default false). Useful for planar particles.
  25526. */
  25527. billboard: boolean;
  25528. /**
  25529. * Recompute normals when adding a shape
  25530. */
  25531. recomputeNormals: boolean;
  25532. /**
  25533. * This a counter ofr your own usage. It's not set by any SPS functions.
  25534. */
  25535. counter: number;
  25536. /**
  25537. * The SPS name. This name is also given to the underlying mesh.
  25538. */
  25539. name: string;
  25540. /**
  25541. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25542. */
  25543. mesh: Mesh;
  25544. /**
  25545. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25546. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  25547. */
  25548. vars: any;
  25549. /**
  25550. * This array is populated when the SPS is set as 'pickable'.
  25551. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25552. * Each element of this array is an object `{idx: int, faceId: int}`.
  25553. * `idx` is the picked particle index in the `SPS.particles` array
  25554. * `faceId` is the picked face index counted within this particle.
  25555. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  25556. */
  25557. pickedParticles: {
  25558. idx: number;
  25559. faceId: number;
  25560. }[];
  25561. /**
  25562. * This array is populated when `enableDepthSort` is set to true.
  25563. * Each element of this array is an instance of the class DepthSortedParticle.
  25564. */
  25565. depthSortedParticles: DepthSortedParticle[];
  25566. /**
  25567. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25568. */
  25569. _bSphereOnly: boolean;
  25570. /**
  25571. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25572. */
  25573. _bSphereRadiusFactor: number;
  25574. private _scene;
  25575. private _positions;
  25576. private _indices;
  25577. private _normals;
  25578. private _colors;
  25579. private _uvs;
  25580. private _indices32;
  25581. private _positions32;
  25582. private _normals32;
  25583. private _fixedNormal32;
  25584. private _colors32;
  25585. private _uvs32;
  25586. private _index;
  25587. private _updatable;
  25588. private _pickable;
  25589. private _isVisibilityBoxLocked;
  25590. private _alwaysVisible;
  25591. private _depthSort;
  25592. private _shapeCounter;
  25593. private _copy;
  25594. private _shape;
  25595. private _shapeUV;
  25596. private _color;
  25597. private _computeParticleColor;
  25598. private _computeParticleTexture;
  25599. private _computeParticleRotation;
  25600. private _computeParticleVertex;
  25601. private _computeBoundingBox;
  25602. private _depthSortParticles;
  25603. private _cam_axisZ;
  25604. private _cam_axisY;
  25605. private _cam_axisX;
  25606. private _axisZ;
  25607. private _camera;
  25608. private _particle;
  25609. private _camDir;
  25610. private _camInvertedPosition;
  25611. private _rotMatrix;
  25612. private _invertMatrix;
  25613. private _rotated;
  25614. private _quaternion;
  25615. private _vertex;
  25616. private _normal;
  25617. private _yaw;
  25618. private _pitch;
  25619. private _roll;
  25620. private _halfroll;
  25621. private _halfpitch;
  25622. private _halfyaw;
  25623. private _sinRoll;
  25624. private _cosRoll;
  25625. private _sinPitch;
  25626. private _cosPitch;
  25627. private _sinYaw;
  25628. private _cosYaw;
  25629. private _mustUnrotateFixedNormals;
  25630. private _minimum;
  25631. private _maximum;
  25632. private _minBbox;
  25633. private _maxBbox;
  25634. private _particlesIntersect;
  25635. private _depthSortFunction;
  25636. private _needs32Bits;
  25637. private _pivotBackTranslation;
  25638. private _scaledPivot;
  25639. private _particleHasParent;
  25640. private _parent;
  25641. /**
  25642. * Creates a SPS (Solid Particle System) object.
  25643. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25644. * @param scene (Scene) is the scene in which the SPS is added.
  25645. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25646. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25647. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25648. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25649. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25650. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25651. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25652. */
  25653. constructor(name: string, scene: Scene, options?: {
  25654. updatable?: boolean;
  25655. isPickable?: boolean;
  25656. enableDepthSort?: boolean;
  25657. particleIntersection?: boolean;
  25658. boundingSphereOnly?: boolean;
  25659. bSphereRadiusFactor?: number;
  25660. });
  25661. /**
  25662. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25663. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25664. * @returns the created mesh
  25665. */
  25666. buildMesh(): Mesh;
  25667. /**
  25668. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25669. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25670. * Thus the particles generated from `digest()` have their property `position` set yet.
  25671. * @param mesh ( Mesh ) is the mesh to be digested
  25672. * @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
  25673. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25674. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25675. * @returns the current SPS
  25676. */
  25677. digest(mesh: Mesh, options?: {
  25678. facetNb?: number;
  25679. number?: number;
  25680. delta?: number;
  25681. }): SolidParticleSystem;
  25682. private _unrotateFixedNormals();
  25683. private _resetCopy();
  25684. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  25685. private _posToShape(positions);
  25686. private _uvsToShapeUV(uvs);
  25687. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  25688. /**
  25689. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25690. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  25691. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25692. * @param nb (positive integer) the number of particles to be created from this model
  25693. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25694. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25695. * @returns the number of shapes in the system
  25696. */
  25697. addShape(mesh: Mesh, nb: number, options?: {
  25698. positionFunction?: any;
  25699. vertexFunction?: any;
  25700. }): number;
  25701. private _rebuildParticle(particle);
  25702. /**
  25703. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25704. * @returns the SPS.
  25705. */
  25706. rebuildMesh(): SolidParticleSystem;
  25707. /**
  25708. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25709. * This method calls `updateParticle()` for each particle of the SPS.
  25710. * For an animated SPS, it is usually called within the render loop.
  25711. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25712. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25713. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25714. * @returns the SPS.
  25715. */
  25716. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25717. private _quaternionRotationYPR();
  25718. private _quaternionToRotationMatrix();
  25719. /**
  25720. * Disposes the SPS.
  25721. */
  25722. dispose(): void;
  25723. /**
  25724. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25725. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25726. * @returns the SPS.
  25727. */
  25728. refreshVisibleSize(): SolidParticleSystem;
  25729. /**
  25730. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25731. * @param size the size (float) of the visibility box
  25732. * note : this doesn't lock the SPS mesh bounding box.
  25733. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25734. */
  25735. setVisibilityBox(size: number): void;
  25736. /**
  25737. * Gets whether the SPS as always visible or not
  25738. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25739. */
  25740. /**
  25741. * Sets the SPS as always visible or not
  25742. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25743. */
  25744. isAlwaysVisible: boolean;
  25745. /**
  25746. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25747. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25748. */
  25749. /**
  25750. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25751. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25752. */
  25753. isVisibilityBoxLocked: boolean;
  25754. /**
  25755. * Gets if `setParticles()` computes the particle rotations or not.
  25756. * Default value : true. The SPS is faster when it's set to false.
  25757. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25758. */
  25759. /**
  25760. * Tells to `setParticles()` to compute the particle rotations or not.
  25761. * Default value : true. The SPS is faster when it's set to false.
  25762. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25763. */
  25764. computeParticleRotation: boolean;
  25765. /**
  25766. * Gets if `setParticles()` computes the particle colors or not.
  25767. * Default value : true. The SPS is faster when it's set to false.
  25768. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25769. */
  25770. /**
  25771. * Tells to `setParticles()` to compute the particle colors or not.
  25772. * Default value : true. The SPS is faster when it's set to false.
  25773. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25774. */
  25775. computeParticleColor: boolean;
  25776. /**
  25777. * Gets if `setParticles()` computes the particle textures or not.
  25778. * Default value : true. The SPS is faster when it's set to false.
  25779. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25780. */
  25781. computeParticleTexture: boolean;
  25782. /**
  25783. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25784. * Default value : false. The SPS is faster when it's set to false.
  25785. * Note : the particle custom vertex positions aren't stored values.
  25786. */
  25787. /**
  25788. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25789. * Default value : false. The SPS is faster when it's set to false.
  25790. * Note : the particle custom vertex positions aren't stored values.
  25791. */
  25792. computeParticleVertex: boolean;
  25793. /**
  25794. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25795. */
  25796. /**
  25797. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25798. */
  25799. computeBoundingBox: boolean;
  25800. /**
  25801. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25802. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25803. * Default : `true`
  25804. */
  25805. /**
  25806. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25807. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25808. * Default : `true`
  25809. */
  25810. depthSortParticles: boolean;
  25811. /**
  25812. * This function does nothing. It may be overwritten to set all the particle first values.
  25813. * The SPS doesn't call this function, you may have to call it by your own.
  25814. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25815. */
  25816. initParticles(): void;
  25817. /**
  25818. * This function does nothing. It may be overwritten to recycle a particle.
  25819. * The SPS doesn't call this function, you may have to call it by your own.
  25820. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25821. * @param particle The particle to recycle
  25822. * @returns the recycled particle
  25823. */
  25824. recycleParticle(particle: SolidParticle): SolidParticle;
  25825. /**
  25826. * Updates a particle : this function should be overwritten by the user.
  25827. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25828. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25829. * @example : just set a particle position or velocity and recycle conditions
  25830. * @param particle The particle to update
  25831. * @returns the updated particle
  25832. */
  25833. updateParticle(particle: SolidParticle): SolidParticle;
  25834. /**
  25835. * Updates a vertex of a particle : it can be overwritten by the user.
  25836. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25837. * @param particle the current particle
  25838. * @param vertex the current index of the current particle
  25839. * @param pt the index of the current vertex in the particle shape
  25840. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  25841. * @example : just set a vertex particle position
  25842. * @returns the updated vertex
  25843. */
  25844. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25845. /**
  25846. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25847. * This does nothing and may be overwritten by the user.
  25848. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25849. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25850. * @param update the boolean update value actually passed to setParticles()
  25851. */
  25852. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25853. /**
  25854. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25855. * This will be passed three parameters.
  25856. * This does nothing and may be overwritten by the user.
  25857. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25858. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25859. * @param update the boolean update value actually passed to setParticles()
  25860. */
  25861. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25862. }
  25863. }
  25864. declare module BABYLON {
  25865. interface PhysicsImpostorJoint {
  25866. mainImpostor: PhysicsImpostor;
  25867. connectedImpostor: PhysicsImpostor;
  25868. joint: PhysicsJoint;
  25869. }
  25870. class PhysicsEngine {
  25871. private _physicsPlugin;
  25872. gravity: Vector3;
  25873. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  25874. setGravity(gravity: Vector3): void;
  25875. /**
  25876. * Set the time step of the physics engine.
  25877. * default is 1/60.
  25878. * To slow it down, enter 1/600 for example.
  25879. * To speed it up, 1/30
  25880. * @param {number} newTimeStep the new timestep to apply to this world.
  25881. */
  25882. setTimeStep(newTimeStep?: number): void;
  25883. /**
  25884. * Get the time step of the physics engine.
  25885. */
  25886. getTimeStep(): number;
  25887. dispose(): void;
  25888. getPhysicsPluginName(): string;
  25889. static Epsilon: number;
  25890. private _impostors;
  25891. private _joints;
  25892. /**
  25893. * Adding a new impostor for the impostor tracking.
  25894. * This will be done by the impostor itself.
  25895. * @param {PhysicsImpostor} impostor the impostor to add
  25896. */
  25897. addImpostor(impostor: PhysicsImpostor): void;
  25898. /**
  25899. * Remove an impostor from the engine.
  25900. * This impostor and its mesh will not longer be updated by the physics engine.
  25901. * @param {PhysicsImpostor} impostor the impostor to remove
  25902. */
  25903. removeImpostor(impostor: PhysicsImpostor): void;
  25904. /**
  25905. * Add a joint to the physics engine
  25906. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  25907. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  25908. * @param {PhysicsJoint} the joint that will connect both impostors.
  25909. */
  25910. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  25911. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  25912. /**
  25913. * Called by the scene. no need to call it.
  25914. */
  25915. _step(delta: number): void;
  25916. getPhysicsPlugin(): IPhysicsEnginePlugin;
  25917. getImpostors(): Array<PhysicsImpostor>;
  25918. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25919. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  25920. }
  25921. interface IPhysicsEnginePlugin {
  25922. world: any;
  25923. name: string;
  25924. setGravity(gravity: Vector3): void;
  25925. setTimeStep(timeStep: number): void;
  25926. getTimeStep(): number;
  25927. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  25928. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  25929. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  25930. generatePhysicsBody(impostor: PhysicsImpostor): void;
  25931. removePhysicsBody(impostor: PhysicsImpostor): void;
  25932. generateJoint(joint: PhysicsImpostorJoint): void;
  25933. removeJoint(joint: PhysicsImpostorJoint): void;
  25934. isSupported(): boolean;
  25935. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  25936. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  25937. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  25938. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  25939. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  25940. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  25941. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  25942. getBodyMass(impostor: PhysicsImpostor): number;
  25943. getBodyFriction(impostor: PhysicsImpostor): number;
  25944. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  25945. getBodyRestitution(impostor: PhysicsImpostor): number;
  25946. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  25947. sleepBody(impostor: PhysicsImpostor): void;
  25948. wakeUpBody(impostor: PhysicsImpostor): void;
  25949. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  25950. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  25951. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25952. getRadius(impostor: PhysicsImpostor): number;
  25953. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  25954. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  25955. dispose(): void;
  25956. }
  25957. }
  25958. declare module BABYLON {
  25959. class PhysicsHelper {
  25960. private _scene;
  25961. private _physicsEngine;
  25962. constructor(scene: Scene);
  25963. /**
  25964. * @param {Vector3} origin the origin of the explosion
  25965. * @param {number} radius the explosion radius
  25966. * @param {number} strength the explosion strength
  25967. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25968. */
  25969. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  25970. /**
  25971. * @param {Vector3} origin the origin of the explosion
  25972. * @param {number} radius the explosion radius
  25973. * @param {number} strength the explosion strength
  25974. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25975. */
  25976. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  25977. /**
  25978. * @param {Vector3} origin the origin of the explosion
  25979. * @param {number} radius the explosion radius
  25980. * @param {number} strength the explosion strength
  25981. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25982. */
  25983. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  25984. /**
  25985. * @param {Vector3} origin the origin of the updraft
  25986. * @param {number} radius the radius of the updraft
  25987. * @param {number} strength the strength of the updraft
  25988. * @param {number} height the height of the updraft
  25989. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  25990. */
  25991. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  25992. /**
  25993. * @param {Vector3} origin the of the vortex
  25994. * @param {number} radius the radius of the vortex
  25995. * @param {number} strength the strength of the vortex
  25996. * @param {number} height the height of the vortex
  25997. */
  25998. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  25999. }
  26000. /***** Radial explosion *****/
  26001. class PhysicsRadialExplosionEvent {
  26002. private _scene;
  26003. private _sphere;
  26004. private _sphereOptions;
  26005. private _rays;
  26006. private _dataFetched;
  26007. constructor(scene: Scene);
  26008. /**
  26009. * Returns the data related to the radial explosion event (sphere & rays).
  26010. * @returns {PhysicsRadialExplosionEventData}
  26011. */
  26012. getData(): PhysicsRadialExplosionEventData;
  26013. /**
  26014. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  26015. * @param impostor
  26016. * @param {Vector3} origin the origin of the explosion
  26017. * @param {number} radius the explosion radius
  26018. * @param {number} strength the explosion strength
  26019. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  26020. * @returns {Nullable<PhysicsForceAndContactPoint>}
  26021. */
  26022. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  26023. /**
  26024. * Disposes the sphere.
  26025. * @param {bolean} force
  26026. */
  26027. dispose(force?: boolean): void;
  26028. /*** Helpers ***/
  26029. private _prepareSphere();
  26030. private _intersectsWithSphere(impostor, origin, radius);
  26031. }
  26032. /***** Gravitational Field *****/
  26033. class PhysicsGravitationalFieldEvent {
  26034. private _physicsHelper;
  26035. private _scene;
  26036. private _origin;
  26037. private _radius;
  26038. private _strength;
  26039. private _falloff;
  26040. private _tickCallback;
  26041. private _sphere;
  26042. private _dataFetched;
  26043. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  26044. /**
  26045. * Returns the data related to the gravitational field event (sphere).
  26046. * @returns {PhysicsGravitationalFieldEventData}
  26047. */
  26048. getData(): PhysicsGravitationalFieldEventData;
  26049. /**
  26050. * Enables the gravitational field.
  26051. */
  26052. enable(): void;
  26053. /**
  26054. * Disables the gravitational field.
  26055. */
  26056. disable(): void;
  26057. /**
  26058. * Disposes the sphere.
  26059. * @param {bolean} force
  26060. */
  26061. dispose(force?: boolean): void;
  26062. private _tick();
  26063. }
  26064. /***** Updraft *****/
  26065. class PhysicsUpdraftEvent {
  26066. private _scene;
  26067. private _origin;
  26068. private _radius;
  26069. private _strength;
  26070. private _height;
  26071. private _updraftMode;
  26072. private _physicsEngine;
  26073. private _originTop;
  26074. private _originDirection;
  26075. private _tickCallback;
  26076. private _cylinder;
  26077. private _cylinderPosition;
  26078. private _dataFetched;
  26079. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  26080. /**
  26081. * Returns the data related to the updraft event (cylinder).
  26082. * @returns {PhysicsUpdraftEventData}
  26083. */
  26084. getData(): PhysicsUpdraftEventData;
  26085. /**
  26086. * Enables the updraft.
  26087. */
  26088. enable(): void;
  26089. /**
  26090. * Disables the cortex.
  26091. */
  26092. disable(): void;
  26093. /**
  26094. * Disposes the sphere.
  26095. * @param {bolean} force
  26096. */
  26097. dispose(force?: boolean): void;
  26098. private getImpostorForceAndContactPoint(impostor);
  26099. private _tick();
  26100. /*** Helpers ***/
  26101. private _prepareCylinder();
  26102. private _intersectsWithCylinder(impostor);
  26103. }
  26104. /***** Vortex *****/
  26105. class PhysicsVortexEvent {
  26106. private _scene;
  26107. private _origin;
  26108. private _radius;
  26109. private _strength;
  26110. private _height;
  26111. private _physicsEngine;
  26112. private _originTop;
  26113. private _centripetalForceThreshold;
  26114. private _updraftMultiplier;
  26115. private _tickCallback;
  26116. private _cylinder;
  26117. private _cylinderPosition;
  26118. private _dataFetched;
  26119. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  26120. /**
  26121. * Returns the data related to the vortex event (cylinder).
  26122. * @returns {PhysicsVortexEventData}
  26123. */
  26124. getData(): PhysicsVortexEventData;
  26125. /**
  26126. * Enables the vortex.
  26127. */
  26128. enable(): void;
  26129. /**
  26130. * Disables the cortex.
  26131. */
  26132. disable(): void;
  26133. /**
  26134. * Disposes the sphere.
  26135. * @param {bolean} force
  26136. */
  26137. dispose(force?: boolean): void;
  26138. private getImpostorForceAndContactPoint(impostor);
  26139. private _tick();
  26140. /*** Helpers ***/
  26141. private _prepareCylinder();
  26142. private _intersectsWithCylinder(impostor);
  26143. }
  26144. /***** Enums *****/
  26145. /**
  26146. * The strenght of the force in correspondence to the distance of the affected object
  26147. */
  26148. enum PhysicsRadialImpulseFalloff {
  26149. /** Defines that impulse is constant in strength across it's whole radius */
  26150. Constant = 0,
  26151. /** DEfines that impulse gets weaker if it's further from the origin */
  26152. Linear = 1,
  26153. }
  26154. /**
  26155. * The strenght of the force in correspondence to the distance of the affected object
  26156. */
  26157. enum PhysicsUpdraftMode {
  26158. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  26159. Center = 0,
  26160. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  26161. Perpendicular = 1,
  26162. }
  26163. /***** Data interfaces *****/
  26164. interface PhysicsForceAndContactPoint {
  26165. force: Vector3;
  26166. contactPoint: Vector3;
  26167. }
  26168. interface PhysicsRadialExplosionEventData {
  26169. sphere: Mesh;
  26170. rays: Array<Ray>;
  26171. }
  26172. interface PhysicsGravitationalFieldEventData {
  26173. sphere: Mesh;
  26174. }
  26175. interface PhysicsUpdraftEventData {
  26176. cylinder: Mesh;
  26177. }
  26178. interface PhysicsVortexEventData {
  26179. cylinder: Mesh;
  26180. }
  26181. }
  26182. declare module BABYLON {
  26183. interface PhysicsImpostorParameters {
  26184. mass: number;
  26185. friction?: number;
  26186. restitution?: number;
  26187. nativeOptions?: any;
  26188. ignoreParent?: boolean;
  26189. disableBidirectionalTransformation?: boolean;
  26190. }
  26191. interface IPhysicsEnabledObject {
  26192. position: Vector3;
  26193. rotationQuaternion: Nullable<Quaternion>;
  26194. scaling: Vector3;
  26195. rotation?: Vector3;
  26196. parent?: any;
  26197. getBoundingInfo(): BoundingInfo;
  26198. computeWorldMatrix(force: boolean): Matrix;
  26199. getWorldMatrix?(): Matrix;
  26200. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26201. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26202. getIndices?(): Nullable<IndicesArray>;
  26203. getScene?(): Scene;
  26204. getAbsolutePosition(): Vector3;
  26205. getAbsolutePivotPoint(): Vector3;
  26206. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26207. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26208. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26209. getClassName(): string;
  26210. }
  26211. class PhysicsImpostor {
  26212. object: IPhysicsEnabledObject;
  26213. type: number;
  26214. private _options;
  26215. private _scene;
  26216. static DEFAULT_OBJECT_SIZE: Vector3;
  26217. static IDENTITY_QUATERNION: Quaternion;
  26218. private _physicsEngine;
  26219. private _physicsBody;
  26220. private _bodyUpdateRequired;
  26221. private _onBeforePhysicsStepCallbacks;
  26222. private _onAfterPhysicsStepCallbacks;
  26223. private _onPhysicsCollideCallbacks;
  26224. private _deltaPosition;
  26225. private _deltaRotation;
  26226. private _deltaRotationConjugated;
  26227. private _parent;
  26228. private _isDisposed;
  26229. private static _tmpVecs;
  26230. private static _tmpQuat;
  26231. readonly isDisposed: boolean;
  26232. mass: number;
  26233. friction: number;
  26234. restitution: number;
  26235. uniqueId: number;
  26236. private _joints;
  26237. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26238. /**
  26239. * This function will completly initialize this impostor.
  26240. * It will create a new body - but only if this mesh has no parent.
  26241. * If it has, this impostor will not be used other than to define the impostor
  26242. * of the child mesh.
  26243. */
  26244. _init(): void;
  26245. private _getPhysicsParent();
  26246. /**
  26247. * Should a new body be generated.
  26248. */
  26249. isBodyInitRequired(): boolean;
  26250. setScalingUpdated(updated: boolean): void;
  26251. /**
  26252. * Force a regeneration of this or the parent's impostor's body.
  26253. * Use under cautious - This will remove all joints already implemented.
  26254. */
  26255. forceUpdate(): void;
  26256. /**
  26257. * Gets the body that holds this impostor. Either its own, or its parent.
  26258. */
  26259. /**
  26260. * Set the physics body. Used mainly by the physics engine/plugin
  26261. */
  26262. physicsBody: any;
  26263. parent: Nullable<PhysicsImpostor>;
  26264. resetUpdateFlags(): void;
  26265. getObjectExtendSize(): Vector3;
  26266. getObjectCenter(): Vector3;
  26267. /**
  26268. * Get a specific parametes from the options parameter.
  26269. */
  26270. getParam(paramName: string): any;
  26271. /**
  26272. * Sets a specific parameter in the options given to the physics plugin
  26273. */
  26274. setParam(paramName: string, value: number): void;
  26275. /**
  26276. * Specifically change the body's mass option. Won't recreate the physics body object
  26277. */
  26278. setMass(mass: number): void;
  26279. getLinearVelocity(): Nullable<Vector3>;
  26280. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26281. getAngularVelocity(): Nullable<Vector3>;
  26282. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26283. /**
  26284. * Execute a function with the physics plugin native code.
  26285. * Provide a function the will have two variables - the world object and the physics body object.
  26286. */
  26287. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26288. /**
  26289. * Register a function that will be executed before the physics world is stepping forward.
  26290. */
  26291. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26292. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26293. /**
  26294. * Register a function that will be executed after the physics step
  26295. */
  26296. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26297. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26298. /**
  26299. * register a function that will be executed when this impostor collides against a different body.
  26300. */
  26301. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26302. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26303. private _tmpQuat;
  26304. private _tmpQuat2;
  26305. getParentsRotation(): Quaternion;
  26306. /**
  26307. * this function is executed by the physics engine.
  26308. */
  26309. beforeStep: () => void;
  26310. /**
  26311. * this function is executed by the physics engine.
  26312. */
  26313. afterStep: () => void;
  26314. /**
  26315. * Legacy collision detection event support
  26316. */
  26317. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26318. onCollide: (e: {
  26319. body: any;
  26320. }) => void;
  26321. /**
  26322. * Apply a force
  26323. */
  26324. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26325. /**
  26326. * Apply an impulse
  26327. */
  26328. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26329. /**
  26330. * A help function to create a joint.
  26331. */
  26332. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26333. /**
  26334. * Add a joint to this impostor with a different impostor.
  26335. */
  26336. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26337. /**
  26338. * Will keep this body still, in a sleep mode.
  26339. */
  26340. sleep(): PhysicsImpostor;
  26341. /**
  26342. * Wake the body up.
  26343. */
  26344. wakeUp(): PhysicsImpostor;
  26345. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26346. dispose(): void;
  26347. setDeltaPosition(position: Vector3): void;
  26348. setDeltaRotation(rotation: Quaternion): void;
  26349. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  26350. getRadius(): number;
  26351. /**
  26352. * Sync a bone with this impostor
  26353. * @param bone The bone to sync to the impostor.
  26354. * @param boneMesh The mesh that the bone is influencing.
  26355. * @param jointPivot The pivot of the joint / bone in local space.
  26356. * @param distToJoint Optional distance from the impostor to the joint.
  26357. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26358. */
  26359. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  26360. /**
  26361. * Sync impostor to a bone
  26362. * @param bone The bone that the impostor will be synced to.
  26363. * @param boneMesh The mesh that the bone is influencing.
  26364. * @param jointPivot The pivot of the joint / bone in local space.
  26365. * @param distToJoint Optional distance from the impostor to the joint.
  26366. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26367. * @param boneAxis Optional vector3 axis the bone is aligned with
  26368. */
  26369. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  26370. static NoImpostor: number;
  26371. static SphereImpostor: number;
  26372. static BoxImpostor: number;
  26373. static PlaneImpostor: number;
  26374. static MeshImpostor: number;
  26375. static CylinderImpostor: number;
  26376. static ParticleImpostor: number;
  26377. static HeightmapImpostor: number;
  26378. }
  26379. }
  26380. declare module BABYLON {
  26381. interface PhysicsJointData {
  26382. mainPivot?: Vector3;
  26383. connectedPivot?: Vector3;
  26384. mainAxis?: Vector3;
  26385. connectedAxis?: Vector3;
  26386. collision?: boolean;
  26387. nativeParams?: any;
  26388. }
  26389. /**
  26390. * This is a holder class for the physics joint created by the physics plugin.
  26391. * It holds a set of functions to control the underlying joint.
  26392. */
  26393. class PhysicsJoint {
  26394. type: number;
  26395. jointData: PhysicsJointData;
  26396. private _physicsJoint;
  26397. protected _physicsPlugin: IPhysicsEnginePlugin;
  26398. constructor(type: number, jointData: PhysicsJointData);
  26399. physicsJoint: any;
  26400. physicsPlugin: IPhysicsEnginePlugin;
  26401. /**
  26402. * Execute a function that is physics-plugin specific.
  26403. * @param {Function} func the function that will be executed.
  26404. * It accepts two parameters: the physics world and the physics joint.
  26405. */
  26406. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26407. static DistanceJoint: number;
  26408. static HingeJoint: number;
  26409. static BallAndSocketJoint: number;
  26410. static WheelJoint: number;
  26411. static SliderJoint: number;
  26412. static PrismaticJoint: number;
  26413. static UniversalJoint: number;
  26414. static Hinge2Joint: number;
  26415. static PointToPointJoint: number;
  26416. static SpringJoint: number;
  26417. static LockJoint: number;
  26418. }
  26419. /**
  26420. * A class representing a physics distance joint.
  26421. */
  26422. class DistanceJoint extends PhysicsJoint {
  26423. constructor(jointData: DistanceJointData);
  26424. /**
  26425. * Update the predefined distance.
  26426. */
  26427. updateDistance(maxDistance: number, minDistance?: number): void;
  26428. }
  26429. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26430. constructor(type: number, jointData: PhysicsJointData);
  26431. /**
  26432. * Set the motor values.
  26433. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26434. * @param {number} force the force to apply
  26435. * @param {number} maxForce max force for this motor.
  26436. */
  26437. setMotor(force?: number, maxForce?: number): void;
  26438. /**
  26439. * Set the motor's limits.
  26440. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26441. */
  26442. setLimit(upperLimit: number, lowerLimit?: number): void;
  26443. }
  26444. /**
  26445. * This class represents a single hinge physics joint
  26446. */
  26447. class HingeJoint extends MotorEnabledJoint {
  26448. constructor(jointData: PhysicsJointData);
  26449. /**
  26450. * Set the motor values.
  26451. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26452. * @param {number} force the force to apply
  26453. * @param {number} maxForce max force for this motor.
  26454. */
  26455. setMotor(force?: number, maxForce?: number): void;
  26456. /**
  26457. * Set the motor's limits.
  26458. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26459. */
  26460. setLimit(upperLimit: number, lowerLimit?: number): void;
  26461. }
  26462. /**
  26463. * This class represents a dual hinge physics joint (same as wheel joint)
  26464. */
  26465. class Hinge2Joint extends MotorEnabledJoint {
  26466. constructor(jointData: PhysicsJointData);
  26467. /**
  26468. * Set the motor values.
  26469. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26470. * @param {number} force the force to apply
  26471. * @param {number} maxForce max force for this motor.
  26472. * @param {motorIndex} the motor's index, 0 or 1.
  26473. */
  26474. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26475. /**
  26476. * Set the motor limits.
  26477. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26478. * @param {number} upperLimit the upper limit
  26479. * @param {number} lowerLimit lower limit
  26480. * @param {motorIndex} the motor's index, 0 or 1.
  26481. */
  26482. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26483. }
  26484. interface IMotorEnabledJoint {
  26485. physicsJoint: any;
  26486. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26487. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26488. }
  26489. interface DistanceJointData extends PhysicsJointData {
  26490. maxDistance: number;
  26491. }
  26492. interface SpringJointData extends PhysicsJointData {
  26493. length: number;
  26494. stiffness: number;
  26495. damping: number;
  26496. }
  26497. }
  26498. declare module BABYLON {
  26499. class ReflectionProbe {
  26500. name: string;
  26501. private _scene;
  26502. private _renderTargetTexture;
  26503. private _projectionMatrix;
  26504. private _viewMatrix;
  26505. private _target;
  26506. private _add;
  26507. private _attachedMesh;
  26508. private _invertYAxis;
  26509. position: Vector3;
  26510. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  26511. samples: number;
  26512. refreshRate: number;
  26513. getScene(): Scene;
  26514. readonly cubeTexture: RenderTargetTexture;
  26515. readonly renderList: Nullable<AbstractMesh[]>;
  26516. attachToMesh(mesh: AbstractMesh): void;
  26517. /**
  26518. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26519. *
  26520. * @param renderingGroupId The rendering group id corresponding to its index
  26521. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26522. */
  26523. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  26524. dispose(): void;
  26525. }
  26526. }
  26527. declare module BABYLON {
  26528. interface Scene {
  26529. /** @hidden (Backing field) */
  26530. _boundingBoxRenderer: BoundingBoxRenderer;
  26531. /** @hidden (Backing field) */
  26532. _forceShowBoundingBoxes: boolean;
  26533. /**
  26534. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  26535. */
  26536. forceShowBoundingBoxes: boolean;
  26537. /**
  26538. * Gets the bounding box renderer associated with the scene
  26539. * @returns a BoundingBoxRenderer
  26540. */
  26541. getBoundingBoxRenderer(): BoundingBoxRenderer;
  26542. }
  26543. interface AbstractMesh {
  26544. /** @hidden (Backing field) */
  26545. _showBoundingBox: boolean;
  26546. /**
  26547. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  26548. */
  26549. showBoundingBox: boolean;
  26550. }
  26551. class BoundingBoxRenderer implements ISceneComponent {
  26552. /**
  26553. * The component name helpfull to identify the component in the list of scene components.
  26554. */
  26555. readonly name: string;
  26556. /**
  26557. * The scene the component belongs to.
  26558. */
  26559. scene: Scene;
  26560. frontColor: Color3;
  26561. backColor: Color3;
  26562. showBackLines: boolean;
  26563. renderList: SmartArray<BoundingBox>;
  26564. private _colorShader;
  26565. private _vertexBuffers;
  26566. private _indexBuffer;
  26567. constructor(scene: Scene);
  26568. /**
  26569. * Registers the component in a given scene
  26570. */
  26571. register(): void;
  26572. private _evaluateSubMesh(mesh, subMesh);
  26573. private _activeMesh(sourceMesh, mesh);
  26574. private _prepareRessources();
  26575. private _createIndexBuffer();
  26576. /**
  26577. * Rebuilds the elements related to this component in case of
  26578. * context lost for instance.
  26579. */
  26580. rebuild(): void;
  26581. reset(): void;
  26582. render(): void;
  26583. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  26584. dispose(): void;
  26585. }
  26586. }
  26587. declare module BABYLON {
  26588. /**
  26589. * This represents a depth renderer in Babylon.
  26590. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  26591. */
  26592. class DepthRenderer {
  26593. private _scene;
  26594. private _depthMap;
  26595. private _effect;
  26596. private _cachedDefines;
  26597. private _camera;
  26598. /**
  26599. * Instantiates a depth renderer
  26600. * @param scene The scene the renderer belongs to
  26601. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  26602. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  26603. */
  26604. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  26605. /**
  26606. * Creates the depth rendering effect and checks if the effect is ready.
  26607. * @param subMesh The submesh to be used to render the depth map of
  26608. * @param useInstances If multiple world instances should be used
  26609. * @returns if the depth renderer is ready to render the depth map
  26610. */
  26611. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26612. /**
  26613. * Gets the texture which the depth map will be written to.
  26614. * @returns The depth map texture
  26615. */
  26616. getDepthMap(): RenderTargetTexture;
  26617. /**
  26618. * Disposes of the depth renderer.
  26619. */
  26620. dispose(): void;
  26621. }
  26622. }
  26623. declare module BABYLON {
  26624. class EdgesRenderer {
  26625. edgesWidthScalerForOrthographic: number;
  26626. edgesWidthScalerForPerspective: number;
  26627. private _source;
  26628. private _linesPositions;
  26629. private _linesNormals;
  26630. private _linesIndices;
  26631. private _epsilon;
  26632. private _indicesCount;
  26633. private _lineShader;
  26634. private _ib;
  26635. private _buffers;
  26636. private _checkVerticesInsteadOfIndices;
  26637. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  26638. isEnabled: boolean;
  26639. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  26640. private _prepareRessources();
  26641. _rebuild(): void;
  26642. dispose(): void;
  26643. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  26644. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  26645. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  26646. _generateEdgesLines(): void;
  26647. render(): void;
  26648. }
  26649. }
  26650. declare module BABYLON {
  26651. /**
  26652. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  26653. */
  26654. class GeometryBufferRenderer {
  26655. private _scene;
  26656. private _multiRenderTarget;
  26657. private _ratio;
  26658. private _enablePosition;
  26659. protected _effect: Effect;
  26660. protected _cachedDefines: string;
  26661. /**
  26662. * Set the render list (meshes to be rendered) used in the G buffer.
  26663. */
  26664. renderList: Mesh[];
  26665. /**
  26666. * Gets wether or not G buffer are supported by the running hardware.
  26667. * This requires draw buffer supports
  26668. */
  26669. readonly isSupported: boolean;
  26670. /**
  26671. * Gets wether or not position are enabled for the G buffer.
  26672. */
  26673. /**
  26674. * Sets wether or not position are enabled for the G buffer.
  26675. */
  26676. enablePosition: boolean;
  26677. /**
  26678. * Gets the scene associated with the buffer.
  26679. */
  26680. readonly scene: Scene;
  26681. /**
  26682. * Gets the ratio used by the buffer during its creation.
  26683. * How big is the buffer related to the main canvas.
  26684. */
  26685. readonly ratio: number;
  26686. /**
  26687. * Creates a new G Buffer for the scene
  26688. * @param scene The scene the buffer belongs to
  26689. * @param ratio How big is the buffer related to the main canvas.
  26690. */
  26691. constructor(scene: Scene, ratio?: number);
  26692. /**
  26693. * Checks wether everything is ready to render a submesh to the G buffer.
  26694. * @param subMesh the submesh to check readiness for
  26695. * @param useInstances is the mesh drawn using instance or not
  26696. * @returns true if ready otherwise false
  26697. */
  26698. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26699. /**
  26700. * Gets the current underlying G Buffer.
  26701. * @returns the buffer
  26702. */
  26703. getGBuffer(): MultiRenderTarget;
  26704. /**
  26705. * Gets the number of samples used to render the buffer (anti aliasing).
  26706. */
  26707. /**
  26708. * Sets the number of samples used to render the buffer (anti aliasing).
  26709. */
  26710. samples: number;
  26711. /**
  26712. * Disposes the renderer and frees up associated resources.
  26713. */
  26714. dispose(): void;
  26715. protected _createRenderTargets(): void;
  26716. }
  26717. }
  26718. declare module BABYLON {
  26719. class OutlineRenderer {
  26720. private _scene;
  26721. private _effect;
  26722. private _cachedDefines;
  26723. zOffset: number;
  26724. constructor(scene: Scene);
  26725. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  26726. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26727. }
  26728. }
  26729. declare module BABYLON {
  26730. class RenderingGroup {
  26731. index: number;
  26732. private _scene;
  26733. private _opaqueSubMeshes;
  26734. private _transparentSubMeshes;
  26735. private _alphaTestSubMeshes;
  26736. private _depthOnlySubMeshes;
  26737. private _particleSystems;
  26738. private _spriteManagers;
  26739. private _opaqueSortCompareFn;
  26740. private _alphaTestSortCompareFn;
  26741. private _transparentSortCompareFn;
  26742. private _renderOpaque;
  26743. private _renderAlphaTest;
  26744. private _renderTransparent;
  26745. private _edgesRenderers;
  26746. onBeforeTransparentRendering: () => void;
  26747. /**
  26748. * Set the opaque sort comparison function.
  26749. * If null the sub meshes will be render in the order they were created
  26750. */
  26751. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26752. /**
  26753. * Set the alpha test sort comparison function.
  26754. * If null the sub meshes will be render in the order they were created
  26755. */
  26756. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26757. /**
  26758. * Set the transparent sort comparison function.
  26759. * If null the sub meshes will be render in the order they were created
  26760. */
  26761. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26762. /**
  26763. * Creates a new rendering group.
  26764. * @param index The rendering group index
  26765. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  26766. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  26767. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  26768. */
  26769. 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>);
  26770. /**
  26771. * Render all the sub meshes contained in the group.
  26772. * @param customRenderFunction Used to override the default render behaviour of the group.
  26773. * @returns true if rendered some submeshes.
  26774. */
  26775. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  26776. /**
  26777. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  26778. * @param subMeshes The submeshes to render
  26779. */
  26780. private renderOpaqueSorted(subMeshes);
  26781. /**
  26782. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  26783. * @param subMeshes The submeshes to render
  26784. */
  26785. private renderAlphaTestSorted(subMeshes);
  26786. /**
  26787. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  26788. * @param subMeshes The submeshes to render
  26789. */
  26790. private renderTransparentSorted(subMeshes);
  26791. /**
  26792. * Renders the submeshes in a specified order.
  26793. * @param subMeshes The submeshes to sort before render
  26794. * @param sortCompareFn The comparison function use to sort
  26795. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  26796. * @param transparent Specifies to activate blending if true
  26797. */
  26798. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  26799. /**
  26800. * Renders the submeshes in the order they were dispatched (no sort applied).
  26801. * @param subMeshes The submeshes to render
  26802. */
  26803. private static renderUnsorted(subMeshes);
  26804. /**
  26805. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26806. * are rendered back to front if in the same alpha index.
  26807. *
  26808. * @param a The first submesh
  26809. * @param b The second submesh
  26810. * @returns The result of the comparison
  26811. */
  26812. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  26813. /**
  26814. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26815. * are rendered back to front.
  26816. *
  26817. * @param a The first submesh
  26818. * @param b The second submesh
  26819. * @returns The result of the comparison
  26820. */
  26821. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  26822. /**
  26823. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26824. * are rendered front to back (prevent overdraw).
  26825. *
  26826. * @param a The first submesh
  26827. * @param b The second submesh
  26828. * @returns The result of the comparison
  26829. */
  26830. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  26831. /**
  26832. * Resets the different lists of submeshes to prepare a new frame.
  26833. */
  26834. prepare(): void;
  26835. dispose(): void;
  26836. /**
  26837. * Inserts the submesh in its correct queue depending on its material.
  26838. * @param subMesh The submesh to dispatch
  26839. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26840. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26841. */
  26842. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26843. dispatchSprites(spriteManager: SpriteManager): void;
  26844. dispatchParticles(particleSystem: IParticleSystem): void;
  26845. private _renderParticles(activeMeshes);
  26846. private _renderSprites();
  26847. }
  26848. }
  26849. declare module BABYLON {
  26850. class RenderingManager {
  26851. /**
  26852. * The max id used for rendering groups (not included)
  26853. */
  26854. static MAX_RENDERINGGROUPS: number;
  26855. /**
  26856. * The min id used for rendering groups (included)
  26857. */
  26858. static MIN_RENDERINGGROUPS: number;
  26859. /**
  26860. * Used to globally prevent autoclearing scenes.
  26861. */
  26862. static AUTOCLEAR: boolean;
  26863. private _scene;
  26864. private _renderingGroups;
  26865. private _depthStencilBufferAlreadyCleaned;
  26866. private _autoClearDepthStencil;
  26867. private _customOpaqueSortCompareFn;
  26868. private _customAlphaTestSortCompareFn;
  26869. private _customTransparentSortCompareFn;
  26870. private _renderinGroupInfo;
  26871. constructor(scene: Scene);
  26872. private _clearDepthStencilBuffer(depth?, stencil?);
  26873. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  26874. reset(): void;
  26875. dispose(): void;
  26876. /**
  26877. * Clear the info related to rendering groups preventing retention points during dispose.
  26878. */
  26879. freeRenderingGroups(): void;
  26880. private _prepareRenderingGroup(renderingGroupId);
  26881. dispatchSprites(spriteManager: SpriteManager): void;
  26882. dispatchParticles(particleSystem: IParticleSystem): void;
  26883. /**
  26884. * @param subMesh The submesh to dispatch
  26885. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26886. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26887. */
  26888. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26889. /**
  26890. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  26891. * This allowed control for front to back rendering or reversly depending of the special needs.
  26892. *
  26893. * @param renderingGroupId The rendering group id corresponding to its index
  26894. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  26895. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  26896. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  26897. */
  26898. 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;
  26899. /**
  26900. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26901. *
  26902. * @param renderingGroupId The rendering group id corresponding to its index
  26903. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26904. * @param depth Automatically clears depth between groups if true and autoClear is true.
  26905. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  26906. */
  26907. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  26908. }
  26909. }
  26910. declare module BABYLON {
  26911. /**
  26912. * Renders a layer on top of an existing scene
  26913. */
  26914. class UtilityLayerRenderer implements IDisposable {
  26915. /** the original scene that will be rendered on top of */ originalScene: Scene;
  26916. private _pointerCaptures;
  26917. private _lastPointerEvents;
  26918. private static _DefaultUtilityLayer;
  26919. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  26920. /**
  26921. * The scene that is rendered on top of the original scene
  26922. */
  26923. utilityLayerScene: Scene;
  26924. /**
  26925. * If the utility layer should automatically be rendered on top of existing scene
  26926. */
  26927. shouldRender: boolean;
  26928. /**
  26929. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  26930. */
  26931. onlyCheckPointerDownEvents: boolean;
  26932. /**
  26933. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  26934. */
  26935. processAllEvents: boolean;
  26936. /**
  26937. * Observable raised when the pointer move from the utility layer scene to the main scene
  26938. */
  26939. onPointerOutObservable: Observable<number>;
  26940. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  26941. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  26942. private _afterRenderObserver;
  26943. private _sceneDisposeObserver;
  26944. private _originalPointerObserver;
  26945. /**
  26946. * Instantiates a UtilityLayerRenderer
  26947. * @param originalScene the original scene that will be rendered on top of
  26948. */
  26949. constructor(/** the original scene that will be rendered on top of */ originalScene: Scene);
  26950. private _notifyObservers(prePointerInfo, pickInfo, pointerEvent);
  26951. /**
  26952. * Renders the utility layers scene on top of the original scene
  26953. */
  26954. render(): void;
  26955. /**
  26956. * Disposes of the renderer
  26957. */
  26958. dispose(): void;
  26959. private _updateCamera();
  26960. }
  26961. }
  26962. declare module BABYLON {
  26963. /**
  26964. * Postprocess used to generate anaglyphic rendering
  26965. */
  26966. class AnaglyphPostProcess extends PostProcess {
  26967. private _passedProcess;
  26968. /**
  26969. * Creates a new AnaglyphPostProcess
  26970. * @param name defines postprocess name
  26971. * @param options defines creation options or target ratio scale
  26972. * @param rigCameras defines cameras using this postprocess
  26973. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  26974. * @param engine defines hosting engine
  26975. * @param reusable defines if the postprocess will be reused multiple times per frame
  26976. */
  26977. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  26978. }
  26979. }
  26980. declare module BABYLON {
  26981. class BlackAndWhitePostProcess extends PostProcess {
  26982. degree: number;
  26983. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26984. }
  26985. }
  26986. declare module BABYLON {
  26987. /**
  26988. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  26989. */
  26990. class BloomEffect extends PostProcessRenderEffect {
  26991. private bloomScale;
  26992. /**
  26993. * Internal
  26994. */
  26995. _effects: Array<PostProcess>;
  26996. /**
  26997. * Internal
  26998. */
  26999. _downscale: ExtractHighlightsPostProcess;
  27000. private _blurX;
  27001. private _blurY;
  27002. private _merge;
  27003. /**
  27004. * The luminance threshold to find bright areas of the image to bloom.
  27005. */
  27006. threshold: number;
  27007. /**
  27008. * The strength of the bloom.
  27009. */
  27010. weight: number;
  27011. /**
  27012. * Specifies the size of the bloom blur kernel, relative to the final output size
  27013. */
  27014. kernel: number;
  27015. /**
  27016. * Creates a new instance of @see BloomEffect
  27017. * @param scene The scene the effect belongs to.
  27018. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  27019. * @param bloomKernel The size of the kernel to be used when applying the blur.
  27020. * @param bloomWeight The the strength of bloom.
  27021. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27022. * @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)
  27023. */
  27024. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  27025. /**
  27026. * Disposes each of the internal effects for a given camera.
  27027. * @param camera The camera to dispose the effect on.
  27028. */
  27029. disposeEffects(camera: Camera): void;
  27030. /**
  27031. * Internal
  27032. */
  27033. _updateEffects(): void;
  27034. /**
  27035. * Internal
  27036. * @returns if all the contained post processes are ready.
  27037. */
  27038. _isReady(): boolean;
  27039. }
  27040. }
  27041. declare module BABYLON {
  27042. /**
  27043. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27044. */
  27045. class BloomMergePostProcess extends PostProcess {
  27046. /** Weight of the bloom to be added to the original input. */ weight: number;
  27047. /**
  27048. * Creates a new instance of @see BloomMergePostProcess
  27049. * @param name The name of the effect.
  27050. * @param originalFromInput Post process which's input will be used for the merge.
  27051. * @param blurred Blurred highlights post process which's output will be used.
  27052. * @param weight Weight of the bloom to be added to the original input.
  27053. * @param options The required width/height ratio to downsize to before computing the render pass.
  27054. * @param camera The camera to apply the render pass to.
  27055. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27056. * @param engine The engine which the post process will be applied. (default: current engine)
  27057. * @param reusable If the post process can be reused on the same frame. (default: false)
  27058. * @param textureType Type of textures used when performing the post process. (default: 0)
  27059. * @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)
  27060. */
  27061. 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);
  27062. }
  27063. }
  27064. declare module BABYLON {
  27065. /**
  27066. * The Blur Post Process which blurs an image based on a kernel and direction.
  27067. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27068. */
  27069. class BlurPostProcess extends PostProcess {
  27070. /** The direction in which to blur the image. */ direction: Vector2;
  27071. private blockCompilation;
  27072. protected _kernel: number;
  27073. protected _idealKernel: number;
  27074. protected _packedFloat: boolean;
  27075. private _staticDefines;
  27076. /**
  27077. * Gets the length in pixels of the blur sample region
  27078. */
  27079. /**
  27080. * Sets the length in pixels of the blur sample region
  27081. */
  27082. kernel: number;
  27083. /**
  27084. * Gets wether or not the blur is unpacking/repacking floats
  27085. */
  27086. /**
  27087. * Sets wether or not the blur needs to unpack/repack floats
  27088. */
  27089. packedFloat: boolean;
  27090. /**
  27091. * Creates a new instance BlurPostProcess
  27092. * @param name The name of the effect.
  27093. * @param direction The direction in which to blur the image.
  27094. * @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.
  27095. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27096. * @param camera The camera to apply the render pass to.
  27097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27098. * @param engine The engine which the post process will be applied. (default: current engine)
  27099. * @param reusable If the post process can be reused on the same frame. (default: false)
  27100. * @param textureType Type of textures used when performing the post process. (default: 0)
  27101. * @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)
  27102. */
  27103. 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);
  27104. /**
  27105. * Updates the effect with the current post process compile time values and recompiles the shader.
  27106. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27107. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27108. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27109. * @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
  27110. * @param onCompiled Called when the shader has been compiled.
  27111. * @param onError Called if there is an error when compiling a shader.
  27112. */
  27113. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27114. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27115. /**
  27116. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27117. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27118. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27119. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27120. * The gaps between physical kernels are compensated for in the weighting of the samples
  27121. * @param idealKernel Ideal blur kernel.
  27122. * @return Nearest best kernel.
  27123. */
  27124. protected _nearestBestKernel(idealKernel: number): number;
  27125. /**
  27126. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27127. * @param x The point on the Gaussian distribution to sample.
  27128. * @return the value of the Gaussian function at x.
  27129. */
  27130. protected _gaussianWeight(x: number): number;
  27131. /**
  27132. * Generates a string that can be used as a floating point number in GLSL.
  27133. * @param x Value to print.
  27134. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27135. * @return GLSL float string.
  27136. */
  27137. protected _glslFloat(x: number, decimalFigures?: number): string;
  27138. }
  27139. }
  27140. declare module BABYLON {
  27141. /**
  27142. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  27143. */
  27144. class ChromaticAberrationPostProcess extends PostProcess {
  27145. /**
  27146. * The amount of seperation of rgb channels (default: 30)
  27147. */
  27148. aberrationAmount: number;
  27149. /**
  27150. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  27151. */
  27152. radialIntensity: number;
  27153. /**
  27154. * 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))
  27155. */
  27156. direction: Vector2;
  27157. /**
  27158. * 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))
  27159. */
  27160. centerPosition: Vector2;
  27161. /**
  27162. * Creates a new instance ChromaticAberrationPostProcess
  27163. * @param name The name of the effect.
  27164. * @param screenWidth The width of the screen to apply the effect on.
  27165. * @param screenHeight The height of the screen to apply the effect on.
  27166. * @param options The required width/height ratio to downsize to before computing the render pass.
  27167. * @param camera The camera to apply the render pass to.
  27168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27169. * @param engine The engine which the post process will be applied. (default: current engine)
  27170. * @param reusable If the post process can be reused on the same frame. (default: false)
  27171. * @param textureType Type of textures used when performing the post process. (default: 0)
  27172. * @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)
  27173. */
  27174. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27175. }
  27176. }
  27177. declare module BABYLON {
  27178. /**
  27179. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  27180. */
  27181. class CircleOfConfusionPostProcess extends PostProcess {
  27182. /**
  27183. * 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.
  27184. */
  27185. lensSize: number;
  27186. /**
  27187. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27188. */
  27189. fStop: number;
  27190. /**
  27191. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27192. */
  27193. focusDistance: number;
  27194. /**
  27195. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  27196. */
  27197. focalLength: number;
  27198. private _depthTexture;
  27199. /**
  27200. * Creates a new instance CircleOfConfusionPostProcess
  27201. * @param name The name of the effect.
  27202. * @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.
  27203. * @param options The required width/height ratio to downsize to before computing the render pass.
  27204. * @param camera The camera to apply the render pass to.
  27205. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27206. * @param engine The engine which the post process will be applied. (default: current engine)
  27207. * @param reusable If the post process can be reused on the same frame. (default: false)
  27208. * @param textureType Type of textures used when performing the post process. (default: 0)
  27209. * @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)
  27210. */
  27211. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27212. /**
  27213. * 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.
  27214. */
  27215. depthTexture: RenderTargetTexture;
  27216. }
  27217. }
  27218. declare module BABYLON {
  27219. class ColorCorrectionPostProcess extends PostProcess {
  27220. private _colorTableTexture;
  27221. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27222. }
  27223. }
  27224. declare module BABYLON {
  27225. /**
  27226. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  27227. * input texture to perform effects such as edge detection or sharpening
  27228. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27229. */
  27230. class ConvolutionPostProcess extends PostProcess {
  27231. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  27232. /**
  27233. * Creates a new instance ConvolutionPostProcess
  27234. * @param name The name of the effect.
  27235. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  27236. * @param options The required width/height ratio to downsize to before computing the render pass.
  27237. * @param camera The camera to apply the render pass to.
  27238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27239. * @param engine The engine which the post process will be applied. (default: current engine)
  27240. * @param reusable If the post process can be reused on the same frame. (default: false)
  27241. * @param textureType Type of textures used when performing the post process. (default: 0)
  27242. */
  27243. 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);
  27244. /**
  27245. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27246. */
  27247. static EdgeDetect0Kernel: number[];
  27248. /**
  27249. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27250. */
  27251. static EdgeDetect1Kernel: number[];
  27252. /**
  27253. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27254. */
  27255. static EdgeDetect2Kernel: number[];
  27256. /**
  27257. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27258. */
  27259. static SharpenKernel: number[];
  27260. /**
  27261. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27262. */
  27263. static EmbossKernel: number[];
  27264. /**
  27265. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27266. */
  27267. static GaussianKernel: number[];
  27268. }
  27269. }
  27270. declare module BABYLON {
  27271. /**
  27272. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  27273. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  27274. * based on samples that have a large difference in distance than the center pixel.
  27275. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  27276. */
  27277. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  27278. direction: Vector2;
  27279. /**
  27280. * Creates a new instance CircleOfConfusionPostProcess
  27281. * @param name The name of the effect.
  27282. * @param scene The scene the effect belongs to.
  27283. * @param direction The direction the blur should be applied.
  27284. * @param kernel The size of the kernel used to blur.
  27285. * @param options The required width/height ratio to downsize to before computing the render pass.
  27286. * @param camera The camera to apply the render pass to.
  27287. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  27288. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  27289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27290. * @param engine The engine which the post process will be applied. (default: current engine)
  27291. * @param reusable If the post process can be reused on the same frame. (default: false)
  27292. * @param textureType Type of textures used when performing the post process. (default: 0)
  27293. * @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)
  27294. */
  27295. 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);
  27296. }
  27297. }
  27298. declare module BABYLON {
  27299. /**
  27300. * Specifies the level of max blur that should be applied when using the depth of field effect
  27301. */
  27302. enum DepthOfFieldEffectBlurLevel {
  27303. /**
  27304. * Subtle blur
  27305. */
  27306. Low = 0,
  27307. /**
  27308. * Medium blur
  27309. */
  27310. Medium = 1,
  27311. /**
  27312. * Large blur
  27313. */
  27314. High = 2,
  27315. }
  27316. /**
  27317. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  27318. */
  27319. class DepthOfFieldEffect extends PostProcessRenderEffect {
  27320. private _circleOfConfusion;
  27321. /**
  27322. * Internal, blurs from high to low
  27323. */
  27324. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  27325. private _depthOfFieldBlurY;
  27326. private _dofMerge;
  27327. /**
  27328. * Internal post processes in depth of field effect
  27329. */
  27330. _effects: Array<PostProcess>;
  27331. /**
  27332. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  27333. */
  27334. focalLength: number;
  27335. /**
  27336. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27337. */
  27338. fStop: number;
  27339. /**
  27340. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27341. */
  27342. focusDistance: number;
  27343. /**
  27344. * 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.
  27345. */
  27346. lensSize: number;
  27347. /**
  27348. * Creates a new instance DepthOfFieldEffect
  27349. * @param scene The scene the effect belongs to.
  27350. * @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.
  27351. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27352. * @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)
  27353. */
  27354. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  27355. /**
  27356. * 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.
  27357. */
  27358. depthTexture: RenderTargetTexture;
  27359. /**
  27360. * Disposes each of the internal effects for a given camera.
  27361. * @param camera The camera to dispose the effect on.
  27362. */
  27363. disposeEffects(camera: Camera): void;
  27364. /**
  27365. * Internal
  27366. */
  27367. _updateEffects(): void;
  27368. /**
  27369. * Internal
  27370. * @returns if all the contained post processes are ready.
  27371. */
  27372. _isReady(): boolean;
  27373. }
  27374. }
  27375. declare module BABYLON {
  27376. /**
  27377. * Options to be set when merging outputs from the default pipeline.
  27378. */
  27379. class DepthOfFieldMergePostProcessOptions {
  27380. /**
  27381. * The original image to merge on top of
  27382. */
  27383. originalFromInput: PostProcess;
  27384. /**
  27385. * Parameters to perform the merge of the depth of field effect
  27386. */
  27387. depthOfField?: {
  27388. circleOfConfusion: PostProcess;
  27389. blurSteps: Array<PostProcess>;
  27390. };
  27391. /**
  27392. * Parameters to perform the merge of bloom effect
  27393. */
  27394. bloom?: {
  27395. blurred: PostProcess;
  27396. weight: number;
  27397. };
  27398. }
  27399. /**
  27400. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27401. */
  27402. class DepthOfFieldMergePostProcess extends PostProcess {
  27403. private blurSteps;
  27404. /**
  27405. * Creates a new instance of DepthOfFieldMergePostProcess
  27406. * @param name The name of the effect.
  27407. * @param originalFromInput Post process which's input will be used for the merge.
  27408. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  27409. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  27410. * @param options The required width/height ratio to downsize to before computing the render pass.
  27411. * @param camera The camera to apply the render pass to.
  27412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27413. * @param engine The engine which the post process will be applied. (default: current engine)
  27414. * @param reusable If the post process can be reused on the same frame. (default: false)
  27415. * @param textureType Type of textures used when performing the post process. (default: 0)
  27416. * @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)
  27417. */
  27418. 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);
  27419. /**
  27420. * Updates the effect with the current post process compile time values and recompiles the shader.
  27421. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27422. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27423. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27424. * @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
  27425. * @param onCompiled Called when the shader has been compiled.
  27426. * @param onError Called if there is an error when compiling a shader.
  27427. */
  27428. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27429. }
  27430. }
  27431. declare module BABYLON {
  27432. class DisplayPassPostProcess extends PostProcess {
  27433. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27434. }
  27435. }
  27436. declare module BABYLON {
  27437. /**
  27438. * 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.
  27439. */
  27440. class ExtractHighlightsPostProcess extends PostProcess {
  27441. /**
  27442. * The luminance threshold, pixels below this value will be set to black.
  27443. */
  27444. threshold: number;
  27445. /**
  27446. * Internal
  27447. */
  27448. _exposure: number;
  27449. /**
  27450. * Post process which has the input texture to be used when performing highlight extraction
  27451. */
  27452. _inputPostProcess: Nullable<PostProcess>;
  27453. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27454. }
  27455. }
  27456. declare module BABYLON {
  27457. class FilterPostProcess extends PostProcess {
  27458. kernelMatrix: Matrix;
  27459. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27460. }
  27461. }
  27462. declare module BABYLON {
  27463. class FxaaPostProcess extends PostProcess {
  27464. texelWidth: number;
  27465. texelHeight: number;
  27466. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27467. private _getDefines();
  27468. }
  27469. }
  27470. declare module BABYLON {
  27471. /**
  27472. * The GrainPostProcess adds noise to the image at mid luminance levels
  27473. */
  27474. class GrainPostProcess extends PostProcess {
  27475. /**
  27476. * The intensity of the grain added (default: 30)
  27477. */
  27478. intensity: number;
  27479. /**
  27480. * If the grain should be randomized on every frame
  27481. */
  27482. animated: boolean;
  27483. /**
  27484. * Creates a new instance of @see GrainPostProcess
  27485. * @param name The name of the effect.
  27486. * @param options The required width/height ratio to downsize to before computing the render pass.
  27487. * @param camera The camera to apply the render pass to.
  27488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27489. * @param engine The engine which the post process will be applied. (default: current engine)
  27490. * @param reusable If the post process can be reused on the same frame. (default: false)
  27491. * @param textureType Type of textures used when performing the post process. (default: 0)
  27492. * @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)
  27493. */
  27494. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27495. }
  27496. }
  27497. declare module BABYLON {
  27498. class HighlightsPostProcess extends PostProcess {
  27499. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27500. }
  27501. }
  27502. declare module BABYLON {
  27503. class ImageProcessingPostProcess extends PostProcess {
  27504. /**
  27505. * Default configuration related to image processing available in the PBR Material.
  27506. */
  27507. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27508. /**
  27509. * Gets the image processing configuration used either in this material.
  27510. */
  27511. /**
  27512. * Sets the Default image processing configuration used either in the this material.
  27513. *
  27514. * If sets to null, the scene one is in use.
  27515. */
  27516. imageProcessingConfiguration: ImageProcessingConfiguration;
  27517. /**
  27518. * Keep track of the image processing observer to allow dispose and replace.
  27519. */
  27520. private _imageProcessingObserver;
  27521. /**
  27522. * Attaches a new image processing configuration to the PBR Material.
  27523. * @param configuration
  27524. */
  27525. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  27526. /**
  27527. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27528. */
  27529. /**
  27530. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27531. */
  27532. colorCurves: Nullable<ColorCurves>;
  27533. /**
  27534. * Gets wether the color curves effect is enabled.
  27535. */
  27536. /**
  27537. * Sets wether the color curves effect is enabled.
  27538. */
  27539. colorCurvesEnabled: boolean;
  27540. /**
  27541. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27542. */
  27543. /**
  27544. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27545. */
  27546. colorGradingTexture: Nullable<BaseTexture>;
  27547. /**
  27548. * Gets wether the color grading effect is enabled.
  27549. */
  27550. /**
  27551. * Gets wether the color grading effect is enabled.
  27552. */
  27553. colorGradingEnabled: boolean;
  27554. /**
  27555. * Gets exposure used in the effect.
  27556. */
  27557. /**
  27558. * Sets exposure used in the effect.
  27559. */
  27560. exposure: number;
  27561. /**
  27562. * Gets wether tonemapping is enabled or not.
  27563. */
  27564. /**
  27565. * Sets wether tonemapping is enabled or not
  27566. */
  27567. toneMappingEnabled: boolean;
  27568. /**
  27569. * Gets contrast used in the effect.
  27570. */
  27571. /**
  27572. * Sets contrast used in the effect.
  27573. */
  27574. contrast: number;
  27575. /**
  27576. * Gets Vignette stretch size.
  27577. */
  27578. /**
  27579. * Sets Vignette stretch size.
  27580. */
  27581. vignetteStretch: number;
  27582. /**
  27583. * Gets Vignette centre X Offset.
  27584. */
  27585. /**
  27586. * Sets Vignette centre X Offset.
  27587. */
  27588. vignetteCentreX: number;
  27589. /**
  27590. * Gets Vignette centre Y Offset.
  27591. */
  27592. /**
  27593. * Sets Vignette centre Y Offset.
  27594. */
  27595. vignetteCentreY: number;
  27596. /**
  27597. * Gets Vignette weight or intensity of the vignette effect.
  27598. */
  27599. /**
  27600. * Sets Vignette weight or intensity of the vignette effect.
  27601. */
  27602. vignetteWeight: number;
  27603. /**
  27604. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27605. * if vignetteEnabled is set to true.
  27606. */
  27607. /**
  27608. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27609. * if vignetteEnabled is set to true.
  27610. */
  27611. vignetteColor: Color4;
  27612. /**
  27613. * Gets Camera field of view used by the Vignette effect.
  27614. */
  27615. /**
  27616. * Sets Camera field of view used by the Vignette effect.
  27617. */
  27618. vignetteCameraFov: number;
  27619. /**
  27620. * Gets the vignette blend mode allowing different kind of effect.
  27621. */
  27622. /**
  27623. * Sets the vignette blend mode allowing different kind of effect.
  27624. */
  27625. vignetteBlendMode: number;
  27626. /**
  27627. * Gets wether the vignette effect is enabled.
  27628. */
  27629. /**
  27630. * Sets wether the vignette effect is enabled.
  27631. */
  27632. vignetteEnabled: boolean;
  27633. private _fromLinearSpace;
  27634. /**
  27635. * Gets wether the input of the processing is in Gamma or Linear Space.
  27636. */
  27637. /**
  27638. * Sets wether the input of the processing is in Gamma or Linear Space.
  27639. */
  27640. fromLinearSpace: boolean;
  27641. /**
  27642. * Defines cache preventing GC.
  27643. */
  27644. private _defines;
  27645. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  27646. getClassName(): string;
  27647. protected _updateParameters(): void;
  27648. dispose(camera?: Camera): void;
  27649. }
  27650. }
  27651. declare module BABYLON {
  27652. class PassPostProcess extends PostProcess {
  27653. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27654. }
  27655. }
  27656. declare module BABYLON {
  27657. type PostProcessOptions = {
  27658. width: number;
  27659. height: number;
  27660. };
  27661. /**
  27662. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27663. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27664. */
  27665. class PostProcess {
  27666. /** Name of the PostProcess. */ name: string;
  27667. /**
  27668. * Width of the texture to apply the post process on
  27669. */
  27670. width: number;
  27671. /**
  27672. * Height of the texture to apply the post process on
  27673. */
  27674. height: number;
  27675. /**
  27676. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27677. */
  27678. _outputTexture: Nullable<InternalTexture>;
  27679. /**
  27680. * Sampling mode used by the shader
  27681. * See https://doc.babylonjs.com/classes/3.1/texture
  27682. */
  27683. renderTargetSamplingMode: number;
  27684. /**
  27685. * Clear color to use when screen clearing
  27686. */
  27687. clearColor: Color4;
  27688. /**
  27689. * If the buffer needs to be cleared before applying the post process. (default: true)
  27690. * Should be set to false if shader will overwrite all previous pixels.
  27691. */
  27692. autoClear: boolean;
  27693. /**
  27694. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27695. */
  27696. alphaMode: number;
  27697. /**
  27698. * Sets the setAlphaBlendConstants of the babylon engine
  27699. */
  27700. alphaConstants: Color4;
  27701. /**
  27702. * Animations to be used for the post processing
  27703. */
  27704. animations: Animation[];
  27705. /**
  27706. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27707. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27708. */
  27709. enablePixelPerfectMode: boolean;
  27710. /**
  27711. * Force the postprocess to be applied without taking in account viewport
  27712. */
  27713. forceFullscreenViewport: boolean;
  27714. /**
  27715. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27716. *
  27717. * | Value | Type | Description |
  27718. * | ----- | ----------------------------------- | ----------- |
  27719. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27720. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27721. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27722. *
  27723. */
  27724. scaleMode: number;
  27725. /**
  27726. * Force textures to be a power of two (default: false)
  27727. */
  27728. alwaysForcePOT: boolean;
  27729. /**
  27730. * Number of sample textures (default: 1)
  27731. */
  27732. samples: number;
  27733. /**
  27734. * Modify the scale of the post process to be the same as the viewport (default: false)
  27735. */
  27736. adaptScaleToCurrentViewport: boolean;
  27737. private _camera;
  27738. private _scene;
  27739. private _engine;
  27740. private _options;
  27741. private _reusable;
  27742. private _textureType;
  27743. /**
  27744. * Smart array of input and output textures for the post process.
  27745. */
  27746. _textures: SmartArray<InternalTexture>;
  27747. /**
  27748. * The index in _textures that corresponds to the output texture.
  27749. */
  27750. _currentRenderTextureInd: number;
  27751. private _effect;
  27752. private _samplers;
  27753. private _fragmentUrl;
  27754. private _vertexUrl;
  27755. private _parameters;
  27756. private _scaleRatio;
  27757. protected _indexParameters: any;
  27758. private _shareOutputWithPostProcess;
  27759. private _texelSize;
  27760. private _forcedOutputTexture;
  27761. /**
  27762. * An event triggered when the postprocess is activated.
  27763. */
  27764. onActivateObservable: Observable<Camera>;
  27765. private _onActivateObserver;
  27766. /**
  27767. * A function that is added to the onActivateObservable
  27768. */
  27769. onActivate: Nullable<(camera: Camera) => void>;
  27770. /**
  27771. * An event triggered when the postprocess changes its size.
  27772. */
  27773. onSizeChangedObservable: Observable<PostProcess>;
  27774. private _onSizeChangedObserver;
  27775. /**
  27776. * A function that is added to the onSizeChangedObservable
  27777. */
  27778. onSizeChanged: (postProcess: PostProcess) => void;
  27779. /**
  27780. * An event triggered when the postprocess applies its effect.
  27781. */
  27782. onApplyObservable: Observable<Effect>;
  27783. private _onApplyObserver;
  27784. /**
  27785. * A function that is added to the onApplyObservable
  27786. */
  27787. onApply: (effect: Effect) => void;
  27788. /**
  27789. * An event triggered before rendering the postprocess
  27790. */
  27791. onBeforeRenderObservable: Observable<Effect>;
  27792. private _onBeforeRenderObserver;
  27793. /**
  27794. * A function that is added to the onBeforeRenderObservable
  27795. */
  27796. onBeforeRender: (effect: Effect) => void;
  27797. /**
  27798. * An event triggered after rendering the postprocess
  27799. */
  27800. onAfterRenderObservable: Observable<Effect>;
  27801. private _onAfterRenderObserver;
  27802. /**
  27803. * A function that is added to the onAfterRenderObservable
  27804. */
  27805. onAfterRender: (efect: Effect) => void;
  27806. /**
  27807. * 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
  27808. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27809. */
  27810. inputTexture: InternalTexture;
  27811. /**
  27812. * Gets the camera which post process is applied to.
  27813. * @returns The camera the post process is applied to.
  27814. */
  27815. getCamera(): Camera;
  27816. /**
  27817. * Gets the texel size of the postprocess.
  27818. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27819. */
  27820. readonly texelSize: Vector2;
  27821. /**
  27822. * Creates a new instance PostProcess
  27823. * @param name The name of the PostProcess.
  27824. * @param fragmentUrl The url of the fragment shader to be used.
  27825. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27826. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27827. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27828. * @param camera The camera to apply the render pass to.
  27829. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27830. * @param engine The engine which the post process will be applied. (default: current engine)
  27831. * @param reusable If the post process can be reused on the same frame. (default: false)
  27832. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27833. * @param textureType Type of textures used when performing the post process. (default: 0)
  27834. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27835. * @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
  27836. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  27837. */
  27838. 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);
  27839. /**
  27840. * Gets the engine which this post process belongs to.
  27841. * @returns The engine the post process was enabled with.
  27842. */
  27843. getEngine(): Engine;
  27844. /**
  27845. * The effect that is created when initializing the post process.
  27846. * @returns The created effect corrisponding the the postprocess.
  27847. */
  27848. getEffect(): Effect;
  27849. /**
  27850. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27851. * @param postProcess The post process to share the output with.
  27852. * @returns This post process.
  27853. */
  27854. shareOutputWith(postProcess: PostProcess): PostProcess;
  27855. /**
  27856. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  27857. * This should be called if the post process that shares output with this post process is disabled/disposed.
  27858. */
  27859. useOwnOutput(): void;
  27860. /**
  27861. * Updates the effect with the current post process compile time values and recompiles the shader.
  27862. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27863. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27864. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27865. * @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
  27866. * @param onCompiled Called when the shader has been compiled.
  27867. * @param onError Called if there is an error when compiling a shader.
  27868. */
  27869. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27870. /**
  27871. * The post process is reusable if it can be used multiple times within one frame.
  27872. * @returns If the post process is reusable
  27873. */
  27874. isReusable(): boolean;
  27875. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  27876. markTextureDirty(): void;
  27877. /**
  27878. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  27879. * 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.
  27880. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  27881. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  27882. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  27883. * @returns The target texture that was bound to be written to.
  27884. */
  27885. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  27886. /**
  27887. * If the post process is supported.
  27888. */
  27889. readonly isSupported: boolean;
  27890. /**
  27891. * The aspect ratio of the output texture.
  27892. */
  27893. readonly aspectRatio: number;
  27894. /**
  27895. * Get a value indicating if the post-process is ready to be used
  27896. * @returns true if the post-process is ready (shader is compiled)
  27897. */
  27898. isReady(): boolean;
  27899. /**
  27900. * Binds all textures and uniforms to the shader, this will be run on every pass.
  27901. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  27902. */
  27903. apply(): Nullable<Effect>;
  27904. private _disposeTextures();
  27905. /**
  27906. * Disposes the post process.
  27907. * @param camera The camera to dispose the post process on.
  27908. */
  27909. dispose(camera?: Camera): void;
  27910. }
  27911. }
  27912. declare module BABYLON {
  27913. /**
  27914. * PostProcessManager is used to manage one or more post processes or post process pipelines
  27915. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27916. */
  27917. class PostProcessManager {
  27918. private _scene;
  27919. private _indexBuffer;
  27920. private _vertexBuffers;
  27921. /**
  27922. * Creates a new instance PostProcess
  27923. * @param scene The scene that the post process is associated with.
  27924. */
  27925. constructor(scene: Scene);
  27926. private _prepareBuffers();
  27927. private _buildIndexBuffer();
  27928. /**
  27929. * Rebuilds the vertex buffers of the manager.
  27930. */
  27931. _rebuild(): void;
  27932. /**
  27933. * Prepares a frame to be run through a post process.
  27934. * @param sourceTexture The input texture to the post procesess. (default: null)
  27935. * @param postProcesses An array of post processes to be run. (default: null)
  27936. * @returns True if the post processes were able to be run.
  27937. */
  27938. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  27939. /**
  27940. * Manually render a set of post processes to a texture.
  27941. * @param postProcesses An array of post processes to be run.
  27942. * @param targetTexture The target texture to render to.
  27943. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  27944. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  27945. * @param lodLevel defines which lod of the texture to render to
  27946. */
  27947. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  27948. /**
  27949. * Finalize the result of the output of the postprocesses.
  27950. * @param doNotPresent If true the result will not be displayed to the screen.
  27951. * @param targetTexture The target texture to render to.
  27952. * @param faceIndex The index of the face to bind the target texture to.
  27953. * @param postProcesses The array of post processes to render.
  27954. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  27955. */
  27956. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  27957. /**
  27958. * Disposes of the post process manager.
  27959. */
  27960. dispose(): void;
  27961. }
  27962. }
  27963. declare module BABYLON {
  27964. class RefractionPostProcess extends PostProcess {
  27965. color: Color3;
  27966. depth: number;
  27967. colorLevel: number;
  27968. private _refTexture;
  27969. private _ownRefractionTexture;
  27970. /**
  27971. * Gets or sets the refraction texture
  27972. * Please note that you are responsible for disposing the texture if you set it manually
  27973. */
  27974. refractionTexture: Texture;
  27975. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27976. dispose(camera: Camera): void;
  27977. }
  27978. }
  27979. declare module BABYLON {
  27980. /**
  27981. * The SharpenPostProcess applies a sharpen kernel to every pixel
  27982. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27983. */
  27984. class SharpenPostProcess extends PostProcess {
  27985. /**
  27986. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  27987. */
  27988. colorAmount: number;
  27989. /**
  27990. * How much sharpness should be applied (default: 0.3)
  27991. */
  27992. edgeAmount: number;
  27993. /**
  27994. * Creates a new instance ConvolutionPostProcess
  27995. * @param name The name of the effect.
  27996. * @param options The required width/height ratio to downsize to before computing the render pass.
  27997. * @param camera The camera to apply the render pass to.
  27998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27999. * @param engine The engine which the post process will be applied. (default: current engine)
  28000. * @param reusable If the post process can be reused on the same frame. (default: false)
  28001. * @param textureType Type of textures used when performing the post process. (default: 0)
  28002. * @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)
  28003. */
  28004. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28005. }
  28006. }
  28007. declare module BABYLON {
  28008. class StereoscopicInterlacePostProcess extends PostProcess {
  28009. private _stepSize;
  28010. private _passedProcess;
  28011. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28012. }
  28013. }
  28014. declare module BABYLON {
  28015. /** Defines operator used for tonemapping */
  28016. enum TonemappingOperator {
  28017. /** Hable */
  28018. Hable = 0,
  28019. /** Reinhard */
  28020. Reinhard = 1,
  28021. /** HejiDawson */
  28022. HejiDawson = 2,
  28023. /** Photographic */
  28024. Photographic = 3,
  28025. }
  28026. /**
  28027. * Defines a post process to apply tone mapping
  28028. */
  28029. class TonemapPostProcess extends PostProcess {
  28030. private _operator;
  28031. /** Defines the required exposure adjustement */
  28032. exposureAdjustment: number;
  28033. /**
  28034. * Creates a new TonemapPostProcess
  28035. * @param name defines the name of the postprocess
  28036. * @param _operator defines the operator to use
  28037. * @param exposureAdjustment defines the required exposure adjustement
  28038. * @param camera defines the camera to use (can be null)
  28039. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  28040. * @param engine defines the hosting engine (can be ignore if camera is set)
  28041. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28042. */
  28043. constructor(name: string, _operator: TonemappingOperator,
  28044. /** Defines the required exposure adjustement */
  28045. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  28046. }
  28047. }
  28048. declare module BABYLON {
  28049. class VolumetricLightScatteringPostProcess extends PostProcess {
  28050. private _volumetricLightScatteringPass;
  28051. private _volumetricLightScatteringRTT;
  28052. private _viewPort;
  28053. private _screenCoordinates;
  28054. private _cachedDefines;
  28055. /**
  28056. * If not undefined, the mesh position is computed from the attached node position
  28057. */
  28058. attachedNode: {
  28059. position: Vector3;
  28060. };
  28061. /**
  28062. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  28063. */
  28064. customMeshPosition: Vector3;
  28065. /**
  28066. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  28067. */
  28068. useCustomMeshPosition: boolean;
  28069. /**
  28070. * If the post-process should inverse the light scattering direction
  28071. */
  28072. invert: boolean;
  28073. /**
  28074. * The internal mesh used by the post-process
  28075. */
  28076. mesh: Mesh;
  28077. useDiffuseColor: boolean;
  28078. /**
  28079. * Array containing the excluded meshes not rendered in the internal pass
  28080. */
  28081. excludedMeshes: AbstractMesh[];
  28082. /**
  28083. * Controls the overall intensity of the post-process
  28084. */
  28085. exposure: number;
  28086. /**
  28087. * Dissipates each sample's contribution in range [0, 1]
  28088. */
  28089. decay: number;
  28090. /**
  28091. * Controls the overall intensity of each sample
  28092. */
  28093. weight: number;
  28094. /**
  28095. * Controls the density of each sample
  28096. */
  28097. density: number;
  28098. /**
  28099. * @constructor
  28100. * @param {string} name - The post-process name
  28101. * @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)
  28102. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  28103. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  28104. * @param {number} samples - The post-process quality, default 100
  28105. * @param {number} samplingMode - The post-process filtering mode
  28106. * @param {BABYLON.Engine} engine - The babylon engine
  28107. * @param {boolean} reusable - If the post-process is reusable
  28108. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  28109. */
  28110. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  28111. getClassName(): string;
  28112. private _isReady(subMesh, useInstances);
  28113. /**
  28114. * Sets the new light position for light scattering effect
  28115. * @param {BABYLON.Vector3} The new custom light position
  28116. */
  28117. setCustomMeshPosition(position: Vector3): void;
  28118. /**
  28119. * Returns the light position for light scattering effect
  28120. * @return {BABYLON.Vector3} The custom light position
  28121. */
  28122. getCustomMeshPosition(): Vector3;
  28123. /**
  28124. * Disposes the internal assets and detaches the post-process from the camera
  28125. */
  28126. dispose(camera: Camera): void;
  28127. /**
  28128. * Returns the render target texture used by the post-process
  28129. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  28130. */
  28131. getPass(): RenderTargetTexture;
  28132. private _meshExcluded(mesh);
  28133. private _createPass(scene, ratio);
  28134. private _updateMeshScreenCoordinates(scene);
  28135. /**
  28136. * Creates a default mesh for the Volumeric Light Scattering post-process
  28137. * @param {string} The mesh name
  28138. * @param {BABYLON.Scene} The scene where to create the mesh
  28139. * @return {BABYLON.Mesh} the default mesh
  28140. */
  28141. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  28142. }
  28143. }
  28144. declare module BABYLON {
  28145. class VRDistortionCorrectionPostProcess extends PostProcess {
  28146. private _isRightEye;
  28147. private _distortionFactors;
  28148. private _postProcessScaleFactor;
  28149. private _lensCenterOffset;
  28150. private _scaleIn;
  28151. private _scaleFactor;
  28152. private _lensCenter;
  28153. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  28154. }
  28155. }
  28156. declare module BABYLON {
  28157. class Sprite {
  28158. name: string;
  28159. position: Vector3;
  28160. color: Color4;
  28161. width: number;
  28162. height: number;
  28163. angle: number;
  28164. cellIndex: number;
  28165. invertU: number;
  28166. invertV: number;
  28167. disposeWhenFinishedAnimating: boolean;
  28168. animations: Animation[];
  28169. isPickable: boolean;
  28170. actionManager: ActionManager;
  28171. private _animationStarted;
  28172. private _loopAnimation;
  28173. private _fromIndex;
  28174. private _toIndex;
  28175. private _delay;
  28176. private _direction;
  28177. private _manager;
  28178. private _time;
  28179. private _onAnimationEnd;
  28180. /**
  28181. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  28182. */
  28183. isVisible: boolean;
  28184. size: number;
  28185. constructor(name: string, manager: SpriteManager);
  28186. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  28187. stopAnimation(): void;
  28188. _animate(deltaTime: number): void;
  28189. dispose(): void;
  28190. }
  28191. }
  28192. declare module BABYLON {
  28193. class SpriteManager {
  28194. name: string;
  28195. sprites: Sprite[];
  28196. renderingGroupId: number;
  28197. layerMask: number;
  28198. fogEnabled: boolean;
  28199. isPickable: boolean;
  28200. cellWidth: number;
  28201. cellHeight: number;
  28202. /**
  28203. * An event triggered when the manager is disposed.
  28204. */
  28205. onDisposeObservable: Observable<SpriteManager>;
  28206. private _onDisposeObserver;
  28207. onDispose: () => void;
  28208. private _capacity;
  28209. private _spriteTexture;
  28210. private _epsilon;
  28211. private _scene;
  28212. private _vertexData;
  28213. private _buffer;
  28214. private _vertexBuffers;
  28215. private _indexBuffer;
  28216. private _effectBase;
  28217. private _effectFog;
  28218. texture: Texture;
  28219. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  28220. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  28221. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  28222. render(): void;
  28223. dispose(): void;
  28224. }
  28225. }
  28226. declare module BABYLON {
  28227. /**
  28228. * @hidden
  28229. **/
  28230. class _AlphaState {
  28231. private _isAlphaBlendDirty;
  28232. private _isBlendFunctionParametersDirty;
  28233. private _isBlendEquationParametersDirty;
  28234. private _isBlendConstantsDirty;
  28235. private _alphaBlend;
  28236. private _blendFunctionParameters;
  28237. private _blendEquationParameters;
  28238. private _blendConstants;
  28239. /**
  28240. * Initializes the state.
  28241. */
  28242. constructor();
  28243. readonly isDirty: boolean;
  28244. alphaBlend: boolean;
  28245. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28246. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28247. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28248. reset(): void;
  28249. apply(gl: WebGLRenderingContext): void;
  28250. }
  28251. }
  28252. declare module BABYLON {
  28253. /**
  28254. * @hidden
  28255. **/
  28256. class _DepthCullingState {
  28257. private _isDepthTestDirty;
  28258. private _isDepthMaskDirty;
  28259. private _isDepthFuncDirty;
  28260. private _isCullFaceDirty;
  28261. private _isCullDirty;
  28262. private _isZOffsetDirty;
  28263. private _isFrontFaceDirty;
  28264. private _depthTest;
  28265. private _depthMask;
  28266. private _depthFunc;
  28267. private _cull;
  28268. private _cullFace;
  28269. private _zOffset;
  28270. private _frontFace;
  28271. /**
  28272. * Initializes the state.
  28273. */
  28274. constructor();
  28275. readonly isDirty: boolean;
  28276. zOffset: number;
  28277. cullFace: Nullable<number>;
  28278. cull: Nullable<boolean>;
  28279. depthFunc: Nullable<number>;
  28280. depthMask: boolean;
  28281. depthTest: boolean;
  28282. frontFace: Nullable<number>;
  28283. reset(): void;
  28284. apply(gl: WebGLRenderingContext): void;
  28285. }
  28286. }
  28287. declare module BABYLON {
  28288. /**
  28289. * @hidden
  28290. **/
  28291. class _StencilState {
  28292. private _isStencilTestDirty;
  28293. private _isStencilMaskDirty;
  28294. private _isStencilFuncDirty;
  28295. private _isStencilOpDirty;
  28296. private _stencilTest;
  28297. private _stencilMask;
  28298. private _stencilFunc;
  28299. private _stencilFuncRef;
  28300. private _stencilFuncMask;
  28301. private _stencilOpStencilFail;
  28302. private _stencilOpDepthFail;
  28303. private _stencilOpStencilDepthPass;
  28304. readonly isDirty: boolean;
  28305. stencilFunc: number;
  28306. stencilFuncRef: number;
  28307. stencilFuncMask: number;
  28308. stencilOpStencilFail: number;
  28309. stencilOpDepthFail: number;
  28310. stencilOpStencilDepthPass: number;
  28311. stencilMask: number;
  28312. stencilTest: boolean;
  28313. constructor();
  28314. reset(): void;
  28315. apply(gl: WebGLRenderingContext): void;
  28316. }
  28317. }
  28318. declare module BABYLON {
  28319. /**
  28320. * Class used to evalaute queries containing `and` and `or` operators
  28321. */
  28322. class AndOrNotEvaluator {
  28323. /**
  28324. * Evaluate a query
  28325. * @param query defines the query to evaluate
  28326. * @param evaluateCallback defines the callback used to filter result
  28327. * @returns true if the query matches
  28328. */
  28329. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  28330. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  28331. private static _SimplifyNegation(booleanString);
  28332. }
  28333. }
  28334. declare module BABYLON {
  28335. /**
  28336. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  28337. */
  28338. enum AssetTaskState {
  28339. /**
  28340. * Initialization
  28341. */
  28342. INIT = 0,
  28343. /**
  28344. * Running
  28345. */
  28346. RUNNING = 1,
  28347. /**
  28348. * Done
  28349. */
  28350. DONE = 2,
  28351. /**
  28352. * Error
  28353. */
  28354. ERROR = 3,
  28355. }
  28356. /**
  28357. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  28358. */
  28359. abstract class AbstractAssetTask {
  28360. /**
  28361. * Task name
  28362. */ name: string;
  28363. /**
  28364. * Callback called when the task is successful
  28365. */
  28366. onSuccess: (task: any) => void;
  28367. /**
  28368. * Callback called when the task is not successful
  28369. */
  28370. onError: (task: any, message?: string, exception?: any) => void;
  28371. /**
  28372. * Creates a new {BABYLON.AssetsManager}
  28373. * @param name defines the name of the task
  28374. */
  28375. constructor(
  28376. /**
  28377. * Task name
  28378. */ name: string);
  28379. private _isCompleted;
  28380. private _taskState;
  28381. private _errorObject;
  28382. /**
  28383. * Get if the task is completed
  28384. */
  28385. readonly isCompleted: boolean;
  28386. /**
  28387. * Gets the current state of the task
  28388. */
  28389. readonly taskState: AssetTaskState;
  28390. /**
  28391. * Gets the current error object (if task is in error)
  28392. */
  28393. readonly errorObject: {
  28394. message?: string;
  28395. exception?: any;
  28396. };
  28397. /**
  28398. * Internal only
  28399. * @hidden
  28400. */
  28401. _setErrorObject(message?: string, exception?: any): void;
  28402. /**
  28403. * Execute the current task
  28404. * @param scene defines the scene where you want your assets to be loaded
  28405. * @param onSuccess is a callback called when the task is successfully executed
  28406. * @param onError is a callback called if an error occurs
  28407. */
  28408. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28409. /**
  28410. * Execute the current task
  28411. * @param scene defines the scene where you want your assets to be loaded
  28412. * @param onSuccess is a callback called when the task is successfully executed
  28413. * @param onError is a callback called if an error occurs
  28414. */
  28415. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28416. /**
  28417. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  28418. * This can be used with failed tasks that have the reason for failure fixed.
  28419. */
  28420. reset(): void;
  28421. private onErrorCallback(onError, message?, exception?);
  28422. private onDoneCallback(onSuccess, onError);
  28423. }
  28424. /**
  28425. * Define the interface used by progress events raised during assets loading
  28426. */
  28427. interface IAssetsProgressEvent {
  28428. /**
  28429. * Defines the number of remaining tasks to process
  28430. */
  28431. remainingCount: number;
  28432. /**
  28433. * Defines the total number of tasks
  28434. */
  28435. totalCount: number;
  28436. /**
  28437. * Defines the task that was just processed
  28438. */
  28439. task: AbstractAssetTask;
  28440. }
  28441. /**
  28442. * Class used to share progress information about assets loading
  28443. */
  28444. class AssetsProgressEvent implements IAssetsProgressEvent {
  28445. /**
  28446. * Defines the number of remaining tasks to process
  28447. */
  28448. remainingCount: number;
  28449. /**
  28450. * Defines the total number of tasks
  28451. */
  28452. totalCount: number;
  28453. /**
  28454. * Defines the task that was just processed
  28455. */
  28456. task: AbstractAssetTask;
  28457. /**
  28458. * Creates a {BABYLON.AssetsProgressEvent}
  28459. * @param remainingCount defines the number of remaining tasks to process
  28460. * @param totalCount defines the total number of tasks
  28461. * @param task defines the task that was just processed
  28462. */
  28463. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  28464. }
  28465. /**
  28466. * Define a task used by {BABYLON.AssetsManager} to load meshes
  28467. */
  28468. class MeshAssetTask extends AbstractAssetTask {
  28469. /**
  28470. * Defines the name of the task
  28471. */
  28472. name: string;
  28473. /**
  28474. * Defines the list of mesh's names you want to load
  28475. */
  28476. meshesNames: any;
  28477. /**
  28478. * Defines the root url to use as a base to load your meshes and associated resources
  28479. */
  28480. rootUrl: string;
  28481. /**
  28482. * Defines the filename of the scene to load from
  28483. */
  28484. sceneFilename: string;
  28485. /**
  28486. * Gets the list of loaded meshes
  28487. */
  28488. loadedMeshes: Array<AbstractMesh>;
  28489. /**
  28490. * Gets the list of loaded particle systems
  28491. */
  28492. loadedParticleSystems: Array<IParticleSystem>;
  28493. /**
  28494. * Gets the list of loaded skeletons
  28495. */
  28496. loadedSkeletons: Array<Skeleton>;
  28497. /**
  28498. * Callback called when the task is successful
  28499. */
  28500. onSuccess: (task: MeshAssetTask) => void;
  28501. /**
  28502. * Callback called when the task is successful
  28503. */
  28504. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  28505. /**
  28506. * Creates a new {BABYLON.MeshAssetTask}
  28507. * @param name defines the name of the task
  28508. * @param meshesNames defines the list of mesh's names you want to load
  28509. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  28510. * @param sceneFilename defines the filename of the scene to load from
  28511. */
  28512. constructor(
  28513. /**
  28514. * Defines the name of the task
  28515. */
  28516. name: string,
  28517. /**
  28518. * Defines the list of mesh's names you want to load
  28519. */
  28520. meshesNames: any,
  28521. /**
  28522. * Defines the root url to use as a base to load your meshes and associated resources
  28523. */
  28524. rootUrl: string,
  28525. /**
  28526. * Defines the filename of the scene to load from
  28527. */
  28528. sceneFilename: string);
  28529. /**
  28530. * Execute the current task
  28531. * @param scene defines the scene where you want your assets to be loaded
  28532. * @param onSuccess is a callback called when the task is successfully executed
  28533. * @param onError is a callback called if an error occurs
  28534. */
  28535. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28536. }
  28537. /**
  28538. * Define a task used by {BABYLON.AssetsManager} to load text content
  28539. */
  28540. class TextFileAssetTask extends AbstractAssetTask {
  28541. /**
  28542. * Defines the name of the task
  28543. */
  28544. name: string;
  28545. /**
  28546. * Defines the location of the file to load
  28547. */
  28548. url: string;
  28549. /**
  28550. * Gets the loaded text string
  28551. */
  28552. text: string;
  28553. /**
  28554. * Callback called when the task is successful
  28555. */
  28556. onSuccess: (task: TextFileAssetTask) => void;
  28557. /**
  28558. * Callback called when the task is successful
  28559. */
  28560. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  28561. /**
  28562. * Creates a new TextFileAssetTask object
  28563. * @param name defines the name of the task
  28564. * @param url defines the location of the file to load
  28565. */
  28566. constructor(
  28567. /**
  28568. * Defines the name of the task
  28569. */
  28570. name: string,
  28571. /**
  28572. * Defines the location of the file to load
  28573. */
  28574. url: string);
  28575. /**
  28576. * Execute the current task
  28577. * @param scene defines the scene where you want your assets to be loaded
  28578. * @param onSuccess is a callback called when the task is successfully executed
  28579. * @param onError is a callback called if an error occurs
  28580. */
  28581. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28582. }
  28583. /**
  28584. * Define a task used by {BABYLON.AssetsManager} to load binary data
  28585. */
  28586. class BinaryFileAssetTask extends AbstractAssetTask {
  28587. /**
  28588. * Defines the name of the task
  28589. */
  28590. name: string;
  28591. /**
  28592. * Defines the location of the file to load
  28593. */
  28594. url: string;
  28595. /**
  28596. * Gets the lodaded data (as an array buffer)
  28597. */
  28598. data: ArrayBuffer;
  28599. /**
  28600. * Callback called when the task is successful
  28601. */
  28602. onSuccess: (task: BinaryFileAssetTask) => void;
  28603. /**
  28604. * Callback called when the task is successful
  28605. */
  28606. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  28607. /**
  28608. * Creates a new BinaryFileAssetTask object
  28609. * @param name defines the name of the new task
  28610. * @param url defines the location of the file to load
  28611. */
  28612. constructor(
  28613. /**
  28614. * Defines the name of the task
  28615. */
  28616. name: string,
  28617. /**
  28618. * Defines the location of the file to load
  28619. */
  28620. url: string);
  28621. /**
  28622. * Execute the current task
  28623. * @param scene defines the scene where you want your assets to be loaded
  28624. * @param onSuccess is a callback called when the task is successfully executed
  28625. * @param onError is a callback called if an error occurs
  28626. */
  28627. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28628. }
  28629. /**
  28630. * Define a task used by {BABYLON.AssetsManager} to load images
  28631. */
  28632. class ImageAssetTask extends AbstractAssetTask {
  28633. /**
  28634. * Defines the name of the task
  28635. */
  28636. name: string;
  28637. /**
  28638. * Defines the location of the image to load
  28639. */
  28640. url: string;
  28641. /**
  28642. * Gets the loaded images
  28643. */
  28644. image: HTMLImageElement;
  28645. /**
  28646. * Callback called when the task is successful
  28647. */
  28648. onSuccess: (task: ImageAssetTask) => void;
  28649. /**
  28650. * Callback called when the task is successful
  28651. */
  28652. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  28653. /**
  28654. * Creates a new ImageAssetTask
  28655. * @param name defines the name of the task
  28656. * @param url defines the location of the image to load
  28657. */
  28658. constructor(
  28659. /**
  28660. * Defines the name of the task
  28661. */
  28662. name: string,
  28663. /**
  28664. * Defines the location of the image to load
  28665. */
  28666. url: string);
  28667. /**
  28668. * Execute the current task
  28669. * @param scene defines the scene where you want your assets to be loaded
  28670. * @param onSuccess is a callback called when the task is successfully executed
  28671. * @param onError is a callback called if an error occurs
  28672. */
  28673. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28674. }
  28675. /**
  28676. * Defines the interface used by texture loading tasks
  28677. */
  28678. interface ITextureAssetTask<TEX extends BaseTexture> {
  28679. /**
  28680. * Gets the loaded texture
  28681. */
  28682. texture: TEX;
  28683. }
  28684. /**
  28685. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  28686. */
  28687. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  28688. /**
  28689. * Defines the name of the task
  28690. */
  28691. name: string;
  28692. /**
  28693. * Defines the location of the file to load
  28694. */
  28695. url: string;
  28696. /**
  28697. * Defines if mipmap should not be generated (default is false)
  28698. */
  28699. noMipmap: boolean | undefined;
  28700. /**
  28701. * Defines if texture must be inverted on Y axis (default is false)
  28702. */
  28703. invertY: boolean | undefined;
  28704. /**
  28705. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28706. */
  28707. samplingMode: number;
  28708. /**
  28709. * Gets the loaded texture
  28710. */
  28711. texture: Texture;
  28712. /**
  28713. * Callback called when the task is successful
  28714. */
  28715. onSuccess: (task: TextureAssetTask) => void;
  28716. /**
  28717. * Callback called when the task is successful
  28718. */
  28719. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  28720. /**
  28721. * Creates a new TextureAssetTask object
  28722. * @param name defines the name of the task
  28723. * @param url defines the location of the file to load
  28724. * @param noMipmap defines if mipmap should not be generated (default is false)
  28725. * @param invertY defines if texture must be inverted on Y axis (default is false)
  28726. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28727. */
  28728. constructor(
  28729. /**
  28730. * Defines the name of the task
  28731. */
  28732. name: string,
  28733. /**
  28734. * Defines the location of the file to load
  28735. */
  28736. url: string,
  28737. /**
  28738. * Defines if mipmap should not be generated (default is false)
  28739. */
  28740. noMipmap?: boolean | undefined,
  28741. /**
  28742. * Defines if texture must be inverted on Y axis (default is false)
  28743. */
  28744. invertY?: boolean | undefined,
  28745. /**
  28746. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28747. */
  28748. samplingMode?: number);
  28749. /**
  28750. * Execute the current task
  28751. * @param scene defines the scene where you want your assets to be loaded
  28752. * @param onSuccess is a callback called when the task is successfully executed
  28753. * @param onError is a callback called if an error occurs
  28754. */
  28755. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28756. }
  28757. /**
  28758. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  28759. */
  28760. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  28761. /**
  28762. * Defines the name of the task
  28763. */
  28764. name: string;
  28765. /**
  28766. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  28767. */
  28768. url: string;
  28769. /**
  28770. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  28771. */
  28772. extensions: string[] | undefined;
  28773. /**
  28774. * Defines if mipmaps should not be generated (default is false)
  28775. */
  28776. noMipmap: boolean | undefined;
  28777. /**
  28778. * Defines the explicit list of files (undefined by default)
  28779. */
  28780. files: string[] | undefined;
  28781. /**
  28782. * Gets the loaded texture
  28783. */
  28784. texture: CubeTexture;
  28785. /**
  28786. * Callback called when the task is successful
  28787. */
  28788. onSuccess: (task: CubeTextureAssetTask) => void;
  28789. /**
  28790. * Callback called when the task is successful
  28791. */
  28792. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  28793. /**
  28794. * Creates a new CubeTextureAssetTask
  28795. * @param name defines the name of the task
  28796. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  28797. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  28798. * @param noMipmap defines if mipmaps should not be generated (default is false)
  28799. * @param files defines the explicit list of files (undefined by default)
  28800. */
  28801. constructor(
  28802. /**
  28803. * Defines the name of the task
  28804. */
  28805. name: string,
  28806. /**
  28807. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  28808. */
  28809. url: string,
  28810. /**
  28811. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  28812. */
  28813. extensions?: string[] | undefined,
  28814. /**
  28815. * Defines if mipmaps should not be generated (default is false)
  28816. */
  28817. noMipmap?: boolean | undefined,
  28818. /**
  28819. * Defines the explicit list of files (undefined by default)
  28820. */
  28821. files?: string[] | undefined);
  28822. /**
  28823. * Execute the current task
  28824. * @param scene defines the scene where you want your assets to be loaded
  28825. * @param onSuccess is a callback called when the task is successfully executed
  28826. * @param onError is a callback called if an error occurs
  28827. */
  28828. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28829. }
  28830. /**
  28831. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  28832. */
  28833. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  28834. /**
  28835. * Defines the name of the task
  28836. */
  28837. name: string;
  28838. /**
  28839. * Defines the location of the file to load
  28840. */
  28841. url: string;
  28842. /**
  28843. * Defines the desired size (the more it increases the longer the generation will be)
  28844. */
  28845. size: number;
  28846. /**
  28847. * Defines if mipmaps should not be generated (default is false)
  28848. */
  28849. noMipmap: boolean;
  28850. /**
  28851. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  28852. */
  28853. generateHarmonics: boolean;
  28854. /**
  28855. * 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)
  28856. */
  28857. gammaSpace: boolean;
  28858. /**
  28859. * Internal Use Only
  28860. */
  28861. reserved: boolean;
  28862. /**
  28863. * Gets the loaded texture
  28864. */
  28865. texture: HDRCubeTexture;
  28866. /**
  28867. * Callback called when the task is successful
  28868. */
  28869. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  28870. /**
  28871. * Callback called when the task is successful
  28872. */
  28873. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  28874. /**
  28875. * Creates a new HDRCubeTextureAssetTask object
  28876. * @param name defines the name of the task
  28877. * @param url defines the location of the file to load
  28878. * @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.
  28879. * @param noMipmap defines if mipmaps should not be generated (default is false)
  28880. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  28881. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  28882. * @param reserved Internal use only
  28883. */
  28884. constructor(
  28885. /**
  28886. * Defines the name of the task
  28887. */
  28888. name: string,
  28889. /**
  28890. * Defines the location of the file to load
  28891. */
  28892. url: string,
  28893. /**
  28894. * Defines the desired size (the more it increases the longer the generation will be)
  28895. */
  28896. size: number,
  28897. /**
  28898. * Defines if mipmaps should not be generated (default is false)
  28899. */
  28900. noMipmap?: boolean,
  28901. /**
  28902. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  28903. */
  28904. generateHarmonics?: boolean,
  28905. /**
  28906. * 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)
  28907. */
  28908. gammaSpace?: boolean,
  28909. /**
  28910. * Internal Use Only
  28911. */
  28912. reserved?: boolean);
  28913. /**
  28914. * Execute the current task
  28915. * @param scene defines the scene where you want your assets to be loaded
  28916. * @param onSuccess is a callback called when the task is successfully executed
  28917. * @param onError is a callback called if an error occurs
  28918. */
  28919. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28920. }
  28921. /**
  28922. * This class can be used to easily import assets into a scene
  28923. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  28924. */
  28925. class AssetsManager {
  28926. private _scene;
  28927. private _isLoading;
  28928. protected _tasks: AbstractAssetTask[];
  28929. protected _waitingTasksCount: number;
  28930. protected _totalTasksCount: number;
  28931. /**
  28932. * Callback called when all tasks are processed
  28933. */
  28934. onFinish: (tasks: AbstractAssetTask[]) => void;
  28935. /**
  28936. * Callback called when a task is successful
  28937. */
  28938. onTaskSuccess: (task: AbstractAssetTask) => void;
  28939. /**
  28940. * Callback called when a task had an error
  28941. */
  28942. onTaskError: (task: AbstractAssetTask) => void;
  28943. /**
  28944. * Callback called when a task is done (whatever the result is)
  28945. */
  28946. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  28947. /**
  28948. * Observable called when all tasks are processed
  28949. */
  28950. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  28951. /**
  28952. * Observable called when a task had an error
  28953. */
  28954. onTaskErrorObservable: Observable<AbstractAssetTask>;
  28955. /**
  28956. * Observable called when a task is successful
  28957. */
  28958. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  28959. /**
  28960. * Observable called when a task is done (whatever the result is)
  28961. */
  28962. onProgressObservable: Observable<IAssetsProgressEvent>;
  28963. /**
  28964. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  28965. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28966. */
  28967. useDefaultLoadingScreen: boolean;
  28968. /**
  28969. * Creates a new AssetsManager
  28970. * @param scene defines the scene to work on
  28971. */
  28972. constructor(scene: Scene);
  28973. /**
  28974. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  28975. * @param taskName defines the name of the new task
  28976. * @param meshesNames defines the name of meshes to load
  28977. * @param rootUrl defines the root url to use to locate files
  28978. * @param sceneFilename defines the filename of the scene file
  28979. * @returns a new {BABYLON.MeshAssetTask} object
  28980. */
  28981. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  28982. /**
  28983. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  28984. * @param taskName defines the name of the new task
  28985. * @param url defines the url of the file to load
  28986. * @returns a new {BABYLON.TextFileAssetTask} object
  28987. */
  28988. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  28989. /**
  28990. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  28991. * @param taskName defines the name of the new task
  28992. * @param url defines the url of the file to load
  28993. * @returns a new {BABYLON.BinaryFileAssetTask} object
  28994. */
  28995. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  28996. /**
  28997. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  28998. * @param taskName defines the name of the new task
  28999. * @param url defines the url of the file to load
  29000. * @returns a new {BABYLON.ImageAssetTask} object
  29001. */
  29002. addImageTask(taskName: string, url: string): ImageAssetTask;
  29003. /**
  29004. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  29005. * @param taskName defines the name of the new task
  29006. * @param url defines the url of the file to load
  29007. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29008. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  29009. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  29010. * @returns a new {BABYLON.TextureAssetTask} object
  29011. */
  29012. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  29013. /**
  29014. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  29015. * @param taskName defines the name of the new task
  29016. * @param url defines the url of the file to load
  29017. * @param extensions defines the extension to use to load the cube map (can be null)
  29018. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29019. * @param files defines the list of files to load (can be null)
  29020. * @returns a new {BABYLON.CubeTextureAssetTask} object
  29021. */
  29022. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  29023. /**
  29024. *
  29025. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  29026. * @param taskName defines the name of the new task
  29027. * @param url defines the url of the file to load
  29028. * @param size defines the size you want for the cubemap (can be null)
  29029. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29030. * @param generateHarmonics defines if you want to automatically generate (true by default)
  29031. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  29032. * @param reserved Internal use only
  29033. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  29034. */
  29035. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  29036. /**
  29037. * Remove a task from the assets manager.
  29038. * @param task the task to remove
  29039. */
  29040. removeTask(task: AbstractAssetTask): void;
  29041. private _decreaseWaitingTasksCount(task);
  29042. private _runTask(task);
  29043. /**
  29044. * Reset the {BABYLON.AssetsManager} and remove all tasks
  29045. * @return the current instance of the {BABYLON.AssetsManager}
  29046. */
  29047. reset(): AssetsManager;
  29048. /**
  29049. * Start the loading process
  29050. * @return the current instance of the {BABYLON.AssetsManager}
  29051. */
  29052. load(): AssetsManager;
  29053. }
  29054. }
  29055. declare module BABYLON {
  29056. /**
  29057. * Class used to enable access to IndexedDB
  29058. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  29059. */
  29060. class Database {
  29061. private callbackManifestChecked;
  29062. private currentSceneUrl;
  29063. private db;
  29064. private _enableSceneOffline;
  29065. private _enableTexturesOffline;
  29066. private manifestVersionFound;
  29067. private mustUpdateRessources;
  29068. private hasReachedQuota;
  29069. private isSupported;
  29070. private idbFactory;
  29071. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  29072. static IsUASupportingBlobStorage: boolean;
  29073. /** Gets a boolean indicating if Database storate is enabled */
  29074. static IDBStorageEnabled: boolean;
  29075. /**
  29076. * Gets a boolean indicating if scene must be saved in the database
  29077. */
  29078. readonly enableSceneOffline: boolean;
  29079. /**
  29080. * Gets a boolean indicating if textures must be saved in the database
  29081. */
  29082. readonly enableTexturesOffline: boolean;
  29083. /**
  29084. * Creates a new Database
  29085. * @param urlToScene defines the url to load the scene
  29086. * @param callbackManifestChecked defines the callback to use when manifest is checked
  29087. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  29088. */
  29089. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  29090. private static _ParseURL;
  29091. private static _ReturnFullUrlLocation;
  29092. private _checkManifestFile();
  29093. /**
  29094. * Open the database and make it available
  29095. * @param successCallback defines the callback to call on success
  29096. * @param errorCallback defines the callback to call on error
  29097. */
  29098. openAsync(successCallback: () => void, errorCallback: () => void): void;
  29099. /**
  29100. * Loads an image from the database
  29101. * @param url defines the url to load from
  29102. * @param image defines the target DOM image
  29103. */
  29104. loadImageFromDB(url: string, image: HTMLImageElement): void;
  29105. private _loadImageFromDBAsync(url, image, notInDBCallback);
  29106. private _saveImageIntoDBAsync(url, image);
  29107. private _checkVersionFromDB(url, versionLoaded);
  29108. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  29109. private _saveVersionIntoDBAsync(url, callback);
  29110. /**
  29111. * Loads a file from database
  29112. * @param url defines the URL to load from
  29113. * @param sceneLoaded defines a callback to call on success
  29114. * @param progressCallBack defines a callback to call when progress changed
  29115. * @param errorCallback defines a callback to call on error
  29116. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  29117. */
  29118. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  29119. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  29120. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?, errorCallback?);
  29121. }
  29122. }
  29123. declare module BABYLON {
  29124. interface DDSInfo {
  29125. width: number;
  29126. height: number;
  29127. mipmapCount: number;
  29128. isFourCC: boolean;
  29129. isRGB: boolean;
  29130. isLuminance: boolean;
  29131. isCube: boolean;
  29132. isCompressed: boolean;
  29133. dxgiFormat: number;
  29134. textureType: number;
  29135. /** Sphericle polynomial created for the dds texture */
  29136. sphericalPolynomial?: SphericalPolynomial;
  29137. }
  29138. class DDSTools {
  29139. static StoreLODInAlphaChannel: boolean;
  29140. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  29141. private static _FloatView;
  29142. private static _Int32View;
  29143. private static _ToHalfFloat(value);
  29144. private static _FromHalfFloat(value);
  29145. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29146. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29147. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29148. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29149. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29150. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  29151. private static _ExtractLongWordOrder(value);
  29152. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  29153. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  29154. /**
  29155. * Uploads DDS Levels to a Babylon Texture
  29156. * @hidden
  29157. */
  29158. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  29159. }
  29160. }
  29161. declare module BABYLON {
  29162. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29163. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29164. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29165. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29166. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29167. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29168. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29169. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29170. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29171. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29172. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29173. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29174. /**
  29175. * Decorator used to define property that can be serialized as reference to a camera
  29176. * @param sourceName defines the name of the property to decorate
  29177. */
  29178. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29179. class SerializationHelper {
  29180. static Serialize<T>(entity: T, serializationObject?: any): any;
  29181. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29182. static Clone<T>(creationFunction: () => T, source: T): T;
  29183. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29184. }
  29185. }
  29186. declare module BABYLON {
  29187. /**
  29188. * Wrapper class for promise with external resolve and reject.
  29189. */
  29190. class Deferred<T> {
  29191. /**
  29192. * The promise associated with this deferred object.
  29193. */
  29194. readonly promise: Promise<T>;
  29195. private _resolve;
  29196. private _reject;
  29197. /**
  29198. * The resolve method of the promise associated with this deferred object.
  29199. */
  29200. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  29201. /**
  29202. * The reject method of the promise associated with this deferred object.
  29203. */
  29204. readonly reject: (reason?: any) => void;
  29205. /**
  29206. * Constructor for this deferred object.
  29207. */
  29208. constructor();
  29209. }
  29210. }
  29211. declare module BABYLON {
  29212. /**
  29213. * Raw texture data and descriptor sufficient for WebGL texture upload
  29214. */
  29215. interface EnvironmentTextureInfo {
  29216. /**
  29217. * Version of the environment map
  29218. */
  29219. version: number;
  29220. /**
  29221. * Width of image
  29222. */
  29223. width: number;
  29224. /**
  29225. * Irradiance information stored in the file.
  29226. */
  29227. irradiance: any;
  29228. /**
  29229. * Specular information stored in the file.
  29230. */
  29231. specular: any;
  29232. }
  29233. /**
  29234. * Sets of helpers addressing the serialization and deserialization of environment texture
  29235. * stored in a BabylonJS env file.
  29236. * Those files are usually stored as .env files.
  29237. */
  29238. class EnvironmentTextureTools {
  29239. /**
  29240. * Magic number identifying the env file.
  29241. */
  29242. private static _MagicBytes;
  29243. /**
  29244. * Gets the environment info from an env file.
  29245. * @param data The array buffer containing the .env bytes.
  29246. * @returns the environment file info (the json header) if successfully parsed.
  29247. */
  29248. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  29249. /**
  29250. * Creates an environment texture from a loaded cube texture.
  29251. * @param texture defines the cube texture to convert in env file
  29252. * @return a promise containing the environment data if succesfull.
  29253. */
  29254. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  29255. /**
  29256. * Creates a JSON representation of the spherical data.
  29257. * @param texture defines the texture containing the polynomials
  29258. * @return the JSON representation of the spherical info
  29259. */
  29260. private static _CreateEnvTextureIrradiance(texture);
  29261. /**
  29262. * Uploads the texture info contained in the env file to the GPU.
  29263. * @param texture defines the internal texture to upload to
  29264. * @param arrayBuffer defines the buffer cotaining the data to load
  29265. * @param info defines the texture info retrieved through the GetEnvInfo method
  29266. * @returns a promise
  29267. */
  29268. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  29269. /**
  29270. * Uploads the levels of image data to the GPU.
  29271. * @param texture defines the internal texture to upload to
  29272. * @param imageData defines the array buffer views of image data [mipmap][face]
  29273. * @returns a promise
  29274. */
  29275. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  29276. /**
  29277. * Uploads spherical polynomials information to the texture.
  29278. * @param texture defines the texture we are trying to upload the information to
  29279. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  29280. */
  29281. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  29282. }
  29283. }
  29284. declare module BABYLON {
  29285. class FilesInput {
  29286. static FilesToLoad: {
  29287. [key: string]: File;
  29288. };
  29289. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  29290. private _engine;
  29291. private _currentScene;
  29292. private _sceneLoadedCallback;
  29293. private _progressCallback;
  29294. private _additionalRenderLoopLogicCallback;
  29295. private _textureLoadingCallback;
  29296. private _startingProcessingFilesCallback;
  29297. private _onReloadCallback;
  29298. private _errorCallback;
  29299. private _elementToMonitor;
  29300. private _sceneFileToLoad;
  29301. private _filesToLoad;
  29302. 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);
  29303. private _dragEnterHandler;
  29304. private _dragOverHandler;
  29305. private _dropHandler;
  29306. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  29307. dispose(): void;
  29308. private renderFunction();
  29309. private drag(e);
  29310. private drop(eventDrop);
  29311. private _traverseFolder(folder, files, remaining, callback);
  29312. private _processFiles(files);
  29313. loadFiles(event: any): void;
  29314. private _processReload();
  29315. reload(): void;
  29316. }
  29317. }
  29318. declare module BABYLON {
  29319. /**
  29320. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29321. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29322. */
  29323. class KhronosTextureContainer {
  29324. arrayBuffer: any;
  29325. static HEADER_LEN: number;
  29326. static COMPRESSED_2D: number;
  29327. static COMPRESSED_3D: number;
  29328. static TEX_2D: number;
  29329. static TEX_3D: number;
  29330. glType: number;
  29331. glTypeSize: number;
  29332. glFormat: number;
  29333. glInternalFormat: number;
  29334. glBaseInternalFormat: number;
  29335. pixelWidth: number;
  29336. pixelHeight: number;
  29337. pixelDepth: number;
  29338. numberOfArrayElements: number;
  29339. numberOfFaces: number;
  29340. numberOfMipmapLevels: number;
  29341. bytesOfKeyValueData: number;
  29342. loadType: number;
  29343. /**
  29344. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  29345. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  29346. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  29347. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  29348. */
  29349. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  29350. switchEndainness(val: number): number;
  29351. /**
  29352. * Uploads KTX content to a Babylon Texture.
  29353. * It is assumed that the texture has already been created & is currently bound
  29354. * @hidden
  29355. */
  29356. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  29357. private _upload2DCompressedLevels(texture, loadMipmaps);
  29358. }
  29359. }
  29360. declare module BABYLON {
  29361. /**
  29362. * A class serves as a medium between the observable and its observers
  29363. */
  29364. class EventState {
  29365. /**
  29366. * Create a new EventState
  29367. * @param mask defines the mask associated with this state
  29368. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  29369. * @param target defines the original target of the state
  29370. * @param currentTarget defines the current target of the state
  29371. */
  29372. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  29373. /**
  29374. * Initialize the current event state
  29375. * @param mask defines the mask associated with this state
  29376. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  29377. * @param target defines the original target of the state
  29378. * @param currentTarget defines the current target of the state
  29379. * @returns the current event state
  29380. */
  29381. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  29382. /**
  29383. * An Observer can set this property to true to prevent subsequent observers of being notified
  29384. */
  29385. skipNextObservers: boolean;
  29386. /**
  29387. * Get the mask value that were used to trigger the event corresponding to this EventState object
  29388. */
  29389. mask: number;
  29390. /**
  29391. * The object that originally notified the event
  29392. */
  29393. target?: any;
  29394. /**
  29395. * The current object in the bubbling phase
  29396. */
  29397. currentTarget?: any;
  29398. /**
  29399. * This will be populated with the return value of the last function that was executed.
  29400. * If it is the first function in the callback chain it will be the event data.
  29401. */
  29402. lastReturnValue?: any;
  29403. }
  29404. /**
  29405. * Represent an Observer registered to a given Observable object.
  29406. */
  29407. class Observer<T> {
  29408. /**
  29409. * Defines the callback to call when the observer is notified
  29410. */
  29411. callback: (eventData: T, eventState: EventState) => void;
  29412. /**
  29413. * Defines the mask of the observer (used to filter notifications)
  29414. */
  29415. mask: number;
  29416. /**
  29417. * Defines the current scope used to restore the JS context
  29418. */
  29419. scope: any;
  29420. /** @hidden */
  29421. _willBeUnregistered: boolean;
  29422. /**
  29423. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  29424. */
  29425. unregisterOnNextCall: boolean;
  29426. /**
  29427. * Creates a new observer
  29428. * @param callback defines the callback to call when the observer is notified
  29429. * @param mask defines the mask of the observer (used to filter notifications)
  29430. * @param scope defines the current scope used to restore the JS context
  29431. */
  29432. constructor(
  29433. /**
  29434. * Defines the callback to call when the observer is notified
  29435. */
  29436. callback: (eventData: T, eventState: EventState) => void,
  29437. /**
  29438. * Defines the mask of the observer (used to filter notifications)
  29439. */
  29440. mask: number,
  29441. /**
  29442. * Defines the current scope used to restore the JS context
  29443. */
  29444. scope?: any);
  29445. }
  29446. /**
  29447. * Represent a list of observers registered to multiple Observables object.
  29448. */
  29449. class MultiObserver<T> {
  29450. private _observers;
  29451. private _observables;
  29452. /**
  29453. * Release associated resources
  29454. */
  29455. dispose(): void;
  29456. /**
  29457. * Raise a callback when one of the observable will notify
  29458. * @param observables defines a list of observables to watch
  29459. * @param callback defines the callback to call on notification
  29460. * @param mask defines the mask used to filter notifications
  29461. * @param scope defines the current scope used to restore the JS context
  29462. * @returns the new MultiObserver
  29463. */
  29464. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  29465. }
  29466. /**
  29467. * The Observable class is a simple implementation of the Observable pattern.
  29468. *
  29469. * 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.
  29470. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  29471. * 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).
  29472. * 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.
  29473. */
  29474. class Observable<T> {
  29475. private _observers;
  29476. private _eventState;
  29477. private _onObserverAdded;
  29478. /**
  29479. * Creates a new observable
  29480. * @param onObserverAdded defines a callback to call when a new observer is added
  29481. */
  29482. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  29483. /**
  29484. * Create a new Observer with the specified callback
  29485. * @param callback the callback that will be executed for that Observer
  29486. * @param mask the mask used to filter observers
  29487. * @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.
  29488. * @param scope optional scope for the callback to be called from
  29489. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  29490. * @returns the new observer created for the callback
  29491. */
  29492. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  29493. /**
  29494. * Create a new Observer with the specified callback and unregisters after the next notification
  29495. * @param callback the callback that will be executed for that Observer
  29496. * @returns the new observer created for the callback
  29497. */
  29498. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  29499. /**
  29500. * Remove an Observer from the Observable object
  29501. * @param observer the instance of the Observer to remove
  29502. * @returns false if it doesn't belong to this Observable
  29503. */
  29504. remove(observer: Nullable<Observer<T>>): boolean;
  29505. /**
  29506. * Remove a callback from the Observable object
  29507. * @param callback the callback to remove
  29508. * @param scope optional scope. If used only the callbacks with this scope will be removed
  29509. * @returns false if it doesn't belong to this Observable
  29510. */
  29511. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  29512. private _deferUnregister(observer);
  29513. private _remove(observer);
  29514. /**
  29515. * Notify all Observers by calling their respective callback with the given data
  29516. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  29517. * @param eventData defines the data to send to all observers
  29518. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  29519. * @param target defines the original target of the state
  29520. * @param currentTarget defines the current target of the state
  29521. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  29522. */
  29523. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  29524. /**
  29525. * Calling this will execute each callback, expecting it to be a promise or return a value.
  29526. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  29527. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  29528. * and it is crucial that all callbacks will be executed.
  29529. * The order of the callbacks is kept, callbacks are not executed parallel.
  29530. *
  29531. * @param eventData The data to be sent to each callback
  29532. * @param mask is used to filter observers defaults to -1
  29533. * @param target defines the callback target (see EventState)
  29534. * @param currentTarget defines he current object in the bubbling phase
  29535. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  29536. */
  29537. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  29538. /**
  29539. * Notify a specific observer
  29540. * @param observer defines the observer to notify
  29541. * @param eventData defines the data to be sent to each callback
  29542. * @param mask is used to filter observers defaults to -1
  29543. */
  29544. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  29545. /**
  29546. * Gets a boolean indicating if the observable has at least one observer
  29547. * @returns true is the Observable has at least one Observer registered
  29548. */
  29549. hasObservers(): boolean;
  29550. /**
  29551. * Clear the list of observers
  29552. */
  29553. clear(): void;
  29554. /**
  29555. * Clone the current observable
  29556. * @returns a new observable
  29557. */
  29558. clone(): Observable<T>;
  29559. /**
  29560. * Does this observable handles observer registered with a given mask
  29561. * @param mask defines the mask to be tested
  29562. * @return whether or not one observer registered with the given mask is handeled
  29563. **/
  29564. hasSpecificMask(mask?: number): boolean;
  29565. }
  29566. }
  29567. declare module BABYLON {
  29568. /**
  29569. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  29570. */
  29571. class PerformanceMonitor {
  29572. private _enabled;
  29573. private _rollingFrameTime;
  29574. private _lastFrameTimeMs;
  29575. /**
  29576. * constructor
  29577. * @param frameSampleSize The number of samples required to saturate the sliding window
  29578. */
  29579. constructor(frameSampleSize?: number);
  29580. /**
  29581. * Samples current frame
  29582. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  29583. */
  29584. sampleFrame(timeMs?: number): void;
  29585. /**
  29586. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  29587. * @return Average frame time in milliseconds
  29588. */
  29589. readonly averageFrameTime: number;
  29590. /**
  29591. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  29592. * @return Frame time variance in milliseconds squared
  29593. */
  29594. readonly averageFrameTimeVariance: number;
  29595. /**
  29596. * Returns the frame time of the most recent frame
  29597. * @return Frame time in milliseconds
  29598. */
  29599. readonly instantaneousFrameTime: number;
  29600. /**
  29601. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  29602. * @return Framerate in frames per second
  29603. */
  29604. readonly averageFPS: number;
  29605. /**
  29606. * Returns the average framerate in frames per second using the most recent frame time
  29607. * @return Framerate in frames per second
  29608. */
  29609. readonly instantaneousFPS: number;
  29610. /**
  29611. * Returns true if enough samples have been taken to completely fill the sliding window
  29612. * @return true if saturated
  29613. */
  29614. readonly isSaturated: boolean;
  29615. /**
  29616. * Enables contributions to the sliding window sample set
  29617. */
  29618. enable(): void;
  29619. /**
  29620. * Disables contributions to the sliding window sample set
  29621. * Samples will not be interpolated over the disabled period
  29622. */
  29623. disable(): void;
  29624. /**
  29625. * Returns true if sampling is enabled
  29626. * @return true if enabled
  29627. */
  29628. readonly isEnabled: boolean;
  29629. /**
  29630. * Resets performance monitor
  29631. */
  29632. reset(): void;
  29633. }
  29634. /**
  29635. * RollingAverage
  29636. *
  29637. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  29638. */
  29639. class RollingAverage {
  29640. /**
  29641. * Current average
  29642. */
  29643. average: number;
  29644. /**
  29645. * Current variance
  29646. */
  29647. variance: number;
  29648. protected _samples: Array<number>;
  29649. protected _sampleCount: number;
  29650. protected _pos: number;
  29651. protected _m2: number;
  29652. /**
  29653. * constructor
  29654. * @param length The number of samples required to saturate the sliding window
  29655. */
  29656. constructor(length: number);
  29657. /**
  29658. * Adds a sample to the sample set
  29659. * @param v The sample value
  29660. */
  29661. add(v: number): void;
  29662. /**
  29663. * Returns previously added values or null if outside of history or outside the sliding window domain
  29664. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  29665. * @return Value previously recorded with add() or null if outside of range
  29666. */
  29667. history(i: number): number;
  29668. /**
  29669. * Returns true if enough samples have been taken to completely fill the sliding window
  29670. * @return true if sample-set saturated
  29671. */
  29672. isSaturated(): boolean;
  29673. /**
  29674. * Resets the rolling average (equivalent to 0 samples taken so far)
  29675. */
  29676. reset(): void;
  29677. /**
  29678. * Wraps a value around the sample range boundaries
  29679. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  29680. * @return Wrapped position in sample range
  29681. */
  29682. protected _wrapPosition(i: number): number;
  29683. }
  29684. }
  29685. declare module BABYLON {
  29686. /**
  29687. * Helper class that provides a small promise polyfill
  29688. */
  29689. class PromisePolyfill {
  29690. /**
  29691. * Static function used to check if the polyfill is required
  29692. * If this is the case then the function will inject the polyfill to window.Promise
  29693. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  29694. */
  29695. static Apply(force?: boolean): void;
  29696. }
  29697. }
  29698. declare module BABYLON {
  29699. /**
  29700. * Defines the root class used to create scene optimization to use with SceneOptimizer
  29701. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29702. */
  29703. class SceneOptimization {
  29704. /**
  29705. * Defines the priority of this optimization (0 by default which means first in the list)
  29706. */
  29707. priority: number;
  29708. /**
  29709. * Gets a string describing the action executed by the current optimization
  29710. * @returns description string
  29711. */
  29712. getDescription(): string;
  29713. /**
  29714. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29715. * @param scene defines the current scene where to apply this optimization
  29716. * @param optimizer defines the current optimizer
  29717. * @returns true if everything that can be done was applied
  29718. */
  29719. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29720. /**
  29721. * Creates the SceneOptimization object
  29722. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29723. * @param desc defines the description associated with the optimization
  29724. */
  29725. constructor(
  29726. /**
  29727. * Defines the priority of this optimization (0 by default which means first in the list)
  29728. */
  29729. priority?: number);
  29730. }
  29731. /**
  29732. * Defines an optimization used to reduce the size of render target textures
  29733. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29734. */
  29735. class TextureOptimization extends SceneOptimization {
  29736. /**
  29737. * Defines the priority of this optimization (0 by default which means first in the list)
  29738. */
  29739. priority: number;
  29740. /**
  29741. * 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
  29742. */
  29743. maximumSize: number;
  29744. /**
  29745. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29746. */
  29747. step: number;
  29748. /**
  29749. * Gets a string describing the action executed by the current optimization
  29750. * @returns description string
  29751. */
  29752. getDescription(): string;
  29753. /**
  29754. * Creates the TextureOptimization object
  29755. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29756. * @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
  29757. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29758. */
  29759. constructor(
  29760. /**
  29761. * Defines the priority of this optimization (0 by default which means first in the list)
  29762. */
  29763. priority?: number,
  29764. /**
  29765. * 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
  29766. */
  29767. maximumSize?: number,
  29768. /**
  29769. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29770. */
  29771. step?: number);
  29772. /**
  29773. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29774. * @param scene defines the current scene where to apply this optimization
  29775. * @param optimizer defines the current optimizer
  29776. * @returns true if everything that can be done was applied
  29777. */
  29778. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29779. }
  29780. /**
  29781. * Defines an optimization used to increase or decrease the rendering resolution
  29782. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29783. */
  29784. class HardwareScalingOptimization extends SceneOptimization {
  29785. /**
  29786. * Defines the priority of this optimization (0 by default which means first in the list)
  29787. */
  29788. priority: number;
  29789. /**
  29790. * Defines the maximum scale to use (2 by default)
  29791. */
  29792. maximumScale: number;
  29793. /**
  29794. * Defines the step to use between two passes (0.5 by default)
  29795. */
  29796. step: number;
  29797. private _currentScale;
  29798. private _directionOffset;
  29799. /**
  29800. * Gets a string describing the action executed by the current optimization
  29801. * @return description string
  29802. */
  29803. getDescription(): string;
  29804. /**
  29805. * Creates the HardwareScalingOptimization object
  29806. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29807. * @param maximumScale defines the maximum scale to use (2 by default)
  29808. * @param step defines the step to use between two passes (0.5 by default)
  29809. */
  29810. constructor(
  29811. /**
  29812. * Defines the priority of this optimization (0 by default which means first in the list)
  29813. */
  29814. priority?: number,
  29815. /**
  29816. * Defines the maximum scale to use (2 by default)
  29817. */
  29818. maximumScale?: number,
  29819. /**
  29820. * Defines the step to use between two passes (0.5 by default)
  29821. */
  29822. step?: number);
  29823. /**
  29824. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29825. * @param scene defines the current scene where to apply this optimization
  29826. * @param optimizer defines the current optimizer
  29827. * @returns true if everything that can be done was applied
  29828. */
  29829. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29830. }
  29831. /**
  29832. * Defines an optimization used to remove shadows
  29833. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29834. */
  29835. class ShadowsOptimization extends SceneOptimization {
  29836. /**
  29837. * Gets a string describing the action executed by the current optimization
  29838. * @return description string
  29839. */
  29840. getDescription(): string;
  29841. /**
  29842. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29843. * @param scene defines the current scene where to apply this optimization
  29844. * @param optimizer defines the current optimizer
  29845. * @returns true if everything that can be done was applied
  29846. */
  29847. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29848. }
  29849. /**
  29850. * Defines an optimization used to turn post-processes off
  29851. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29852. */
  29853. class PostProcessesOptimization extends SceneOptimization {
  29854. /**
  29855. * Gets a string describing the action executed by the current optimization
  29856. * @return description string
  29857. */
  29858. getDescription(): string;
  29859. /**
  29860. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29861. * @param scene defines the current scene where to apply this optimization
  29862. * @param optimizer defines the current optimizer
  29863. * @returns true if everything that can be done was applied
  29864. */
  29865. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29866. }
  29867. /**
  29868. * Defines an optimization used to turn lens flares off
  29869. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29870. */
  29871. class LensFlaresOptimization extends SceneOptimization {
  29872. /**
  29873. * Gets a string describing the action executed by the current optimization
  29874. * @return description string
  29875. */
  29876. getDescription(): string;
  29877. /**
  29878. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29879. * @param scene defines the current scene where to apply this optimization
  29880. * @param optimizer defines the current optimizer
  29881. * @returns true if everything that can be done was applied
  29882. */
  29883. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29884. }
  29885. /**
  29886. * Defines an optimization based on user defined callback.
  29887. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29888. */
  29889. class CustomOptimization extends SceneOptimization {
  29890. /**
  29891. * Callback called to apply the custom optimization.
  29892. */
  29893. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  29894. /**
  29895. * Callback called to get custom description
  29896. */
  29897. onGetDescription: () => string;
  29898. /**
  29899. * Gets a string describing the action executed by the current optimization
  29900. * @returns description string
  29901. */
  29902. getDescription(): string;
  29903. /**
  29904. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29905. * @param scene defines the current scene where to apply this optimization
  29906. * @param optimizer defines the current optimizer
  29907. * @returns true if everything that can be done was applied
  29908. */
  29909. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29910. }
  29911. /**
  29912. * Defines an optimization used to turn particles off
  29913. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29914. */
  29915. class ParticlesOptimization extends SceneOptimization {
  29916. /**
  29917. * Gets a string describing the action executed by the current optimization
  29918. * @return description string
  29919. */
  29920. getDescription(): string;
  29921. /**
  29922. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29923. * @param scene defines the current scene where to apply this optimization
  29924. * @param optimizer defines the current optimizer
  29925. * @returns true if everything that can be done was applied
  29926. */
  29927. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29928. }
  29929. /**
  29930. * Defines an optimization used to turn render targets off
  29931. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29932. */
  29933. class RenderTargetsOptimization extends SceneOptimization {
  29934. /**
  29935. * Gets a string describing the action executed by the current optimization
  29936. * @return description string
  29937. */
  29938. getDescription(): string;
  29939. /**
  29940. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29941. * @param scene defines the current scene where to apply this optimization
  29942. * @param optimizer defines the current optimizer
  29943. * @returns true if everything that can be done was applied
  29944. */
  29945. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29946. }
  29947. /**
  29948. * Defines an optimization used to merge meshes with compatible materials
  29949. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29950. */
  29951. class MergeMeshesOptimization extends SceneOptimization {
  29952. private static _UpdateSelectionTree;
  29953. /**
  29954. * Gets or sets a boolean which defines if optimization octree has to be updated
  29955. */
  29956. /**
  29957. * Gets or sets a boolean which defines if optimization octree has to be updated
  29958. */
  29959. static UpdateSelectionTree: boolean;
  29960. /**
  29961. * Gets a string describing the action executed by the current optimization
  29962. * @return description string
  29963. */
  29964. getDescription(): string;
  29965. private _canBeMerged;
  29966. /**
  29967. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29968. * @param scene defines the current scene where to apply this optimization
  29969. * @param optimizer defines the current optimizer
  29970. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  29971. * @returns true if everything that can be done was applied
  29972. */
  29973. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  29974. }
  29975. /**
  29976. * Defines a list of options used by SceneOptimizer
  29977. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29978. */
  29979. class SceneOptimizerOptions {
  29980. /**
  29981. * Defines the target frame rate to reach (60 by default)
  29982. */
  29983. targetFrameRate: number;
  29984. /**
  29985. * Defines the interval between two checkes (2000ms by default)
  29986. */
  29987. trackerDuration: number;
  29988. /**
  29989. * Gets the list of optimizations to apply
  29990. */
  29991. optimizations: SceneOptimization[];
  29992. /**
  29993. * Creates a new list of options used by SceneOptimizer
  29994. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  29995. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  29996. */
  29997. constructor(
  29998. /**
  29999. * Defines the target frame rate to reach (60 by default)
  30000. */
  30001. targetFrameRate?: number,
  30002. /**
  30003. * Defines the interval between two checkes (2000ms by default)
  30004. */
  30005. trackerDuration?: number);
  30006. /**
  30007. * Add a new optimization
  30008. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  30009. * @returns the current SceneOptimizerOptions
  30010. */
  30011. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  30012. /**
  30013. * Add a new custom optimization
  30014. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  30015. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  30016. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30017. * @returns the current SceneOptimizerOptions
  30018. */
  30019. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  30020. /**
  30021. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  30022. * @param targetFrameRate defines the target frame rate (60 by default)
  30023. * @returns a SceneOptimizerOptions object
  30024. */
  30025. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30026. /**
  30027. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  30028. * @param targetFrameRate defines the target frame rate (60 by default)
  30029. * @returns a SceneOptimizerOptions object
  30030. */
  30031. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30032. /**
  30033. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  30034. * @param targetFrameRate defines the target frame rate (60 by default)
  30035. * @returns a SceneOptimizerOptions object
  30036. */
  30037. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30038. }
  30039. /**
  30040. * Class used to run optimizations in order to reach a target frame rate
  30041. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30042. */
  30043. class SceneOptimizer implements IDisposable {
  30044. private _isRunning;
  30045. private _options;
  30046. private _scene;
  30047. private _currentPriorityLevel;
  30048. private _targetFrameRate;
  30049. private _trackerDuration;
  30050. private _currentFrameRate;
  30051. private _sceneDisposeObserver;
  30052. private _improvementMode;
  30053. /**
  30054. * Defines an observable called when the optimizer reaches the target frame rate
  30055. */
  30056. onSuccessObservable: Observable<SceneOptimizer>;
  30057. /**
  30058. * Defines an observable called when the optimizer enables an optimization
  30059. */
  30060. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  30061. /**
  30062. * Defines an observable called when the optimizer is not able to reach the target frame rate
  30063. */
  30064. onFailureObservable: Observable<SceneOptimizer>;
  30065. /**
  30066. * Gets a boolean indicating if the optimizer is in improvement mode
  30067. */
  30068. readonly isInImprovementMode: boolean;
  30069. /**
  30070. * Gets the current priority level (0 at start)
  30071. */
  30072. readonly currentPriorityLevel: number;
  30073. /**
  30074. * Gets the current frame rate checked by the SceneOptimizer
  30075. */
  30076. readonly currentFrameRate: number;
  30077. /**
  30078. * Gets or sets the current target frame rate (60 by default)
  30079. */
  30080. /**
  30081. * Gets or sets the current target frame rate (60 by default)
  30082. */
  30083. targetFrameRate: number;
  30084. /**
  30085. * Gets or sets the current interval between two checks (every 2000ms by default)
  30086. */
  30087. /**
  30088. * Gets or sets the current interval between two checks (every 2000ms by default)
  30089. */
  30090. trackerDuration: number;
  30091. /**
  30092. * Gets the list of active optimizations
  30093. */
  30094. readonly optimizations: SceneOptimization[];
  30095. /**
  30096. * Creates a new SceneOptimizer
  30097. * @param scene defines the scene to work on
  30098. * @param options defines the options to use with the SceneOptimizer
  30099. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  30100. * @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)
  30101. */
  30102. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  30103. /**
  30104. * Stops the current optimizer
  30105. */
  30106. stop(): void;
  30107. /**
  30108. * Reset the optimizer to initial step (current priority level = 0)
  30109. */
  30110. reset(): void;
  30111. /**
  30112. * Start the optimizer. By default it will try to reach a specific framerate
  30113. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  30114. */
  30115. start(): void;
  30116. private _checkCurrentState();
  30117. /**
  30118. * Release all resources
  30119. */
  30120. dispose(): void;
  30121. /**
  30122. * Helper function to create a SceneOptimizer with one single line of code
  30123. * @param scene defines the scene to work on
  30124. * @param options defines the options to use with the SceneOptimizer
  30125. * @param onSuccess defines a callback to call on success
  30126. * @param onFailure defines a callback to call on failure
  30127. * @returns the new SceneOptimizer object
  30128. */
  30129. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  30130. }
  30131. }
  30132. declare module BABYLON {
  30133. class SceneSerializer {
  30134. static ClearCache(): void;
  30135. static Serialize(scene: Scene): any;
  30136. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  30137. }
  30138. }
  30139. declare module BABYLON {
  30140. class SmartArray<T> {
  30141. data: Array<T>;
  30142. length: number;
  30143. protected _id: number;
  30144. [index: number]: T;
  30145. constructor(capacity: number);
  30146. push(value: T): void;
  30147. forEach(func: (content: T) => void): void;
  30148. sort(compareFn: (a: T, b: T) => number): void;
  30149. reset(): void;
  30150. dispose(): void;
  30151. concat(array: any): void;
  30152. indexOf(value: T): number;
  30153. contains(value: T): boolean;
  30154. private static _GlobalId;
  30155. }
  30156. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  30157. private _duplicateId;
  30158. [index: number]: T;
  30159. push(value: T): void;
  30160. pushNoDuplicate(value: T): boolean;
  30161. reset(): void;
  30162. concatWithNoDuplicate(array: any): void;
  30163. }
  30164. }
  30165. declare module BABYLON {
  30166. /**
  30167. * This class implement a typical dictionary using a string as key and the generic type T as value.
  30168. * The underlying implementation relies on an associative array to ensure the best performances.
  30169. * The value can be anything including 'null' but except 'undefined'
  30170. */
  30171. class StringDictionary<T> {
  30172. /**
  30173. * This will clear this dictionary and copy the content from the 'source' one.
  30174. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  30175. * @param source the dictionary to take the content from and copy to this dictionary
  30176. */
  30177. copyFrom(source: StringDictionary<T>): void;
  30178. /**
  30179. * Get a value based from its key
  30180. * @param key the given key to get the matching value from
  30181. * @return the value if found, otherwise undefined is returned
  30182. */
  30183. get(key: string): T | undefined;
  30184. /**
  30185. * Get a value from its key or add it if it doesn't exist.
  30186. * This method will ensure you that a given key/data will be present in the dictionary.
  30187. * @param key the given key to get the matching value from
  30188. * @param factory the factory that will create the value if the key is not present in the dictionary.
  30189. * The factory will only be invoked if there's no data for the given key.
  30190. * @return the value corresponding to the key.
  30191. */
  30192. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  30193. /**
  30194. * Get a value from its key if present in the dictionary otherwise add it
  30195. * @param key the key to get the value from
  30196. * @param val if there's no such key/value pair in the dictionary add it with this value
  30197. * @return the value corresponding to the key
  30198. */
  30199. getOrAdd(key: string, val: T): T;
  30200. /**
  30201. * Check if there's a given key in the dictionary
  30202. * @param key the key to check for
  30203. * @return true if the key is present, false otherwise
  30204. */
  30205. contains(key: string): boolean;
  30206. /**
  30207. * Add a new key and its corresponding value
  30208. * @param key the key to add
  30209. * @param value the value corresponding to the key
  30210. * @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
  30211. */
  30212. add(key: string, value: T): boolean;
  30213. set(key: string, value: T): boolean;
  30214. /**
  30215. * Get the element of the given key and remove it from the dictionary
  30216. * @param key
  30217. */
  30218. getAndRemove(key: string): Nullable<T>;
  30219. /**
  30220. * Remove a key/value from the dictionary.
  30221. * @param key the key to remove
  30222. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  30223. */
  30224. remove(key: string): boolean;
  30225. /**
  30226. * Clear the whole content of the dictionary
  30227. */
  30228. clear(): void;
  30229. readonly count: number;
  30230. /**
  30231. * Execute a callback on each key/val of the dictionary.
  30232. * Note that you can remove any element in this dictionary in the callback implementation
  30233. * @param callback the callback to execute on a given key/value pair
  30234. */
  30235. forEach(callback: (key: string, val: T) => void): void;
  30236. /**
  30237. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  30238. * If the callback returns null or undefined the method will iterate to the next key/value pair
  30239. * Note that you can remove any element in this dictionary in the callback implementation
  30240. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  30241. */
  30242. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  30243. private _count;
  30244. private _data;
  30245. }
  30246. }
  30247. declare module BABYLON {
  30248. class Tags {
  30249. static EnableFor(obj: any): void;
  30250. static DisableFor(obj: any): void;
  30251. static HasTags(obj: any): boolean;
  30252. static GetTags(obj: any, asString?: boolean): any;
  30253. static AddTagsTo(obj: any, tagsString: string): void;
  30254. static _AddTagTo(obj: any, tag: string): void;
  30255. static RemoveTagsFrom(obj: any, tagsString: string): void;
  30256. static _RemoveTagFrom(obj: any, tag: string): void;
  30257. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  30258. }
  30259. }
  30260. declare module BABYLON {
  30261. class TextureTools {
  30262. /**
  30263. * Uses the GPU to create a copy texture rescaled at a given size
  30264. * @param texture Texture to copy from
  30265. * @param width Desired width
  30266. * @param height Desired height
  30267. * @return Generated texture
  30268. */
  30269. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  30270. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  30271. private static _environmentBRDFBase64Texture;
  30272. }
  30273. }
  30274. declare module BABYLON {
  30275. class TGATools {
  30276. private static _TYPE_INDEXED;
  30277. private static _TYPE_RGB;
  30278. private static _TYPE_GREY;
  30279. private static _TYPE_RLE_INDEXED;
  30280. private static _TYPE_RLE_RGB;
  30281. private static _TYPE_RLE_GREY;
  30282. private static _ORIGIN_MASK;
  30283. private static _ORIGIN_SHIFT;
  30284. private static _ORIGIN_BL;
  30285. private static _ORIGIN_BR;
  30286. private static _ORIGIN_UL;
  30287. private static _ORIGIN_UR;
  30288. static GetTGAHeader(data: Uint8Array): any;
  30289. /**
  30290. * Uploads TGA content to a Babylon Texture
  30291. * @hidden
  30292. */
  30293. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  30294. 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;
  30295. 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;
  30296. 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;
  30297. 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;
  30298. 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;
  30299. 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;
  30300. }
  30301. }
  30302. declare module BABYLON {
  30303. interface IAnimatable {
  30304. animations: Array<Animation>;
  30305. }
  30306. /** Interface used by value gradients (color, factor, ...) */
  30307. interface IValueGradient {
  30308. /**
  30309. * Gets or sets the gradient value (between 0 and 1)
  30310. */
  30311. gradient: number;
  30312. }
  30313. /** Class used to store color gradient */
  30314. class ColorGradient implements IValueGradient {
  30315. /**
  30316. * Gets or sets the gradient value (between 0 and 1)
  30317. */
  30318. gradient: number;
  30319. /**
  30320. * Gets or sets first associated color
  30321. */
  30322. color1: Color4;
  30323. /**
  30324. * Gets or sets second associated color
  30325. */
  30326. color2?: Color4;
  30327. /**
  30328. * Will get a color picked randomly between color1 and color2.
  30329. * If color2 is undefined then color1 will be used
  30330. * @param result defines the target Color4 to store the result in
  30331. */
  30332. getColorToRef(result: Color4): void;
  30333. }
  30334. /** Class used to store factor gradient */
  30335. class FactorGradient implements IValueGradient {
  30336. /**
  30337. * Gets or sets the gradient value (between 0 and 1)
  30338. */
  30339. gradient: number;
  30340. /**
  30341. * Gets or sets first associated factor
  30342. */
  30343. factor1: number;
  30344. /**
  30345. * Gets or sets second associated factor
  30346. */
  30347. factor2?: number;
  30348. /**
  30349. * Will get a number picked randomly between factor1 and factor2.
  30350. * If factor2 is undefined then factor1 will be used
  30351. * @returns the picked number
  30352. */
  30353. getFactor(): number;
  30354. }
  30355. class LoadFileError extends Error {
  30356. request: XMLHttpRequest | undefined;
  30357. private static _setPrototypeOf;
  30358. constructor(message: string, request?: XMLHttpRequest | undefined);
  30359. }
  30360. class RetryStrategy {
  30361. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30362. }
  30363. interface IFileRequest {
  30364. /**
  30365. * Raised when the request is complete (success or error).
  30366. */
  30367. onCompleteObservable: Observable<IFileRequest>;
  30368. /**
  30369. * Aborts the request for a file.
  30370. */
  30371. abort: () => void;
  30372. }
  30373. class Tools {
  30374. static BaseUrl: string;
  30375. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30376. /**
  30377. * Default behaviour for cors in the application.
  30378. * It can be a string if the expected behavior is identical in the entire app.
  30379. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30380. */
  30381. static CorsBehavior: string | ((url: string | string[]) => string);
  30382. static UseFallbackTexture: boolean;
  30383. /**
  30384. * Use this object to register external classes like custom textures or material
  30385. * to allow the laoders to instantiate them
  30386. */
  30387. static RegisteredExternalClasses: {
  30388. [key: string]: Object;
  30389. };
  30390. static fallbackTexture: string;
  30391. /**
  30392. * Interpolates between a and b via alpha
  30393. * @param a The lower value (returned when alpha = 0)
  30394. * @param b The upper value (returned when alpha = 1)
  30395. * @param alpha The interpolation-factor
  30396. * @return The mixed value
  30397. */
  30398. static Mix(a: number, b: number, alpha: number): number;
  30399. static Instantiate(className: string): any;
  30400. /**
  30401. * Provides a slice function that will work even on IE
  30402. * @param data defines the array to slice
  30403. * @param start defines the start of the data (optional)
  30404. * @param end defines the end of the data (optional)
  30405. * @returns the new sliced array
  30406. */
  30407. static Slice<T>(data: T, start?: number, end?: number): T;
  30408. static SetImmediate(action: () => void): void;
  30409. static IsExponentOfTwo(value: number): boolean;
  30410. private static _tmpFloatArray;
  30411. /**
  30412. * Returns the nearest 32-bit single precision float representation of a Number
  30413. * @param value A Number. If the parameter is of a different type, it will get converted
  30414. * to a number or to NaN if it cannot be converted
  30415. * @returns number
  30416. */
  30417. static FloatRound(value: number): number;
  30418. /**
  30419. * Find the next highest power of two.
  30420. * @param x Number to start search from.
  30421. * @return Next highest power of two.
  30422. */
  30423. static CeilingPOT(x: number): number;
  30424. /**
  30425. * Find the next lowest power of two.
  30426. * @param x Number to start search from.
  30427. * @return Next lowest power of two.
  30428. */
  30429. static FloorPOT(x: number): number;
  30430. /**
  30431. * Find the nearest power of two.
  30432. * @param x Number to start search from.
  30433. * @return Next nearest power of two.
  30434. */
  30435. static NearestPOT(x: number): number;
  30436. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30437. static GetFilename(path: string): string;
  30438. /**
  30439. * Extracts the "folder" part of a path (everything before the filename).
  30440. * @param uri The URI to extract the info from
  30441. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30442. * @returns The "folder" part of the path
  30443. */
  30444. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30445. static GetDOMTextContent(element: HTMLElement): string;
  30446. static ToDegrees(angle: number): number;
  30447. static ToRadians(angle: number): number;
  30448. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30449. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30450. minimum: Vector3;
  30451. maximum: Vector3;
  30452. };
  30453. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30454. minimum: Vector3;
  30455. maximum: Vector3;
  30456. };
  30457. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  30458. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  30459. minimum: Vector2;
  30460. maximum: Vector2;
  30461. };
  30462. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30463. static GetPointerPrefix(): string;
  30464. /**
  30465. * @param func - the function to be called
  30466. * @param requester - the object that will request the next frame. Falls back to window.
  30467. */
  30468. static QueueNewFrame(func: () => void, requester?: any): number;
  30469. static RequestFullscreen(element: HTMLElement): void;
  30470. static ExitFullscreen(): void;
  30471. static SetCorsBehavior(url: string | string[], element: {
  30472. crossOrigin: string | null;
  30473. }): void;
  30474. static CleanUrl(url: string): string;
  30475. static PreprocessUrl: (url: string) => string;
  30476. /**
  30477. * Loads an image as an HTMLImageElement.
  30478. * @param input url string, ArrayBuffer, or Blob to load
  30479. * @param onLoad callback called when the image successfully loads
  30480. * @param onError callback called when the image fails to load
  30481. * @param database database for caching
  30482. * @returns the HTMLImageElement of the loaded image
  30483. */
  30484. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  30485. 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;
  30486. /**
  30487. * Load a script (identified by an url). When the url returns, the
  30488. * content of this file is added into a new script element, attached to the DOM (body element)
  30489. */
  30490. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30491. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30492. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30493. static FileAsURL(content: string): string;
  30494. static Format(value: number, decimals?: number): string;
  30495. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30496. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30497. static IsEmpty(obj: any): boolean;
  30498. static RegisterTopRootEvents(events: {
  30499. name: string;
  30500. handler: Nullable<(e: FocusEvent) => any>;
  30501. }[]): void;
  30502. static UnregisterTopRootEvents(events: {
  30503. name: string;
  30504. handler: Nullable<(e: FocusEvent) => any>;
  30505. }[]): void;
  30506. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30507. /**
  30508. * Converts the canvas data to blob.
  30509. * This acts as a polyfill for browsers not supporting the to blob function.
  30510. * @param canvas Defines the canvas to extract the data from
  30511. * @param successCallback Defines the callback triggered once the data are available
  30512. * @param mimeType Defines the mime type of the result
  30513. */
  30514. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30515. /**
  30516. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30517. * @param successCallback Defines the callback triggered once the data are available
  30518. * @param mimeType Defines the mime type of the result
  30519. * @param fileName The filename to download. If present, the result will automatically be downloaded
  30520. */
  30521. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30522. /**
  30523. * Downloads a blob in the browser
  30524. * @param blob defines the blob to download
  30525. * @param fileName defines the name of the downloaded file
  30526. */
  30527. static Download(blob: Blob, fileName: string): void;
  30528. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30529. /**
  30530. * Generates an image screenshot from the specified camera.
  30531. *
  30532. * @param engine The engine to use for rendering
  30533. * @param camera The camera to use for rendering
  30534. * @param size This parameter can be set to a single number or to an object with the
  30535. * following (optional) properties: precision, width, height. If a single number is passed,
  30536. * it will be used for both width and height. If an object is passed, the screenshot size
  30537. * will be derived from the parameters. The precision property is a multiplier allowing
  30538. * rendering at a higher or lower resolution.
  30539. * @param successCallback The callback receives a single parameter which contains the
  30540. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30541. * src parameter of an <img> to display it.
  30542. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30543. * Check your browser for supported MIME types.
  30544. * @param samples Texture samples (default: 1)
  30545. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30546. * @param fileName A name for for the downloaded file.
  30547. * @constructor
  30548. */
  30549. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30550. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  30551. /**
  30552. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30553. * Be aware Math.random() could cause collisions, but:
  30554. * "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"
  30555. */
  30556. static RandomId(): string;
  30557. /**
  30558. * Test if the given uri is a base64 string.
  30559. * @param uri The uri to test
  30560. * @return True if the uri is a base64 string or false otherwise.
  30561. */
  30562. static IsBase64(uri: string): boolean;
  30563. /**
  30564. * Decode the given base64 uri.
  30565. * @param uri The uri to decode
  30566. * @return The decoded base64 data.
  30567. */
  30568. static DecodeBase64(uri: string): ArrayBuffer;
  30569. private static _NoneLogLevel;
  30570. private static _MessageLogLevel;
  30571. private static _WarningLogLevel;
  30572. private static _ErrorLogLevel;
  30573. private static _LogCache;
  30574. static errorsCount: number;
  30575. static OnNewCacheEntry: (entry: string) => void;
  30576. static readonly NoneLogLevel: number;
  30577. static readonly MessageLogLevel: number;
  30578. static readonly WarningLogLevel: number;
  30579. static readonly ErrorLogLevel: number;
  30580. static readonly AllLogLevel: number;
  30581. private static _AddLogEntry(entry);
  30582. private static _FormatMessage(message);
  30583. private static _LogDisabled(message);
  30584. private static _LogEnabled(message);
  30585. private static _WarnDisabled(message);
  30586. private static _WarnEnabled(message);
  30587. private static _ErrorDisabled(message);
  30588. private static _ErrorEnabled(message);
  30589. static Log: (message: string) => void;
  30590. static Warn: (message: string) => void;
  30591. static Error: (message: string) => void;
  30592. static readonly LogCache: string;
  30593. static ClearLogCache(): void;
  30594. static LogLevels: number;
  30595. static IsWindowObjectExist(): boolean;
  30596. private static _PerformanceNoneLogLevel;
  30597. private static _PerformanceUserMarkLogLevel;
  30598. private static _PerformanceConsoleLogLevel;
  30599. private static _performance;
  30600. static readonly PerformanceNoneLogLevel: number;
  30601. static readonly PerformanceUserMarkLogLevel: number;
  30602. static readonly PerformanceConsoleLogLevel: number;
  30603. static PerformanceLogLevel: number;
  30604. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  30605. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  30606. static _StartUserMark(counterName: string, condition?: boolean): void;
  30607. static _EndUserMark(counterName: string, condition?: boolean): void;
  30608. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  30609. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  30610. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30611. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30612. static readonly Now: number;
  30613. /**
  30614. * This method will return the name of the class used to create the instance of the given object.
  30615. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30616. * @param object the object to get the class name from
  30617. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  30618. */
  30619. static GetClassName(object: any, isType?: boolean): string;
  30620. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30621. /**
  30622. * This method will return the name of the full name of the class, including its owning module (if any).
  30623. * 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).
  30624. * @param object the object to get the class name from
  30625. * @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.
  30626. */
  30627. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30628. /**
  30629. * 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.
  30630. * @param array
  30631. */
  30632. static arrayOrStringFeeder(array: any): (i: number) => number;
  30633. /**
  30634. * Compute the hashCode of a stream of number
  30635. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  30636. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  30637. * @return the hash code computed
  30638. */
  30639. static hashCodeFromStream(feeder: (index: number) => number): number;
  30640. /**
  30641. * Returns a promise that resolves after the given amount of time.
  30642. * @param delay Number of milliseconds to delay
  30643. * @returns Promise that resolves after the given amount of time
  30644. */
  30645. static DelayAsync(delay: number): Promise<void>;
  30646. /**
  30647. * Gets the current gradient from an array of IValueGradient
  30648. * @param ratio defines the current ratio to get
  30649. * @param gradients defines the array of IValueGradient
  30650. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30651. */
  30652. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30653. }
  30654. /**
  30655. * This class is used to track a performance counter which is number based.
  30656. * The user has access to many properties which give statistics of different nature
  30657. *
  30658. * The implementer can track two kinds of Performance Counter: time and count
  30659. * 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.
  30660. * 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.
  30661. */
  30662. class PerfCounter {
  30663. static Enabled: boolean;
  30664. /**
  30665. * Returns the smallest value ever
  30666. */
  30667. readonly min: number;
  30668. /**
  30669. * Returns the biggest value ever
  30670. */
  30671. readonly max: number;
  30672. /**
  30673. * Returns the average value since the performance counter is running
  30674. */
  30675. readonly average: number;
  30676. /**
  30677. * Returns the average value of the last second the counter was monitored
  30678. */
  30679. readonly lastSecAverage: number;
  30680. /**
  30681. * Returns the current value
  30682. */
  30683. readonly current: number;
  30684. readonly total: number;
  30685. readonly count: number;
  30686. constructor();
  30687. /**
  30688. * Call this method to start monitoring a new frame.
  30689. * 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.
  30690. */
  30691. fetchNewFrame(): void;
  30692. /**
  30693. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30694. * @param newCount the count value to add to the monitored count
  30695. * @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.
  30696. */
  30697. addCount(newCount: number, fetchResult: boolean): void;
  30698. /**
  30699. * Start monitoring this performance counter
  30700. */
  30701. beginMonitoring(): void;
  30702. /**
  30703. * Compute the time lapsed since the previous beginMonitoring() call.
  30704. * @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
  30705. */
  30706. endMonitoring(newFrame?: boolean): void;
  30707. private _fetchResult();
  30708. private _startMonitoringTime;
  30709. private _min;
  30710. private _max;
  30711. private _average;
  30712. private _current;
  30713. private _totalValueCount;
  30714. private _totalAccumulated;
  30715. private _lastSecAverage;
  30716. private _lastSecAccumulated;
  30717. private _lastSecTime;
  30718. private _lastSecValueCount;
  30719. }
  30720. /**
  30721. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30722. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30723. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30724. * @param name The name of the class, case should be preserved
  30725. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30726. */
  30727. function className(name: string, module?: string): (target: Object) => void;
  30728. /**
  30729. * An implementation of a loop for asynchronous functions.
  30730. */
  30731. class AsyncLoop {
  30732. iterations: number;
  30733. private _fn;
  30734. private _successCallback;
  30735. index: number;
  30736. private _done;
  30737. /**
  30738. * Constroctor.
  30739. * @param iterations the number of iterations.
  30740. * @param _fn the function to run each iteration
  30741. * @param _successCallback the callback that will be called upon succesful execution
  30742. * @param offset starting offset.
  30743. */
  30744. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  30745. /**
  30746. * Execute the next iteration. Must be called after the last iteration was finished.
  30747. */
  30748. executeNext(): void;
  30749. /**
  30750. * Break the loop and run the success callback.
  30751. */
  30752. breakLoop(): void;
  30753. /**
  30754. * Helper function
  30755. */
  30756. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  30757. /**
  30758. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30759. * @param iterations total number of iterations
  30760. * @param syncedIterations number of synchronous iterations in each async iteration.
  30761. * @param fn the function to call each iteration.
  30762. * @param callback a success call back that will be called when iterating stops.
  30763. * @param breakFunction a break condition (optional)
  30764. * @param timeout timeout settings for the setTimeout function. default - 0.
  30765. * @constructor
  30766. */
  30767. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  30768. }
  30769. }
  30770. declare module BABYLON {
  30771. /**
  30772. * Defines the potential axis of a Joystick
  30773. */
  30774. enum JoystickAxis {
  30775. /** X axis */
  30776. X = 0,
  30777. /** Y axis */
  30778. Y = 1,
  30779. /** Z axis */
  30780. Z = 2,
  30781. }
  30782. /**
  30783. * Class used to define virtual joystick (used in touch mode)
  30784. */
  30785. class VirtualJoystick {
  30786. /**
  30787. * Gets or sets a boolean indicating that left and right values must be inverted
  30788. */
  30789. reverseLeftRight: boolean;
  30790. /**
  30791. * Gets or sets a boolean indicating that up and down values must be inverted
  30792. */
  30793. reverseUpDown: boolean;
  30794. /**
  30795. * Gets the offset value for the position (ie. the change of the position value)
  30796. */
  30797. deltaPosition: Vector3;
  30798. /**
  30799. * Gets a boolean indicating if the virtual joystick was pressed
  30800. */
  30801. pressed: boolean;
  30802. private static _globalJoystickIndex;
  30803. private static vjCanvas;
  30804. private static vjCanvasContext;
  30805. private static vjCanvasWidth;
  30806. private static vjCanvasHeight;
  30807. private static halfWidth;
  30808. private _action;
  30809. private _axisTargetedByLeftAndRight;
  30810. private _axisTargetedByUpAndDown;
  30811. private _joystickSensibility;
  30812. private _inversedSensibility;
  30813. private _joystickPointerID;
  30814. private _joystickColor;
  30815. private _joystickPointerPos;
  30816. private _joystickPreviousPointerPos;
  30817. private _joystickPointerStartPos;
  30818. private _deltaJoystickVector;
  30819. private _leftJoystick;
  30820. private _touches;
  30821. private _onPointerDownHandlerRef;
  30822. private _onPointerMoveHandlerRef;
  30823. private _onPointerUpHandlerRef;
  30824. private _onResize;
  30825. /**
  30826. * Creates a new virtual joystick
  30827. * @param leftJoystick defines that the joystick is for left hand (false by default)
  30828. */
  30829. constructor(leftJoystick?: boolean);
  30830. /**
  30831. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  30832. * @param newJoystickSensibility defines the new sensibility
  30833. */
  30834. setJoystickSensibility(newJoystickSensibility: number): void;
  30835. private _onPointerDown(e);
  30836. private _onPointerMove(e);
  30837. private _onPointerUp(e);
  30838. /**
  30839. * Change the color of the virtual joystick
  30840. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  30841. */
  30842. setJoystickColor(newColor: string): void;
  30843. /**
  30844. * Defines a callback to call when the joystick is touched
  30845. * @param action defines the callback
  30846. */
  30847. setActionOnTouch(action: () => any): void;
  30848. /**
  30849. * Defines which axis you'd like to control for left & right
  30850. * @param axis defines the axis to use
  30851. */
  30852. setAxisForLeftRight(axis: JoystickAxis): void;
  30853. /**
  30854. * Defines which axis you'd like to control for up & down
  30855. * @param axis defines the axis to use
  30856. */
  30857. setAxisForUpDown(axis: JoystickAxis): void;
  30858. private _drawVirtualJoystick();
  30859. /**
  30860. * Release internal HTML canvas
  30861. */
  30862. releaseCanvas(): void;
  30863. }
  30864. }
  30865. declare module BABYLON {
  30866. /**
  30867. * Helper class to push actions to a pool of workers.
  30868. */
  30869. class WorkerPool implements IDisposable {
  30870. private _workerInfos;
  30871. private _pendingActions;
  30872. /**
  30873. * Constructor
  30874. * @param workers Array of workers to use for actions
  30875. */
  30876. constructor(workers: Array<Worker>);
  30877. /**
  30878. * Terminates all workers and clears any pending actions.
  30879. */
  30880. dispose(): void;
  30881. /**
  30882. * Pushes an action to the worker pool. If all the workers are active, the action will be
  30883. * pended until a worker has completed its action.
  30884. * @param action The action to perform. Call onComplete when the action is complete.
  30885. */
  30886. push(action: (worker: Worker, onComplete: () => void) => void): void;
  30887. private _execute(workerInfo, action);
  30888. }
  30889. }
  30890. declare module BABYLON {
  30891. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  30892. readonly name: string;
  30893. private _zoomStopsAnimation;
  30894. private _idleRotationSpeed;
  30895. private _idleRotationWaitTime;
  30896. private _idleRotationSpinupTime;
  30897. /**
  30898. * Gets the flag that indicates if user zooming should stop animation.
  30899. */
  30900. /**
  30901. * Sets the flag that indicates if user zooming should stop animation.
  30902. */
  30903. zoomStopsAnimation: boolean;
  30904. /**
  30905. * Gets the default speed at which the camera rotates around the model.
  30906. */
  30907. /**
  30908. * Sets the default speed at which the camera rotates around the model.
  30909. */
  30910. idleRotationSpeed: number;
  30911. /**
  30912. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  30913. */
  30914. /**
  30915. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  30916. */
  30917. idleRotationWaitTime: number;
  30918. /**
  30919. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  30920. */
  30921. /**
  30922. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  30923. */
  30924. idleRotationSpinupTime: number;
  30925. /**
  30926. * Gets a value indicating if the camera is currently rotating because of this behavior
  30927. */
  30928. readonly rotationInProgress: boolean;
  30929. private _onPrePointerObservableObserver;
  30930. private _onAfterCheckInputsObserver;
  30931. private _attachedCamera;
  30932. private _isPointerDown;
  30933. private _lastFrameTime;
  30934. private _lastInteractionTime;
  30935. private _cameraRotationSpeed;
  30936. init(): void;
  30937. attach(camera: ArcRotateCamera): void;
  30938. detach(): void;
  30939. /**
  30940. * Returns true if user is scrolling.
  30941. * @return true if user is scrolling.
  30942. */
  30943. private _userIsZooming();
  30944. private _lastFrameRadius;
  30945. private _shouldAnimationStopForInteraction();
  30946. /**
  30947. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  30948. */
  30949. private _applyUserInteraction();
  30950. private _userIsMoving();
  30951. }
  30952. }
  30953. declare module BABYLON {
  30954. /**
  30955. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  30956. */
  30957. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  30958. readonly name: string;
  30959. /**
  30960. * The easing function used by animations
  30961. */
  30962. static EasingFunction: BackEase;
  30963. /**
  30964. * The easing mode used by animations
  30965. */
  30966. static EasingMode: number;
  30967. /**
  30968. * The duration of the animation, in milliseconds
  30969. */
  30970. transitionDuration: number;
  30971. /**
  30972. * Length of the distance animated by the transition when lower radius is reached
  30973. */
  30974. lowerRadiusTransitionRange: number;
  30975. /**
  30976. * Length of the distance animated by the transition when upper radius is reached
  30977. */
  30978. upperRadiusTransitionRange: number;
  30979. private _autoTransitionRange;
  30980. /**
  30981. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  30982. */
  30983. /**
  30984. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  30985. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  30986. */
  30987. autoTransitionRange: boolean;
  30988. private _attachedCamera;
  30989. private _onAfterCheckInputsObserver;
  30990. private _onMeshTargetChangedObserver;
  30991. init(): void;
  30992. attach(camera: ArcRotateCamera): void;
  30993. detach(): void;
  30994. private _radiusIsAnimating;
  30995. private _radiusBounceTransition;
  30996. private _animatables;
  30997. private _cachedWheelPrecision;
  30998. /**
  30999. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  31000. * @param radiusLimit The limit to check against.
  31001. * @return Bool to indicate if at limit.
  31002. */
  31003. private _isRadiusAtLimit(radiusLimit);
  31004. /**
  31005. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  31006. * @param radiusDelta The delta by which to animate to. Can be negative.
  31007. */
  31008. private _applyBoundRadiusAnimation(radiusDelta);
  31009. /**
  31010. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  31011. */
  31012. protected _clearAnimationLocks(): void;
  31013. /**
  31014. * Stops and removes all animations that have been applied to the camera
  31015. */
  31016. stopAllAnimations(): void;
  31017. }
  31018. }
  31019. declare module BABYLON {
  31020. class FramingBehavior implements Behavior<ArcRotateCamera> {
  31021. readonly name: string;
  31022. private _mode;
  31023. private _radiusScale;
  31024. private _positionScale;
  31025. private _defaultElevation;
  31026. private _elevationReturnTime;
  31027. private _elevationReturnWaitTime;
  31028. private _zoomStopsAnimation;
  31029. private _framingTime;
  31030. /**
  31031. * The easing function used by animations
  31032. */
  31033. static EasingFunction: ExponentialEase;
  31034. /**
  31035. * The easing mode used by animations
  31036. */
  31037. static EasingMode: number;
  31038. /**
  31039. * Gets current mode used by the behavior.
  31040. */
  31041. /**
  31042. * Sets the current mode used by the behavior
  31043. */
  31044. mode: number;
  31045. /**
  31046. * Gets the scale applied to the radius
  31047. */
  31048. /**
  31049. * Sets the scale applied to the radius (1 by default)
  31050. */
  31051. radiusScale: number;
  31052. /**
  31053. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  31054. */
  31055. /**
  31056. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  31057. */
  31058. positionScale: number;
  31059. /**
  31060. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  31061. * behaviour is triggered, in radians.
  31062. */
  31063. /**
  31064. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  31065. * behaviour is triggered, in radians.
  31066. */
  31067. defaultElevation: number;
  31068. /**
  31069. * Gets the time (in milliseconds) taken to return to the default beta position.
  31070. * Negative value indicates camera should not return to default.
  31071. */
  31072. /**
  31073. * Sets the time (in milliseconds) taken to return to the default beta position.
  31074. * Negative value indicates camera should not return to default.
  31075. */
  31076. elevationReturnTime: number;
  31077. /**
  31078. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  31079. */
  31080. /**
  31081. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  31082. */
  31083. elevationReturnWaitTime: number;
  31084. /**
  31085. * Gets the flag that indicates if user zooming should stop animation.
  31086. */
  31087. /**
  31088. * Sets the flag that indicates if user zooming should stop animation.
  31089. */
  31090. zoomStopsAnimation: boolean;
  31091. /**
  31092. * Gets the transition time when framing the mesh, in milliseconds
  31093. */
  31094. /**
  31095. * Sets the transition time when framing the mesh, in milliseconds
  31096. */
  31097. framingTime: number;
  31098. private _onPrePointerObservableObserver;
  31099. private _onAfterCheckInputsObserver;
  31100. private _onMeshTargetChangedObserver;
  31101. private _attachedCamera;
  31102. private _isPointerDown;
  31103. private _lastInteractionTime;
  31104. init(): void;
  31105. attach(camera: ArcRotateCamera): void;
  31106. detach(): void;
  31107. private _animatables;
  31108. private _betaIsAnimating;
  31109. private _betaTransition;
  31110. private _radiusTransition;
  31111. private _vectorTransition;
  31112. /**
  31113. * Targets the given mesh and updates zoom level accordingly.
  31114. * @param mesh The mesh to target.
  31115. * @param radius Optional. If a cached radius position already exists, overrides default.
  31116. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31117. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31118. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31119. */
  31120. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31121. /**
  31122. * Targets the given mesh with its children and updates zoom level accordingly.
  31123. * @param mesh The mesh to target.
  31124. * @param radius Optional. If a cached radius position already exists, overrides default.
  31125. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31126. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31127. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31128. */
  31129. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31130. /**
  31131. * Targets the given meshes with their children and updates zoom level accordingly.
  31132. * @param meshes The mesh to target.
  31133. * @param radius Optional. If a cached radius position already exists, overrides default.
  31134. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31135. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31136. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31137. */
  31138. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31139. /**
  31140. * Targets the given mesh and updates zoom level accordingly.
  31141. * @param mesh The mesh to target.
  31142. * @param radius Optional. If a cached radius position already exists, overrides default.
  31143. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31144. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31145. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31146. */
  31147. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31148. /**
  31149. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  31150. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  31151. * frustum width.
  31152. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  31153. * to fully enclose the mesh in the viewing frustum.
  31154. */
  31155. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  31156. /**
  31157. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  31158. * is automatically returned to its default position (expected to be above ground plane).
  31159. */
  31160. private _maintainCameraAboveGround();
  31161. /**
  31162. * Returns the frustum slope based on the canvas ratio and camera FOV
  31163. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  31164. */
  31165. private _getFrustumSlope();
  31166. /**
  31167. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  31168. */
  31169. private _clearAnimationLocks();
  31170. /**
  31171. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  31172. */
  31173. private _applyUserInteraction();
  31174. /**
  31175. * Stops and removes all animations that have been applied to the camera
  31176. */
  31177. stopAllAnimations(): void;
  31178. /**
  31179. * Gets a value indicating if the user is moving the camera
  31180. */
  31181. readonly isUserIsMoving: boolean;
  31182. /**
  31183. * The camera can move all the way towards the mesh.
  31184. */
  31185. static IgnoreBoundsSizeMode: number;
  31186. /**
  31187. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  31188. */
  31189. static FitFrustumSidesMode: number;
  31190. }
  31191. }
  31192. declare module BABYLON {
  31193. /**
  31194. * A behavior that when attached to a mesh will allow the mesh to be scaled
  31195. */
  31196. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  31197. private _dragBehaviorA;
  31198. private _dragBehaviorB;
  31199. private _startDistance;
  31200. private _initialScale;
  31201. private _targetScale;
  31202. private _ownerNode;
  31203. private _sceneRenderObserver;
  31204. constructor();
  31205. /**
  31206. * The name of the behavior
  31207. */
  31208. readonly name: string;
  31209. /**
  31210. * Initializes the behavior
  31211. */
  31212. init(): void;
  31213. private _getCurrentDistance();
  31214. /**
  31215. * Attaches the scale behavior the passed in mesh
  31216. * @param ownerNode The mesh that will be scaled around once attached
  31217. */
  31218. attach(ownerNode: Mesh): void;
  31219. /**
  31220. * Detaches the behavior from the mesh
  31221. */
  31222. detach(): void;
  31223. }
  31224. }
  31225. declare module BABYLON {
  31226. /**
  31227. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  31228. */
  31229. class PointerDragBehavior implements Behavior<Mesh> {
  31230. private options;
  31231. private _attachedNode;
  31232. private _dragPlane;
  31233. private _scene;
  31234. private _pointerObserver;
  31235. private static _planeScene;
  31236. /**
  31237. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  31238. */
  31239. maxDragAngle: number;
  31240. /**
  31241. * @hidden
  31242. */
  31243. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  31244. /**
  31245. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  31246. */
  31247. currentDraggingPointerID: number;
  31248. /**
  31249. * The last position where the pointer hit the drag plane in world space
  31250. */
  31251. lastDragPosition: Vector3;
  31252. /**
  31253. * If the behavior is currently in a dragging state
  31254. */
  31255. dragging: boolean;
  31256. /**
  31257. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  31258. */
  31259. dragDeltaRatio: number;
  31260. /**
  31261. * If the drag plane orientation should be updated during the dragging (Default: true)
  31262. */
  31263. updateDragPlane: boolean;
  31264. private _debugMode;
  31265. private _moving;
  31266. /**
  31267. * Fires each time the attached mesh is dragged with the pointer
  31268. * * delta between last drag position and current drag position in world space
  31269. * * dragDistance along the drag axis
  31270. * * dragPlaneNormal normal of the current drag plane used during the drag
  31271. * * dragPlanePoint in world space where the drag intersects the drag plane
  31272. */
  31273. onDragObservable: Observable<{
  31274. delta: Vector3;
  31275. dragPlanePoint: Vector3;
  31276. dragPlaneNormal: Vector3;
  31277. dragDistance: number;
  31278. pointerId: number;
  31279. }>;
  31280. /**
  31281. * Fires each time a drag begins (eg. mouse down on mesh)
  31282. */
  31283. onDragStartObservable: Observable<{
  31284. dragPlanePoint: Vector3;
  31285. pointerId: number;
  31286. }>;
  31287. /**
  31288. * Fires each time a drag ends (eg. mouse release after drag)
  31289. */
  31290. onDragEndObservable: Observable<{
  31291. dragPlanePoint: Vector3;
  31292. pointerId: number;
  31293. }>;
  31294. /**
  31295. * If the attached mesh should be moved when dragged
  31296. */
  31297. moveAttached: boolean;
  31298. /**
  31299. * If the drag behavior will react to drag events (Default: true)
  31300. */
  31301. enabled: boolean;
  31302. /**
  31303. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  31304. */
  31305. useObjectOrienationForDragging: boolean;
  31306. /**
  31307. * Creates a pointer drag behavior that can be attached to a mesh
  31308. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  31309. */
  31310. constructor(options: {
  31311. dragAxis?: Vector3;
  31312. dragPlaneNormal?: Vector3;
  31313. });
  31314. /**
  31315. * The name of the behavior
  31316. */
  31317. readonly name: string;
  31318. /**
  31319. * Initializes the behavior
  31320. */
  31321. init(): void;
  31322. private _tmpVector;
  31323. private _alternatePickedPoint;
  31324. private _worldDragAxis;
  31325. /**
  31326. * Attaches the drag behavior the passed in mesh
  31327. * @param ownerNode The mesh that will be dragged around once attached
  31328. */
  31329. attach(ownerNode: Mesh): void;
  31330. releaseDrag(): void;
  31331. private _pickWithRayOnDragPlane(ray);
  31332. private _pointA;
  31333. private _pointB;
  31334. private _pointC;
  31335. private _lineA;
  31336. private _lineB;
  31337. private _localAxis;
  31338. private _lookAt;
  31339. private _updateDragPlanePosition(ray, dragPlanePosition);
  31340. /**
  31341. * Detaches the behavior from the mesh
  31342. */
  31343. detach(): void;
  31344. }
  31345. }
  31346. declare module BABYLON {
  31347. /**
  31348. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  31349. */
  31350. class SixDofDragBehavior implements Behavior<Mesh> {
  31351. private static _virtualScene;
  31352. private _ownerNode;
  31353. private _sceneRenderObserver;
  31354. private _scene;
  31355. private _targetPosition;
  31356. private _virtualOriginMesh;
  31357. private _virtualDragMesh;
  31358. private _pointerObserver;
  31359. private _moving;
  31360. private _startingOrientation;
  31361. /**
  31362. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 5)
  31363. */
  31364. private zDragFactor;
  31365. /**
  31366. * If the behavior is currently in a dragging state
  31367. */
  31368. dragging: boolean;
  31369. /**
  31370. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  31371. */
  31372. dragDeltaRatio: number;
  31373. /**
  31374. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  31375. */
  31376. currentDraggingPointerID: number;
  31377. constructor();
  31378. /**
  31379. * The name of the behavior
  31380. */
  31381. readonly name: string;
  31382. /**
  31383. * Initializes the behavior
  31384. */
  31385. init(): void;
  31386. /**
  31387. * Attaches the scale behavior the passed in mesh
  31388. * @param ownerNode The mesh that will be scaled around once attached
  31389. */
  31390. attach(ownerNode: Mesh): void;
  31391. /**
  31392. * Detaches the behavior from the mesh
  31393. */
  31394. detach(): void;
  31395. }
  31396. }
  31397. declare module BABYLON {
  31398. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  31399. camera: ArcRotateCamera;
  31400. gamepad: Nullable<Gamepad>;
  31401. private _onGamepadConnectedObserver;
  31402. private _onGamepadDisconnectedObserver;
  31403. gamepadRotationSensibility: number;
  31404. gamepadMoveSensibility: number;
  31405. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31406. detachControl(element: Nullable<HTMLElement>): void;
  31407. checkInputs(): void;
  31408. getClassName(): string;
  31409. getSimpleName(): string;
  31410. }
  31411. }
  31412. declare module BABYLON {
  31413. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  31414. camera: ArcRotateCamera;
  31415. private _keys;
  31416. keysUp: number[];
  31417. keysDown: number[];
  31418. keysLeft: number[];
  31419. keysRight: number[];
  31420. keysReset: number[];
  31421. panningSensibility: number;
  31422. zoomingSensibility: number;
  31423. useAltToZoom: boolean;
  31424. private _ctrlPressed;
  31425. private _altPressed;
  31426. private _onCanvasBlurObserver;
  31427. private _onKeyboardObserver;
  31428. private _engine;
  31429. private _scene;
  31430. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31431. detachControl(element: Nullable<HTMLElement>): void;
  31432. checkInputs(): void;
  31433. getClassName(): string;
  31434. getSimpleName(): string;
  31435. }
  31436. }
  31437. declare module BABYLON {
  31438. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  31439. camera: ArcRotateCamera;
  31440. private _wheel;
  31441. private _observer;
  31442. wheelPrecision: number;
  31443. /**
  31444. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  31445. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  31446. */
  31447. wheelDeltaPercentage: number;
  31448. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31449. detachControl(element: Nullable<HTMLElement>): void;
  31450. getClassName(): string;
  31451. getSimpleName(): string;
  31452. }
  31453. }
  31454. declare module BABYLON {
  31455. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  31456. camera: ArcRotateCamera;
  31457. buttons: number[];
  31458. angularSensibilityX: number;
  31459. angularSensibilityY: number;
  31460. pinchPrecision: number;
  31461. /**
  31462. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  31463. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  31464. */
  31465. pinchDeltaPercentage: number;
  31466. panningSensibility: number;
  31467. multiTouchPanning: boolean;
  31468. multiTouchPanAndZoom: boolean;
  31469. private _isPanClick;
  31470. pinchInwards: boolean;
  31471. private _pointerInput;
  31472. private _observer;
  31473. private _onMouseMove;
  31474. private _onGestureStart;
  31475. private _onGesture;
  31476. private _MSGestureHandler;
  31477. private _onLostFocus;
  31478. private _onContextMenu;
  31479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31480. detachControl(element: Nullable<HTMLElement>): void;
  31481. getClassName(): string;
  31482. getSimpleName(): string;
  31483. }
  31484. }
  31485. declare module BABYLON {
  31486. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  31487. camera: ArcRotateCamera;
  31488. alphaCorrection: number;
  31489. betaCorrection: number;
  31490. gammaCorrection: number;
  31491. private _alpha;
  31492. private _gamma;
  31493. private _dirty;
  31494. private _deviceOrientationHandler;
  31495. constructor();
  31496. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31497. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  31498. checkInputs(): void;
  31499. detachControl(element: Nullable<HTMLElement>): void;
  31500. getClassName(): string;
  31501. getSimpleName(): string;
  31502. }
  31503. }
  31504. declare module BABYLON {
  31505. /**
  31506. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  31507. * Screen rotation is taken into account.
  31508. */
  31509. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  31510. private _camera;
  31511. private _screenOrientationAngle;
  31512. private _constantTranform;
  31513. private _screenQuaternion;
  31514. private _alpha;
  31515. private _beta;
  31516. private _gamma;
  31517. constructor();
  31518. camera: FreeCamera;
  31519. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31520. private _orientationChanged;
  31521. private _deviceOrientation;
  31522. detachControl(element: Nullable<HTMLElement>): void;
  31523. checkInputs(): void;
  31524. getClassName(): string;
  31525. getSimpleName(): string;
  31526. }
  31527. }
  31528. declare module BABYLON {
  31529. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  31530. camera: FreeCamera;
  31531. gamepad: Nullable<Gamepad>;
  31532. private _onGamepadConnectedObserver;
  31533. private _onGamepadDisconnectedObserver;
  31534. gamepadAngularSensibility: number;
  31535. gamepadMoveSensibility: number;
  31536. private _cameraTransform;
  31537. private _deltaTransform;
  31538. private _vector3;
  31539. private _vector2;
  31540. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31541. detachControl(element: Nullable<HTMLElement>): void;
  31542. checkInputs(): void;
  31543. getClassName(): string;
  31544. getSimpleName(): string;
  31545. }
  31546. }
  31547. declare module BABYLON {
  31548. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  31549. camera: FreeCamera;
  31550. private _keys;
  31551. private _onCanvasBlurObserver;
  31552. private _onKeyboardObserver;
  31553. private _engine;
  31554. private _scene;
  31555. keysUp: number[];
  31556. keysDown: number[];
  31557. keysLeft: number[];
  31558. keysRight: number[];
  31559. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31560. detachControl(element: Nullable<HTMLElement>): void;
  31561. checkInputs(): void;
  31562. getClassName(): string;
  31563. _onLostFocus(e: FocusEvent): void;
  31564. getSimpleName(): string;
  31565. }
  31566. }
  31567. declare module BABYLON {
  31568. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  31569. touchEnabled: boolean;
  31570. camera: FreeCamera;
  31571. buttons: number[];
  31572. angularSensibility: number;
  31573. private _pointerInput;
  31574. private _onMouseMove;
  31575. private _observer;
  31576. private previousPosition;
  31577. constructor(touchEnabled?: boolean);
  31578. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31579. detachControl(element: Nullable<HTMLElement>): void;
  31580. getClassName(): string;
  31581. getSimpleName(): string;
  31582. }
  31583. }
  31584. declare module BABYLON {
  31585. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  31586. camera: FreeCamera;
  31587. private _offsetX;
  31588. private _offsetY;
  31589. private _pointerPressed;
  31590. private _pointerInput;
  31591. private _observer;
  31592. private _onLostFocus;
  31593. touchAngularSensibility: number;
  31594. touchMoveSensibility: number;
  31595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31596. detachControl(element: Nullable<HTMLElement>): void;
  31597. checkInputs(): void;
  31598. getClassName(): string;
  31599. getSimpleName(): string;
  31600. }
  31601. }
  31602. declare module BABYLON {
  31603. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  31604. camera: FreeCamera;
  31605. private _leftjoystick;
  31606. private _rightjoystick;
  31607. getLeftJoystick(): VirtualJoystick;
  31608. getRightJoystick(): VirtualJoystick;
  31609. checkInputs(): void;
  31610. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31611. detachControl(element: Nullable<HTMLElement>): void;
  31612. getClassName(): string;
  31613. getSimpleName(): string;
  31614. }
  31615. }
  31616. declare module BABYLON {
  31617. /**
  31618. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  31619. */
  31620. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  31621. /**
  31622. * Creates a new AnaglyphArcRotateCamera
  31623. * @param name defines camera name
  31624. * @param alpha defines alpha angle (in radians)
  31625. * @param beta defines beta angle (in radians)
  31626. * @param radius defines radius
  31627. * @param target defines camera target
  31628. * @param interaxialDistance defines distance between each color axis
  31629. * @param scene defines the hosting scene
  31630. */
  31631. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  31632. /**
  31633. * Gets camera class name
  31634. * @returns AnaglyphArcRotateCamera
  31635. */
  31636. getClassName(): string;
  31637. }
  31638. }
  31639. declare module BABYLON {
  31640. /**
  31641. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  31642. */
  31643. class AnaglyphFreeCamera extends FreeCamera {
  31644. /**
  31645. * Creates a new AnaglyphFreeCamera
  31646. * @param name defines camera name
  31647. * @param position defines initial position
  31648. * @param interaxialDistance defines distance between each color axis
  31649. * @param scene defines the hosting scene
  31650. */
  31651. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  31652. /**
  31653. * Gets camera class name
  31654. * @returns AnaglyphFreeCamera
  31655. */
  31656. getClassName(): string;
  31657. }
  31658. }
  31659. declare module BABYLON {
  31660. /**
  31661. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  31662. */
  31663. class AnaglyphGamepadCamera extends GamepadCamera {
  31664. /**
  31665. * Creates a new AnaglyphGamepadCamera
  31666. * @param name defines camera name
  31667. * @param position defines initial position
  31668. * @param interaxialDistance defines distance between each color axis
  31669. * @param scene defines the hosting scene
  31670. */
  31671. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  31672. /**
  31673. * Gets camera class name
  31674. * @returns AnaglyphGamepadCamera
  31675. */
  31676. getClassName(): string;
  31677. }
  31678. }
  31679. declare module BABYLON {
  31680. /**
  31681. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  31682. */
  31683. class AnaglyphUniversalCamera extends UniversalCamera {
  31684. /**
  31685. * Creates a new AnaglyphUniversalCamera
  31686. * @param name defines camera name
  31687. * @param position defines initial position
  31688. * @param interaxialDistance defines distance between each color axis
  31689. * @param scene defines the hosting scene
  31690. */
  31691. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  31692. /**
  31693. * Gets camera class name
  31694. * @returns AnaglyphUniversalCamera
  31695. */
  31696. getClassName(): string;
  31697. }
  31698. }
  31699. declare module BABYLON {
  31700. /**
  31701. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  31702. */
  31703. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  31704. /**
  31705. * Creates a new StereoscopicArcRotateCamera
  31706. * @param name defines camera name
  31707. * @param alpha defines alpha angle (in radians)
  31708. * @param beta defines beta angle (in radians)
  31709. * @param radius defines radius
  31710. * @param target defines camera target
  31711. * @param interaxialDistance defines distance between each color axis
  31712. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  31713. * @param scene defines the hosting scene
  31714. */
  31715. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  31716. /**
  31717. * Gets camera class name
  31718. * @returns StereoscopicArcRotateCamera
  31719. */
  31720. getClassName(): string;
  31721. }
  31722. }
  31723. declare module BABYLON {
  31724. /**
  31725. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  31726. */
  31727. class StereoscopicFreeCamera extends FreeCamera {
  31728. /**
  31729. * Creates a new StereoscopicFreeCamera
  31730. * @param name defines camera name
  31731. * @param position defines initial position
  31732. * @param interaxialDistance defines distance between each color axis
  31733. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  31734. * @param scene defines the hosting scene
  31735. */
  31736. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  31737. /**
  31738. * Gets camera class name
  31739. * @returns StereoscopicFreeCamera
  31740. */
  31741. getClassName(): string;
  31742. }
  31743. }
  31744. declare module BABYLON {
  31745. /**
  31746. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  31747. */
  31748. class StereoscopicGamepadCamera extends GamepadCamera {
  31749. /**
  31750. * Creates a new StereoscopicGamepadCamera
  31751. * @param name defines camera name
  31752. * @param position defines initial position
  31753. * @param interaxialDistance defines distance between each color axis
  31754. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  31755. * @param scene defines the hosting scene
  31756. */
  31757. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  31758. /**
  31759. * Gets camera class name
  31760. * @returns StereoscopicGamepadCamera
  31761. */
  31762. getClassName(): string;
  31763. }
  31764. }
  31765. declare module BABYLON {
  31766. /**
  31767. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  31768. */
  31769. class StereoscopicUniversalCamera extends UniversalCamera {
  31770. /**
  31771. * Creates a new StereoscopicUniversalCamera
  31772. * @param name defines camera name
  31773. * @param position defines initial position
  31774. * @param interaxialDistance defines distance between each color axis
  31775. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  31776. * @param scene defines the hosting scene
  31777. */
  31778. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  31779. /**
  31780. * Gets camera class name
  31781. * @returns StereoscopicUniversalCamera
  31782. */
  31783. getClassName(): string;
  31784. }
  31785. }
  31786. declare module BABYLON {
  31787. class VRCameraMetrics {
  31788. hResolution: number;
  31789. vResolution: number;
  31790. hScreenSize: number;
  31791. vScreenSize: number;
  31792. vScreenCenter: number;
  31793. eyeToScreenDistance: number;
  31794. lensSeparationDistance: number;
  31795. interpupillaryDistance: number;
  31796. distortionK: number[];
  31797. chromaAbCorrection: number[];
  31798. postProcessScaleFactor: number;
  31799. lensCenterOffset: number;
  31800. compensateDistortion: boolean;
  31801. readonly aspectRatio: number;
  31802. readonly aspectRatioFov: number;
  31803. readonly leftHMatrix: Matrix;
  31804. readonly rightHMatrix: Matrix;
  31805. readonly leftPreViewMatrix: Matrix;
  31806. readonly rightPreViewMatrix: Matrix;
  31807. static GetDefault(): VRCameraMetrics;
  31808. }
  31809. }
  31810. declare module BABYLON {
  31811. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  31812. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  31813. getClassName(): string;
  31814. }
  31815. }
  31816. declare module BABYLON {
  31817. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  31818. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  31819. getClassName(): string;
  31820. }
  31821. }
  31822. declare module BABYLON {
  31823. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  31824. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  31825. getClassName(): string;
  31826. }
  31827. }
  31828. declare module BABYLON {
  31829. /**
  31830. * Options to modify the vr teleportation behavior.
  31831. */
  31832. interface VRTeleportationOptions {
  31833. /**
  31834. * The name of the mesh which should be used as the teleportation floor. (default: null)
  31835. */
  31836. floorMeshName?: string;
  31837. /**
  31838. * A list of meshes to be used as the teleportation floor. (default: empty)
  31839. */
  31840. floorMeshes?: Mesh[];
  31841. }
  31842. /**
  31843. * Options to modify the vr experience helper's behavior.
  31844. */
  31845. interface VRExperienceHelperOptions extends WebVROptions {
  31846. /**
  31847. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  31848. */
  31849. createDeviceOrientationCamera?: boolean;
  31850. /**
  31851. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  31852. */
  31853. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  31854. /**
  31855. * Uses the main button on the controller to toggle the laser casted. (default: true)
  31856. */
  31857. laserToggle?: boolean;
  31858. /**
  31859. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  31860. */
  31861. floorMeshes?: Mesh[];
  31862. }
  31863. /**
  31864. * Helps to quickly add VR support to an existing scene.
  31865. * See http://doc.babylonjs.com/how_to/webvr_helper
  31866. */
  31867. class VRExperienceHelper {
  31868. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  31869. private _scene;
  31870. private _position;
  31871. private _btnVR;
  31872. private _btnVRDisplayed;
  31873. private _webVRsupported;
  31874. private _webVRready;
  31875. private _webVRrequesting;
  31876. private _webVRpresenting;
  31877. private _fullscreenVRpresenting;
  31878. private _canvas;
  31879. private _webVRCamera;
  31880. private _vrDeviceOrientationCamera;
  31881. private _deviceOrientationCamera;
  31882. private _existingCamera;
  31883. private _onKeyDown;
  31884. private _onVrDisplayPresentChange;
  31885. private _onVRDisplayChanged;
  31886. private _onVRRequestPresentStart;
  31887. private _onVRRequestPresentComplete;
  31888. /**
  31889. * Observable raised when entering VR.
  31890. */
  31891. onEnteringVRObservable: Observable<VRExperienceHelper>;
  31892. /**
  31893. * Observable raised when exiting VR.
  31894. */
  31895. onExitingVRObservable: Observable<VRExperienceHelper>;
  31896. /**
  31897. * Observable raised when controller mesh is loaded.
  31898. */
  31899. onControllerMeshLoadedObservable: Observable<WebVRController>;
  31900. /** Return this.onEnteringVRObservable
  31901. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  31902. */
  31903. readonly onEnteringVR: Observable<VRExperienceHelper>;
  31904. /** Return this.onExitingVRObservable
  31905. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  31906. */
  31907. readonly onExitingVR: Observable<VRExperienceHelper>;
  31908. /** Return this.onControllerMeshLoadedObservable
  31909. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  31910. */
  31911. readonly onControllerMeshLoaded: Observable<WebVRController>;
  31912. private _rayLength;
  31913. private _useCustomVRButton;
  31914. private _teleportationRequested;
  31915. private _teleportActive;
  31916. private _floorMeshName;
  31917. private _floorMeshesCollection;
  31918. private _rotationAllowed;
  31919. private _teleportBackwardsVector;
  31920. private _teleportationTarget;
  31921. private _isDefaultTeleportationTarget;
  31922. private _postProcessMove;
  31923. private _teleportationFillColor;
  31924. private _teleportationBorderColor;
  31925. private _rotationAngle;
  31926. private _haloCenter;
  31927. private _cameraGazer;
  31928. private _padSensibilityUp;
  31929. private _padSensibilityDown;
  31930. private leftController;
  31931. private rightController;
  31932. /**
  31933. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  31934. */
  31935. onNewMeshSelected: Observable<AbstractMesh>;
  31936. /**
  31937. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  31938. */
  31939. onNewMeshPicked: Observable<PickingInfo>;
  31940. private _circleEase;
  31941. /**
  31942. * Observable raised before camera teleportation
  31943. */
  31944. onBeforeCameraTeleport: Observable<Vector3>;
  31945. /**
  31946. * Observable raised after camera teleportation
  31947. */
  31948. onAfterCameraTeleport: Observable<Vector3>;
  31949. /**
  31950. * Observable raised when current selected mesh gets unselected
  31951. */
  31952. onSelectedMeshUnselected: Observable<AbstractMesh>;
  31953. private _raySelectionPredicate;
  31954. /**
  31955. * To be optionaly changed by user to define custom ray selection
  31956. */
  31957. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  31958. /**
  31959. * To be optionaly changed by user to define custom selection logic (after ray selection)
  31960. */
  31961. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  31962. /**
  31963. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  31964. */
  31965. teleportationEnabled: boolean;
  31966. private _defaultHeight;
  31967. private _teleportationInitialized;
  31968. private _interactionsEnabled;
  31969. private _interactionsRequested;
  31970. private _displayGaze;
  31971. private _displayLaserPointer;
  31972. /**
  31973. * The mesh used to display where the user is going to teleport.
  31974. */
  31975. /**
  31976. * Sets the mesh to be used to display where the user is going to teleport.
  31977. */
  31978. teleportationTarget: Mesh;
  31979. /**
  31980. * The mesh used to display where the user is selecting,
  31981. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  31982. * See http://doc.babylonjs.com/resources/baking_transformations
  31983. */
  31984. gazeTrackerMesh: Mesh;
  31985. /**
  31986. * If the ray of the gaze should be displayed.
  31987. */
  31988. /**
  31989. * Sets if the ray of the gaze should be displayed.
  31990. */
  31991. displayGaze: boolean;
  31992. /**
  31993. * If the ray of the LaserPointer should be displayed.
  31994. */
  31995. /**
  31996. * Sets if the ray of the LaserPointer should be displayed.
  31997. */
  31998. displayLaserPointer: boolean;
  31999. /**
  32000. * The deviceOrientationCamera used as the camera when not in VR.
  32001. */
  32002. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  32003. /**
  32004. * Based on the current WebVR support, returns the current VR camera used.
  32005. */
  32006. readonly currentVRCamera: Nullable<Camera>;
  32007. /**
  32008. * The webVRCamera which is used when in VR.
  32009. */
  32010. readonly webVRCamera: WebVRFreeCamera;
  32011. /**
  32012. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  32013. */
  32014. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  32015. private readonly _teleportationRequestInitiated;
  32016. /**
  32017. * Instantiates a VRExperienceHelper.
  32018. * Helps to quickly add VR support to an existing scene.
  32019. * @param scene The scene the VRExperienceHelper belongs to.
  32020. * @param webVROptions Options to modify the vr experience helper's behavior.
  32021. */
  32022. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  32023. private _onDefaultMeshLoaded(webVRController);
  32024. private _onResize;
  32025. private _onFullscreenChange;
  32026. /**
  32027. * Gets a value indicating if we are currently in VR mode.
  32028. */
  32029. readonly isInVRMode: boolean;
  32030. private onVrDisplayPresentChange();
  32031. private onVRDisplayChanged(eventArgs);
  32032. private moveButtonToBottomRight();
  32033. private displayVRButton();
  32034. private updateButtonVisibility();
  32035. /**
  32036. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  32037. * Otherwise, will use the fullscreen API.
  32038. */
  32039. enterVR(): void;
  32040. /**
  32041. * Attempt to exit VR, or fullscreen.
  32042. */
  32043. exitVR(): void;
  32044. /**
  32045. * The position of the vr experience helper.
  32046. */
  32047. /**
  32048. * Sets the position of the vr experience helper.
  32049. */
  32050. position: Vector3;
  32051. /**
  32052. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  32053. */
  32054. enableInteractions(): void;
  32055. private readonly _noControllerIsActive;
  32056. private beforeRender;
  32057. private _isTeleportationFloor(mesh);
  32058. /**
  32059. * Adds a floor mesh to be used for teleportation.
  32060. * @param floorMesh the mesh to be used for teleportation.
  32061. */
  32062. addFloorMesh(floorMesh: Mesh): void;
  32063. /**
  32064. * Removes a floor mesh from being used for teleportation.
  32065. * @param floorMesh the mesh to be removed.
  32066. */
  32067. removeFloorMesh(floorMesh: Mesh): void;
  32068. /**
  32069. * Enables interactions and teleportation using the VR controllers and gaze.
  32070. * @param vrTeleportationOptions options to modify teleportation behavior.
  32071. */
  32072. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  32073. private _onNewGamepadConnected;
  32074. private _tryEnableInteractionOnController;
  32075. private _onNewGamepadDisconnected;
  32076. private _enableInteractionOnController(controller);
  32077. private _checkTeleportWithRay(stateObject, gazer);
  32078. private _checkRotate(stateObject, gazer);
  32079. private _checkTeleportBackwards(stateObject, gazer);
  32080. private _enableTeleportationOnController(controller);
  32081. private _createTeleportationCircles();
  32082. private _displayTeleportationTarget();
  32083. private _hideTeleportationTarget();
  32084. private _rotateCamera(right);
  32085. private _moveTeleportationSelectorTo(hit, gazer, ray);
  32086. private _workingVector;
  32087. private _workingQuaternion;
  32088. private _workingMatrix;
  32089. private _teleportCamera(location);
  32090. private _convertNormalToDirectionOfRay(normal, ray);
  32091. private _castRayAndSelectObject(gazer);
  32092. private _notifySelectedMeshUnselected(mesh);
  32093. /**
  32094. * Sets the color of the laser ray from the vr controllers.
  32095. * @param color new color for the ray.
  32096. */
  32097. changeLaserColor(color: Color3): void;
  32098. /**
  32099. * Sets the color of the ray from the vr headsets gaze.
  32100. * @param color new color for the ray.
  32101. */
  32102. changeGazeColor(color: Color3): void;
  32103. /**
  32104. * Exits VR and disposes of the vr experience helper
  32105. */
  32106. dispose(): void;
  32107. /**
  32108. * Gets the name of the VRExperienceHelper class
  32109. * @returns "VRExperienceHelper"
  32110. */
  32111. getClassName(): string;
  32112. }
  32113. }
  32114. declare module BABYLON {
  32115. /**
  32116. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  32117. * IMPORTANT!! The data is right-hand data.
  32118. * @export
  32119. * @interface DevicePose
  32120. */
  32121. interface DevicePose {
  32122. /**
  32123. * The position of the device, values in array are [x,y,z].
  32124. */
  32125. readonly position: Nullable<Float32Array>;
  32126. /**
  32127. * The linearVelocity of the device, values in array are [x,y,z].
  32128. */
  32129. readonly linearVelocity: Nullable<Float32Array>;
  32130. /**
  32131. * The linearAcceleration of the device, values in array are [x,y,z].
  32132. */
  32133. readonly linearAcceleration: Nullable<Float32Array>;
  32134. /**
  32135. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  32136. */
  32137. readonly orientation: Nullable<Float32Array>;
  32138. /**
  32139. * The angularVelocity of the device, values in array are [x,y,z].
  32140. */
  32141. readonly angularVelocity: Nullable<Float32Array>;
  32142. /**
  32143. * The angularAcceleration of the device, values in array are [x,y,z].
  32144. */
  32145. readonly angularAcceleration: Nullable<Float32Array>;
  32146. }
  32147. /**
  32148. * Interface representing a pose controlled object in Babylon.
  32149. * A pose controlled object has both regular pose values as well as pose values
  32150. * from an external device such as a VR head mounted display
  32151. */
  32152. interface PoseControlled {
  32153. /**
  32154. * The position of the object in babylon space.
  32155. */
  32156. position: Vector3;
  32157. /**
  32158. * The rotation quaternion of the object in babylon space.
  32159. */
  32160. rotationQuaternion: Quaternion;
  32161. /**
  32162. * The position of the device in babylon space.
  32163. */
  32164. devicePosition?: Vector3;
  32165. /**
  32166. * The rotation quaternion of the device in babylon space.
  32167. */
  32168. deviceRotationQuaternion: Quaternion;
  32169. /**
  32170. * The raw pose coming from the device.
  32171. */
  32172. rawPose: Nullable<DevicePose>;
  32173. /**
  32174. * The scale of the device to be used when translating from device space to babylon space.
  32175. */
  32176. deviceScaleFactor: number;
  32177. /**
  32178. * Updates the poseControlled values based on the input device pose.
  32179. * @param poseData the pose data to update the object with
  32180. */
  32181. updateFromDevice(poseData: DevicePose): void;
  32182. }
  32183. /**
  32184. * Set of options to customize the webVRCamera
  32185. */
  32186. interface WebVROptions {
  32187. /**
  32188. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  32189. */
  32190. trackPosition?: boolean;
  32191. /**
  32192. * Sets the scale of the vrDevice in babylon space. (default: 1)
  32193. */
  32194. positionScale?: number;
  32195. /**
  32196. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  32197. */
  32198. displayName?: string;
  32199. /**
  32200. * Should the native controller meshes be initialized. (default: true)
  32201. */
  32202. controllerMeshes?: boolean;
  32203. /**
  32204. * Creating a default HemiLight only on controllers. (default: true)
  32205. */
  32206. defaultLightingOnControllers?: boolean;
  32207. /**
  32208. * If you don't want to use the default VR button of the helper. (default: false)
  32209. */
  32210. useCustomVRButton?: boolean;
  32211. /**
  32212. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  32213. */
  32214. customVRButton?: HTMLButtonElement;
  32215. /**
  32216. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  32217. */
  32218. rayLength?: number;
  32219. /**
  32220. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  32221. */
  32222. defaultHeight?: number;
  32223. }
  32224. /**
  32225. * This represents a WebVR camera.
  32226. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  32227. * @example http://doc.babylonjs.com/how_to/webvr_camera
  32228. */
  32229. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  32230. private webVROptions;
  32231. /**
  32232. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  32233. */
  32234. _vrDevice: any;
  32235. /**
  32236. * The rawPose of the vrDevice.
  32237. */
  32238. rawPose: Nullable<DevicePose>;
  32239. private _onVREnabled;
  32240. private _specsVersion;
  32241. private _attached;
  32242. private _frameData;
  32243. protected _descendants: Array<Node>;
  32244. private _deviceRoomPosition;
  32245. private _deviceRoomRotationQuaternion;
  32246. private _standingMatrix;
  32247. /**
  32248. * Represents device position in babylon space.
  32249. */
  32250. devicePosition: Vector3;
  32251. /**
  32252. * Represents device rotation in babylon space.
  32253. */
  32254. deviceRotationQuaternion: Quaternion;
  32255. /**
  32256. * The scale of the device to be used when translating from device space to babylon space.
  32257. */
  32258. deviceScaleFactor: number;
  32259. private _deviceToWorld;
  32260. private _worldToDevice;
  32261. /**
  32262. * References to the webVR controllers for the vrDevice.
  32263. */
  32264. controllers: Array<WebVRController>;
  32265. /**
  32266. * Emits an event when a controller is attached.
  32267. */
  32268. onControllersAttachedObservable: Observable<WebVRController[]>;
  32269. /**
  32270. * Emits an event when a controller's mesh has been loaded;
  32271. */
  32272. onControllerMeshLoadedObservable: Observable<WebVRController>;
  32273. /**
  32274. * If the rig cameras be used as parent instead of this camera.
  32275. */
  32276. rigParenting: boolean;
  32277. private _lightOnControllers;
  32278. private _defaultHeight?;
  32279. /**
  32280. * Instantiates a WebVRFreeCamera.
  32281. * @param name The name of the WebVRFreeCamera
  32282. * @param position The starting anchor position for the camera
  32283. * @param scene The scene the camera belongs to
  32284. * @param webVROptions a set of customizable options for the webVRCamera
  32285. */
  32286. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  32287. /**
  32288. * Gets the device distance from the ground in meters.
  32289. * @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.
  32290. */
  32291. deviceDistanceToRoomGround(): number;
  32292. /**
  32293. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  32294. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  32295. */
  32296. useStandingMatrix(callback?: (bool: boolean) => void): void;
  32297. /**
  32298. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  32299. * @returns A promise with a boolean set to if the standing matrix is supported.
  32300. */
  32301. useStandingMatrixAsync(): Promise<boolean>;
  32302. /**
  32303. * Disposes the camera
  32304. */
  32305. dispose(): void;
  32306. /**
  32307. * Gets a vrController by name.
  32308. * @param name The name of the controller to retreive
  32309. * @returns the controller matching the name specified or null if not found
  32310. */
  32311. getControllerByName(name: string): Nullable<WebVRController>;
  32312. private _leftController;
  32313. /**
  32314. * The controller corrisponding to the users left hand.
  32315. */
  32316. readonly leftController: Nullable<WebVRController>;
  32317. private _rightController;
  32318. /**
  32319. * The controller corrisponding to the users right hand.
  32320. */
  32321. readonly rightController: Nullable<WebVRController>;
  32322. /**
  32323. * Casts a ray forward from the vrCamera's gaze.
  32324. * @param length Length of the ray (default: 100)
  32325. * @returns the ray corrisponding to the gaze
  32326. */
  32327. getForwardRay(length?: number): Ray;
  32328. /**
  32329. * Updates the camera based on device's frame data
  32330. */
  32331. _checkInputs(): void;
  32332. /**
  32333. * Updates the poseControlled values based on the input device pose.
  32334. * @param poseData Pose coming from the device
  32335. */
  32336. updateFromDevice(poseData: DevicePose): void;
  32337. /**
  32338. * WebVR's attach control will start broadcasting frames to the device.
  32339. * Note that in certain browsers (chrome for example) this function must be called
  32340. * within a user-interaction callback. Example:
  32341. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  32342. *
  32343. * @param element html element to attach the vrDevice to
  32344. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  32345. */
  32346. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32347. /**
  32348. * Detaches the camera from the html element and disables VR
  32349. *
  32350. * @param element html element to detach from
  32351. */
  32352. detachControl(element: HTMLElement): void;
  32353. /**
  32354. * @returns the name of this class
  32355. */
  32356. getClassName(): string;
  32357. /**
  32358. * Calls resetPose on the vrDisplay
  32359. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  32360. */
  32361. resetToCurrentRotation(): void;
  32362. /**
  32363. * Updates the rig cameras (left and right eye)
  32364. */
  32365. _updateRigCameras(): void;
  32366. private _workingVector;
  32367. private _oneVector;
  32368. private _workingMatrix;
  32369. private updateCacheCalled;
  32370. /**
  32371. * Updates the cached values of the camera
  32372. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  32373. */
  32374. _updateCache(ignoreParentClass?: boolean): void;
  32375. /**
  32376. * Updates the current device position and rotation in the babylon world
  32377. */
  32378. update(): void;
  32379. /**
  32380. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  32381. * @returns an identity matrix
  32382. */
  32383. _getViewMatrix(): Matrix;
  32384. /**
  32385. * This function is called by the two RIG cameras.
  32386. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  32387. */
  32388. protected _getWebVRViewMatrix(): Matrix;
  32389. protected _getWebVRProjectionMatrix(): Matrix;
  32390. private _onGamepadConnectedObserver;
  32391. private _onGamepadDisconnectedObserver;
  32392. /**
  32393. * Initializes the controllers and their meshes
  32394. */
  32395. initControllers(): void;
  32396. }
  32397. }
  32398. declare module BABYLON {
  32399. interface IOctreeContainer<T> {
  32400. blocks: Array<OctreeBlock<T>>;
  32401. }
  32402. class Octree<T> {
  32403. maxDepth: number;
  32404. blocks: Array<OctreeBlock<T>>;
  32405. dynamicContent: T[];
  32406. private _maxBlockCapacity;
  32407. private _selectionContent;
  32408. private _creationFunc;
  32409. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  32410. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  32411. addMesh(entry: T): void;
  32412. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  32413. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  32414. intersectsRay(ray: Ray): SmartArray<T>;
  32415. 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;
  32416. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  32417. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  32418. }
  32419. }
  32420. declare module BABYLON {
  32421. class OctreeBlock<T> {
  32422. entries: T[];
  32423. blocks: Array<OctreeBlock<T>>;
  32424. private _depth;
  32425. private _maxDepth;
  32426. private _capacity;
  32427. private _minPoint;
  32428. private _maxPoint;
  32429. private _boundingVectors;
  32430. private _creationFunc;
  32431. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  32432. readonly capacity: number;
  32433. readonly minPoint: Vector3;
  32434. readonly maxPoint: Vector3;
  32435. addEntry(entry: T): void;
  32436. addEntries(entries: T[]): void;
  32437. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  32438. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  32439. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  32440. createInnerBlocks(): void;
  32441. }
  32442. }
  32443. declare module BABYLON {
  32444. /**
  32445. * Google Daydream controller
  32446. */
  32447. class DaydreamController extends WebVRController {
  32448. /**
  32449. * Base Url for the controller model.
  32450. */
  32451. static MODEL_BASE_URL: string;
  32452. /**
  32453. * File name for the controller model.
  32454. */
  32455. static MODEL_FILENAME: string;
  32456. /**
  32457. * Gamepad Id prefix used to identify Daydream Controller.
  32458. */
  32459. static readonly GAMEPAD_ID_PREFIX: string;
  32460. /**
  32461. * Creates a new DaydreamController from a gamepad
  32462. * @param vrGamepad the gamepad that the controller should be created from
  32463. */
  32464. constructor(vrGamepad: any);
  32465. /**
  32466. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32467. * @param scene scene in which to add meshes
  32468. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32469. */
  32470. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32471. /**
  32472. * Called once for each button that changed state since the last frame
  32473. * @param buttonIdx Which button index changed
  32474. * @param state New state of the button
  32475. * @param changes Which properties on the state changed since last frame
  32476. */
  32477. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32478. }
  32479. }
  32480. declare module BABYLON {
  32481. /**
  32482. * Gear VR Controller
  32483. */
  32484. class GearVRController extends WebVRController {
  32485. /**
  32486. * Base Url for the controller model.
  32487. */
  32488. static MODEL_BASE_URL: string;
  32489. /**
  32490. * File name for the controller model.
  32491. */
  32492. static MODEL_FILENAME: string;
  32493. /**
  32494. * Gamepad Id prefix used to identify this controller.
  32495. */
  32496. static readonly GAMEPAD_ID_PREFIX: string;
  32497. private readonly _buttonIndexToObservableNameMap;
  32498. /**
  32499. * Creates a new GearVRController from a gamepad
  32500. * @param vrGamepad the gamepad that the controller should be created from
  32501. */
  32502. constructor(vrGamepad: any);
  32503. /**
  32504. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32505. * @param scene scene in which to add meshes
  32506. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32507. */
  32508. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32509. /**
  32510. * Called once for each button that changed state since the last frame
  32511. * @param buttonIdx Which button index changed
  32512. * @param state New state of the button
  32513. * @param changes Which properties on the state changed since last frame
  32514. */
  32515. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32516. }
  32517. }
  32518. declare module BABYLON {
  32519. /**
  32520. * Generic Controller
  32521. */
  32522. class GenericController extends WebVRController {
  32523. /**
  32524. * Base Url for the controller model.
  32525. */
  32526. static readonly MODEL_BASE_URL: string;
  32527. /**
  32528. * File name for the controller model.
  32529. */
  32530. static readonly MODEL_FILENAME: string;
  32531. /**
  32532. * Creates a new GenericController from a gamepad
  32533. * @param vrGamepad the gamepad that the controller should be created from
  32534. */
  32535. constructor(vrGamepad: any);
  32536. /**
  32537. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32538. * @param scene scene in which to add meshes
  32539. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32540. */
  32541. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32542. /**
  32543. * Called once for each button that changed state since the last frame
  32544. * @param buttonIdx Which button index changed
  32545. * @param state New state of the button
  32546. * @param changes Which properties on the state changed since last frame
  32547. */
  32548. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32549. }
  32550. }
  32551. declare module BABYLON {
  32552. /**
  32553. * Oculus Touch Controller
  32554. */
  32555. class OculusTouchController extends WebVRController {
  32556. /**
  32557. * Base Url for the controller model.
  32558. */
  32559. static MODEL_BASE_URL: string;
  32560. /**
  32561. * File name for the left controller model.
  32562. */
  32563. static MODEL_LEFT_FILENAME: string;
  32564. /**
  32565. * File name for the right controller model.
  32566. */
  32567. static MODEL_RIGHT_FILENAME: string;
  32568. /**
  32569. * Fired when the secondary trigger on this controller is modified
  32570. */
  32571. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  32572. /**
  32573. * Fired when the thumb rest on this controller is modified
  32574. */
  32575. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  32576. /**
  32577. * Creates a new OculusTouchController from a gamepad
  32578. * @param vrGamepad the gamepad that the controller should be created from
  32579. */
  32580. constructor(vrGamepad: any);
  32581. /**
  32582. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32583. * @param scene scene in which to add meshes
  32584. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32585. */
  32586. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32587. /**
  32588. * Fired when the A button on this controller is modified
  32589. */
  32590. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32591. /**
  32592. * Fired when the B button on this controller is modified
  32593. */
  32594. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32595. /**
  32596. * Fired when the X button on this controller is modified
  32597. */
  32598. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32599. /**
  32600. * Fired when the Y button on this controller is modified
  32601. */
  32602. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32603. /**
  32604. * Called once for each button that changed state since the last frame
  32605. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  32606. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  32607. * 2) secondary trigger (same)
  32608. * 3) A (right) X (left), touch, pressed = value
  32609. * 4) B / Y
  32610. * 5) thumb rest
  32611. * @param buttonIdx Which button index changed
  32612. * @param state New state of the button
  32613. * @param changes Which properties on the state changed since last frame
  32614. */
  32615. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32616. }
  32617. }
  32618. declare module BABYLON {
  32619. /**
  32620. * Defines the types of pose enabled controllers that are supported
  32621. */
  32622. enum PoseEnabledControllerType {
  32623. /**
  32624. * HTC Vive
  32625. */
  32626. VIVE = 0,
  32627. /**
  32628. * Oculus Rift
  32629. */
  32630. OCULUS = 1,
  32631. /**
  32632. * Windows mixed reality
  32633. */
  32634. WINDOWS = 2,
  32635. /**
  32636. * Samsung gear VR
  32637. */
  32638. GEAR_VR = 3,
  32639. /**
  32640. * Google Daydream
  32641. */
  32642. DAYDREAM = 4,
  32643. /**
  32644. * Generic
  32645. */
  32646. GENERIC = 5,
  32647. }
  32648. /**
  32649. * Defines the MutableGamepadButton interface for the state of a gamepad button
  32650. */
  32651. interface MutableGamepadButton {
  32652. /**
  32653. * Value of the button/trigger
  32654. */
  32655. value: number;
  32656. /**
  32657. * If the button/trigger is currently touched
  32658. */
  32659. touched: boolean;
  32660. /**
  32661. * If the button/trigger is currently pressed
  32662. */
  32663. pressed: boolean;
  32664. }
  32665. /**
  32666. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  32667. * @hidden
  32668. */
  32669. interface ExtendedGamepadButton extends GamepadButton {
  32670. /**
  32671. * If the button/trigger is currently pressed
  32672. */
  32673. readonly pressed: boolean;
  32674. /**
  32675. * If the button/trigger is currently touched
  32676. */
  32677. readonly touched: boolean;
  32678. /**
  32679. * Value of the button/trigger
  32680. */
  32681. readonly value: number;
  32682. }
  32683. /**
  32684. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  32685. */
  32686. class PoseEnabledControllerHelper {
  32687. /**
  32688. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  32689. * @param vrGamepad the gamepad to initialized
  32690. * @returns a vr controller of the type the gamepad identified as
  32691. */
  32692. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  32693. }
  32694. /**
  32695. * Defines the PoseEnabledController object that contains state of a vr capable controller
  32696. */
  32697. class PoseEnabledController extends Gamepad implements PoseControlled {
  32698. private _deviceRoomPosition;
  32699. private _deviceRoomRotationQuaternion;
  32700. /**
  32701. * The device position in babylon space
  32702. */
  32703. devicePosition: Vector3;
  32704. /**
  32705. * The device rotation in babylon space
  32706. */
  32707. deviceRotationQuaternion: Quaternion;
  32708. /**
  32709. * The scale factor of the device in babylon space
  32710. */
  32711. deviceScaleFactor: number;
  32712. /**
  32713. * (Likely devicePosition should be used instead) The device position in its room space
  32714. */
  32715. position: Vector3;
  32716. /**
  32717. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  32718. */
  32719. rotationQuaternion: Quaternion;
  32720. /**
  32721. * The type of controller (Eg. Windows mixed reality)
  32722. */
  32723. controllerType: PoseEnabledControllerType;
  32724. protected _calculatedPosition: Vector3;
  32725. private _calculatedRotation;
  32726. /**
  32727. * The raw pose from the device
  32728. */
  32729. rawPose: DevicePose;
  32730. /**
  32731. * Internal, the mesh attached to the controller
  32732. */
  32733. _mesh: Nullable<AbstractMesh>;
  32734. private _poseControlledCamera;
  32735. private _leftHandSystemQuaternion;
  32736. /**
  32737. * Internal, matrix used to convert room space to babylon space
  32738. */
  32739. _deviceToWorld: Matrix;
  32740. /**
  32741. * Node to be used when casting a ray from the controller
  32742. */
  32743. _pointingPoseNode: Nullable<AbstractMesh>;
  32744. /**
  32745. * Name of the child mesh that can be used to cast a ray from the controller
  32746. */
  32747. static readonly POINTING_POSE: string;
  32748. /**
  32749. * Creates a new PoseEnabledController from a gamepad
  32750. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  32751. */
  32752. constructor(browserGamepad: any);
  32753. private _workingMatrix;
  32754. /**
  32755. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  32756. */
  32757. update(): void;
  32758. /**
  32759. * Updates only the pose device and mesh without doing any button event checking
  32760. */
  32761. protected _updatePoseAndMesh(): void;
  32762. /**
  32763. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  32764. * @param poseData raw pose fromthe device
  32765. */
  32766. updateFromDevice(poseData: DevicePose): void;
  32767. /**
  32768. * @hidden
  32769. */
  32770. _meshAttachedObservable: Observable<AbstractMesh>;
  32771. /**
  32772. * Attaches a mesh to the controller
  32773. * @param mesh the mesh to be attached
  32774. */
  32775. attachToMesh(mesh: AbstractMesh): void;
  32776. /**
  32777. * Attaches the controllers mesh to a camera
  32778. * @param camera the camera the mesh should be attached to
  32779. */
  32780. attachToPoseControlledCamera(camera: TargetCamera): void;
  32781. /**
  32782. * Disposes of the controller
  32783. */
  32784. dispose(): void;
  32785. /**
  32786. * The mesh that is attached to the controller
  32787. */
  32788. readonly mesh: Nullable<AbstractMesh>;
  32789. /**
  32790. * Gets the ray of the controller in the direction the controller is pointing
  32791. * @param length the length the resulting ray should be
  32792. * @returns a ray in the direction the controller is pointing
  32793. */
  32794. getForwardRay(length?: number): Ray;
  32795. }
  32796. }
  32797. declare module BABYLON {
  32798. /**
  32799. * Vive Controller
  32800. */
  32801. class ViveController extends WebVRController {
  32802. /**
  32803. * Base Url for the controller model.
  32804. */
  32805. static MODEL_BASE_URL: string;
  32806. /**
  32807. * File name for the controller model.
  32808. */
  32809. static MODEL_FILENAME: string;
  32810. /**
  32811. * Creates a new ViveController from a gamepad
  32812. * @param vrGamepad the gamepad that the controller should be created from
  32813. */
  32814. constructor(vrGamepad: any);
  32815. /**
  32816. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32817. * @param scene scene in which to add meshes
  32818. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32819. */
  32820. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32821. /**
  32822. * Fired when the left button on this controller is modified
  32823. */
  32824. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32825. /**
  32826. * Fired when the right button on this controller is modified
  32827. */
  32828. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32829. /**
  32830. * Fired when the menu button on this controller is modified
  32831. */
  32832. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32833. /**
  32834. * Called once for each button that changed state since the last frame
  32835. * Vive mapping:
  32836. * 0: touchpad
  32837. * 1: trigger
  32838. * 2: left AND right buttons
  32839. * 3: menu button
  32840. * @param buttonIdx Which button index changed
  32841. * @param state New state of the button
  32842. * @param changes Which properties on the state changed since last frame
  32843. */
  32844. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32845. }
  32846. }
  32847. declare module BABYLON {
  32848. /**
  32849. * Defines the WebVRController object that represents controllers tracked in 3D space
  32850. */
  32851. abstract class WebVRController extends PoseEnabledController {
  32852. /**
  32853. * Internal, the default controller model for the controller
  32854. */
  32855. protected _defaultModel: AbstractMesh;
  32856. /**
  32857. * Fired when the trigger state has changed
  32858. */
  32859. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  32860. /**
  32861. * Fired when the main button state has changed
  32862. */
  32863. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32864. /**
  32865. * Fired when the secondary button state has changed
  32866. */
  32867. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32868. /**
  32869. * Fired when the pad state has changed
  32870. */
  32871. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  32872. /**
  32873. * Fired when controllers stick values have changed
  32874. */
  32875. onPadValuesChangedObservable: Observable<StickValues>;
  32876. /**
  32877. * Array of button availible on the controller
  32878. */
  32879. protected _buttons: Array<MutableGamepadButton>;
  32880. private _onButtonStateChange;
  32881. /**
  32882. * Fired when a controller button's state has changed
  32883. * @param callback the callback containing the button that was modified
  32884. */
  32885. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  32886. /**
  32887. * X and Y axis corrisponding to the controllers joystick
  32888. */
  32889. pad: StickValues;
  32890. /**
  32891. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  32892. */
  32893. hand: string;
  32894. /**
  32895. * The default controller model for the controller
  32896. */
  32897. readonly defaultModel: AbstractMesh;
  32898. /**
  32899. * Creates a new WebVRController from a gamepad
  32900. * @param vrGamepad the gamepad that the WebVRController should be created from
  32901. */
  32902. constructor(vrGamepad: any);
  32903. /**
  32904. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  32905. */
  32906. update(): void;
  32907. /**
  32908. * Function to be called when a button is modified
  32909. */
  32910. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32911. /**
  32912. * Loads a mesh and attaches it to the controller
  32913. * @param scene the scene the mesh should be added to
  32914. * @param meshLoaded callback for when the mesh has been loaded
  32915. */
  32916. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32917. private _setButtonValue(newState, currentState, buttonIndex);
  32918. private _changes;
  32919. private _checkChanges(newState, currentState);
  32920. /**
  32921. * Disposes of th webVRCOntroller
  32922. */
  32923. dispose(): void;
  32924. }
  32925. }
  32926. declare module BABYLON {
  32927. /**
  32928. * Defines the WindowsMotionController object that the state of the windows motion controller
  32929. */
  32930. class WindowsMotionController extends WebVRController {
  32931. /**
  32932. * The base url used to load the left and right controller models
  32933. */
  32934. static MODEL_BASE_URL: string;
  32935. /**
  32936. * The name of the left controller model file
  32937. */
  32938. static MODEL_LEFT_FILENAME: string;
  32939. /**
  32940. * The name of the right controller model file
  32941. */
  32942. static MODEL_RIGHT_FILENAME: string;
  32943. /**
  32944. * The controller name prefix for this controller type
  32945. */
  32946. static readonly GAMEPAD_ID_PREFIX: string;
  32947. /**
  32948. * The controller id pattern for this controller type
  32949. */
  32950. private static readonly GAMEPAD_ID_PATTERN;
  32951. private _loadedMeshInfo;
  32952. private readonly _mapping;
  32953. /**
  32954. * Fired when the trackpad on this controller is clicked
  32955. */
  32956. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  32957. /**
  32958. * Fired when the trackpad on this controller is modified
  32959. */
  32960. onTrackpadValuesChangedObservable: Observable<StickValues>;
  32961. /**
  32962. * The current x and y values of this controller's trackpad
  32963. */
  32964. trackpad: StickValues;
  32965. /**
  32966. * Creates a new WindowsMotionController from a gamepad
  32967. * @param vrGamepad the gamepad that the controller should be created from
  32968. */
  32969. constructor(vrGamepad: any);
  32970. /**
  32971. * Fired when the trigger on this controller is modified
  32972. */
  32973. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32974. /**
  32975. * Fired when the menu button on this controller is modified
  32976. */
  32977. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32978. /**
  32979. * Fired when the grip button on this controller is modified
  32980. */
  32981. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32982. /**
  32983. * Fired when the thumbstick button on this controller is modified
  32984. */
  32985. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32986. /**
  32987. * Fired when the touchpad button on this controller is modified
  32988. */
  32989. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32990. /**
  32991. * Fired when the touchpad values on this controller are modified
  32992. */
  32993. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  32994. private _updateTrackpad();
  32995. /**
  32996. * Called once per frame by the engine.
  32997. */
  32998. update(): void;
  32999. /**
  33000. * Called once for each button that changed state since the last frame
  33001. * @param buttonIdx Which button index changed
  33002. * @param state New state of the button
  33003. * @param changes Which properties on the state changed since last frame
  33004. */
  33005. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33006. /**
  33007. * Moves the buttons on the controller mesh based on their current state
  33008. * @param buttonName the name of the button to move
  33009. * @param buttonValue the value of the button which determines the buttons new position
  33010. */
  33011. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  33012. /**
  33013. * Moves the axis on the controller mesh based on its current state
  33014. * @param axis the index of the axis
  33015. * @param axisValue the value of the axis which determines the meshes new position
  33016. * @hidden
  33017. */
  33018. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  33019. /**
  33020. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33021. * @param scene scene in which to add meshes
  33022. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33023. */
  33024. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  33025. /**
  33026. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  33027. * can be transformed by button presses and axes values, based on this._mapping.
  33028. *
  33029. * @param scene scene in which the meshes exist
  33030. * @param meshes list of meshes that make up the controller model to process
  33031. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  33032. */
  33033. private processModel(scene, meshes);
  33034. private createMeshInfo(rootNode);
  33035. /**
  33036. * Gets the ray of the controller in the direction the controller is pointing
  33037. * @param length the length the resulting ray should be
  33038. * @returns a ray in the direction the controller is pointing
  33039. */
  33040. getForwardRay(length?: number): Ray;
  33041. /**
  33042. * Disposes of the controller
  33043. */
  33044. dispose(): void;
  33045. }
  33046. }
  33047. declare module BABYLON {
  33048. }
  33049. declare module BABYLON {
  33050. /**
  33051. * Interface to implement to create a shadow generator compatible with BJS.
  33052. */
  33053. interface IShadowGenerator {
  33054. /**
  33055. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  33056. * @returns The render target texture if present otherwise, null
  33057. */
  33058. getShadowMap(): Nullable<RenderTargetTexture>;
  33059. /**
  33060. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  33061. * @returns The render target texture if the shadow map is present otherwise, null
  33062. */
  33063. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  33064. /**
  33065. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  33066. * @param subMesh The submesh we want to render in the shadow map
  33067. * @param useInstances Defines wether will draw in the map using instances
  33068. * @returns true if ready otherwise, false
  33069. */
  33070. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  33071. /**
  33072. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  33073. * @param defines Defines of the material we want to update
  33074. * @param lightIndex Index of the light in the enabled light list of the material
  33075. */
  33076. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  33077. /**
  33078. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  33079. * defined in the generator but impacting the effect).
  33080. * It implies the unifroms available on the materials are the standard BJS ones.
  33081. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  33082. * @param effect The effect we are binfing the information for
  33083. */
  33084. bindShadowLight(lightIndex: string, effect: Effect): void;
  33085. /**
  33086. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  33087. * (eq to shadow prjection matrix * light transform matrix)
  33088. * @returns The transform matrix used to create the shadow map
  33089. */
  33090. getTransformMatrix(): Matrix;
  33091. /**
  33092. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  33093. * Cube and 2D textures for instance.
  33094. */
  33095. recreateShadowMap(): void;
  33096. /**
  33097. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33098. * @param onCompiled Callback triggered at the and of the effects compilation
  33099. * @param options Sets of optional options forcing the compilation with different modes
  33100. */
  33101. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  33102. useInstances: boolean;
  33103. }>): void;
  33104. /**
  33105. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33106. * @param options Sets of optional options forcing the compilation with different modes
  33107. * @returns A promise that resolves when the compilation completes
  33108. */
  33109. forceCompilationAsync(options?: Partial<{
  33110. useInstances: boolean;
  33111. }>): Promise<void>;
  33112. /**
  33113. * Serializes the shadow generator setup to a json object.
  33114. * @returns The serialized JSON object
  33115. */
  33116. serialize(): any;
  33117. /**
  33118. * Disposes the Shadow map and related Textures and effects.
  33119. */
  33120. dispose(): void;
  33121. }
  33122. /**
  33123. * Default implementation IShadowGenerator.
  33124. * This is the main object responsible of generating shadows in the framework.
  33125. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  33126. */
  33127. class ShadowGenerator implements IShadowGenerator {
  33128. /**
  33129. * Shadow generator mode None: no filtering applied.
  33130. */
  33131. static readonly FILTER_NONE: number;
  33132. /**
  33133. * Shadow generator mode ESM: Exponential Shadow Mapping.
  33134. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33135. */
  33136. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  33137. /**
  33138. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  33139. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  33140. */
  33141. static readonly FILTER_POISSONSAMPLING: number;
  33142. /**
  33143. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  33144. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33145. */
  33146. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  33147. /**
  33148. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  33149. * edge artifacts on steep falloff.
  33150. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33151. */
  33152. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  33153. /**
  33154. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  33155. * edge artifacts on steep falloff.
  33156. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33157. */
  33158. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  33159. /**
  33160. * Shadow generator mode PCF: Percentage Closer Filtering
  33161. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  33162. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  33163. */
  33164. static readonly FILTER_PCF: number;
  33165. /**
  33166. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  33167. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  33168. * Contact Hardening
  33169. */
  33170. static readonly FILTER_PCSS: number;
  33171. /**
  33172. * Reserved for PCF and PCSS
  33173. * Highest Quality.
  33174. *
  33175. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  33176. *
  33177. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  33178. */
  33179. static readonly QUALITY_HIGH: number;
  33180. /**
  33181. * Reserved for PCF and PCSS
  33182. * Good tradeoff for quality/perf cross devices
  33183. *
  33184. * Execute PCF on a 3*3 kernel.
  33185. *
  33186. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  33187. */
  33188. static readonly QUALITY_MEDIUM: number;
  33189. /**
  33190. * Reserved for PCF and PCSS
  33191. * The lowest quality but the fastest.
  33192. *
  33193. * Execute PCF on a 1*1 kernel.
  33194. *
  33195. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  33196. */
  33197. static readonly QUALITY_LOW: number;
  33198. private _bias;
  33199. /**
  33200. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  33201. */
  33202. /**
  33203. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  33204. */
  33205. bias: number;
  33206. private _normalBias;
  33207. /**
  33208. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  33209. */
  33210. /**
  33211. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  33212. */
  33213. normalBias: number;
  33214. private _blurBoxOffset;
  33215. /**
  33216. * Gets the blur box offset: offset applied during the blur pass.
  33217. * Only usefull if useKernelBlur = false
  33218. */
  33219. /**
  33220. * Sets the blur box offset: offset applied during the blur pass.
  33221. * Only usefull if useKernelBlur = false
  33222. */
  33223. blurBoxOffset: number;
  33224. private _blurScale;
  33225. /**
  33226. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  33227. * 2 means half of the size.
  33228. */
  33229. /**
  33230. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  33231. * 2 means half of the size.
  33232. */
  33233. blurScale: number;
  33234. private _blurKernel;
  33235. /**
  33236. * Gets the blur kernel: kernel size of the blur pass.
  33237. * Only usefull if useKernelBlur = true
  33238. */
  33239. /**
  33240. * Sets the blur kernel: kernel size of the blur pass.
  33241. * Only usefull if useKernelBlur = true
  33242. */
  33243. blurKernel: number;
  33244. private _useKernelBlur;
  33245. /**
  33246. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  33247. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  33248. */
  33249. /**
  33250. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  33251. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  33252. */
  33253. useKernelBlur: boolean;
  33254. private _depthScale;
  33255. /**
  33256. * Gets the depth scale used in ESM mode.
  33257. */
  33258. /**
  33259. * Sets the depth scale used in ESM mode.
  33260. * This can override the scale stored on the light.
  33261. */
  33262. depthScale: number;
  33263. private _filter;
  33264. /**
  33265. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  33266. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  33267. */
  33268. /**
  33269. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  33270. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  33271. */
  33272. filter: number;
  33273. /**
  33274. * Gets if the current filter is set to Poisson Sampling.
  33275. */
  33276. /**
  33277. * Sets the current filter to Poisson Sampling.
  33278. */
  33279. usePoissonSampling: boolean;
  33280. /**
  33281. * Gets if the current filter is set to VSM.
  33282. * DEPRECATED. Should use useExponentialShadowMap instead.
  33283. */
  33284. /**
  33285. * Sets the current filter is to VSM.
  33286. * DEPRECATED. Should use useExponentialShadowMap instead.
  33287. */
  33288. useVarianceShadowMap: boolean;
  33289. /**
  33290. * Gets if the current filter is set to blurred VSM.
  33291. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  33292. */
  33293. /**
  33294. * Sets the current filter is to blurred VSM.
  33295. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  33296. */
  33297. useBlurVarianceShadowMap: boolean;
  33298. /**
  33299. * Gets if the current filter is set to ESM.
  33300. */
  33301. /**
  33302. * Sets the current filter is to ESM.
  33303. */
  33304. useExponentialShadowMap: boolean;
  33305. /**
  33306. * Gets if the current filter is set to filtered ESM.
  33307. */
  33308. /**
  33309. * Gets if the current filter is set to filtered ESM.
  33310. */
  33311. useBlurExponentialShadowMap: boolean;
  33312. /**
  33313. * Gets if the current filter is set to "close ESM" (using the inverse of the
  33314. * exponential to prevent steep falloff artifacts).
  33315. */
  33316. /**
  33317. * Sets the current filter to "close ESM" (using the inverse of the
  33318. * exponential to prevent steep falloff artifacts).
  33319. */
  33320. useCloseExponentialShadowMap: boolean;
  33321. /**
  33322. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  33323. * exponential to prevent steep falloff artifacts).
  33324. */
  33325. /**
  33326. * Sets the current filter to filtered "close ESM" (using the inverse of the
  33327. * exponential to prevent steep falloff artifacts).
  33328. */
  33329. useBlurCloseExponentialShadowMap: boolean;
  33330. /**
  33331. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  33332. */
  33333. /**
  33334. * Sets the current filter to "PCF" (percentage closer filtering).
  33335. */
  33336. usePercentageCloserFiltering: boolean;
  33337. private _filteringQuality;
  33338. /**
  33339. * Gets the PCF or PCSS Quality.
  33340. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  33341. */
  33342. /**
  33343. * Sets the PCF or PCSS Quality.
  33344. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  33345. */
  33346. filteringQuality: number;
  33347. /**
  33348. * Gets if the current filter is set to "PCSS" (contact hardening).
  33349. */
  33350. /**
  33351. * Sets the current filter to "PCSS" (contact hardening).
  33352. */
  33353. useContactHardeningShadow: boolean;
  33354. private _contactHardeningLightSizeUVRatio;
  33355. /**
  33356. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  33357. * Using a ratio helps keeping shape stability independently of the map size.
  33358. *
  33359. * It does not account for the light projection as it was having too much
  33360. * instability during the light setup or during light position changes.
  33361. *
  33362. * Only valid if useContactHardeningShadow is true.
  33363. */
  33364. /**
  33365. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  33366. * Using a ratio helps keeping shape stability independently of the map size.
  33367. *
  33368. * It does not account for the light projection as it was having too much
  33369. * instability during the light setup or during light position changes.
  33370. *
  33371. * Only valid if useContactHardeningShadow is true.
  33372. */
  33373. contactHardeningLightSizeUVRatio: number;
  33374. private _darkness;
  33375. /**
  33376. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  33377. * 0 means strongest and 1 would means no shadow.
  33378. * @returns the darkness.
  33379. */
  33380. getDarkness(): number;
  33381. /**
  33382. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  33383. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  33384. * @returns the shadow generator allowing fluent coding.
  33385. */
  33386. setDarkness(darkness: number): ShadowGenerator;
  33387. private _transparencyShadow;
  33388. /**
  33389. * Sets the ability to have transparent shadow (boolean).
  33390. * @param transparent True if transparent else False
  33391. * @returns the shadow generator allowing fluent coding
  33392. */
  33393. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  33394. private _shadowMap;
  33395. private _shadowMap2;
  33396. /**
  33397. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  33398. * @returns The render target texture if present otherwise, null
  33399. */
  33400. getShadowMap(): Nullable<RenderTargetTexture>;
  33401. /**
  33402. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  33403. * @returns The render target texture if the shadow map is present otherwise, null
  33404. */
  33405. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  33406. /**
  33407. * Helper function to add a mesh and its descendants to the list of shadow casters.
  33408. * @param mesh Mesh to add
  33409. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  33410. * @returns the Shadow Generator itself
  33411. */
  33412. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  33413. /**
  33414. * Helper function to remove a mesh and its descendants from the list of shadow casters
  33415. * @param mesh Mesh to remove
  33416. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  33417. * @returns the Shadow Generator itself
  33418. */
  33419. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  33420. /**
  33421. * Controls the extent to which the shadows fade out at the edge of the frustum
  33422. * Used only by directionals and spots
  33423. */
  33424. frustumEdgeFalloff: number;
  33425. private _light;
  33426. /**
  33427. * Returns the associated light object.
  33428. * @returns the light generating the shadow
  33429. */
  33430. getLight(): IShadowLight;
  33431. /**
  33432. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  33433. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  33434. * It might on the other hand introduce peter panning.
  33435. */
  33436. forceBackFacesOnly: boolean;
  33437. private _scene;
  33438. private _lightDirection;
  33439. private _effect;
  33440. private _viewMatrix;
  33441. private _projectionMatrix;
  33442. private _transformMatrix;
  33443. private _cachedPosition;
  33444. private _cachedDirection;
  33445. private _cachedDefines;
  33446. private _currentRenderID;
  33447. private _boxBlurPostprocess;
  33448. private _kernelBlurXPostprocess;
  33449. private _kernelBlurYPostprocess;
  33450. private _blurPostProcesses;
  33451. private _mapSize;
  33452. private _currentFaceIndex;
  33453. private _currentFaceIndexCache;
  33454. private _textureType;
  33455. private _defaultTextureMatrix;
  33456. /**
  33457. * Creates a ShadowGenerator object.
  33458. * A ShadowGenerator is the required tool to use the shadows.
  33459. * Each light casting shadows needs to use its own ShadowGenerator.
  33460. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  33461. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  33462. * @param light The light object generating the shadows.
  33463. * @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.
  33464. */
  33465. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  33466. private _initializeGenerator();
  33467. private _initializeShadowMap();
  33468. private _initializeBlurRTTAndPostProcesses();
  33469. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  33470. private _renderSubMeshForShadowMap(subMesh);
  33471. private _applyFilterValues();
  33472. /**
  33473. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33474. * @param onCompiled Callback triggered at the and of the effects compilation
  33475. * @param options Sets of optional options forcing the compilation with different modes
  33476. */
  33477. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  33478. useInstances: boolean;
  33479. }>): void;
  33480. /**
  33481. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33482. * @param options Sets of optional options forcing the compilation with different modes
  33483. * @returns A promise that resolves when the compilation completes
  33484. */
  33485. forceCompilationAsync(options?: Partial<{
  33486. useInstances: boolean;
  33487. }>): Promise<void>;
  33488. /**
  33489. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  33490. * @param subMesh The submesh we want to render in the shadow map
  33491. * @param useInstances Defines wether will draw in the map using instances
  33492. * @returns true if ready otherwise, false
  33493. */
  33494. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  33495. /**
  33496. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  33497. * @param defines Defines of the material we want to update
  33498. * @param lightIndex Index of the light in the enabled light list of the material
  33499. */
  33500. prepareDefines(defines: any, lightIndex: number): void;
  33501. /**
  33502. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  33503. * defined in the generator but impacting the effect).
  33504. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  33505. * @param effect The effect we are binfing the information for
  33506. */
  33507. bindShadowLight(lightIndex: string, effect: Effect): void;
  33508. /**
  33509. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  33510. * (eq to shadow prjection matrix * light transform matrix)
  33511. * @returns The transform matrix used to create the shadow map
  33512. */
  33513. getTransformMatrix(): Matrix;
  33514. /**
  33515. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  33516. * Cube and 2D textures for instance.
  33517. */
  33518. recreateShadowMap(): void;
  33519. private _disposeBlurPostProcesses();
  33520. private _disposeRTTandPostProcesses();
  33521. /**
  33522. * Disposes the ShadowGenerator.
  33523. * Returns nothing.
  33524. */
  33525. dispose(): void;
  33526. /**
  33527. * Serializes the shadow generator setup to a json object.
  33528. * @returns The serialized JSON object
  33529. */
  33530. serialize(): any;
  33531. /**
  33532. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  33533. * @param parsedShadowGenerator The JSON object to parse
  33534. * @param scene The scene to create the shadow map for
  33535. * @returns The parsed shadow generator
  33536. */
  33537. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  33538. }
  33539. }
  33540. declare module BABYLON {
  33541. /**
  33542. * Background material used to create an efficient environement around your scene.
  33543. */
  33544. class BackgroundMaterial extends PushMaterial {
  33545. /**
  33546. * Standard reflectance value at parallel view angle.
  33547. */
  33548. static StandardReflectance0: number;
  33549. /**
  33550. * Standard reflectance value at grazing angle.
  33551. */
  33552. static StandardReflectance90: number;
  33553. protected _primaryColor: Color3;
  33554. /**
  33555. * Key light Color (multiply against the environement texture)
  33556. */
  33557. primaryColor: Color3;
  33558. protected __perceptualColor: Nullable<Color3>;
  33559. /**
  33560. * Experimental Internal Use Only.
  33561. *
  33562. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  33563. * This acts as a helper to set the primary color to a more "human friendly" value.
  33564. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  33565. * output color as close as possible from the chosen value.
  33566. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  33567. * part of lighting setup.)
  33568. */
  33569. _perceptualColor: Nullable<Color3>;
  33570. protected _primaryColorShadowLevel: float;
  33571. /**
  33572. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  33573. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  33574. */
  33575. primaryColorShadowLevel: float;
  33576. protected _primaryColorHighlightLevel: float;
  33577. /**
  33578. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  33579. * The primary color is used at the level chosen to define what the white area would look.
  33580. */
  33581. primaryColorHighlightLevel: float;
  33582. protected _reflectionTexture: Nullable<BaseTexture>;
  33583. /**
  33584. * Reflection Texture used in the material.
  33585. * Should be author in a specific way for the best result (refer to the documentation).
  33586. */
  33587. reflectionTexture: Nullable<BaseTexture>;
  33588. protected _reflectionBlur: float;
  33589. /**
  33590. * Reflection Texture level of blur.
  33591. *
  33592. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  33593. * texture twice.
  33594. */
  33595. reflectionBlur: float;
  33596. protected _diffuseTexture: Nullable<BaseTexture>;
  33597. /**
  33598. * Diffuse Texture used in the material.
  33599. * Should be author in a specific way for the best result (refer to the documentation).
  33600. */
  33601. diffuseTexture: Nullable<BaseTexture>;
  33602. protected _shadowLights: Nullable<IShadowLight[]>;
  33603. /**
  33604. * Specify the list of lights casting shadow on the material.
  33605. * All scene shadow lights will be included if null.
  33606. */
  33607. shadowLights: Nullable<IShadowLight[]>;
  33608. protected _shadowLevel: float;
  33609. /**
  33610. * Helps adjusting the shadow to a softer level if required.
  33611. * 0 means black shadows and 1 means no shadows.
  33612. */
  33613. shadowLevel: float;
  33614. protected _sceneCenter: Vector3;
  33615. /**
  33616. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  33617. * It is usually zero but might be interesting to modify according to your setup.
  33618. */
  33619. sceneCenter: Vector3;
  33620. protected _opacityFresnel: boolean;
  33621. /**
  33622. * This helps specifying that the material is falling off to the sky box at grazing angle.
  33623. * This helps ensuring a nice transition when the camera goes under the ground.
  33624. */
  33625. opacityFresnel: boolean;
  33626. protected _reflectionFresnel: boolean;
  33627. /**
  33628. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  33629. * This helps adding a mirror texture on the ground.
  33630. */
  33631. reflectionFresnel: boolean;
  33632. protected _reflectionFalloffDistance: number;
  33633. /**
  33634. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  33635. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  33636. */
  33637. reflectionFalloffDistance: number;
  33638. protected _reflectionAmount: number;
  33639. /**
  33640. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  33641. */
  33642. reflectionAmount: number;
  33643. protected _reflectionReflectance0: number;
  33644. /**
  33645. * This specifies the weight of the reflection at grazing angle.
  33646. */
  33647. reflectionReflectance0: number;
  33648. protected _reflectionReflectance90: number;
  33649. /**
  33650. * This specifies the weight of the reflection at a perpendicular point of view.
  33651. */
  33652. reflectionReflectance90: number;
  33653. /**
  33654. * Sets the reflection reflectance fresnel values according to the default standard
  33655. * empirically know to work well :-)
  33656. */
  33657. reflectionStandardFresnelWeight: number;
  33658. protected _useRGBColor: boolean;
  33659. /**
  33660. * Helps to directly use the maps channels instead of their level.
  33661. */
  33662. useRGBColor: boolean;
  33663. protected _enableNoise: boolean;
  33664. /**
  33665. * This helps reducing the banding effect that could occur on the background.
  33666. */
  33667. enableNoise: boolean;
  33668. /**
  33669. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  33670. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  33671. * Recommended to be keep at 1.0 except for special cases.
  33672. */
  33673. fovMultiplier: number;
  33674. private _fovMultiplier;
  33675. /**
  33676. * Enable the FOV adjustment feature controlled by fovMultiplier.
  33677. */
  33678. useEquirectangularFOV: boolean;
  33679. private _maxSimultaneousLights;
  33680. /**
  33681. * Number of Simultaneous lights allowed on the material.
  33682. */
  33683. maxSimultaneousLights: int;
  33684. /**
  33685. * Default configuration related to image processing available in the Background Material.
  33686. */
  33687. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33688. /**
  33689. * Keep track of the image processing observer to allow dispose and replace.
  33690. */
  33691. private _imageProcessingObserver;
  33692. /**
  33693. * Attaches a new image processing configuration to the PBR Material.
  33694. * @param configuration (if null the scene configuration will be use)
  33695. */
  33696. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  33697. /**
  33698. * Gets the image processing configuration used either in this material.
  33699. */
  33700. /**
  33701. * Sets the Default image processing configuration used either in the this material.
  33702. *
  33703. * If sets to null, the scene one is in use.
  33704. */
  33705. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  33706. /**
  33707. * Gets wether the color curves effect is enabled.
  33708. */
  33709. /**
  33710. * Sets wether the color curves effect is enabled.
  33711. */
  33712. cameraColorCurvesEnabled: boolean;
  33713. /**
  33714. * Gets wether the color grading effect is enabled.
  33715. */
  33716. /**
  33717. * Gets wether the color grading effect is enabled.
  33718. */
  33719. cameraColorGradingEnabled: boolean;
  33720. /**
  33721. * Gets wether tonemapping is enabled or not.
  33722. */
  33723. /**
  33724. * Sets wether tonemapping is enabled or not
  33725. */
  33726. cameraToneMappingEnabled: boolean;
  33727. /**
  33728. * The camera exposure used on this material.
  33729. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33730. * This corresponds to a photographic exposure.
  33731. */
  33732. /**
  33733. * The camera exposure used on this material.
  33734. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33735. * This corresponds to a photographic exposure.
  33736. */
  33737. cameraExposure: float;
  33738. /**
  33739. * Gets The camera contrast used on this material.
  33740. */
  33741. /**
  33742. * Sets The camera contrast used on this material.
  33743. */
  33744. cameraContrast: float;
  33745. /**
  33746. * Gets the Color Grading 2D Lookup Texture.
  33747. */
  33748. /**
  33749. * Sets the Color Grading 2D Lookup Texture.
  33750. */
  33751. cameraColorGradingTexture: Nullable<BaseTexture>;
  33752. /**
  33753. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33754. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33755. * 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;
  33756. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33757. */
  33758. /**
  33759. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33760. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33761. * 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;
  33762. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33763. */
  33764. cameraColorCurves: Nullable<ColorCurves>;
  33765. /**
  33766. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  33767. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  33768. */
  33769. switchToBGR: boolean;
  33770. private _renderTargets;
  33771. private _reflectionControls;
  33772. private _white;
  33773. private _primaryShadowColor;
  33774. private _primaryHighlightColor;
  33775. /**
  33776. * Instantiates a Background Material in the given scene
  33777. * @param name The friendly name of the material
  33778. * @param scene The scene to add the material to
  33779. */
  33780. constructor(name: string, scene: Scene);
  33781. /**
  33782. * The entire material has been created in order to prevent overdraw.
  33783. * @returns false
  33784. */
  33785. needAlphaTesting(): boolean;
  33786. /**
  33787. * The entire material has been created in order to prevent overdraw.
  33788. * @returns true if blending is enable
  33789. */
  33790. needAlphaBlending(): boolean;
  33791. /**
  33792. * Checks wether the material is ready to be rendered for a given mesh.
  33793. * @param mesh The mesh to render
  33794. * @param subMesh The submesh to check against
  33795. * @param useInstances Specify wether or not the material is used with instances
  33796. * @returns true if all the dependencies are ready (Textures, Effects...)
  33797. */
  33798. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  33799. /**
  33800. * Compute the primary color according to the chosen perceptual color.
  33801. */
  33802. private _computePrimaryColorFromPerceptualColor();
  33803. /**
  33804. * Compute the highlights and shadow colors according to their chosen levels.
  33805. */
  33806. private _computePrimaryColors();
  33807. /**
  33808. * Build the uniform buffer used in the material.
  33809. */
  33810. buildUniformLayout(): void;
  33811. /**
  33812. * Unbind the material.
  33813. */
  33814. unbind(): void;
  33815. /**
  33816. * Bind only the world matrix to the material.
  33817. * @param world The world matrix to bind.
  33818. */
  33819. bindOnlyWorldMatrix(world: Matrix): void;
  33820. /**
  33821. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  33822. * @param world The world matrix to bind.
  33823. * @param subMesh The submesh to bind for.
  33824. */
  33825. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  33826. /**
  33827. * Dispose the material.
  33828. * @param forceDisposeEffect Force disposal of the associated effect.
  33829. * @param forceDisposeTextures Force disposal of the associated textures.
  33830. */
  33831. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  33832. /**
  33833. * Clones the material.
  33834. * @param name The cloned name.
  33835. * @returns The cloned material.
  33836. */
  33837. clone(name: string): BackgroundMaterial;
  33838. /**
  33839. * Serializes the current material to its JSON representation.
  33840. * @returns The JSON representation.
  33841. */
  33842. serialize(): any;
  33843. /**
  33844. * Gets the class name of the material
  33845. * @returns "BackgroundMaterial"
  33846. */
  33847. getClassName(): string;
  33848. /**
  33849. * Parse a JSON input to create back a background material.
  33850. * @param source The JSON data to parse
  33851. * @param scene The scene to create the parsed material in
  33852. * @param rootUrl The root url of the assets the material depends upon
  33853. * @returns the instantiated BackgroundMaterial.
  33854. */
  33855. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  33856. }
  33857. }
  33858. declare module BABYLON {
  33859. /**
  33860. * The Physically based material base class of BJS.
  33861. *
  33862. * This offers the main features of a standard PBR material.
  33863. * For more information, please refer to the documentation :
  33864. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  33865. */
  33866. abstract class PBRBaseMaterial extends PushMaterial {
  33867. /**
  33868. * Intensity of the direct lights e.g. the four lights available in your scene.
  33869. * This impacts both the direct diffuse and specular highlights.
  33870. */
  33871. protected _directIntensity: number;
  33872. /**
  33873. * Intensity of the emissive part of the material.
  33874. * This helps controlling the emissive effect without modifying the emissive color.
  33875. */
  33876. protected _emissiveIntensity: number;
  33877. /**
  33878. * Intensity of the environment e.g. how much the environment will light the object
  33879. * either through harmonics for rough material or through the refelction for shiny ones.
  33880. */
  33881. protected _environmentIntensity: number;
  33882. /**
  33883. * This is a special control allowing the reduction of the specular highlights coming from the
  33884. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  33885. */
  33886. protected _specularIntensity: number;
  33887. /**
  33888. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  33889. */
  33890. private _lightingInfos;
  33891. /**
  33892. * Debug Control allowing disabling the bump map on this material.
  33893. */
  33894. protected _disableBumpMap: boolean;
  33895. /**
  33896. * AKA Diffuse Texture in standard nomenclature.
  33897. */
  33898. protected _albedoTexture: BaseTexture;
  33899. /**
  33900. * AKA Occlusion Texture in other nomenclature.
  33901. */
  33902. protected _ambientTexture: BaseTexture;
  33903. /**
  33904. * AKA Occlusion Texture Intensity in other nomenclature.
  33905. */
  33906. protected _ambientTextureStrength: number;
  33907. /**
  33908. * Stores the alpha values in a texture.
  33909. */
  33910. protected _opacityTexture: BaseTexture;
  33911. /**
  33912. * Stores the reflection values in a texture.
  33913. */
  33914. protected _reflectionTexture: BaseTexture;
  33915. /**
  33916. * Stores the refraction values in a texture.
  33917. */
  33918. protected _refractionTexture: BaseTexture;
  33919. /**
  33920. * Stores the emissive values in a texture.
  33921. */
  33922. protected _emissiveTexture: BaseTexture;
  33923. /**
  33924. * AKA Specular texture in other nomenclature.
  33925. */
  33926. protected _reflectivityTexture: BaseTexture;
  33927. /**
  33928. * Used to switch from specular/glossiness to metallic/roughness workflow.
  33929. */
  33930. protected _metallicTexture: BaseTexture;
  33931. /**
  33932. * Specifies the metallic scalar of the metallic/roughness workflow.
  33933. * Can also be used to scale the metalness values of the metallic texture.
  33934. */
  33935. protected _metallic: number;
  33936. /**
  33937. * Specifies the roughness scalar of the metallic/roughness workflow.
  33938. * Can also be used to scale the roughness values of the metallic texture.
  33939. */
  33940. protected _roughness: number;
  33941. /**
  33942. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  33943. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  33944. */
  33945. protected _microSurfaceTexture: BaseTexture;
  33946. /**
  33947. * Stores surface normal data used to displace a mesh in a texture.
  33948. */
  33949. protected _bumpTexture: BaseTexture;
  33950. /**
  33951. * Stores the pre-calculated light information of a mesh in a texture.
  33952. */
  33953. protected _lightmapTexture: BaseTexture;
  33954. /**
  33955. * The color of a material in ambient lighting.
  33956. */
  33957. protected _ambientColor: Color3;
  33958. /**
  33959. * AKA Diffuse Color in other nomenclature.
  33960. */
  33961. protected _albedoColor: Color3;
  33962. /**
  33963. * AKA Specular Color in other nomenclature.
  33964. */
  33965. protected _reflectivityColor: Color3;
  33966. /**
  33967. * The color applied when light is reflected from a material.
  33968. */
  33969. protected _reflectionColor: Color3;
  33970. /**
  33971. * The color applied when light is emitted from a material.
  33972. */
  33973. protected _emissiveColor: Color3;
  33974. /**
  33975. * AKA Glossiness in other nomenclature.
  33976. */
  33977. protected _microSurface: number;
  33978. /**
  33979. * source material index of refraction (IOR)' / 'destination material IOR.
  33980. */
  33981. protected _indexOfRefraction: number;
  33982. /**
  33983. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  33984. */
  33985. protected _invertRefractionY: boolean;
  33986. /**
  33987. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  33988. * Materials half opaque for instance using refraction could benefit from this control.
  33989. */
  33990. protected _linkRefractionWithTransparency: boolean;
  33991. /**
  33992. * Specifies that the material will use the light map as a show map.
  33993. */
  33994. protected _useLightmapAsShadowmap: boolean;
  33995. /**
  33996. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  33997. * makes the reflect vector face the model (under horizon).
  33998. */
  33999. protected _useHorizonOcclusion: boolean;
  34000. /**
  34001. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  34002. * too much the area relying on ambient texture to define their ambient occlusion.
  34003. */
  34004. protected _useRadianceOcclusion: boolean;
  34005. /**
  34006. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  34007. */
  34008. protected _useAlphaFromAlbedoTexture: boolean;
  34009. /**
  34010. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  34011. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  34012. */
  34013. protected _useSpecularOverAlpha: boolean;
  34014. /**
  34015. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  34016. */
  34017. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  34018. /**
  34019. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  34020. */
  34021. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  34022. /**
  34023. * Specifies if the metallic texture contains the roughness information in its green channel.
  34024. */
  34025. protected _useRoughnessFromMetallicTextureGreen: boolean;
  34026. /**
  34027. * Specifies if the metallic texture contains the metallness information in its blue channel.
  34028. */
  34029. protected _useMetallnessFromMetallicTextureBlue: boolean;
  34030. /**
  34031. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  34032. */
  34033. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  34034. /**
  34035. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  34036. */
  34037. protected _useAmbientInGrayScale: boolean;
  34038. /**
  34039. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  34040. * The material will try to infer what glossiness each pixel should be.
  34041. */
  34042. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  34043. /**
  34044. * BJS is using an harcoded light falloff based on a manually sets up range.
  34045. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  34046. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  34047. */
  34048. protected _usePhysicalLightFalloff: boolean;
  34049. /**
  34050. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  34051. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  34052. */
  34053. protected _useRadianceOverAlpha: boolean;
  34054. /**
  34055. * Allows using an object space normal map (instead of tangent space).
  34056. */
  34057. protected _useObjectSpaceNormalMap: boolean;
  34058. /**
  34059. * Allows using the bump map in parallax mode.
  34060. */
  34061. protected _useParallax: boolean;
  34062. /**
  34063. * Allows using the bump map in parallax occlusion mode.
  34064. */
  34065. protected _useParallaxOcclusion: boolean;
  34066. /**
  34067. * Controls the scale bias of the parallax mode.
  34068. */
  34069. protected _parallaxScaleBias: number;
  34070. /**
  34071. * If sets to true, disables all the lights affecting the material.
  34072. */
  34073. protected _disableLighting: boolean;
  34074. /**
  34075. * Number of Simultaneous lights allowed on the material.
  34076. */
  34077. protected _maxSimultaneousLights: number;
  34078. /**
  34079. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  34080. */
  34081. protected _invertNormalMapX: boolean;
  34082. /**
  34083. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  34084. */
  34085. protected _invertNormalMapY: boolean;
  34086. /**
  34087. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  34088. */
  34089. protected _twoSidedLighting: boolean;
  34090. /**
  34091. * Defines the alpha limits in alpha test mode.
  34092. */
  34093. protected _alphaCutOff: number;
  34094. /**
  34095. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  34096. */
  34097. protected _forceAlphaTest: boolean;
  34098. /**
  34099. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34100. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  34101. */
  34102. protected _useAlphaFresnel: boolean;
  34103. /**
  34104. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34105. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  34106. */
  34107. protected _useLinearAlphaFresnel: boolean;
  34108. /**
  34109. * The transparency mode of the material.
  34110. */
  34111. protected _transparencyMode: Nullable<number>;
  34112. /**
  34113. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  34114. * from cos thetav and roughness:
  34115. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  34116. */
  34117. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  34118. /**
  34119. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  34120. */
  34121. protected _forceIrradianceInFragment: boolean;
  34122. /**
  34123. * Force normal to face away from face.
  34124. */
  34125. protected _forceNormalForward: boolean;
  34126. /**
  34127. * Enables specular anti aliasing in the PBR shader.
  34128. * It will both interacts on the Geometry for analytical and IBL lighting.
  34129. * It also prefilter the roughness map based on the bump values.
  34130. */
  34131. protected _enableSpecularAntiAliasing: boolean;
  34132. /**
  34133. * Default configuration related to image processing available in the PBR Material.
  34134. */
  34135. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34136. /**
  34137. * Keep track of the image processing observer to allow dispose and replace.
  34138. */
  34139. private _imageProcessingObserver;
  34140. /**
  34141. * Attaches a new image processing configuration to the PBR Material.
  34142. * @param configuration
  34143. */
  34144. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  34145. /**
  34146. * Stores the available render targets.
  34147. */
  34148. private _renderTargets;
  34149. /**
  34150. * Sets the global ambient color for the material used in lighting calculations.
  34151. */
  34152. private _globalAmbientColor;
  34153. /**
  34154. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  34155. */
  34156. private _useLogarithmicDepth;
  34157. /**
  34158. * If set to true, no lighting calculations will be applied.
  34159. */
  34160. private _unlit;
  34161. /**
  34162. * Instantiates a new PBRMaterial instance.
  34163. *
  34164. * @param name The material name
  34165. * @param scene The scene the material will be use in.
  34166. */
  34167. constructor(name: string, scene: Scene);
  34168. /**
  34169. * Gets the name of the material class.
  34170. */
  34171. getClassName(): string;
  34172. /**
  34173. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  34174. */
  34175. /**
  34176. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  34177. */
  34178. useLogarithmicDepth: boolean;
  34179. /**
  34180. * Gets the current transparency mode.
  34181. */
  34182. /**
  34183. * Sets the transparency mode of the material.
  34184. *
  34185. * | Value | Type | Description |
  34186. * | ----- | ----------------------------------- | ----------- |
  34187. * | 0 | OPAQUE | |
  34188. * | 1 | ALPHATEST | |
  34189. * | 2 | ALPHABLEND | |
  34190. * | 3 | ALPHATESTANDBLEND | |
  34191. *
  34192. */
  34193. transparencyMode: Nullable<number>;
  34194. /**
  34195. * Returns true if alpha blending should be disabled.
  34196. */
  34197. private readonly _disableAlphaBlending;
  34198. /**
  34199. * Specifies whether or not this material should be rendered in alpha blend mode.
  34200. */
  34201. needAlphaBlending(): boolean;
  34202. /**
  34203. * Specifies if the mesh will require alpha blending.
  34204. * @param mesh - BJS mesh.
  34205. */
  34206. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  34207. /**
  34208. * Specifies whether or not this material should be rendered in alpha test mode.
  34209. */
  34210. needAlphaTesting(): boolean;
  34211. /**
  34212. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  34213. */
  34214. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  34215. /**
  34216. * Gets the texture used for the alpha test.
  34217. */
  34218. getAlphaTestTexture(): BaseTexture;
  34219. /**
  34220. * Stores the reflectivity values based on metallic roughness workflow.
  34221. */
  34222. private static _scaledReflectivity;
  34223. /**
  34224. * Specifies that the submesh is ready to be used.
  34225. * @param mesh - BJS mesh.
  34226. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  34227. * @param useInstances - Specifies that instances should be used.
  34228. * @returns - boolean indicating that the submesh is ready or not.
  34229. */
  34230. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  34231. /**
  34232. * Specifies if the material uses metallic roughness workflow.
  34233. * @returns boolean specifiying if the material uses metallic roughness workflow.
  34234. */
  34235. isMetallicWorkflow(): boolean;
  34236. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  34237. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  34238. /**
  34239. * Force shader compilation
  34240. */
  34241. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  34242. clipPlane: boolean;
  34243. }>): void;
  34244. /**
  34245. * Initializes the uniform buffer layout for the shader.
  34246. */
  34247. buildUniformLayout(): void;
  34248. /**
  34249. * Unbinds the textures.
  34250. */
  34251. unbind(): void;
  34252. /**
  34253. * Binds the submesh data.
  34254. * @param world - The world matrix.
  34255. * @param mesh - The BJS mesh.
  34256. * @param subMesh - A submesh of the BJS mesh.
  34257. */
  34258. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  34259. /**
  34260. * Returns the animatable textures.
  34261. * @returns - Array of animatable textures.
  34262. */
  34263. getAnimatables(): IAnimatable[];
  34264. /**
  34265. * Returns the texture used for reflections.
  34266. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  34267. */
  34268. private _getReflectionTexture();
  34269. /**
  34270. * Returns the texture used for refraction or null if none is used.
  34271. * @returns - Refection texture if present. If no refraction texture and refraction
  34272. * is linked with transparency, returns environment texture. Otherwise, returns null.
  34273. */
  34274. private _getRefractionTexture();
  34275. /**
  34276. * Disposes the resources of the material.
  34277. * @param forceDisposeEffect - Forces the disposal of effects.
  34278. * @param forceDisposeTextures - Forces the disposal of all textures.
  34279. */
  34280. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  34281. }
  34282. }
  34283. declare module BABYLON {
  34284. /**
  34285. * The Physically based simple base material of BJS.
  34286. *
  34287. * This enables better naming and convention enforcements on top of the pbrMaterial.
  34288. * It is used as the base class for both the specGloss and metalRough conventions.
  34289. */
  34290. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  34291. /**
  34292. * Number of Simultaneous lights allowed on the material.
  34293. */
  34294. maxSimultaneousLights: number;
  34295. /**
  34296. * If sets to true, disables all the lights affecting the material.
  34297. */
  34298. disableLighting: boolean;
  34299. /**
  34300. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  34301. */
  34302. environmentTexture: BaseTexture;
  34303. /**
  34304. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  34305. */
  34306. invertNormalMapX: boolean;
  34307. /**
  34308. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  34309. */
  34310. invertNormalMapY: boolean;
  34311. /**
  34312. * Normal map used in the model.
  34313. */
  34314. normalTexture: BaseTexture;
  34315. /**
  34316. * Emissivie color used to self-illuminate the model.
  34317. */
  34318. emissiveColor: Color3;
  34319. /**
  34320. * Emissivie texture used to self-illuminate the model.
  34321. */
  34322. emissiveTexture: BaseTexture;
  34323. /**
  34324. * Occlusion Channel Strenght.
  34325. */
  34326. occlusionStrength: number;
  34327. /**
  34328. * Occlusion Texture of the material (adding extra occlusion effects).
  34329. */
  34330. occlusionTexture: BaseTexture;
  34331. /**
  34332. * Defines the alpha limits in alpha test mode.
  34333. */
  34334. alphaCutOff: number;
  34335. /**
  34336. * Gets the current double sided mode.
  34337. */
  34338. /**
  34339. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  34340. */
  34341. doubleSided: boolean;
  34342. lightmapTexture: BaseTexture;
  34343. useLightmapAsShadowmap: boolean;
  34344. /**
  34345. * Return the active textures of the material.
  34346. */
  34347. getActiveTextures(): BaseTexture[];
  34348. hasTexture(texture: BaseTexture): boolean;
  34349. /**
  34350. * Instantiates a new PBRMaterial instance.
  34351. *
  34352. * @param name The material name
  34353. * @param scene The scene the material will be use in.
  34354. */
  34355. constructor(name: string, scene: Scene);
  34356. getClassName(): string;
  34357. }
  34358. }
  34359. declare module BABYLON {
  34360. /**
  34361. * The Physically based material of BJS.
  34362. *
  34363. * This offers the main features of a standard PBR material.
  34364. * For more information, please refer to the documentation :
  34365. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  34366. */
  34367. class PBRMaterial extends PBRBaseMaterial {
  34368. private static _PBRMATERIAL_OPAQUE;
  34369. /**
  34370. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  34371. */
  34372. static readonly PBRMATERIAL_OPAQUE: number;
  34373. /**
  34374. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  34375. */
  34376. private static _PBRMATERIAL_ALPHATEST;
  34377. /**
  34378. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  34379. */
  34380. static readonly PBRMATERIAL_ALPHATEST: number;
  34381. /**
  34382. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  34383. */
  34384. private static _PBRMATERIAL_ALPHABLEND;
  34385. /**
  34386. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  34387. */
  34388. static readonly PBRMATERIAL_ALPHABLEND: number;
  34389. /**
  34390. * 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.
  34391. * They are also discarded below the alpha cutoff threshold to improve performances.
  34392. */
  34393. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  34394. /**
  34395. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  34396. * They are also discarded below the alpha cutoff threshold to improve performances.
  34397. */
  34398. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  34399. /**
  34400. * Intensity of the direct lights e.g. the four lights available in your scene.
  34401. * This impacts both the direct diffuse and specular highlights.
  34402. */
  34403. directIntensity: number;
  34404. /**
  34405. * Intensity of the emissive part of the material.
  34406. * This helps controlling the emissive effect without modifying the emissive color.
  34407. */
  34408. emissiveIntensity: number;
  34409. /**
  34410. * Intensity of the environment e.g. how much the environment will light the object
  34411. * either through harmonics for rough material or through the refelction for shiny ones.
  34412. */
  34413. environmentIntensity: number;
  34414. /**
  34415. * This is a special control allowing the reduction of the specular highlights coming from the
  34416. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  34417. */
  34418. specularIntensity: number;
  34419. /**
  34420. * Debug Control allowing disabling the bump map on this material.
  34421. */
  34422. disableBumpMap: boolean;
  34423. /**
  34424. * AKA Diffuse Texture in standard nomenclature.
  34425. */
  34426. albedoTexture: BaseTexture;
  34427. /**
  34428. * AKA Occlusion Texture in other nomenclature.
  34429. */
  34430. ambientTexture: BaseTexture;
  34431. /**
  34432. * AKA Occlusion Texture Intensity in other nomenclature.
  34433. */
  34434. ambientTextureStrength: number;
  34435. /**
  34436. * Stores the alpha values in a texture.
  34437. */
  34438. opacityTexture: BaseTexture;
  34439. /**
  34440. * Stores the reflection values in a texture.
  34441. */
  34442. reflectionTexture: Nullable<BaseTexture>;
  34443. /**
  34444. * Stores the emissive values in a texture.
  34445. */
  34446. emissiveTexture: BaseTexture;
  34447. /**
  34448. * AKA Specular texture in other nomenclature.
  34449. */
  34450. reflectivityTexture: BaseTexture;
  34451. /**
  34452. * Used to switch from specular/glossiness to metallic/roughness workflow.
  34453. */
  34454. metallicTexture: BaseTexture;
  34455. /**
  34456. * Specifies the metallic scalar of the metallic/roughness workflow.
  34457. * Can also be used to scale the metalness values of the metallic texture.
  34458. */
  34459. metallic: number;
  34460. /**
  34461. * Specifies the roughness scalar of the metallic/roughness workflow.
  34462. * Can also be used to scale the roughness values of the metallic texture.
  34463. */
  34464. roughness: number;
  34465. /**
  34466. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  34467. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  34468. */
  34469. microSurfaceTexture: BaseTexture;
  34470. /**
  34471. * Stores surface normal data used to displace a mesh in a texture.
  34472. */
  34473. bumpTexture: BaseTexture;
  34474. /**
  34475. * Stores the pre-calculated light information of a mesh in a texture.
  34476. */
  34477. lightmapTexture: BaseTexture;
  34478. /**
  34479. * Stores the refracted light information in a texture.
  34480. */
  34481. refractionTexture: BaseTexture;
  34482. /**
  34483. * The color of a material in ambient lighting.
  34484. */
  34485. ambientColor: Color3;
  34486. /**
  34487. * AKA Diffuse Color in other nomenclature.
  34488. */
  34489. albedoColor: Color3;
  34490. /**
  34491. * AKA Specular Color in other nomenclature.
  34492. */
  34493. reflectivityColor: Color3;
  34494. /**
  34495. * The color reflected from the material.
  34496. */
  34497. reflectionColor: Color3;
  34498. /**
  34499. * The color emitted from the material.
  34500. */
  34501. emissiveColor: Color3;
  34502. /**
  34503. * AKA Glossiness in other nomenclature.
  34504. */
  34505. microSurface: number;
  34506. /**
  34507. * source material index of refraction (IOR)' / 'destination material IOR.
  34508. */
  34509. indexOfRefraction: number;
  34510. /**
  34511. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  34512. */
  34513. invertRefractionY: boolean;
  34514. /**
  34515. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  34516. * Materials half opaque for instance using refraction could benefit from this control.
  34517. */
  34518. linkRefractionWithTransparency: boolean;
  34519. useLightmapAsShadowmap: boolean;
  34520. /**
  34521. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  34522. */
  34523. useAlphaFromAlbedoTexture: boolean;
  34524. /**
  34525. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  34526. */
  34527. forceAlphaTest: boolean;
  34528. /**
  34529. * Defines the alpha limits in alpha test mode.
  34530. */
  34531. alphaCutOff: number;
  34532. /**
  34533. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  34534. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  34535. */
  34536. useSpecularOverAlpha: boolean;
  34537. /**
  34538. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  34539. */
  34540. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  34541. /**
  34542. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  34543. */
  34544. useRoughnessFromMetallicTextureAlpha: boolean;
  34545. /**
  34546. * Specifies if the metallic texture contains the roughness information in its green channel.
  34547. */
  34548. useRoughnessFromMetallicTextureGreen: boolean;
  34549. /**
  34550. * Specifies if the metallic texture contains the metallness information in its blue channel.
  34551. */
  34552. useMetallnessFromMetallicTextureBlue: boolean;
  34553. /**
  34554. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  34555. */
  34556. useAmbientOcclusionFromMetallicTextureRed: boolean;
  34557. /**
  34558. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  34559. */
  34560. useAmbientInGrayScale: boolean;
  34561. /**
  34562. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  34563. * The material will try to infer what glossiness each pixel should be.
  34564. */
  34565. useAutoMicroSurfaceFromReflectivityMap: boolean;
  34566. /**
  34567. * BJS is using an harcoded light falloff based on a manually sets up range.
  34568. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  34569. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  34570. */
  34571. usePhysicalLightFalloff: boolean;
  34572. /**
  34573. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  34574. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  34575. */
  34576. useRadianceOverAlpha: boolean;
  34577. /**
  34578. * Allows using an object space normal map (instead of tangent space).
  34579. */
  34580. useObjectSpaceNormalMap: boolean;
  34581. /**
  34582. * Allows using the bump map in parallax mode.
  34583. */
  34584. useParallax: boolean;
  34585. /**
  34586. * Allows using the bump map in parallax occlusion mode.
  34587. */
  34588. useParallaxOcclusion: boolean;
  34589. /**
  34590. * Controls the scale bias of the parallax mode.
  34591. */
  34592. parallaxScaleBias: number;
  34593. /**
  34594. * If sets to true, disables all the lights affecting the material.
  34595. */
  34596. disableLighting: boolean;
  34597. /**
  34598. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  34599. */
  34600. forceIrradianceInFragment: boolean;
  34601. /**
  34602. * Number of Simultaneous lights allowed on the material.
  34603. */
  34604. maxSimultaneousLights: number;
  34605. /**
  34606. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  34607. */
  34608. invertNormalMapX: boolean;
  34609. /**
  34610. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  34611. */
  34612. invertNormalMapY: boolean;
  34613. /**
  34614. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  34615. */
  34616. twoSidedLighting: boolean;
  34617. /**
  34618. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34619. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  34620. */
  34621. useAlphaFresnel: boolean;
  34622. /**
  34623. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34624. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  34625. */
  34626. useLinearAlphaFresnel: boolean;
  34627. /**
  34628. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34629. * And/Or occlude the blended part.
  34630. */
  34631. environmentBRDFTexture: Nullable<BaseTexture>;
  34632. /**
  34633. * Force normal to face away from face.
  34634. */
  34635. forceNormalForward: boolean;
  34636. /**
  34637. * Enables specular anti aliasing in the PBR shader.
  34638. * It will both interacts on the Geometry for analytical and IBL lighting.
  34639. * It also prefilter the roughness map based on the bump values.
  34640. */
  34641. enableSpecularAntiAliasing: boolean;
  34642. /**
  34643. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  34644. * makes the reflect vector face the model (under horizon).
  34645. */
  34646. useHorizonOcclusion: boolean;
  34647. /**
  34648. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  34649. * too much the area relying on ambient texture to define their ambient occlusion.
  34650. */
  34651. useRadianceOcclusion: boolean;
  34652. /**
  34653. * If set to true, no lighting calculations will be applied.
  34654. */
  34655. unlit: boolean;
  34656. /**
  34657. * Gets the image processing configuration used either in this material.
  34658. */
  34659. /**
  34660. * Sets the Default image processing configuration used either in the this material.
  34661. *
  34662. * If sets to null, the scene one is in use.
  34663. */
  34664. imageProcessingConfiguration: ImageProcessingConfiguration;
  34665. /**
  34666. * Gets wether the color curves effect is enabled.
  34667. */
  34668. /**
  34669. * Sets wether the color curves effect is enabled.
  34670. */
  34671. cameraColorCurvesEnabled: boolean;
  34672. /**
  34673. * Gets wether the color grading effect is enabled.
  34674. */
  34675. /**
  34676. * Gets wether the color grading effect is enabled.
  34677. */
  34678. cameraColorGradingEnabled: boolean;
  34679. /**
  34680. * Gets wether tonemapping is enabled or not.
  34681. */
  34682. /**
  34683. * Sets wether tonemapping is enabled or not
  34684. */
  34685. cameraToneMappingEnabled: boolean;
  34686. /**
  34687. * The camera exposure used on this material.
  34688. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  34689. * This corresponds to a photographic exposure.
  34690. */
  34691. /**
  34692. * The camera exposure used on this material.
  34693. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  34694. * This corresponds to a photographic exposure.
  34695. */
  34696. cameraExposure: number;
  34697. /**
  34698. * Gets The camera contrast used on this material.
  34699. */
  34700. /**
  34701. * Sets The camera contrast used on this material.
  34702. */
  34703. cameraContrast: number;
  34704. /**
  34705. * Gets the Color Grading 2D Lookup Texture.
  34706. */
  34707. /**
  34708. * Sets the Color Grading 2D Lookup Texture.
  34709. */
  34710. cameraColorGradingTexture: Nullable<BaseTexture>;
  34711. /**
  34712. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  34713. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  34714. * 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;
  34715. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  34716. */
  34717. /**
  34718. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  34719. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  34720. * 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;
  34721. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  34722. */
  34723. cameraColorCurves: Nullable<ColorCurves>;
  34724. /**
  34725. * Instantiates a new PBRMaterial instance.
  34726. *
  34727. * @param name The material name
  34728. * @param scene The scene the material will be use in.
  34729. */
  34730. constructor(name: string, scene: Scene);
  34731. /**
  34732. * Returns the name of this material class.
  34733. */
  34734. getClassName(): string;
  34735. /**
  34736. * Returns an array of the actively used textures.
  34737. * @returns - Array of BaseTextures
  34738. */
  34739. getActiveTextures(): BaseTexture[];
  34740. /**
  34741. * Checks to see if a texture is used in the material.
  34742. * @param texture - Base texture to use.
  34743. * @returns - Boolean specifying if a texture is used in the material.
  34744. */
  34745. hasTexture(texture: BaseTexture): boolean;
  34746. /**
  34747. * Makes a duplicate of the current material.
  34748. * @param name - name to use for the new material.
  34749. */
  34750. clone(name: string): PBRMaterial;
  34751. /**
  34752. * Serializes this PBR Material.
  34753. * @returns - An object with the serialized material.
  34754. */
  34755. serialize(): any;
  34756. /**
  34757. * Parses a PBR Material from a serialized object.
  34758. * @param source - Serialized object.
  34759. * @param scene - BJS scene instance.
  34760. * @param rootUrl - url for the scene object
  34761. * @returns - PBRMaterial
  34762. */
  34763. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  34764. }
  34765. }
  34766. declare module BABYLON {
  34767. /**
  34768. * The PBR material of BJS following the metal roughness convention.
  34769. *
  34770. * This fits to the PBR convention in the GLTF definition:
  34771. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  34772. */
  34773. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  34774. /**
  34775. * The base color has two different interpretations depending on the value of metalness.
  34776. * When the material is a metal, the base color is the specific measured reflectance value
  34777. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  34778. * of the material.
  34779. */
  34780. baseColor: Color3;
  34781. /**
  34782. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  34783. * well as opacity information in the alpha channel.
  34784. */
  34785. baseTexture: BaseTexture;
  34786. /**
  34787. * Specifies the metallic scalar value of the material.
  34788. * Can also be used to scale the metalness values of the metallic texture.
  34789. */
  34790. metallic: number;
  34791. /**
  34792. * Specifies the roughness scalar value of the material.
  34793. * Can also be used to scale the roughness values of the metallic texture.
  34794. */
  34795. roughness: number;
  34796. /**
  34797. * Texture containing both the metallic value in the B channel and the
  34798. * roughness value in the G channel to keep better precision.
  34799. */
  34800. metallicRoughnessTexture: BaseTexture;
  34801. /**
  34802. * Instantiates a new PBRMetalRoughnessMaterial instance.
  34803. *
  34804. * @param name The material name
  34805. * @param scene The scene the material will be use in.
  34806. */
  34807. constructor(name: string, scene: Scene);
  34808. /**
  34809. * Return the currrent class name of the material.
  34810. */
  34811. getClassName(): string;
  34812. /**
  34813. * Return the active textures of the material.
  34814. */
  34815. getActiveTextures(): BaseTexture[];
  34816. /**
  34817. * Checks to see if a texture is used in the material.
  34818. * @param texture - Base texture to use.
  34819. * @returns - Boolean specifying if a texture is used in the material.
  34820. */
  34821. hasTexture(texture: BaseTexture): boolean;
  34822. /**
  34823. * Makes a duplicate of the current material.
  34824. * @param name - name to use for the new material.
  34825. */
  34826. clone(name: string): PBRMetallicRoughnessMaterial;
  34827. /**
  34828. * Serialize the material to a parsable JSON object.
  34829. */
  34830. serialize(): any;
  34831. /**
  34832. * Parses a JSON object correponding to the serialize function.
  34833. */
  34834. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  34835. }
  34836. }
  34837. declare module BABYLON {
  34838. /**
  34839. * The PBR material of BJS following the specular glossiness convention.
  34840. *
  34841. * This fits to the PBR convention in the GLTF definition:
  34842. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  34843. */
  34844. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  34845. /**
  34846. * Specifies the diffuse color of the material.
  34847. */
  34848. diffuseColor: Color3;
  34849. /**
  34850. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  34851. * channel.
  34852. */
  34853. diffuseTexture: BaseTexture;
  34854. /**
  34855. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  34856. */
  34857. specularColor: Color3;
  34858. /**
  34859. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  34860. */
  34861. glossiness: number;
  34862. /**
  34863. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  34864. */
  34865. specularGlossinessTexture: BaseTexture;
  34866. /**
  34867. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  34868. *
  34869. * @param name The material name
  34870. * @param scene The scene the material will be use in.
  34871. */
  34872. constructor(name: string, scene: Scene);
  34873. /**
  34874. * Return the currrent class name of the material.
  34875. */
  34876. getClassName(): string;
  34877. /**
  34878. * Return the active textures of the material.
  34879. */
  34880. getActiveTextures(): BaseTexture[];
  34881. /**
  34882. * Checks to see if a texture is used in the material.
  34883. * @param texture - Base texture to use.
  34884. * @returns - Boolean specifying if a texture is used in the material.
  34885. */
  34886. hasTexture(texture: BaseTexture): boolean;
  34887. /**
  34888. * Makes a duplicate of the current material.
  34889. * @param name - name to use for the new material.
  34890. */
  34891. clone(name: string): PBRSpecularGlossinessMaterial;
  34892. /**
  34893. * Serialize the material to a parsable JSON object.
  34894. */
  34895. serialize(): any;
  34896. /**
  34897. * Parses a JSON object correponding to the serialize function.
  34898. */
  34899. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  34900. }
  34901. }
  34902. declare module BABYLON {
  34903. class BaseTexture {
  34904. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34905. name: string;
  34906. private _hasAlpha;
  34907. hasAlpha: boolean;
  34908. getAlphaFromRGB: boolean;
  34909. level: number;
  34910. coordinatesIndex: number;
  34911. private _coordinatesMode;
  34912. /**
  34913. * How a texture is mapped.
  34914. *
  34915. * | Value | Type | Description |
  34916. * | ----- | ----------------------------------- | ----------- |
  34917. * | 0 | EXPLICIT_MODE | |
  34918. * | 1 | SPHERICAL_MODE | |
  34919. * | 2 | PLANAR_MODE | |
  34920. * | 3 | CUBIC_MODE | |
  34921. * | 4 | PROJECTION_MODE | |
  34922. * | 5 | SKYBOX_MODE | |
  34923. * | 6 | INVCUBIC_MODE | |
  34924. * | 7 | EQUIRECTANGULAR_MODE | |
  34925. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34926. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34927. */
  34928. coordinatesMode: number;
  34929. /**
  34930. * | Value | Type | Description |
  34931. * | ----- | ------------------ | ----------- |
  34932. * | 0 | CLAMP_ADDRESSMODE | |
  34933. * | 1 | WRAP_ADDRESSMODE | |
  34934. * | 2 | MIRROR_ADDRESSMODE | |
  34935. */
  34936. wrapU: number;
  34937. /**
  34938. * | Value | Type | Description |
  34939. * | ----- | ------------------ | ----------- |
  34940. * | 0 | CLAMP_ADDRESSMODE | |
  34941. * | 1 | WRAP_ADDRESSMODE | |
  34942. * | 2 | MIRROR_ADDRESSMODE | |
  34943. */
  34944. wrapV: number;
  34945. /**
  34946. * | Value | Type | Description |
  34947. * | ----- | ------------------ | ----------- |
  34948. * | 0 | CLAMP_ADDRESSMODE | |
  34949. * | 1 | WRAP_ADDRESSMODE | |
  34950. * | 2 | MIRROR_ADDRESSMODE | |
  34951. */
  34952. wrapR: number;
  34953. anisotropicFilteringLevel: number;
  34954. isCube: boolean;
  34955. is3D: boolean;
  34956. gammaSpace: boolean;
  34957. /**
  34958. * Gets whether or not the texture contains RGBD data.
  34959. */
  34960. readonly isRGBD: boolean;
  34961. invertZ: boolean;
  34962. lodLevelInAlpha: boolean;
  34963. lodGenerationOffset: number;
  34964. lodGenerationScale: number;
  34965. isRenderTarget: boolean;
  34966. readonly uid: string;
  34967. toString(): string;
  34968. getClassName(): string;
  34969. animations: Animation[];
  34970. /**
  34971. * An event triggered when the texture is disposed.
  34972. */
  34973. onDisposeObservable: Observable<BaseTexture>;
  34974. private _onDisposeObserver;
  34975. onDispose: () => void;
  34976. delayLoadState: number;
  34977. private _scene;
  34978. _texture: Nullable<InternalTexture>;
  34979. private _uid;
  34980. readonly isBlocking: boolean;
  34981. constructor(scene: Nullable<Scene>);
  34982. getScene(): Nullable<Scene>;
  34983. getTextureMatrix(): Matrix;
  34984. getReflectionTextureMatrix(): Matrix;
  34985. getInternalTexture(): Nullable<InternalTexture>;
  34986. isReadyOrNotBlocking(): boolean;
  34987. isReady(): boolean;
  34988. private _cachedSize;
  34989. getSize(): ISize;
  34990. getBaseSize(): ISize;
  34991. scale(ratio: number): void;
  34992. readonly canRescale: boolean;
  34993. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  34994. _rebuild(): void;
  34995. delayLoad(): void;
  34996. clone(): Nullable<BaseTexture>;
  34997. readonly textureType: number;
  34998. readonly textureFormat: number;
  34999. /**
  35000. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35001. * This will returns an RGBA array buffer containing either in values (0-255) or
  35002. * float values (0-1) depending of the underlying buffer type.
  35003. * @param faceIndex The face of the texture to read (in case of cube texture)
  35004. * @param level The LOD level of the texture to read (in case of Mip Maps)
  35005. * @returns The Array buffer containing the pixels data.
  35006. */
  35007. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  35008. releaseInternalTexture(): void;
  35009. sphericalPolynomial: Nullable<SphericalPolynomial>;
  35010. readonly _lodTextureHigh: Nullable<BaseTexture>;
  35011. readonly _lodTextureMid: Nullable<BaseTexture>;
  35012. readonly _lodTextureLow: Nullable<BaseTexture>;
  35013. dispose(): void;
  35014. serialize(): any;
  35015. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35016. }
  35017. }
  35018. declare module BABYLON {
  35019. /**
  35020. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  35021. * It can help converting any input color in a desired output one. This can then be used to create effects
  35022. * from sepia, black and white to sixties or futuristic rendering...
  35023. *
  35024. * The only supported format is currently 3dl.
  35025. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  35026. */
  35027. class ColorGradingTexture extends BaseTexture {
  35028. /**
  35029. * The current texture matrix. (will always be identity in color grading texture)
  35030. */
  35031. private _textureMatrix;
  35032. /**
  35033. * The texture URL.
  35034. */
  35035. url: string;
  35036. /**
  35037. * Empty line regex stored for GC.
  35038. */
  35039. private static _noneEmptyLineRegex;
  35040. private _engine;
  35041. /**
  35042. * Instantiates a ColorGradingTexture from the following parameters.
  35043. *
  35044. * @param url The location of the color gradind data (currently only supporting 3dl)
  35045. * @param scene The scene the texture will be used in
  35046. */
  35047. constructor(url: string, scene: Scene);
  35048. /**
  35049. * Returns the texture matrix used in most of the material.
  35050. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  35051. */
  35052. getTextureMatrix(): Matrix;
  35053. /**
  35054. * Occurs when the file being loaded is a .3dl LUT file.
  35055. */
  35056. private load3dlTexture();
  35057. /**
  35058. * Starts the loading process of the texture.
  35059. */
  35060. private loadTexture();
  35061. /**
  35062. * Clones the color gradind texture.
  35063. */
  35064. clone(): ColorGradingTexture;
  35065. /**
  35066. * Called during delayed load for textures.
  35067. */
  35068. delayLoad(): void;
  35069. /**
  35070. * Parses a color grading texture serialized by Babylon.
  35071. * @param parsedTexture The texture information being parsedTexture
  35072. * @param scene The scene to load the texture in
  35073. * @param rootUrl The root url of the data assets to load
  35074. * @return A color gradind texture
  35075. */
  35076. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  35077. /**
  35078. * Serializes the LUT texture to json format.
  35079. */
  35080. serialize(): any;
  35081. }
  35082. }
  35083. declare module BABYLON {
  35084. class CubeTexture extends BaseTexture {
  35085. url: string;
  35086. /**
  35087. * Gets or sets the center of the bounding box associated with the cube texture
  35088. * It must define where the camera used to render the texture was set
  35089. */
  35090. boundingBoxPosition: Vector3;
  35091. private _boundingBoxSize;
  35092. /**
  35093. * Gets or sets the size of the bounding box associated with the cube texture
  35094. * When defined, the cubemap will switch to local mode
  35095. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  35096. * @example https://www.babylonjs-playground.com/#RNASML
  35097. */
  35098. boundingBoxSize: Vector3;
  35099. protected _rotationY: number;
  35100. /**
  35101. * Gets texture matrix rotation angle around Y axis radians.
  35102. */
  35103. /**
  35104. * Sets texture matrix rotation angle around Y axis in radians.
  35105. */
  35106. rotationY: number;
  35107. private _noMipmap;
  35108. private _files;
  35109. private _extensions;
  35110. private _textureMatrix;
  35111. private _format;
  35112. private _createPolynomials;
  35113. /** @hidden */
  35114. readonly _prefiltered: boolean;
  35115. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  35116. /**
  35117. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  35118. * @param url defines the url of the prefiltered texture
  35119. * @param scene defines the scene the texture is attached to
  35120. * @param forcedExtension defines the extension of the file if different from the url
  35121. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  35122. * @return the prefiltered texture
  35123. */
  35124. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  35125. /**
  35126. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  35127. * as prefiltered data.
  35128. * @param rootUrl defines the url of the texture or the root name of the six images
  35129. * @param scene defines the scene the texture is attached to
  35130. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  35131. * @param noMipmap defines if mipmaps should be created or not
  35132. * @param files defines the six files to load for the different faces
  35133. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  35134. * @param onError defines a callback triggered in case of error during load
  35135. * @param format defines the internal format to use for the texture once loaded
  35136. * @param prefiltered defines whether or not the texture is created from prefiltered data
  35137. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  35138. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  35139. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  35140. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  35141. * @return the cube texture
  35142. */
  35143. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  35144. delayLoad(): void;
  35145. getReflectionTextureMatrix(): Matrix;
  35146. setReflectionTextureMatrix(value: Matrix): void;
  35147. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  35148. clone(): CubeTexture;
  35149. }
  35150. }
  35151. declare module BABYLON {
  35152. /**
  35153. * A class extending {BABYLON.Texture} allowing drawing on a texture
  35154. * @see http://doc.babylonjs.com/how_to/dynamictexture
  35155. */
  35156. class DynamicTexture extends Texture {
  35157. private _generateMipMaps;
  35158. private _canvas;
  35159. private _context;
  35160. private _engine;
  35161. /**
  35162. * Creates a {BABYLON.DynamicTexture}
  35163. * @param name defines the name of the texture
  35164. * @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
  35165. * @param scene defines the scene where you want the texture
  35166. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  35167. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  35168. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  35169. */
  35170. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  35171. /**
  35172. * Gets the current state of canRescale
  35173. */
  35174. readonly canRescale: boolean;
  35175. private _recreate(textureSize);
  35176. /**
  35177. * Scales the texture
  35178. * @param ratio the scale factor to apply to both width and height
  35179. */
  35180. scale(ratio: number): void;
  35181. /**
  35182. * Resizes the texture
  35183. * @param width the new width
  35184. * @param height the new height
  35185. */
  35186. scaleTo(width: number, height: number): void;
  35187. /**
  35188. * Gets the context of the canvas used by the texture
  35189. * @returns the canvas context of the dynamic texture
  35190. */
  35191. getContext(): CanvasRenderingContext2D;
  35192. /**
  35193. * Clears the texture
  35194. */
  35195. clear(): void;
  35196. /**
  35197. * Updates the texture
  35198. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  35199. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  35200. */
  35201. update(invertY?: boolean, premulAlpha?: boolean): void;
  35202. /**
  35203. * Draws text onto the texture
  35204. * @param text defines the text to be drawn
  35205. * @param x defines the placement of the text from the left
  35206. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  35207. * @param font defines the font to be used with font-style, font-size, font-name
  35208. * @param color defines the color used for the text
  35209. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  35210. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  35211. * @param update defines whether texture is immediately update (default is true)
  35212. */
  35213. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  35214. /**
  35215. * Clones the texture
  35216. * @returns the clone of the texture.
  35217. */
  35218. clone(): DynamicTexture;
  35219. /** @hidden */
  35220. _rebuild(): void;
  35221. }
  35222. }
  35223. declare module BABYLON {
  35224. /**
  35225. * This represents a texture coming from an HDR input.
  35226. *
  35227. * The only supported format is currently panorama picture stored in RGBE format.
  35228. * Example of such files can be found on HDRLib: http://hdrlib.com/
  35229. */
  35230. class HDRCubeTexture extends BaseTexture {
  35231. private static _facesMapping;
  35232. private _generateHarmonics;
  35233. private _noMipmap;
  35234. private _textureMatrix;
  35235. private _size;
  35236. private _onLoad;
  35237. private _onError;
  35238. /**
  35239. * The texture URL.
  35240. */
  35241. url: string;
  35242. /**
  35243. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  35244. */
  35245. coordinatesMode: number;
  35246. protected _isBlocking: boolean;
  35247. /**
  35248. * Gets wether or not the texture is blocking during loading.
  35249. */
  35250. /**
  35251. * Sets wether or not the texture is blocking during loading.
  35252. */
  35253. isBlocking: boolean;
  35254. protected _rotationY: number;
  35255. /**
  35256. * Gets texture matrix rotation angle around Y axis radians.
  35257. */
  35258. /**
  35259. * Sets texture matrix rotation angle around Y axis in radians.
  35260. */
  35261. rotationY: number;
  35262. /**
  35263. * Gets or sets the center of the bounding box associated with the cube texture
  35264. * It must define where the camera used to render the texture was set
  35265. */
  35266. boundingBoxPosition: Vector3;
  35267. private _boundingBoxSize;
  35268. /**
  35269. * Gets or sets the size of the bounding box associated with the cube texture
  35270. * When defined, the cubemap will switch to local mode
  35271. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  35272. * @example https://www.babylonjs-playground.com/#RNASML
  35273. */
  35274. boundingBoxSize: Vector3;
  35275. /**
  35276. * Instantiates an HDRTexture from the following parameters.
  35277. *
  35278. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  35279. * @param scene The scene the texture will be used in
  35280. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  35281. * @param noMipmap Forces to not generate the mipmap if true
  35282. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  35283. * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  35284. * @param reserved Reserved flag for internal use.
  35285. */
  35286. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  35287. /**
  35288. * Occurs when the file is raw .hdr file.
  35289. */
  35290. private loadTexture();
  35291. clone(): HDRCubeTexture;
  35292. delayLoad(): void;
  35293. getReflectionTextureMatrix(): Matrix;
  35294. setReflectionTextureMatrix(value: Matrix): void;
  35295. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  35296. serialize(): any;
  35297. }
  35298. }
  35299. declare module BABYLON {
  35300. /**
  35301. * Class used to store data associated with WebGL texture data for the engine
  35302. * This class should not be used directly
  35303. */
  35304. class InternalTexture implements IInternalTextureTracker {
  35305. /**
  35306. * The source of the texture data is unknown
  35307. */
  35308. static DATASOURCE_UNKNOWN: number;
  35309. /**
  35310. * Texture data comes from an URL
  35311. */
  35312. static DATASOURCE_URL: number;
  35313. /**
  35314. * Texture data is only used for temporary storage
  35315. */
  35316. static DATASOURCE_TEMP: number;
  35317. /**
  35318. * Texture data comes from raw data (ArrayBuffer)
  35319. */
  35320. static DATASOURCE_RAW: number;
  35321. /**
  35322. * Texture content is dynamic (video or dynamic texture)
  35323. */
  35324. static DATASOURCE_DYNAMIC: number;
  35325. /**
  35326. * Texture content is generated by rendering to it
  35327. */
  35328. static DATASOURCE_RENDERTARGET: number;
  35329. /**
  35330. * Texture content is part of a multi render target process
  35331. */
  35332. static DATASOURCE_MULTIRENDERTARGET: number;
  35333. /**
  35334. * Texture data comes from a cube data file
  35335. */
  35336. static DATASOURCE_CUBE: number;
  35337. /**
  35338. * Texture data comes from a raw cube data
  35339. */
  35340. static DATASOURCE_CUBERAW: number;
  35341. /**
  35342. * Texture data come from a prefiltered cube data file
  35343. */
  35344. static DATASOURCE_CUBEPREFILTERED: number;
  35345. /**
  35346. * Texture content is raw 3D data
  35347. */
  35348. static DATASOURCE_RAW3D: number;
  35349. /**
  35350. * Texture content is a depth texture
  35351. */
  35352. static DATASOURCE_DEPTHTEXTURE: number;
  35353. /**
  35354. * Texture data comes from a raw cube data encoded with RGBD
  35355. */
  35356. static DATASOURCE_CUBERAW_RGBD: number;
  35357. /**
  35358. * Defines if the texture is ready
  35359. */
  35360. isReady: boolean;
  35361. /**
  35362. * Defines if the texture is a cube texture
  35363. */
  35364. isCube: boolean;
  35365. /**
  35366. * Defines if the texture contains 3D data
  35367. */
  35368. is3D: boolean;
  35369. /**
  35370. * Gets the URL used to load this texture
  35371. */
  35372. url: string;
  35373. /**
  35374. * Gets the sampling mode of the texture
  35375. */
  35376. samplingMode: number;
  35377. /**
  35378. * Gets a boolean indicating if the texture needs mipmaps generation
  35379. */
  35380. generateMipMaps: boolean;
  35381. /**
  35382. * Gets the number of samples used by the texture (WebGL2+ only)
  35383. */
  35384. samples: number;
  35385. /**
  35386. * Gets the type of the texture
  35387. */
  35388. type: number;
  35389. /**
  35390. * Gets the format of the texture
  35391. */
  35392. format: number;
  35393. /**
  35394. * Observable called when the texture is loaded
  35395. */
  35396. onLoadedObservable: Observable<InternalTexture>;
  35397. /**
  35398. * Gets the width of the texture
  35399. */
  35400. width: number;
  35401. /**
  35402. * Gets the height of the texture
  35403. */
  35404. height: number;
  35405. /**
  35406. * Gets the depth of the texture
  35407. */
  35408. depth: number;
  35409. /**
  35410. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35411. */
  35412. baseWidth: number;
  35413. /**
  35414. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35415. */
  35416. baseHeight: number;
  35417. /**
  35418. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35419. */
  35420. baseDepth: number;
  35421. /**
  35422. * Gets a boolean indicating if the texture is inverted on Y axis
  35423. */
  35424. invertY: boolean;
  35425. /**
  35426. * Gets or set the previous tracker in the list
  35427. */
  35428. previous: Nullable<IInternalTextureTracker>;
  35429. /**
  35430. * Gets or set the next tracker in the list
  35431. */
  35432. next: Nullable<IInternalTextureTracker>;
  35433. /** @hidden */
  35434. _initialSlot: number;
  35435. /** @hidden */
  35436. _designatedSlot: number;
  35437. /** @hidden */
  35438. _dataSource: number;
  35439. /** @hidden */
  35440. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  35441. /** @hidden */
  35442. _bufferView: Nullable<ArrayBufferView>;
  35443. /** @hidden */
  35444. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35445. /** @hidden */
  35446. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35447. /** @hidden */
  35448. _size: number;
  35449. /** @hidden */
  35450. _extension: string;
  35451. /** @hidden */
  35452. _files: Nullable<string[]>;
  35453. /** @hidden */
  35454. _workingCanvas: HTMLCanvasElement;
  35455. /** @hidden */
  35456. _workingContext: CanvasRenderingContext2D;
  35457. /** @hidden */
  35458. _framebuffer: Nullable<WebGLFramebuffer>;
  35459. /** @hidden */
  35460. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35461. /** @hidden */
  35462. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35463. /** @hidden */
  35464. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35465. /** @hidden */
  35466. _attachments: Nullable<number[]>;
  35467. /** @hidden */
  35468. _cachedCoordinatesMode: Nullable<number>;
  35469. /** @hidden */
  35470. _cachedWrapU: Nullable<number>;
  35471. /** @hidden */
  35472. _cachedWrapV: Nullable<number>;
  35473. /** @hidden */
  35474. _cachedWrapR: Nullable<number>;
  35475. /** @hidden */
  35476. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35477. /** @hidden */
  35478. _isDisabled: boolean;
  35479. /** @hidden */
  35480. _compression: Nullable<string>;
  35481. /** @hidden */
  35482. _generateStencilBuffer: boolean;
  35483. /** @hidden */
  35484. _generateDepthBuffer: boolean;
  35485. /** @hidden */
  35486. _comparisonFunction: number;
  35487. /** @hidden */
  35488. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35489. /** @hidden */
  35490. _lodGenerationScale: number;
  35491. /** @hidden */
  35492. _lodGenerationOffset: number;
  35493. /** @hidden */
  35494. _lodTextureHigh: BaseTexture;
  35495. /** @hidden */
  35496. _lodTextureMid: BaseTexture;
  35497. /** @hidden */
  35498. _lodTextureLow: BaseTexture;
  35499. /** @hidden */
  35500. _isRGBD: boolean;
  35501. /** @hidden */
  35502. _webGLTexture: Nullable<WebGLTexture>;
  35503. /** @hidden */
  35504. _references: number;
  35505. private _engine;
  35506. /**
  35507. * Gets the Engine the texture belongs to.
  35508. * @returns The babylon engine
  35509. */
  35510. getEngine(): Engine;
  35511. /**
  35512. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  35513. */
  35514. readonly dataSource: number;
  35515. /**
  35516. * Creates a new InternalTexture
  35517. * @param engine defines the engine to use
  35518. * @param dataSource defines the type of data that will be used
  35519. */
  35520. constructor(engine: Engine, dataSource: number);
  35521. /**
  35522. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  35523. */
  35524. incrementReferences(): void;
  35525. /**
  35526. * Change the size of the texture (not the size of the content)
  35527. * @param width defines the new width
  35528. * @param height defines the new height
  35529. * @param depth defines the new depth (1 by default)
  35530. */
  35531. updateSize(width: int, height: int, depth?: int): void;
  35532. /** @hidden */
  35533. _rebuild(): void;
  35534. _swapAndDie(target: InternalTexture): void;
  35535. /**
  35536. * Dispose the current allocated resources
  35537. */
  35538. dispose(): void;
  35539. }
  35540. }
  35541. declare module BABYLON {
  35542. /**
  35543. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  35544. */
  35545. interface IInternalTextureTracker {
  35546. /**
  35547. * Gets or set the previous tracker in the list
  35548. */
  35549. previous: Nullable<IInternalTextureTracker>;
  35550. /**
  35551. * Gets or set the next tracker in the list
  35552. */
  35553. next: Nullable<IInternalTextureTracker>;
  35554. }
  35555. /**
  35556. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  35557. */
  35558. class DummyInternalTextureTracker {
  35559. /**
  35560. * Gets or set the previous tracker in the list
  35561. */
  35562. previous: Nullable<IInternalTextureTracker>;
  35563. /**
  35564. * Gets or set the next tracker in the list
  35565. */
  35566. next: Nullable<IInternalTextureTracker>;
  35567. }
  35568. }
  35569. declare module BABYLON {
  35570. class MirrorTexture extends RenderTargetTexture {
  35571. private scene;
  35572. mirrorPlane: Plane;
  35573. private _transformMatrix;
  35574. private _mirrorMatrix;
  35575. private _savedViewMatrix;
  35576. private _blurX;
  35577. private _blurY;
  35578. private _adaptiveBlurKernel;
  35579. private _blurKernelX;
  35580. private _blurKernelY;
  35581. private _blurRatio;
  35582. blurRatio: number;
  35583. adaptiveBlurKernel: number;
  35584. blurKernel: number;
  35585. blurKernelX: number;
  35586. blurKernelY: number;
  35587. private _autoComputeBlurKernel();
  35588. protected _onRatioRescale(): void;
  35589. private _updateGammaSpace();
  35590. private _imageProcessingConfigChangeObserver;
  35591. constructor(name: string, size: number | {
  35592. width: number;
  35593. height: number;
  35594. } | {
  35595. ratio: number;
  35596. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  35597. private _preparePostProcesses();
  35598. clone(): MirrorTexture;
  35599. serialize(): any;
  35600. dispose(): void;
  35601. }
  35602. }
  35603. declare module BABYLON {
  35604. interface IMultiRenderTargetOptions {
  35605. generateMipMaps?: boolean;
  35606. types?: number[];
  35607. samplingModes?: number[];
  35608. generateDepthBuffer?: boolean;
  35609. generateStencilBuffer?: boolean;
  35610. generateDepthTexture?: boolean;
  35611. textureCount?: number;
  35612. doNotChangeAspectRatio?: boolean;
  35613. defaultType?: number;
  35614. }
  35615. class MultiRenderTarget extends RenderTargetTexture {
  35616. private _internalTextures;
  35617. private _textures;
  35618. readonly isSupported: boolean;
  35619. private _multiRenderTargetOptions;
  35620. readonly textures: Texture[];
  35621. readonly depthTexture: Texture;
  35622. wrapU: number;
  35623. wrapV: number;
  35624. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  35625. _rebuild(): void;
  35626. private _createInternalTextures();
  35627. private _createTextures();
  35628. samples: number;
  35629. resize(size: any): void;
  35630. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  35631. dispose(): void;
  35632. releaseInternalTextures(): void;
  35633. }
  35634. }
  35635. declare module BABYLON {
  35636. /**
  35637. * Raw cube texture where the raw buffers are passed in
  35638. */
  35639. class RawCubeTexture extends CubeTexture {
  35640. /**
  35641. * Creates a cube texture where the raw buffers are passed in.
  35642. * @param scene defines the scene the texture is attached to
  35643. * @param data defines the array of data to use to create each face
  35644. * @param size defines the size of the textures
  35645. * @param format defines the format of the data
  35646. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  35647. * @param generateMipMaps defines if the engine should generate the mip levels
  35648. * @param invertY defines if data must be stored with Y axis inverted
  35649. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  35650. * @param compression defines the compression used (null by default)
  35651. */
  35652. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  35653. /**
  35654. * Updates the raw cube texture.
  35655. * @param data defines the data to store
  35656. * @param format defines the data format
  35657. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35658. * @param invertY defines if data must be stored with Y axis inverted
  35659. * @param compression defines the compression used (null by default)
  35660. * @param level defines which level of the texture to update
  35661. */
  35662. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  35663. /**
  35664. * Updates a raw cube texture with RGBD encoded data.
  35665. * @param data defines the array of data [mipmap][face] to use to create each face
  35666. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  35667. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  35668. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  35669. * @returns a promsie that resolves when the operation is complete
  35670. */
  35671. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  35672. /**
  35673. * Clones the raw cube texture.
  35674. * @return a new cube texture
  35675. */
  35676. clone(): CubeTexture;
  35677. /** @hidden */
  35678. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  35679. }
  35680. }
  35681. declare module BABYLON {
  35682. class RawTexture extends Texture {
  35683. format: number;
  35684. private _engine;
  35685. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  35686. update(data: ArrayBufferView): void;
  35687. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  35688. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  35689. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  35690. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  35691. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  35692. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  35693. }
  35694. }
  35695. declare module BABYLON {
  35696. /**
  35697. * Class used to store 3D textures containing user data
  35698. */
  35699. class RawTexture3D extends Texture {
  35700. /** Gets or sets the texture format to use */
  35701. format: number;
  35702. private _engine;
  35703. /**
  35704. * Create a new RawTexture3D
  35705. * @param data defines the data of the texture
  35706. * @param width defines the width of the texture
  35707. * @param height defines the height of the texture
  35708. * @param depth defines the depth of the texture
  35709. * @param format defines the texture format to use
  35710. * @param scene defines the hosting scene
  35711. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  35712. * @param invertY defines if texture must be stored with Y axis inverted
  35713. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  35714. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  35715. */
  35716. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  35717. /** Gets or sets the texture format to use */
  35718. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  35719. /**
  35720. * Update the texture with new data
  35721. * @param data defines the data to store in the texture
  35722. */
  35723. update(data: ArrayBufferView): void;
  35724. }
  35725. }
  35726. declare module BABYLON {
  35727. /**
  35728. * Creates a refraction texture used by refraction channel of the standard material.
  35729. * @param name the texture name
  35730. * @param size size of the underlying texture
  35731. * @param scene root scene
  35732. */
  35733. class RefractionTexture extends RenderTargetTexture {
  35734. refractionPlane: Plane;
  35735. depth: number;
  35736. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  35737. clone(): RefractionTexture;
  35738. serialize(): any;
  35739. }
  35740. }
  35741. declare module BABYLON {
  35742. class RenderTargetTexture extends Texture {
  35743. isCube: boolean;
  35744. static _REFRESHRATE_RENDER_ONCE: number;
  35745. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  35746. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  35747. static readonly REFRESHRATE_RENDER_ONCE: number;
  35748. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  35749. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  35750. /**
  35751. * Use this predicate to dynamically define the list of mesh you want to render.
  35752. * If set, the renderList property will be overwritten.
  35753. */
  35754. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  35755. /**
  35756. * Use this list to define the list of mesh you want to render.
  35757. */
  35758. renderList: Nullable<Array<AbstractMesh>>;
  35759. renderParticles: boolean;
  35760. renderSprites: boolean;
  35761. coordinatesMode: number;
  35762. activeCamera: Nullable<Camera>;
  35763. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  35764. useCameraPostProcesses: boolean;
  35765. ignoreCameraViewport: boolean;
  35766. private _postProcessManager;
  35767. private _postProcesses;
  35768. private _resizeObserver;
  35769. /**
  35770. * An event triggered when the texture is unbind.
  35771. */
  35772. onBeforeBindObservable: Observable<RenderTargetTexture>;
  35773. /**
  35774. * An event triggered when the texture is unbind.
  35775. */
  35776. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  35777. private _onAfterUnbindObserver;
  35778. onAfterUnbind: () => void;
  35779. /**
  35780. * An event triggered before rendering the texture
  35781. */
  35782. onBeforeRenderObservable: Observable<number>;
  35783. private _onBeforeRenderObserver;
  35784. onBeforeRender: (faceIndex: number) => void;
  35785. /**
  35786. * An event triggered after rendering the texture
  35787. */
  35788. onAfterRenderObservable: Observable<number>;
  35789. private _onAfterRenderObserver;
  35790. onAfterRender: (faceIndex: number) => void;
  35791. /**
  35792. * An event triggered after the texture clear
  35793. */
  35794. onClearObservable: Observable<Engine>;
  35795. private _onClearObserver;
  35796. onClear: (Engine: Engine) => void;
  35797. clearColor: Color4;
  35798. protected _size: number | {
  35799. width: number;
  35800. height: number;
  35801. };
  35802. protected _initialSizeParameter: number | {
  35803. width: number;
  35804. height: number;
  35805. } | {
  35806. ratio: number;
  35807. };
  35808. protected _sizeRatio: Nullable<number>;
  35809. _generateMipMaps: boolean;
  35810. protected _renderingManager: RenderingManager;
  35811. _waitingRenderList: string[];
  35812. protected _doNotChangeAspectRatio: boolean;
  35813. protected _currentRefreshId: number;
  35814. protected _refreshRate: number;
  35815. protected _textureMatrix: Matrix;
  35816. protected _samples: number;
  35817. protected _renderTargetOptions: RenderTargetCreationOptions;
  35818. readonly renderTargetOptions: RenderTargetCreationOptions;
  35819. protected _engine: Engine;
  35820. protected _onRatioRescale(): void;
  35821. /**
  35822. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  35823. * It must define where the camera used to render the texture is set
  35824. */
  35825. boundingBoxPosition: Vector3;
  35826. private _boundingBoxSize;
  35827. /**
  35828. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  35829. * When defined, the cubemap will switch to local mode
  35830. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  35831. * @example https://www.babylonjs-playground.com/#RNASML
  35832. */
  35833. boundingBoxSize: Vector3;
  35834. /**
  35835. * In case the RTT has been created with a depth texture, get the associated
  35836. * depth texture.
  35837. * Otherwise, return null.
  35838. */
  35839. depthStencilTexture: Nullable<InternalTexture>;
  35840. /**
  35841. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  35842. * or used a shadow, depth texture...
  35843. * @param name The friendly name of the texture
  35844. * @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)
  35845. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  35846. * @param generateMipMaps True if mip maps need to be generated after render.
  35847. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  35848. * @param type The type of the buffer in the RTT (int, half float, float...)
  35849. * @param isCube True if a cube texture needs to be created
  35850. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  35851. * @param generateDepthBuffer True to generate a depth buffer
  35852. * @param generateStencilBuffer True to generate a stencil buffer
  35853. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  35854. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  35855. */
  35856. constructor(name: string, size: number | {
  35857. width: number;
  35858. height: number;
  35859. } | {
  35860. ratio: number;
  35861. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  35862. /**
  35863. * Creates a depth stencil texture.
  35864. * This is only available in WebGL 2 or with the depth texture extension available.
  35865. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  35866. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  35867. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  35868. */
  35869. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  35870. private _processSizeParameter(size);
  35871. samples: number;
  35872. resetRefreshCounter(): void;
  35873. refreshRate: number;
  35874. addPostProcess(postProcess: PostProcess): void;
  35875. clearPostProcesses(dispose?: boolean): void;
  35876. removePostProcess(postProcess: PostProcess): void;
  35877. _shouldRender(): boolean;
  35878. getRenderSize(): number;
  35879. getRenderWidth(): number;
  35880. getRenderHeight(): number;
  35881. readonly canRescale: boolean;
  35882. scale(ratio: number): void;
  35883. getReflectionTextureMatrix(): Matrix;
  35884. resize(size: number | {
  35885. width: number;
  35886. height: number;
  35887. } | {
  35888. ratio: number;
  35889. }): void;
  35890. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  35891. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  35892. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  35893. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  35894. /**
  35895. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35896. * This allowed control for front to back rendering or reversly depending of the special needs.
  35897. *
  35898. * @param renderingGroupId The rendering group id corresponding to its index
  35899. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35900. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35901. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35902. */
  35903. 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;
  35904. /**
  35905. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35906. *
  35907. * @param renderingGroupId The rendering group id corresponding to its index
  35908. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35909. */
  35910. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  35911. clone(): RenderTargetTexture;
  35912. serialize(): any;
  35913. disposeFramebufferObjects(): void;
  35914. dispose(): void;
  35915. _rebuild(): void;
  35916. /**
  35917. * Clear the info related to rendering groups preventing retention point in material dispose.
  35918. */
  35919. freeRenderingGroups(): void;
  35920. }
  35921. }
  35922. declare module BABYLON {
  35923. class Texture extends BaseTexture {
  35924. static NEAREST_SAMPLINGMODE: number;
  35925. static NEAREST_NEAREST_MIPLINEAR: number;
  35926. static BILINEAR_SAMPLINGMODE: number;
  35927. static LINEAR_LINEAR_MIPNEAREST: number;
  35928. static TRILINEAR_SAMPLINGMODE: number;
  35929. static LINEAR_LINEAR_MIPLINEAR: number;
  35930. static NEAREST_NEAREST_MIPNEAREST: number;
  35931. static NEAREST_LINEAR_MIPNEAREST: number;
  35932. static NEAREST_LINEAR_MIPLINEAR: number;
  35933. static NEAREST_LINEAR: number;
  35934. static NEAREST_NEAREST: number;
  35935. static LINEAR_NEAREST_MIPNEAREST: number;
  35936. static LINEAR_NEAREST_MIPLINEAR: number;
  35937. static LINEAR_LINEAR: number;
  35938. static LINEAR_NEAREST: number;
  35939. static EXPLICIT_MODE: number;
  35940. static SPHERICAL_MODE: number;
  35941. static PLANAR_MODE: number;
  35942. static CUBIC_MODE: number;
  35943. static PROJECTION_MODE: number;
  35944. static SKYBOX_MODE: number;
  35945. static INVCUBIC_MODE: number;
  35946. static EQUIRECTANGULAR_MODE: number;
  35947. static FIXED_EQUIRECTANGULAR_MODE: number;
  35948. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  35949. static readonly CLAMP_ADDRESSMODE: number;
  35950. static readonly WRAP_ADDRESSMODE: number;
  35951. static readonly MIRROR_ADDRESSMODE: number;
  35952. /**
  35953. * 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
  35954. */
  35955. static UseSerializedUrlIfAny: boolean;
  35956. url: Nullable<string>;
  35957. uOffset: number;
  35958. vOffset: number;
  35959. uScale: number;
  35960. vScale: number;
  35961. uAng: number;
  35962. vAng: number;
  35963. wAng: number;
  35964. /**
  35965. * Defines the center of rotation (U)
  35966. */
  35967. uRotationCenter: number;
  35968. /**
  35969. * Defines the center of rotation (V)
  35970. */
  35971. vRotationCenter: number;
  35972. /**
  35973. * Defines the center of rotation (W)
  35974. */
  35975. wRotationCenter: number;
  35976. readonly noMipmap: boolean;
  35977. private _noMipmap;
  35978. _invertY: boolean;
  35979. private _rowGenerationMatrix;
  35980. private _cachedTextureMatrix;
  35981. private _projectionModeMatrix;
  35982. private _t0;
  35983. private _t1;
  35984. private _t2;
  35985. private _cachedUOffset;
  35986. private _cachedVOffset;
  35987. private _cachedUScale;
  35988. private _cachedVScale;
  35989. private _cachedUAng;
  35990. private _cachedVAng;
  35991. private _cachedWAng;
  35992. private _cachedProjectionMatrixId;
  35993. private _cachedCoordinatesMode;
  35994. _samplingMode: number;
  35995. /** @hidden */
  35996. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  35997. private _deleteBuffer;
  35998. protected _format: Nullable<number>;
  35999. private _delayedOnLoad;
  36000. private _delayedOnError;
  36001. protected _onLoadObservable: Nullable<Observable<Texture>>;
  36002. protected _isBlocking: boolean;
  36003. isBlocking: boolean;
  36004. readonly samplingMode: number;
  36005. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  36006. /**
  36007. * Update the url (and optional buffer) of this texture if url was null during construction.
  36008. * @param url the url of the texture
  36009. * @param buffer the buffer of the texture (defaults to null)
  36010. */
  36011. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  36012. delayLoad(): void;
  36013. updateSamplingMode(samplingMode: number): void;
  36014. private _prepareRowForTextureGeneration(x, y, z, t);
  36015. getTextureMatrix(): Matrix;
  36016. getReflectionTextureMatrix(): Matrix;
  36017. clone(): Texture;
  36018. readonly onLoadObservable: Observable<Texture>;
  36019. serialize(): any;
  36020. getClassName(): string;
  36021. dispose(): void;
  36022. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  36023. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  36024. 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;
  36025. }
  36026. }
  36027. declare module BABYLON {
  36028. /**
  36029. * Settings for finer control over video usage
  36030. */
  36031. interface VideoTextureSettings {
  36032. /**
  36033. * Applies `autoplay` to video, if specified
  36034. */
  36035. autoPlay?: boolean;
  36036. /**
  36037. * Applies `loop` to video, if specified
  36038. */
  36039. loop?: boolean;
  36040. /**
  36041. * Automatically updates internal texture from video at every frame in the render loop
  36042. */
  36043. autoUpdateTexture: boolean;
  36044. /**
  36045. * Image src displayed during the video loading or until the user interacts with the video.
  36046. */
  36047. poster?: string;
  36048. }
  36049. class VideoTexture extends Texture {
  36050. /**
  36051. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36052. */
  36053. readonly autoUpdateTexture: boolean;
  36054. /**
  36055. * The video instance used by the texture internally
  36056. */
  36057. readonly video: HTMLVideoElement;
  36058. private _onUserActionRequestedObservable;
  36059. readonly onUserActionRequestedObservable: Observable<Texture>;
  36060. private _generateMipMaps;
  36061. private _engine;
  36062. private _stillImageCaptured;
  36063. /**
  36064. * Creates a video texture.
  36065. * Sample : https://doc.babylonjs.com/how_to/video_texture
  36066. * @param {string | null} name optional name, will detect from video source, if not defined
  36067. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  36068. * @param {BABYLON.Scene} scene is obviously the current scene.
  36069. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36070. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  36071. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36072. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  36073. */
  36074. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36075. private _getName(src);
  36076. private _getVideo(src);
  36077. private _createInternalTexture;
  36078. private reset;
  36079. /**
  36080. * Internal method to initiate `update`.
  36081. */
  36082. _rebuild(): void;
  36083. /**
  36084. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36085. */
  36086. update(): void;
  36087. /**
  36088. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36089. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36090. */
  36091. updateTexture(isVisible: boolean): void;
  36092. protected _updateInternalTexture: (e?: Event | undefined) => void;
  36093. /**
  36094. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36095. * @param url New url.
  36096. */
  36097. updateURL(url: string): void;
  36098. dispose(): void;
  36099. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36100. minWidth: number;
  36101. maxWidth: number;
  36102. minHeight: number;
  36103. maxHeight: number;
  36104. deviceId: string;
  36105. }): void;
  36106. }
  36107. }
  36108. declare var DracoDecoderModule: any;
  36109. declare var WebAssembly: any;
  36110. declare module BABYLON {
  36111. /**
  36112. * Configuration for Draco compression
  36113. */
  36114. interface IDracoCompressionConfiguration {
  36115. /**
  36116. * Configuration for the decoder.
  36117. */
  36118. decoder?: {
  36119. /**
  36120. * The url to the WebAssembly module.
  36121. */
  36122. wasmUrl?: string;
  36123. /**
  36124. * The url to the WebAssembly binary.
  36125. */
  36126. wasmBinaryUrl?: string;
  36127. /**
  36128. * The url to the fallback JavaScript module.
  36129. */
  36130. fallbackUrl?: string;
  36131. };
  36132. }
  36133. /**
  36134. * Draco compression (https://google.github.io/draco/)
  36135. *
  36136. * This class wraps the Draco module.
  36137. *
  36138. * **Encoder**
  36139. *
  36140. * The encoder is not currently implemented.
  36141. *
  36142. * **Decoder**
  36143. *
  36144. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  36145. *
  36146. * To update the configuration, use the following code:
  36147. * ```javascript
  36148. * BABYLON.DracoCompression.Configuration = {
  36149. * decoder: {
  36150. * wasmUrl: "<url to the WebAssembly library>",
  36151. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  36152. * fallbackUrl: "<url to the fallback JavaScript library>",
  36153. * }
  36154. * };
  36155. * ```
  36156. *
  36157. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  36158. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  36159. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  36160. *
  36161. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  36162. * ```javascript
  36163. * var dracoCompression = new BABYLON.DracoCompression();
  36164. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  36165. * [BABYLON.VertexBuffer.PositionKind]: 0
  36166. * });
  36167. * ```
  36168. *
  36169. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  36170. */
  36171. class DracoCompression implements IDisposable {
  36172. private static _DecoderModulePromise;
  36173. /**
  36174. * The configuration. Defaults to the following urls:
  36175. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  36176. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  36177. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  36178. */
  36179. static Configuration: IDracoCompressionConfiguration;
  36180. /**
  36181. * Returns true if the decoder is available.
  36182. */
  36183. static readonly DecoderAvailable: boolean;
  36184. /**
  36185. * Constructor
  36186. */
  36187. constructor();
  36188. /**
  36189. * Stop all async operations and release resources.
  36190. */
  36191. dispose(): void;
  36192. /**
  36193. * Decode Draco compressed mesh data to vertex data.
  36194. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  36195. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  36196. * @returns A promise that resolves with the decoded vertex data
  36197. */
  36198. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  36199. [kind: string]: number;
  36200. }): Promise<VertexData>;
  36201. private static _GetDecoderModule();
  36202. private static _LoadScriptAsync(url);
  36203. private static _LoadFileAsync(url);
  36204. }
  36205. }
  36206. declare module BABYLON {
  36207. /**
  36208. * Particle emitter emitting particles from the inside of a box.
  36209. * It emits the particles randomly between 2 given directions.
  36210. */
  36211. class BoxParticleEmitter implements IParticleEmitterType {
  36212. /**
  36213. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  36214. */
  36215. direction1: Vector3;
  36216. /**
  36217. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  36218. */
  36219. direction2: Vector3;
  36220. /**
  36221. * 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.
  36222. */
  36223. minEmitBox: Vector3;
  36224. /**
  36225. * 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.
  36226. */
  36227. maxEmitBox: Vector3;
  36228. /**
  36229. * Creates a new instance BoxParticleEmitter
  36230. */
  36231. constructor();
  36232. /**
  36233. * Called by the particle System when the direction is computed for the created particle.
  36234. * @param worldMatrix is the world matrix of the particle system
  36235. * @param directionToUpdate is the direction vector to update with the result
  36236. * @param particle is the particle we are computed the direction for
  36237. */
  36238. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36239. /**
  36240. * Called by the particle System when the position is computed for the created particle.
  36241. * @param worldMatrix is the world matrix of the particle system
  36242. * @param positionToUpdate is the position vector to update with the result
  36243. * @param particle is the particle we are computed the position for
  36244. */
  36245. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  36246. /**
  36247. * Clones the current emitter and returns a copy of it
  36248. * @returns the new emitter
  36249. */
  36250. clone(): BoxParticleEmitter;
  36251. /**
  36252. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  36253. * @param effect defines the update shader
  36254. */
  36255. applyToShader(effect: Effect): void;
  36256. /**
  36257. * Returns a string to use to update the GPU particles update shader
  36258. * @returns a string containng the defines string
  36259. */
  36260. getEffectDefines(): string;
  36261. /**
  36262. * Returns the string "BoxParticleEmitter"
  36263. * @returns a string containing the class name
  36264. */
  36265. getClassName(): string;
  36266. /**
  36267. * Serializes the particle system to a JSON object.
  36268. * @returns the JSON object
  36269. */
  36270. serialize(): any;
  36271. /**
  36272. * Parse properties from a JSON object
  36273. * @param serializationObject defines the JSON object
  36274. */
  36275. parse(serializationObject: any): void;
  36276. }
  36277. }
  36278. declare module BABYLON {
  36279. /**
  36280. * Particle emitter emitting particles from the inside of a cone.
  36281. * It emits the particles alongside the cone volume from the base to the particle.
  36282. * The emission direction might be randomized.
  36283. */
  36284. class ConeParticleEmitter implements IParticleEmitterType {
  36285. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  36286. directionRandomizer: number;
  36287. private _radius;
  36288. private _angle;
  36289. private _height;
  36290. /**
  36291. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  36292. */
  36293. radiusRange: number;
  36294. /**
  36295. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  36296. */
  36297. heightRange: number;
  36298. /**
  36299. * Gets or sets the radius of the emission cone
  36300. */
  36301. radius: number;
  36302. /**
  36303. * Gets or sets the angle of the emission cone
  36304. */
  36305. angle: number;
  36306. private _buildHeight();
  36307. /**
  36308. * Creates a new instance ConeParticleEmitter
  36309. * @param radius the radius of the emission cone (1 by default)
  36310. * @param angles the cone base angle (PI by default)
  36311. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  36312. */
  36313. constructor(radius?: number, angle?: number,
  36314. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  36315. directionRandomizer?: number);
  36316. /**
  36317. * Called by the particle System when the direction is computed for the created particle.
  36318. * @param worldMatrix is the world matrix of the particle system
  36319. * @param directionToUpdate is the direction vector to update with the result
  36320. * @param particle is the particle we are computed the direction for
  36321. */
  36322. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36323. /**
  36324. * Called by the particle System when the position is computed for the created particle.
  36325. * @param worldMatrix is the world matrix of the particle system
  36326. * @param positionToUpdate is the position vector to update with the result
  36327. * @param particle is the particle we are computed the position for
  36328. */
  36329. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  36330. /**
  36331. * Clones the current emitter and returns a copy of it
  36332. * @returns the new emitter
  36333. */
  36334. clone(): ConeParticleEmitter;
  36335. /**
  36336. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  36337. * @param effect defines the update shader
  36338. */
  36339. applyToShader(effect: Effect): void;
  36340. /**
  36341. * Returns a string to use to update the GPU particles update shader
  36342. * @returns a string containng the defines string
  36343. */
  36344. getEffectDefines(): string;
  36345. /**
  36346. * Returns the string "ConeParticleEmitter"
  36347. * @returns a string containing the class name
  36348. */
  36349. getClassName(): string;
  36350. /**
  36351. * Serializes the particle system to a JSON object.
  36352. * @returns the JSON object
  36353. */
  36354. serialize(): any;
  36355. /**
  36356. * Parse properties from a JSON object
  36357. * @param serializationObject defines the JSON object
  36358. */
  36359. parse(serializationObject: any): void;
  36360. }
  36361. }
  36362. declare module BABYLON {
  36363. /**
  36364. * Particle emitter represents a volume emitting particles.
  36365. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  36366. */
  36367. interface IParticleEmitterType {
  36368. /**
  36369. * Called by the particle System when the direction is computed for the created particle.
  36370. * @param worldMatrix is the world matrix of the particle system
  36371. * @param directionToUpdate is the direction vector to update with the result
  36372. * @param particle is the particle we are computed the direction for
  36373. */
  36374. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36375. /**
  36376. * Called by the particle System when the position is computed for the created particle.
  36377. * @param worldMatrix is the world matrix of the particle system
  36378. * @param positionToUpdate is the position vector to update with the result
  36379. * @param particle is the particle we are computed the position for
  36380. */
  36381. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  36382. /**
  36383. * Clones the current emitter and returns a copy of it
  36384. * @returns the new emitter
  36385. */
  36386. clone(): IParticleEmitterType;
  36387. /**
  36388. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  36389. * @param effect defines the update shader
  36390. */
  36391. applyToShader(effect: Effect): void;
  36392. /**
  36393. * Returns a string to use to update the GPU particles update shader
  36394. * @returns the effect defines string
  36395. */
  36396. getEffectDefines(): string;
  36397. /**
  36398. * Returns a string representing the class name
  36399. * @returns a string containing the class name
  36400. */
  36401. getClassName(): string;
  36402. /**
  36403. * Serializes the particle system to a JSON object.
  36404. * @returns the JSON object
  36405. */
  36406. serialize(): any;
  36407. /**
  36408. * Parse properties from a JSON object
  36409. * @param serializationObject defines the JSON object
  36410. */
  36411. parse(serializationObject: any): void;
  36412. }
  36413. }
  36414. declare module BABYLON {
  36415. /**
  36416. * Particle emitter emitting particles from the inside of a sphere.
  36417. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  36418. */
  36419. class SphereParticleEmitter implements IParticleEmitterType {
  36420. /**
  36421. * The radius of the emission sphere.
  36422. */
  36423. radius: number;
  36424. /**
  36425. * How much to randomize the particle direction [0-1].
  36426. */
  36427. directionRandomizer: number;
  36428. /**
  36429. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  36430. */
  36431. radiusRange: number;
  36432. /**
  36433. * Creates a new instance SphereParticleEmitter
  36434. * @param radius the radius of the emission sphere (1 by default)
  36435. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  36436. */
  36437. constructor(
  36438. /**
  36439. * The radius of the emission sphere.
  36440. */
  36441. radius?: number,
  36442. /**
  36443. * How much to randomize the particle direction [0-1].
  36444. */
  36445. directionRandomizer?: number);
  36446. /**
  36447. * Called by the particle System when the direction is computed for the created particle.
  36448. * @param worldMatrix is the world matrix of the particle system
  36449. * @param directionToUpdate is the direction vector to update with the result
  36450. * @param particle is the particle we are computed the direction for
  36451. */
  36452. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36453. /**
  36454. * Called by the particle System when the position is computed for the created particle.
  36455. * @param worldMatrix is the world matrix of the particle system
  36456. * @param positionToUpdate is the position vector to update with the result
  36457. * @param particle is the particle we are computed the position for
  36458. */
  36459. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  36460. /**
  36461. * Clones the current emitter and returns a copy of it
  36462. * @returns the new emitter
  36463. */
  36464. clone(): SphereParticleEmitter;
  36465. /**
  36466. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  36467. * @param effect defines the update shader
  36468. */
  36469. applyToShader(effect: Effect): void;
  36470. /**
  36471. * Returns a string to use to update the GPU particles update shader
  36472. * @returns a string containng the defines string
  36473. */
  36474. getEffectDefines(): string;
  36475. /**
  36476. * Returns the string "SphereParticleEmitter"
  36477. * @returns a string containing the class name
  36478. */
  36479. getClassName(): string;
  36480. /**
  36481. * Serializes the particle system to a JSON object.
  36482. * @returns the JSON object
  36483. */
  36484. serialize(): any;
  36485. /**
  36486. * Parse properties from a JSON object
  36487. * @param serializationObject defines the JSON object
  36488. */
  36489. parse(serializationObject: any): void;
  36490. }
  36491. /**
  36492. * Particle emitter emitting particles from the inside of a sphere.
  36493. * It emits the particles randomly between two vectors.
  36494. */
  36495. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  36496. /**
  36497. * The min limit of the emission direction.
  36498. */
  36499. direction1: Vector3;
  36500. /**
  36501. * The max limit of the emission direction.
  36502. */
  36503. direction2: Vector3;
  36504. /**
  36505. * Creates a new instance SphereDirectedParticleEmitter
  36506. * @param radius the radius of the emission sphere (1 by default)
  36507. * @param direction1 the min limit of the emission direction (up vector by default)
  36508. * @param direction2 the max limit of the emission direction (up vector by default)
  36509. */
  36510. constructor(radius?: number,
  36511. /**
  36512. * The min limit of the emission direction.
  36513. */
  36514. direction1?: Vector3,
  36515. /**
  36516. * The max limit of the emission direction.
  36517. */
  36518. direction2?: Vector3);
  36519. /**
  36520. * Called by the particle System when the direction is computed for the created particle.
  36521. * @param worldMatrix is the world matrix of the particle system
  36522. * @param directionToUpdate is the direction vector to update with the result
  36523. * @param particle is the particle we are computed the direction for
  36524. */
  36525. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36526. /**
  36527. * Clones the current emitter and returns a copy of it
  36528. * @returns the new emitter
  36529. */
  36530. clone(): SphereDirectedParticleEmitter;
  36531. /**
  36532. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  36533. * @param effect defines the update shader
  36534. */
  36535. applyToShader(effect: Effect): void;
  36536. /**
  36537. * Returns a string to use to update the GPU particles update shader
  36538. * @returns a string containng the defines string
  36539. */
  36540. getEffectDefines(): string;
  36541. /**
  36542. * Returns the string "SphereDirectedParticleEmitter"
  36543. * @returns a string containing the class name
  36544. */
  36545. getClassName(): string;
  36546. /**
  36547. * Serializes the particle system to a JSON object.
  36548. * @returns the JSON object
  36549. */
  36550. serialize(): any;
  36551. /**
  36552. * Parse properties from a JSON object
  36553. * @param serializationObject defines the JSON object
  36554. */
  36555. parse(serializationObject: any): void;
  36556. }
  36557. }
  36558. declare module BABYLON {
  36559. class CannonJSPlugin implements IPhysicsEnginePlugin {
  36560. private _useDeltaForWorldStep;
  36561. world: any;
  36562. name: string;
  36563. private _physicsMaterials;
  36564. private _fixedTimeStep;
  36565. BJSCANNON: any;
  36566. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  36567. setGravity(gravity: Vector3): void;
  36568. setTimeStep(timeStep: number): void;
  36569. getTimeStep(): number;
  36570. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  36571. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36572. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36573. generatePhysicsBody(impostor: PhysicsImpostor): void;
  36574. private _processChildMeshes(mainImpostor);
  36575. removePhysicsBody(impostor: PhysicsImpostor): void;
  36576. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  36577. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  36578. private _addMaterial(name, friction, restitution);
  36579. private _checkWithEpsilon(value);
  36580. private _createShape(impostor);
  36581. private _createHeightmap(object, pointDepth?);
  36582. private _minus90X;
  36583. private _plus90X;
  36584. private _tmpPosition;
  36585. private _tmpDeltaPosition;
  36586. private _tmpUnityRotation;
  36587. private _updatePhysicsBodyTransformation(impostor);
  36588. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  36589. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  36590. isSupported(): boolean;
  36591. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36592. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36593. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36594. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36595. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  36596. getBodyMass(impostor: PhysicsImpostor): number;
  36597. getBodyFriction(impostor: PhysicsImpostor): number;
  36598. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  36599. getBodyRestitution(impostor: PhysicsImpostor): number;
  36600. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  36601. sleepBody(impostor: PhysicsImpostor): void;
  36602. wakeUpBody(impostor: PhysicsImpostor): void;
  36603. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  36604. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  36605. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  36606. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  36607. getRadius(impostor: PhysicsImpostor): number;
  36608. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  36609. dispose(): void;
  36610. private _extendNamespace();
  36611. }
  36612. }
  36613. declare module BABYLON {
  36614. class OimoJSPlugin implements IPhysicsEnginePlugin {
  36615. world: any;
  36616. name: string;
  36617. BJSOIMO: any;
  36618. constructor(iterations?: number);
  36619. setGravity(gravity: Vector3): void;
  36620. setTimeStep(timeStep: number): void;
  36621. getTimeStep(): number;
  36622. private _tmpImpostorsArray;
  36623. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  36624. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36625. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36626. generatePhysicsBody(impostor: PhysicsImpostor): void;
  36627. private _tmpPositionVector;
  36628. removePhysicsBody(impostor: PhysicsImpostor): void;
  36629. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  36630. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  36631. isSupported(): boolean;
  36632. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  36633. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  36634. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36635. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36636. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36637. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36638. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  36639. getBodyMass(impostor: PhysicsImpostor): number;
  36640. getBodyFriction(impostor: PhysicsImpostor): number;
  36641. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  36642. getBodyRestitution(impostor: PhysicsImpostor): number;
  36643. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  36644. sleepBody(impostor: PhysicsImpostor): void;
  36645. wakeUpBody(impostor: PhysicsImpostor): void;
  36646. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  36647. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  36648. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  36649. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  36650. getRadius(impostor: PhysicsImpostor): number;
  36651. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  36652. dispose(): void;
  36653. }
  36654. }
  36655. declare module BABYLON {
  36656. /**
  36657. * This represents a set of one or more post processes in Babylon.
  36658. * A post process can be used to apply a shader to a texture after it is rendered.
  36659. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  36660. */
  36661. class PostProcessRenderEffect {
  36662. private _postProcesses;
  36663. private _getPostProcesses;
  36664. private _singleInstance;
  36665. private _cameras;
  36666. private _indicesForCamera;
  36667. /**
  36668. * Name of the effect
  36669. */
  36670. _name: string;
  36671. /**
  36672. * Instantiates a post process render effect.
  36673. * A post process can be used to apply a shader to a texture after it is rendered.
  36674. * @param engine The engine the effect is tied to
  36675. * @param name The name of the effect
  36676. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  36677. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  36678. */
  36679. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  36680. /**
  36681. * Checks if all the post processes in the effect are supported.
  36682. */
  36683. readonly isSupported: boolean;
  36684. /**
  36685. * Updates the current state of the effect
  36686. */
  36687. _update(): void;
  36688. /**
  36689. * Attaches the effect on cameras
  36690. * @param cameras The camera to attach to.
  36691. */
  36692. _attachCameras(cameras: Camera): void;
  36693. /**
  36694. * Attaches the effect on cameras
  36695. * @param cameras The camera to attach to.
  36696. */
  36697. _attachCameras(cameras: Camera[]): void;
  36698. /**
  36699. * Detatches the effect on cameras
  36700. * @param cameras The camera to detatch from.
  36701. */
  36702. _detachCameras(cameras: Camera): void;
  36703. /**
  36704. * Detatches the effect on cameras
  36705. * @param cameras The camera to detatch from.
  36706. */
  36707. _detachCameras(cameras: Camera[]): void;
  36708. /**
  36709. * Enables the effect on given cameras
  36710. * @param cameras The camera to enable.
  36711. */
  36712. _enable(cameras: Camera): void;
  36713. /**
  36714. * Enables the effect on given cameras
  36715. * @param cameras The camera to enable.
  36716. */
  36717. _enable(cameras: Nullable<Camera[]>): void;
  36718. /**
  36719. * Disables the effect on the given cameras
  36720. * @param cameras The camera to disable.
  36721. */
  36722. _disable(cameras: Camera): void;
  36723. /**
  36724. * Disables the effect on the given cameras
  36725. * @param cameras The camera to disable.
  36726. */
  36727. _disable(cameras: Nullable<Camera[]>): void;
  36728. /**
  36729. * Gets a list of the post processes contained in the effect.
  36730. * @param camera The camera to get the post processes on.
  36731. * @returns The list of the post processes in the effect.
  36732. */
  36733. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  36734. }
  36735. }
  36736. declare module BABYLON {
  36737. class PostProcessRenderPipeline {
  36738. private engine;
  36739. private _renderEffects;
  36740. private _renderEffectsForIsolatedPass;
  36741. protected _cameras: Camera[];
  36742. _name: string;
  36743. constructor(engine: Engine, name: string);
  36744. getClassName(): string;
  36745. readonly isSupported: boolean;
  36746. addEffect(renderEffect: PostProcessRenderEffect): void;
  36747. _rebuild(): void;
  36748. _enableEffect(renderEffectName: string, cameras: Camera): void;
  36749. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  36750. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  36751. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  36752. _attachCameras(cameras: Camera, unique: boolean): void;
  36753. _attachCameras(cameras: Camera[], unique: boolean): void;
  36754. _detachCameras(cameras: Camera): void;
  36755. _detachCameras(cameras: Nullable<Camera[]>): void;
  36756. _update(): void;
  36757. _reset(): void;
  36758. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  36759. dispose(): void;
  36760. }
  36761. }
  36762. declare module BABYLON {
  36763. class PostProcessRenderPipelineManager {
  36764. private _renderPipelines;
  36765. constructor();
  36766. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  36767. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  36768. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  36769. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  36770. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  36771. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  36772. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  36773. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  36774. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  36775. update(): void;
  36776. _rebuild(): void;
  36777. dispose(): void;
  36778. }
  36779. }
  36780. declare module BABYLON {
  36781. /**
  36782. * Helper class dealing with the extraction of spherical polynomial dataArray
  36783. * from a cube map.
  36784. */
  36785. class CubeMapToSphericalPolynomialTools {
  36786. private static FileFaces;
  36787. /**
  36788. * Converts a texture to the according Spherical Polynomial data.
  36789. * This extracts the first 3 orders only as they are the only one used in the lighting.
  36790. *
  36791. * @param texture The texture to extract the information from.
  36792. * @return The Spherical Polynomial data.
  36793. */
  36794. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  36795. /**
  36796. * Converts a cubemap to the according Spherical Polynomial data.
  36797. * This extracts the first 3 orders only as they are the only one used in the lighting.
  36798. *
  36799. * @param cubeInfo The Cube map to extract the information from.
  36800. * @return The Spherical Polynomial data.
  36801. */
  36802. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  36803. }
  36804. }
  36805. declare module BABYLON {
  36806. /**
  36807. * Header information of HDR texture files.
  36808. */
  36809. interface HDRInfo {
  36810. /**
  36811. * The height of the texture in pixels.
  36812. */
  36813. height: number;
  36814. /**
  36815. * The width of the texture in pixels.
  36816. */
  36817. width: number;
  36818. /**
  36819. * The index of the beginning of the data in the binary file.
  36820. */
  36821. dataPosition: number;
  36822. }
  36823. /**
  36824. * This groups tools to convert HDR texture to native colors array.
  36825. */
  36826. class HDRTools {
  36827. private static Ldexp(mantissa, exponent);
  36828. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  36829. private static readStringLine(uint8array, startIndex);
  36830. /**
  36831. * Reads header information from an RGBE texture stored in a native array.
  36832. * More information on this format are available here:
  36833. * https://en.wikipedia.org/wiki/RGBE_image_format
  36834. *
  36835. * @param uint8array The binary file stored in native array.
  36836. * @return The header information.
  36837. */
  36838. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  36839. /**
  36840. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  36841. * This RGBE texture needs to store the information as a panorama.
  36842. *
  36843. * More information on this format are available here:
  36844. * https://en.wikipedia.org/wiki/RGBE_image_format
  36845. *
  36846. * @param buffer The binary file stored in an array buffer.
  36847. * @param size The expected size of the extracted cubemap.
  36848. * @return The Cube Map information.
  36849. */
  36850. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  36851. /**
  36852. * Returns the pixels data extracted from an RGBE texture.
  36853. * This pixels will be stored left to right up to down in the R G B order in one array.
  36854. *
  36855. * More information on this format are available here:
  36856. * https://en.wikipedia.org/wiki/RGBE_image_format
  36857. *
  36858. * @param uint8array The binary file stored in an array buffer.
  36859. * @param hdrInfo The header information of the file.
  36860. * @return The pixels data in RGB right to left up to down order.
  36861. */
  36862. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  36863. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  36864. }
  36865. }
  36866. declare module BABYLON {
  36867. /**
  36868. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  36869. */
  36870. interface CubeMapInfo {
  36871. /**
  36872. * The pixel array for the front face.
  36873. * This is stored in format, left to right, up to down format.
  36874. */
  36875. front: Nullable<ArrayBufferView>;
  36876. /**
  36877. * The pixel array for the back face.
  36878. * This is stored in format, left to right, up to down format.
  36879. */
  36880. back: Nullable<ArrayBufferView>;
  36881. /**
  36882. * The pixel array for the left face.
  36883. * This is stored in format, left to right, up to down format.
  36884. */
  36885. left: Nullable<ArrayBufferView>;
  36886. /**
  36887. * The pixel array for the right face.
  36888. * This is stored in format, left to right, up to down format.
  36889. */
  36890. right: Nullable<ArrayBufferView>;
  36891. /**
  36892. * The pixel array for the up face.
  36893. * This is stored in format, left to right, up to down format.
  36894. */
  36895. up: Nullable<ArrayBufferView>;
  36896. /**
  36897. * The pixel array for the down face.
  36898. * This is stored in format, left to right, up to down format.
  36899. */
  36900. down: Nullable<ArrayBufferView>;
  36901. /**
  36902. * The size of the cubemap stored.
  36903. *
  36904. * Each faces will be size * size pixels.
  36905. */
  36906. size: number;
  36907. /**
  36908. * The format of the texture.
  36909. *
  36910. * RGBA, RGB.
  36911. */
  36912. format: number;
  36913. /**
  36914. * The type of the texture data.
  36915. *
  36916. * UNSIGNED_INT, FLOAT.
  36917. */
  36918. type: number;
  36919. /**
  36920. * Specifies whether the texture is in gamma space.
  36921. */
  36922. gammaSpace: boolean;
  36923. }
  36924. /**
  36925. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  36926. */
  36927. class PanoramaToCubeMapTools {
  36928. private static FACE_FRONT;
  36929. private static FACE_BACK;
  36930. private static FACE_RIGHT;
  36931. private static FACE_LEFT;
  36932. private static FACE_DOWN;
  36933. private static FACE_UP;
  36934. /**
  36935. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  36936. *
  36937. * @param float32Array The source data.
  36938. * @param inputWidth The width of the input panorama.
  36939. * @param inputhHeight The height of the input panorama.
  36940. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  36941. * @return The cubemap data
  36942. */
  36943. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  36944. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  36945. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  36946. }
  36947. }
  36948. declare module BABYLON {
  36949. class CustomProceduralTexture extends ProceduralTexture {
  36950. private _animate;
  36951. private _time;
  36952. private _config;
  36953. private _texturePath;
  36954. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  36955. private loadJson(jsonUrl);
  36956. isReady(): boolean;
  36957. render(useCameraPostProcess?: boolean): void;
  36958. updateTextures(): void;
  36959. updateShaderUniforms(): void;
  36960. animate: boolean;
  36961. }
  36962. }
  36963. declare module BABYLON {
  36964. class ProceduralTexture extends Texture {
  36965. isCube: boolean;
  36966. private _size;
  36967. _generateMipMaps: boolean;
  36968. isEnabled: boolean;
  36969. private _currentRefreshId;
  36970. private _refreshRate;
  36971. onGenerated: () => void;
  36972. private _vertexBuffers;
  36973. private _indexBuffer;
  36974. private _effect;
  36975. private _uniforms;
  36976. private _samplers;
  36977. private _fragment;
  36978. _textures: {
  36979. [key: string]: Texture;
  36980. };
  36981. private _floats;
  36982. private _floatsArrays;
  36983. private _colors3;
  36984. private _colors4;
  36985. private _vectors2;
  36986. private _vectors3;
  36987. private _matrices;
  36988. private _fallbackTexture;
  36989. private _fallbackTextureUsed;
  36990. private _engine;
  36991. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  36992. private _createIndexBuffer();
  36993. _rebuild(): void;
  36994. reset(): void;
  36995. isReady(): boolean;
  36996. resetRefreshCounter(): void;
  36997. setFragment(fragment: any): void;
  36998. refreshRate: number;
  36999. _shouldRender(): boolean;
  37000. getRenderSize(): number;
  37001. resize(size: number, generateMipMaps: boolean): void;
  37002. private _checkUniform(uniformName);
  37003. setTexture(name: string, texture: Texture): ProceduralTexture;
  37004. setFloat(name: string, value: number): ProceduralTexture;
  37005. setFloats(name: string, value: number[]): ProceduralTexture;
  37006. setColor3(name: string, value: Color3): ProceduralTexture;
  37007. setColor4(name: string, value: Color4): ProceduralTexture;
  37008. setVector2(name: string, value: Vector2): ProceduralTexture;
  37009. setVector3(name: string, value: Vector3): ProceduralTexture;
  37010. setMatrix(name: string, value: Matrix): ProceduralTexture;
  37011. render(useCameraPostProcess?: boolean): void;
  37012. clone(): ProceduralTexture;
  37013. dispose(): void;
  37014. }
  37015. }
  37016. declare module BABYLON {
  37017. /**
  37018. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  37019. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  37020. */
  37021. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  37022. private _scene;
  37023. private _camerasToBeAttached;
  37024. /**
  37025. * ID of the sharpen post process,
  37026. */
  37027. private readonly SharpenPostProcessId;
  37028. /**
  37029. * ID of the image processing post process;
  37030. */
  37031. readonly ImageProcessingPostProcessId: string;
  37032. /**
  37033. * ID of the Fast Approximate Anti-Aliasing post process;
  37034. */
  37035. readonly FxaaPostProcessId: string;
  37036. /**
  37037. * ID of the chromatic aberration post process,
  37038. */
  37039. private readonly ChromaticAberrationPostProcessId;
  37040. /**
  37041. * ID of the grain post process
  37042. */
  37043. private readonly GrainPostProcessId;
  37044. /**
  37045. * Sharpen post process which will apply a sharpen convolution to enhance edges
  37046. */
  37047. sharpen: SharpenPostProcess;
  37048. private _sharpenEffect;
  37049. private bloom;
  37050. /**
  37051. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  37052. */
  37053. depthOfField: DepthOfFieldEffect;
  37054. /**
  37055. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  37056. */
  37057. fxaa: FxaaPostProcess;
  37058. /**
  37059. * Image post processing pass used to perform operations such as tone mapping or color grading.
  37060. */
  37061. imageProcessing: ImageProcessingPostProcess;
  37062. /**
  37063. * Chromatic aberration post process which will shift rgb colors in the image
  37064. */
  37065. chromaticAberration: ChromaticAberrationPostProcess;
  37066. private _chromaticAberrationEffect;
  37067. /**
  37068. * Grain post process which add noise to the image
  37069. */
  37070. grain: GrainPostProcess;
  37071. private _grainEffect;
  37072. /**
  37073. * Glow post process which adds a glow to emmisive areas of the image
  37074. */
  37075. private _glowLayer;
  37076. /**
  37077. * Animations which can be used to tweak settings over a period of time
  37078. */
  37079. animations: Animation[];
  37080. private _imageProcessingConfigurationObserver;
  37081. private _sharpenEnabled;
  37082. private _bloomEnabled;
  37083. private _depthOfFieldEnabled;
  37084. private _depthOfFieldBlurLevel;
  37085. private _fxaaEnabled;
  37086. private _imageProcessingEnabled;
  37087. private _defaultPipelineTextureType;
  37088. private _bloomScale;
  37089. private _chromaticAberrationEnabled;
  37090. private _grainEnabled;
  37091. private _buildAllowed;
  37092. /**
  37093. * Enable or disable the sharpen process from the pipeline
  37094. */
  37095. sharpenEnabled: boolean;
  37096. private _resizeObserver;
  37097. private _hardwareScaleLevel;
  37098. private _bloomKernel;
  37099. /**
  37100. * Specifies the size of the bloom blur kernel, relative to the final output size
  37101. */
  37102. bloomKernel: number;
  37103. /**
  37104. * Specifies the weight of the bloom in the final rendering
  37105. */
  37106. private _bloomWeight;
  37107. /**
  37108. * Specifies the luma threshold for the area that will be blurred by the bloom
  37109. */
  37110. private _bloomThreshold;
  37111. private _hdr;
  37112. /**
  37113. * The strength of the bloom.
  37114. */
  37115. bloomWeight: number;
  37116. /**
  37117. * The strength of the bloom.
  37118. */
  37119. bloomThreshold: number;
  37120. /**
  37121. * The scale of the bloom, lower value will provide better performance.
  37122. */
  37123. bloomScale: number;
  37124. /**
  37125. * Enable or disable the bloom from the pipeline
  37126. */
  37127. bloomEnabled: boolean;
  37128. private _rebuildBloom();
  37129. /**
  37130. * If the depth of field is enabled.
  37131. */
  37132. depthOfFieldEnabled: boolean;
  37133. /**
  37134. * Blur level of the depth of field effect. (Higher blur will effect performance)
  37135. */
  37136. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  37137. /**
  37138. * If the anti aliasing is enabled.
  37139. */
  37140. fxaaEnabled: boolean;
  37141. private _samples;
  37142. /**
  37143. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  37144. */
  37145. samples: number;
  37146. /**
  37147. * If image processing is enabled.
  37148. */
  37149. imageProcessingEnabled: boolean;
  37150. /**
  37151. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  37152. */
  37153. glowLayerEnabled: boolean;
  37154. /**
  37155. * Enable or disable the chromaticAberration process from the pipeline
  37156. */
  37157. chromaticAberrationEnabled: boolean;
  37158. /**
  37159. * Enable or disable the grain process from the pipeline
  37160. */
  37161. grainEnabled: boolean;
  37162. /**
  37163. * @constructor
  37164. * @param {string} name - The rendering pipeline name (default: "")
  37165. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  37166. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  37167. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  37168. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  37169. */
  37170. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  37171. /**
  37172. * Force the compilation of the entire pipeline.
  37173. */
  37174. prepare(): void;
  37175. private _hasCleared;
  37176. private _prevPostProcess;
  37177. private _prevPrevPostProcess;
  37178. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  37179. private _buildPipeline();
  37180. private _disposePostProcesses(disposeNonRecreated?);
  37181. /**
  37182. * Adds a camera to the pipeline
  37183. * @param camera the camera to be added
  37184. */
  37185. addCamera(camera: Camera): void;
  37186. /**
  37187. * Removes a camera from the pipeline
  37188. * @param camera the camera to remove
  37189. */
  37190. removeCamera(camera: Camera): void;
  37191. /**
  37192. * Dispose of the pipeline and stop all post processes
  37193. */
  37194. dispose(): void;
  37195. /**
  37196. * Serialize the rendering pipeline (Used when exporting)
  37197. * @returns the serialized object
  37198. */
  37199. serialize(): any;
  37200. /**
  37201. * Parse the serialized pipeline
  37202. * @param source Source pipeline.
  37203. * @param scene The scene to load the pipeline to.
  37204. * @param rootUrl The URL of the serialized pipeline.
  37205. * @returns An instantiated pipeline from the serialized object.
  37206. */
  37207. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  37208. }
  37209. }
  37210. declare module BABYLON {
  37211. class LensRenderingPipeline extends PostProcessRenderPipeline {
  37212. /**
  37213. * The chromatic aberration PostProcess id in the pipeline
  37214. */
  37215. LensChromaticAberrationEffect: string;
  37216. /**
  37217. * The highlights enhancing PostProcess id in the pipeline
  37218. */
  37219. HighlightsEnhancingEffect: string;
  37220. /**
  37221. * The depth-of-field PostProcess id in the pipeline
  37222. */
  37223. LensDepthOfFieldEffect: string;
  37224. private _scene;
  37225. private _depthTexture;
  37226. private _grainTexture;
  37227. private _chromaticAberrationPostProcess;
  37228. private _highlightsPostProcess;
  37229. private _depthOfFieldPostProcess;
  37230. private _edgeBlur;
  37231. private _grainAmount;
  37232. private _chromaticAberration;
  37233. private _distortion;
  37234. private _highlightsGain;
  37235. private _highlightsThreshold;
  37236. private _dofDistance;
  37237. private _dofAperture;
  37238. private _dofDarken;
  37239. private _dofPentagon;
  37240. private _blurNoise;
  37241. /**
  37242. * @constructor
  37243. *
  37244. * Effect parameters are as follow:
  37245. * {
  37246. * chromatic_aberration: number; // from 0 to x (1 for realism)
  37247. * edge_blur: number; // from 0 to x (1 for realism)
  37248. * distortion: number; // from 0 to x (1 for realism)
  37249. * grain_amount: number; // from 0 to 1
  37250. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  37251. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  37252. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  37253. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  37254. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  37255. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  37256. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  37257. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  37258. * }
  37259. * Note: if an effect parameter is unset, effect is disabled
  37260. *
  37261. * @param {string} name - The rendering pipeline name
  37262. * @param {object} parameters - An object containing all parameters (see above)
  37263. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  37264. * @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)
  37265. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  37266. */
  37267. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  37268. setEdgeBlur(amount: number): void;
  37269. disableEdgeBlur(): void;
  37270. setGrainAmount(amount: number): void;
  37271. disableGrain(): void;
  37272. setChromaticAberration(amount: number): void;
  37273. disableChromaticAberration(): void;
  37274. setEdgeDistortion(amount: number): void;
  37275. disableEdgeDistortion(): void;
  37276. setFocusDistance(amount: number): void;
  37277. disableDepthOfField(): void;
  37278. setAperture(amount: number): void;
  37279. setDarkenOutOfFocus(amount: number): void;
  37280. enablePentagonBokeh(): void;
  37281. disablePentagonBokeh(): void;
  37282. enableNoiseBlur(): void;
  37283. disableNoiseBlur(): void;
  37284. setHighlightsGain(amount: number): void;
  37285. setHighlightsThreshold(amount: number): void;
  37286. disableHighlights(): void;
  37287. /**
  37288. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  37289. */
  37290. dispose(disableDepthRender?: boolean): void;
  37291. private _createChromaticAberrationPostProcess(ratio);
  37292. private _createHighlightsPostProcess(ratio);
  37293. private _createDepthOfFieldPostProcess(ratio);
  37294. private _createGrainTexture();
  37295. }
  37296. }
  37297. declare module BABYLON {
  37298. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  37299. /**
  37300. * The PassPostProcess id in the pipeline that contains the original scene color
  37301. */
  37302. SSAOOriginalSceneColorEffect: string;
  37303. /**
  37304. * The SSAO PostProcess id in the pipeline
  37305. */
  37306. SSAORenderEffect: string;
  37307. /**
  37308. * The horizontal blur PostProcess id in the pipeline
  37309. */
  37310. SSAOBlurHRenderEffect: string;
  37311. /**
  37312. * The vertical blur PostProcess id in the pipeline
  37313. */
  37314. SSAOBlurVRenderEffect: string;
  37315. /**
  37316. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  37317. */
  37318. SSAOCombineRenderEffect: string;
  37319. /**
  37320. * The output strength of the SSAO post-process. Default value is 1.0.
  37321. */
  37322. totalStrength: number;
  37323. /**
  37324. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  37325. */
  37326. maxZ: number;
  37327. /**
  37328. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  37329. */
  37330. minZAspect: number;
  37331. /**
  37332. * Number of samples used for the SSAO calculations. Default value is 8
  37333. */
  37334. private _samples;
  37335. /**
  37336. * Ratio object used for SSAO ratio and blur ratio
  37337. */
  37338. private _ratio;
  37339. /**
  37340. * Dynamically generated sphere sampler.
  37341. */
  37342. private _sampleSphere;
  37343. /**
  37344. * Blur filter offsets
  37345. */
  37346. private _samplerOffsets;
  37347. samples: number;
  37348. /**
  37349. * Are we using bilateral blur ?
  37350. */
  37351. private _expensiveBlur;
  37352. expensiveBlur: boolean;
  37353. /**
  37354. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  37355. */
  37356. radius: number;
  37357. /**
  37358. * The base color of the SSAO post-process
  37359. * The final result is "base + ssao" between [0, 1]
  37360. */
  37361. base: number;
  37362. /**
  37363. * Support test.
  37364. */
  37365. static readonly IsSupported: boolean;
  37366. private _scene;
  37367. private _depthTexture;
  37368. private _normalTexture;
  37369. private _randomTexture;
  37370. private _originalColorPostProcess;
  37371. private _ssaoPostProcess;
  37372. private _blurHPostProcess;
  37373. private _blurVPostProcess;
  37374. private _ssaoCombinePostProcess;
  37375. private _firstUpdate;
  37376. /**
  37377. * @constructor
  37378. * @param {string} name - The rendering pipeline name
  37379. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  37380. * @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 }
  37381. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  37382. */
  37383. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  37384. /**
  37385. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  37386. */
  37387. dispose(disableGeometryBufferRenderer?: boolean): void;
  37388. private _createBlurPostProcess(ssaoRatio, blurRatio);
  37389. _rebuild(): void;
  37390. private _generateHemisphere();
  37391. private _createSSAOPostProcess(ratio);
  37392. private _createSSAOCombinePostProcess(ratio);
  37393. private _createRandomTexture();
  37394. /**
  37395. * Serialize the rendering pipeline (Used when exporting)
  37396. * @returns the serialized object
  37397. */
  37398. serialize(): any;
  37399. /**
  37400. * Parse the serialized pipeline
  37401. * @param source Source pipeline.
  37402. * @param scene The scene to load the pipeline to.
  37403. * @param rootUrl The URL of the serialized pipeline.
  37404. * @returns An instantiated pipeline from the serialized object.
  37405. */
  37406. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  37407. }
  37408. }
  37409. declare module BABYLON {
  37410. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  37411. /**
  37412. * The PassPostProcess id in the pipeline that contains the original scene color
  37413. */
  37414. SSAOOriginalSceneColorEffect: string;
  37415. /**
  37416. * The SSAO PostProcess id in the pipeline
  37417. */
  37418. SSAORenderEffect: string;
  37419. /**
  37420. * The horizontal blur PostProcess id in the pipeline
  37421. */
  37422. SSAOBlurHRenderEffect: string;
  37423. /**
  37424. * The vertical blur PostProcess id in the pipeline
  37425. */
  37426. SSAOBlurVRenderEffect: string;
  37427. /**
  37428. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  37429. */
  37430. SSAOCombineRenderEffect: string;
  37431. /**
  37432. * The output strength of the SSAO post-process. Default value is 1.0.
  37433. */
  37434. totalStrength: number;
  37435. /**
  37436. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  37437. */
  37438. radius: number;
  37439. /**
  37440. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  37441. * Must not be equal to fallOff and superior to fallOff.
  37442. * Default value is 0.975
  37443. */
  37444. area: number;
  37445. /**
  37446. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  37447. * Must not be equal to area and inferior to area.
  37448. * Default value is 0.0
  37449. */
  37450. fallOff: number;
  37451. /**
  37452. * The base color of the SSAO post-process
  37453. * The final result is "base + ssao" between [0, 1]
  37454. */
  37455. base: number;
  37456. private _scene;
  37457. private _depthTexture;
  37458. private _randomTexture;
  37459. private _originalColorPostProcess;
  37460. private _ssaoPostProcess;
  37461. private _blurHPostProcess;
  37462. private _blurVPostProcess;
  37463. private _ssaoCombinePostProcess;
  37464. private _firstUpdate;
  37465. /**
  37466. * @constructor
  37467. * @param {string} name - The rendering pipeline name
  37468. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  37469. * @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 }
  37470. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  37471. */
  37472. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  37473. /**
  37474. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  37475. */
  37476. dispose(disableDepthRender?: boolean): void;
  37477. private _createBlurPostProcess(ratio);
  37478. _rebuild(): void;
  37479. private _createSSAOPostProcess(ratio);
  37480. private _createSSAOCombinePostProcess(ratio);
  37481. private _createRandomTexture();
  37482. }
  37483. }
  37484. declare module BABYLON {
  37485. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  37486. /**
  37487. * Public members
  37488. */
  37489. originalPostProcess: Nullable<PostProcess>;
  37490. downSampleX4PostProcess: Nullable<PostProcess>;
  37491. brightPassPostProcess: Nullable<PostProcess>;
  37492. blurHPostProcesses: PostProcess[];
  37493. blurVPostProcesses: PostProcess[];
  37494. textureAdderPostProcess: Nullable<PostProcess>;
  37495. volumetricLightPostProcess: Nullable<PostProcess>;
  37496. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  37497. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  37498. volumetricLightMergePostProces: Nullable<PostProcess>;
  37499. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  37500. luminancePostProcess: Nullable<PostProcess>;
  37501. luminanceDownSamplePostProcesses: PostProcess[];
  37502. hdrPostProcess: Nullable<PostProcess>;
  37503. textureAdderFinalPostProcess: Nullable<PostProcess>;
  37504. lensFlareFinalPostProcess: Nullable<PostProcess>;
  37505. hdrFinalPostProcess: Nullable<PostProcess>;
  37506. lensFlarePostProcess: Nullable<PostProcess>;
  37507. lensFlareComposePostProcess: Nullable<PostProcess>;
  37508. motionBlurPostProcess: Nullable<PostProcess>;
  37509. depthOfFieldPostProcess: Nullable<PostProcess>;
  37510. brightThreshold: number;
  37511. blurWidth: number;
  37512. horizontalBlur: boolean;
  37513. exposure: number;
  37514. lensTexture: Nullable<Texture>;
  37515. volumetricLightCoefficient: number;
  37516. volumetricLightPower: number;
  37517. volumetricLightBlurScale: number;
  37518. sourceLight: Nullable<SpotLight | DirectionalLight>;
  37519. hdrMinimumLuminance: number;
  37520. hdrDecreaseRate: number;
  37521. hdrIncreaseRate: number;
  37522. lensColorTexture: Nullable<Texture>;
  37523. lensFlareStrength: number;
  37524. lensFlareGhostDispersal: number;
  37525. lensFlareHaloWidth: number;
  37526. lensFlareDistortionStrength: number;
  37527. lensStarTexture: Nullable<Texture>;
  37528. lensFlareDirtTexture: Nullable<Texture>;
  37529. depthOfFieldDistance: number;
  37530. depthOfFieldBlurWidth: number;
  37531. motionStrength: number;
  37532. animations: Animation[];
  37533. /**
  37534. * Private members
  37535. */
  37536. private _scene;
  37537. private _currentDepthOfFieldSource;
  37538. private _basePostProcess;
  37539. private _hdrCurrentLuminance;
  37540. private _floatTextureType;
  37541. private _ratio;
  37542. private _bloomEnabled;
  37543. private _depthOfFieldEnabled;
  37544. private _vlsEnabled;
  37545. private _lensFlareEnabled;
  37546. private _hdrEnabled;
  37547. private _motionBlurEnabled;
  37548. private _motionBlurSamples;
  37549. private _volumetricLightStepsCount;
  37550. BloomEnabled: boolean;
  37551. DepthOfFieldEnabled: boolean;
  37552. LensFlareEnabled: boolean;
  37553. HDREnabled: boolean;
  37554. VLSEnabled: boolean;
  37555. MotionBlurEnabled: boolean;
  37556. volumetricLightStepsCount: number;
  37557. motionBlurSamples: number;
  37558. /**
  37559. * @constructor
  37560. * @param {string} name - The rendering pipeline name
  37561. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  37562. * @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)
  37563. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  37564. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  37565. */
  37566. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  37567. private _buildPipeline();
  37568. private _createDownSampleX4PostProcess(scene, ratio);
  37569. private _createBrightPassPostProcess(scene, ratio);
  37570. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  37571. private _createTextureAdderPostProcess(scene, ratio);
  37572. private _createVolumetricLightPostProcess(scene, ratio);
  37573. private _createLuminancePostProcesses(scene, textureType);
  37574. private _createHdrPostProcess(scene, ratio);
  37575. private _createLensFlarePostProcess(scene, ratio);
  37576. private _createDepthOfFieldPostProcess(scene, ratio);
  37577. private _createMotionBlurPostProcess(scene, ratio);
  37578. private _getDepthTexture();
  37579. private _disposePostProcesses();
  37580. /**
  37581. * Dispose of the pipeline and stop all post processes
  37582. */
  37583. dispose(): void;
  37584. /**
  37585. * Serialize the rendering pipeline (Used when exporting)
  37586. * @returns the serialized object
  37587. */
  37588. serialize(): any;
  37589. /**
  37590. * Parse the serialized pipeline
  37591. * @param source Source pipeline.
  37592. * @param scene The scene to load the pipeline to.
  37593. * @param rootUrl The URL of the serialized pipeline.
  37594. * @returns An instantiated pipeline from the serialized object.
  37595. */
  37596. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  37597. static LuminanceSteps: number;
  37598. }
  37599. }